This might be Angular and not Typescript. I have an Angular form that is saving the entire form instead of one component (Copy Schedule from Site) in the form. Is there a way to do that? My form setup is using formly in typescript and the autosave is set to true in the html.
<div id="siteSchedule" class="linq-py-3"> <h3>Site Schedule</h3> <mat-divider></mat-divider> **<app-form [autosave]="true"** [form]="form" [fields]="fields" [model]="model" [options]="options" (submitted)="onSubmit($event)"> </app-form> </div>
This is just the formly part of the typescript code. If more typescript would help I would provide. I have posted too much code before and have been told it's too much so please let me know if this is not enough. I don't want to post the entire Typescript if I don't have to.
import {AutosaveService} from '@app/core/services/autosave.service'; constructor( @Inject(CoreApi.SiteApplicationClient) private readonly siteApplicationClient: CoreApi.ISiteApplicationClient, @Inject(SnackbarService) private readonly snackBar: ISnackbarService, private readonly autosaveService: AutosaveService, private readonly mealServiceDetailsService: MealServiceDetailsService, private readonly dialog: MatDialog ) {} copySiteScheduleControl: FormlyFieldConfig | undefined; model: SiteScheduleModel = { siteScheduleControl: undefined, monthsOfOperation: new CoreApi.MonthsOfOperation(), daysOfOperation: {days: []}, hoursOfOperation: {days: []}, exception: [], }; modelLoaded = false; form = new FormGroup({}); options: FormlyFormOptions = {}; fields: FormlyFieldConfig[] = [ { fieldGroupClassName: 'row', fieldGroup: [ { wrappers: ['form-field'], className: 'col-6', key: 'siteScheduleControl', type: 'select', templateOptions: { label: 'Copy Schedule from Site', options: this.approvedSites, labelProp: 'text', }, expressionProperties: { 'templateOptions.disabled': (): boolean => { return this.siteSubmissionModel.disableControls; }, }, hooks: { onInit: (field: FormlyFieldConfig | undefined): void => { this.copySiteScheduleControl = field; if (field?.templateOptions?.options) { field.templateOptions.options = this.approvedSites; } }, }, }, ]; return this.siteApplicationClient.upsertSiteSchedule(command).pipe( tap((result: CoreApi.SiteSchedule) => { this.autosaveService.setSaved(); this.mealServiceDetailsService.siteSchedulesChange(result); }) ); } else { return; }
I appreciate any assistance on this on how I could possibly get this to autosave for just the Copy Site from Schedule field.