Last active
November 7, 2022 14:50
-
-
Save guilnorth/288214616b305fc37067906306a731eb to your computer and use it in GitHub Desktop.
feat(page-job-scheduler): adiciona funcionalidade de template na parametrização
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<po-page-job-scheduler | |
p-service-api="https://po-sample-api.herokuapp.com/v1/scheduler" | |
p-title="Background Process Scheduler with dynamic template" | |
> | |
<ng-template p-job-scheduler-parameters-template [p-execution-parameter]="executionParameter" [p-disable-advance]="disableAdvance"> | |
<form #parametersForm="ngForm"> | |
<po-dynamic-form | |
[p-fields]="graphViewFields" | |
#dynamicForm | |
(p-form)="getForm($event)" | |
> | |
</po-dynamic-form> | |
</form> | |
</ng-template> | |
</po-page-job-scheduler> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, ViewChild } from '@angular/core'; | |
import { NgForm } from '@angular/forms'; | |
import { PoDynamicFormField } from '@po-ui/ng-components'; | |
/** | |
* @description | |
* | |
*/ | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html' | |
}) | |
export class AppComponent { | |
@ViewChild('parametersForm', { static: true }) dynamicForm: NgForm; | |
executionParameter; // model | |
disableAdvance = false; | |
graphViewFields: Array<PoDynamicFormField> = [ | |
{ property: 'title', label: 'Título do gráfico', gridColumns: 6, required: true }, | |
{ property: 'description', label: 'Descrição do gráfico', gridColumns: 6 }, | |
{ | |
property: "percent", | |
maxValue: 100, | |
type: 'number', | |
}]; | |
constructor() {} | |
/** | |
* @description | |
* Atualizando executionParameter com as alterações do formulário | |
* @param form | |
*/ | |
getForm(form) { | |
this.disableAdvance = form?.invalid; | |
form.valueChanges.subscribe((formModel) => { | |
this.disableAdvance = form?.invalid; | |
this.executionParameter = formModel | |
}) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { FormsModule } from '@angular/forms'; | |
import { NgModule } from '@angular/core'; | |
import { RouterModule } from '@angular/router'; | |
import { AppComponent } from './app.component'; | |
import { PoModule } from '../../../ui/src/lib'; | |
import { PoPageJobSchedulerModule } from '../../../templates/src/lib'; | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [ | |
BrowserModule, | |
FormsModule, | |
RouterModule.forRoot([], | |
{ relativeLinkResolution: 'legacy' }), | |
PoModule, | |
PoPageJobSchedulerModule, | |
], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment