Skip to content

Commit

Permalink
updated cancel changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Katherine Brown authored and Katherine Brown committed Oct 22, 2024
1 parent ff3a971 commit f740e27
Showing 1 changed file with 39 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,56 +66,63 @@ export class ArcAdminComponent implements OnInit {
this.configChangedNotifier.next();
}

//map attribute form to fields
ngOnInit(): void {
this.attributesForm = this.fb.group({
observationIdField: [''],
idSeparator: [''],
eventIdField: [''],
lastEditedDateField: [''],
eventNameField: [''],
userIdField: [''],
usernameField: [''],
userDisplayNameField: [''],
deviceIdField: [''],
createdAtField: [''],
lastModifiedField: [''],
geometryType: ['']
observationIdField: [this.editConfig.observationIdField],
idSeparator: [this.editConfig.idSeparator],
eventIdField: [this.editConfig.eventIdField],
lastEditedDateField: [this.editConfig.lastEditedDateField],
eventNameField: [this.editConfig.eventNameField],
userIdField: [this.editConfig.userIdField],
usernameField: [this.editConfig.usernameField],
userDisplayNameField: [this.editConfig.userDisplayNameField],
deviceIdField: [this.editConfig.deviceIdField],
createdAtField: [this.editConfig.createdAtField],
lastModifiedField: [this.editConfig.lastModifiedField],
geometryType: [this.editConfig.geometryType]
});
}

//save attributes form
onSubmit(): void {
if (this.attributesForm.valid) {
const formValue = this.attributesForm.value;
console.log('Form Submitted:', formValue);
}}

this.editConfig = {
...this.editConfig,
observationIdField: formValue.observationIdField,
idSeparator: formValue.idSeparator,
eventIdField: formValue.eventIdField,
lastEditedDateField: formValue.lastEditedDateField,
eventNameField: formValue.eventNameField,
userIdField: formValue.userIdField,
usernameField: formValue.usernameField,
userDisplayNameField: formValue.userDisplayNameField,
deviceIdField: formValue.deviceIdField,
createdAtField: formValue.createdAtField,
lastModifiedField: formValue.lastModifiedField,
geometryType: formValue.geometryType
};

console.log('Form Submitted:', this.editConfig);

this.editConfig = this.copyConfig();
}
}

//when edit attributes is canceled, preserve initial data
onCancel(): void {
this.attributesForm.reset({
config: defaultArcGISPluginConfig,
editConfig: defaultArcGISPluginConfig,
editFieldMappings: false,
observationIdField: '',
idSeparator: '',
eventIdField: '',
lastEditedDateField: '',
eventNameField: '',
userIdField: '',
usernameField: '',
userDisplayNameField: '',
deviceIdField: '',
createdAtField: '',
lastModifiedField: '',
geometryType: ''
...this.editConfig
});

console.log('Canceled configuration edit');
console.log('Canceled edit');

}

handleEventResults(x: MageEvent[]) {
this.events = x
}

onDeleteLayer(layerUrl: string) {
let index = 0;
for (const featureServiceConfig of this.config.featureServices) {
Expand All @@ -135,11 +142,6 @@ export class ArcAdminComponent implements OnInit {
this.dialog.open<unknown, unknown, string>(this.editProcessingTemplate)
}

// onEditAttributes() {
// this.editConfig = this.copyConfig()
// this.dialog.open<unknown, unknown, string>(this.editAttributesTemplate)
// }

setField(field: string, value: any) {
if (value != undefined && value.length == 0) {
value = undefined
Expand Down

0 comments on commit f740e27

Please sign in to comment.