Skip to content

Commit

Permalink
additional cleanup:
Browse files Browse the repository at this point in the history
* Added loading indicator to list page
* default config type schema to empty object if missing
  • Loading branch information
rgallettonf committed Feb 12, 2025
1 parent 808376c commit 4e5b5d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ export class ConfigTypeFormComponent extends ProjectableForm implements OnInit,
}

override entityUpdated() {
if (isEmpty(this.formData?.data)) {
this.formData.data = {};
}
if (isEmpty(this.formData?.configTypeId)) {
this.formData.configTypeId = '';
if (isEmpty(this.formData?.schema)) {
this.formData.schema = {};
this.initData = cloneDeep(this.formData);
}
this.selectedConfigTypeId = this.formData.configTypeId;
this.initData = cloneDeep(this.formData);
Expand Down Expand Up @@ -185,17 +183,14 @@ export class ConfigTypeFormComponent extends ProjectableForm implements OnInit,

async save(event?: any) {
this.errors = {};
if (isEmpty(this.formData.status)) {
this.formData.status = {};
}
if (!this.validate()) {
this.isLoading = false;
return;
}
const configId = await this.svc.save(this.formData).then((result) => {
if (!isEmpty(result?.id)) {
this.formData = result;
this.initData = this.formData;
this.initData = cloneDeep(this.formData);
}
return result?.id;
}).finally(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {SchemaService} from "../../../services/schema.service";
import {defer, isBoolean, isEmpty, isNil, keys} from "lodash";
import {GrowlerModel} from "../../messaging/growler.model";
import {GrowlerService} from "../../messaging/growler.service";
import {Config} from "../../../models/config";
import {ConfigType} from "../../../models/config-type";
import {ExtensionService, SHAREDZ_EXTENSION} from "../../extendable/extensions-noop.service";
import {SERVICE_EXTENSION_SERVICE} from "../service/service-form.service";
import {ValidationService} from "../../../services/validation.service";
Expand Down Expand Up @@ -41,7 +41,7 @@ export class ConfigTypeFormService {

save(formData) {
const isUpdate = !isEmpty(formData.id);
const data: any = this.getConfigDataModel(formData, isUpdate);
const data: any = this.getConfigTypeDataModel(formData, isUpdate);
let prom;
if (isUpdate) {
prom = this.dataService.patch('config-types', data, formData.id, true);
Expand Down Expand Up @@ -82,16 +82,15 @@ export class ConfigTypeFormService {
})
}

getConfigDataModel(formData, isUpdate) {
const saveModel = new Config();
getConfigTypeDataModel(formData, isUpdate) {
const saveModel = new ConfigType();
const modelProperties = keys(saveModel);
modelProperties.forEach((prop) => {
switch(prop) {
default:
saveModel[prop] = formData[prop];
}
});
saveModel.data = this.validationService.redefineObject(saveModel.data);
return saveModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
>
</lib-data-table>
</div>
<lib-loading-indicator *ngIf="isLoading" [isLoading]="isLoading"></lib-loading-indicator>

0 comments on commit 4e5b5d4

Please sign in to comment.