cat-qw-lib 0.32.0 → 0.32.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -739,9 +739,11 @@ class FormContainerComponent {
739
739
  });
740
740
  }
741
741
  handleSaveClick() {
742
+ console.log("7");
742
743
  this.onSave.emit();
743
744
  }
744
745
  handleCancelClick() {
746
+ console.log("8");
745
747
  this.onCancel.emit();
746
748
  }
747
749
  handleCreateBtnClick() { }
@@ -955,25 +957,16 @@ class BaseService {
955
957
  }
956
958
  }
957
959
  create(entity) {
958
- console.log('Calling POST API for entity:', entity);
959
960
  const baseUrl = this._pathName === DATASOURCES.Template ? this.interactBaseApi : this.apiUrl;
960
- return this.http.post(baseUrl + this._pathName, entity).pipe(tap((newEntity) => {
961
- console.log('POST response received:', newEntity);
962
- this.store.add(newEntity);
963
- }));
961
+ return this.http.post(baseUrl + this._pathName, entity).pipe(tap((newEntity) => this.store.add(newEntity)));
964
962
  }
965
963
  getAll() {
966
- console.log("get ALl init list");
967
964
  const baseUrl = this._pathName === DATASOURCES.Template ? this.interactBaseApi : this.apiUrl;
968
965
  const url = `${baseUrl}${this._pathName}`;
969
- return this.http.get(url).pipe(tap((entities) => {
970
- console.log("get ALl list");
971
- this.store.set(entities);
972
- }));
966
+ return this.http.get(url).pipe(tap((entities) => this.store.set(entities)));
973
967
  }
