Skip to content

Instantly share code, notes, and snippets.

@guilnorth
Last active November 7, 2022 14:50
Show Gist options
  • Save guilnorth/288214616b305fc37067906306a731eb to your computer and use it in GitHub Desktop.
Save guilnorth/288214616b305fc37067906306a731eb to your computer and use it in GitHub Desktop.
feat(page-job-scheduler): adiciona funcionalidade de template na parametrização
<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>
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
})
}
}
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