974
968
  getPaginatedList(search = SHARED.EMPTY, page = 1, limit = 10, sortBy = SHARED.EMPTY, order = SHARED.EMPTY, type = SHARED.EMPTY, pathName) {
975
969
  this._pathName = (!!pathName ? pathName : this._pathName);
976
- console.log("get pagination init list");
977
970
  const paramsObj = Object.fromEntries(Object.entries({
978
971
  searchKey: search,
979
972
  page: page ? page.toString() : SHARED.EMPTY,
@@ -985,22 +978,15 @@ class BaseService {
985
978
  const params = new URLSearchParams(paramsObj);
986
979
  const baseUrl = this._pathName === DATASOURCES.Template ? this.interactBaseApi : this.apiUrl;
987
980
  const url = `${baseUrl}${this._pathName}${params.toString() ? SHARED.QUESTION_MARK + params.toString() : SHARED.EMPTY}`;
988
- return this.http.get(url).pipe(tap((entities) => {
989
- console.log('pagination list');
990
- this.store.set(entities);
991
- }));
981
+ return this.http.get(url).pipe(tap((entities) => this.store.set(entities)));
992
982
  }
993
983
  getById(id) {
994
984
  const baseUrl = this._pathName === DATASOURCES.Template ? this.interactBaseApi : this.apiUrl;
995
985
  return this.http.get(`${baseUrl}${this._pathName}/${id}`).pipe(tap((entity) => this.store.upsert(id, entity)));
996
986
  }
997
987
  update(id, entity) {
998
- console.log('Calling PUT API for ID:', id);
999
988
  const baseUrl = this._pathName === DATASOURCES.Template ? this.interactBaseApi : this.apiUrl;
1000
- return this.http.put(`${baseUrl}${this._pathName}/${id}`, entity).pipe(tap((updatedEntity) => {
1001
- console.log('PUT response received:', updatedEntity);
1002
- this.store.update(id, updatedEntity);
1003
- }));
989
+ return this.http.put(`${baseUrl}${this._pathName}/${id}`, entity).pipe(tap((updatedEntity) => this.store.update(id, updatedEntity)));
1004
990
  }
1005
991
  delete(id) {
1006
992
  const baseUrl = this._pathName === DATASOURCES.Template ? this.interactBaseApi : this.apiUrl;
@@ -1201,7 +1187,7 @@ class BaseFormComponent {
1201
1187
  record;
1202
1188
  recordChange = new BehaviorSubject({});
1203
1189
  destroy$ = new Subject();
1204
- onSave = new EventEmitter();
1190
+ isSubmitting = false;
1205
1191
  onFormNavigate = new EventEmitter();
1206
1192
  onCancel = new EventEmitter();
1207
1193
  constructor(service, validatorService, router, activatedRoute, baseStore, baseQuery) {
@@ -1233,11 +1219,15 @@ class BaseFormComponent {
1233
1219
  }
1234
1220
  }
1235
1221
  handleSubmit() {
1236
- console.log('testing11');
1222
+ if (this.isSubmitting) {
1223
+ return;
1224
+ }
1225
+ this.isSubmitting = true;
1226
+ console.log("Submitting form...");
1237
1227
  const validateRecords = this.validatorService
1238
1228
  ? this.validatorService.handleValidateRecords(this.record)
1239
1229
  : true;
1240
- if (!this.record)
1230
+ if (!this.record || Object.keys(this.record).length === 0)
1241
1231
  return;
1242
1232
  if (this.baseStore)
1243
1233
  this.baseStore.missingFields = [];
@@ -1265,24 +1255,22 @@ class BaseFormComponent {
1265
1255
  });
1266
1256
  });
1267
1257
  if (this.baseStore && this.baseStore.missingFields.length > 0) {
1268
- if (this.baseStore)
1269
- this.baseStore.setIsFormSubmitted(true);
1258
+ this.baseStore.setIsFormSubmitted(true);
1270
1259
  console.error(ERROR.MISSING_REQUIRED_FIELD, this.baseStore.missingFields);
1260
+ this.isSubmitting = false;
1271
1261
  }
1272
1262
  else {
1273
1263
  if (!this.currentState?.isApiValidated && this.currentState?.isApiValidated !== null) {
1274
1264
  this.baseStore?.setIsShowMessage(!this.currentState?.isApiValidated);
1265
+ this.isSubmitting = false;
1275
1266
  }
1276
1267
  else if (validateRecords) {
1277
- console.log('Submitting form...');
1278
- if (!this.record)
1268
+ if (!this.record || Object.keys(this.record).length === 0)
1279
1269
  return;
1280
1270
  if (this.record._id) {
1281
- console.log('Calling update API for:', this.record._id);
1282
1271
  this.handleUpdateRecord();
1283
1272
  }
1284
1273
  else {
1285
- console.log('Calling create API...');
1286
1274
  this.handleAddRecord();
1287
1275
  }
1288
1276
  }
@@ -1291,9 +1279,7 @@ class BaseFormComponent {
1291
1279
  }
1292
1280
  }
1293
1281
  handleUpdateRecord() {
1294
- console.log('Submitting form...');
1295
- console.log(this.record);
1296
- if (!this.record._id)
1282
+ if (!this.record._id || Object.keys(this.record).length === 0)
1297
1283
  return;
1298
1284
  this.service.update(this.record._id, this.record).subscribe({
1299
1285
  next: (response) => {
@@ -1308,9 +1294,7 @@ class BaseFormComponent {
1308
1294
  });
1309
1295
  }
1310
1296
  handleAddRecord() {
1311
- console.log('form submitted');
1312
- console.log(this.record);
1313
- if (!this.record)
1297
+ if (!this.record || Object.keys(this.record).length === 0)
1314
1298
  return;
1315
1299
  this.service.create(this.record).subscribe({
1316
1300
  next: (response) => {
@@ -1338,14 +1322,12 @@ class BaseFormComponent {
1338
1322
  this.destroy$.complete();
1339
1323
  }
1340
1324
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: BaseFormComponent, deps: [{ token: BaseService }, { token: ValidatorService }, { token: i3$4.Router }, { token: i3$4.ActivatedRoute }, { token: BaseStore }, { token: BaseQuery }], target: i0.ɵɵFactoryTarget.Component });
1341
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.4", type: BaseFormComponent, isStandalone: true, selector: "base-form", outputs: { onSave: "onSave", onFormNavigate: "onFormNavigate", onCancel: "onCancel" }, providers: [ValidatorService], ngImport: i0, template: "<p>base-form works!</p>\r\n", styles: [""] });
1325
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.4", type: BaseFormComponent, isStandalone: true, selector: "base-form", outputs: { onFormNavigate: "onFormNavigate", onCancel: "onCancel" }, providers: [ValidatorService], ngImport: i0, template: "<p>base-form works!</p>\r\n", styles: [""] });
1342
1326
  }
1343
1327
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: BaseFormComponent, decorators: [{
1344
1328
  type: Component,
1345
1329
  args: [{ selector: 'base-form', providers: [ValidatorService], template: "<p>base-form works!</p>\r\n" }]
1346
- }], ctorParameters: () => [{ type: BaseService }, { type: ValidatorService }, { type: i3$4.Router }, { type: i3$4.ActivatedRoute }, { type: BaseStore }, { type: BaseQuery }], propDecorators: { onSave: [{
1347
- type: Output
1348
- }], onFormNavigate: [{
1330
+ }], ctorParameters: () => [{ type: BaseService }, { type: ValidatorService }, { type: i3$4.Router }, { type: i3$4.ActivatedRoute }, { type: BaseStore }, { type: BaseQuery }], propDecorators: { onFormNavigate: [{
1349
1331
  type: Output
1350
1332
  }], onCancel: [{
1351
1333
  type: Output