ngx-techlify-core 11.2.4 → 11.2.8

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.
@@ -569,25 +569,27 @@ class ErrorHandlerService {
569
569
  this.alerter = alerter;
570
570
  }
571
571
  handleError(errorResponse, msg = '') {
572
- var _a;
572
+ var _a, _b, _c, _d;
573
573
  // 1 - Create empty array to store errors
574
574
  const errors = [];
575
575
  // 2 - check if the error object is present in the response
576
- if (errorResponse.error) {
577
- // 3 - Push the main error message to the array of errors
578
- errors.push(errorResponse.error.message ? errorResponse.error.message : (_a = errorResponse.error) === null || _a === void 0 ? void 0 : _a.error);
579
- // 4 - Check for Laravel form validation error messages object
580
- if (errorResponse.error.errors) {
581
- // 5 - For each error property (which is a form field)
576
+ if (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) {
577
+ // 3 - Check for Laravel form validation error messages object
578
+ if ((_a = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) === null || _a === void 0 ? void 0 : _a.errors) {
579
+ // 4 - For each error property (which is a form field)
582
580
  for (const property in errorResponse.error.errors) {
583
- if (errorResponse.error.errors.hasOwnProperty(property)) {
584
- // 6 - Extract it's array of errors
585
- const propertyErrors = errorResponse.error.errors[property];
586
- // 7 - Push all errors in the array to the errors array
581
+ if ((_b = errorResponse.error.errors) === null || _b === void 0 ? void 0 : _b.hasOwnProperty(property)) {
582
+ // 5 - Extract it's array of errors
583
+ const propertyErrors = (_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) === null || _c === void 0 ? void 0 : _c.errors[property];
584
+ // 6 - Push all errors in the array to the errors array
587
585
  propertyErrors.forEach(error => errors.push(error));
588
586
  }
589
587
  }
590
588
  }
589
+ if (errors.length === 0) {
590
+ // 7 - Push the main error message to the array of errors if there is no validation error
591
+ errors.push(errorResponse.error.message ? errorResponse.error.message : (_d = errorResponse.error) === null || _d === void 0 ? void 0 : _d.error);
592
+ }
591
593
  }
592
594
  var errMessage = errors.length ? errors[0] : msg;
593
595
  this.alerter.addAlert("Error: " + errMessage, "warning");
@@ -1550,6 +1552,7 @@ class NoteFormComponent {
1550
1552
  }
1551
1553
  //Method to trigger login
1552
1554
  submit() {
1555
+ var _a;
1553
1556
  return __awaiter(this, void 0, void 0, function* () {
1554
1557
  this.noteFormFirstAttempt = true;
1555
1558
  if (this.noteFormGroup.valid) {
@@ -1557,7 +1560,7 @@ class NoteFormComponent {
1557
1560
  const result = this.updateMode
1558
1561
  ? yield this.noteService.editNote(model)
1559
1562
  : yield this.noteService.addNote(model);
1560
- this.alertService.addAlert("Note saved successfully", "success");
1563
+ this.alertService.addAlert(`${(_a = this.data) === null || _a === void 0 ? void 0 : _a.labelText} saved successfully`, "success");
1561
1564
  this.dialogRef.close(result);
1562
1565
  }
1563
1566
  });
@@ -1577,7 +1580,7 @@ class NoteFormComponent {
1577
1580
  NoteFormComponent.decorators = [
1578
1581
  { type: Component, args: [{
1579
1582
  selector: 'app-note-form',
1580
- template: "<form [formGroup]=\"noteFormGroup\" (ngSubmit)=\"submit()\">\n <div fxLayout=\"column\" class=\"mat-typography\">\n <div mat-dialog-title class=\"text-center\">\n <div>Note</div>\n </div>\n\n <div mat-dialog-content fxLayout=\"column\">\n <div fxLayout=\"row wrap\" fxLayoutAlign=\"space-between\">\n <mat-form-field fxFlex=\"100%\">\n <textarea matInput formControlName=\"note\" placeholder=\"Note\" autocomplete=\"off\" required></textarea>\n <mat-error *ngIf=\"isFieldValid('note')\">{{\n getErrorMessage(\"note\")\n }}</mat-error>\n </mat-form-field>\n\n <div class=\"my-2\" fxLayout=\"row\" fxLayoutGap=\"30px\" fxLayoutAlign=\"end\" fxFlex=\"100%\">\n <button mat-raised-button type=\"button\" (click)=\"cancel()\">\n Cancel\n </button>\n <button mat-raised-button type=\"submit\" color=\"primary\">Save</button>\n </div>\n </div>\n </div>\n </div>\n</form>",
1583
+ template: "<form [formGroup]=\"noteFormGroup\" (ngSubmit)=\"submit()\">\n <div fxLayout=\"column\" class=\"mat-typography\">\n <div mat-dialog-title class=\"text-center\">\n <div>{{data?.labelText}}</div>\n </div>\n\n <div mat-dialog-content fxLayout=\"column\">\n <div fxLayout=\"row wrap\" fxLayoutAlign=\"space-between\">\n <mat-form-field fxFlex=\"100%\">\n <textarea matInput formControlName=\"note\" placeholder=\"{{data?.labelText}}\" autocomplete=\"off\"\n required></textarea>\n <mat-error *ngIf=\"isFieldValid('note')\">{{\n getErrorMessage(\"note\")\n }}</mat-error>\n </mat-form-field>\n\n <div class=\"my-2\" fxLayout=\"row\" fxLayoutGap=\"30px\" fxLayoutAlign=\"end\" fxFlex=\"100%\">\n <button mat-raised-button type=\"button\" (click)=\"cancel()\">\n Cancel\n </button>\n <button mat-raised-button type=\"submit\" color=\"primary\">Save</button>\n </div>\n </div>\n </div>\n </div>\n</form>",
1581
1584
  styles: [""]
1582
1585
  },] }
1583
1586
  ];
@@ -1591,11 +1594,11 @@ NoteFormComponent.ctorParameters = () => [
1591
1594
  ];
1592
1595
 
1593
1596
  class NoteListComponent {
1594
- constructor(noteService, alertService, dialog) {
1597
+ constructor(noteService, dialog) {
1595
1598
  this.noteService = noteService;
1596
- this.alertService = alertService;
1597
1599
  this.dialog = dialog;
1598
1600
  this.readonly = false;
1601
+ this.labelText = 'Note';
1599
1602
  this.notes = [];
1600
1603
  this.displayedColumns = [
1601
1604
  'index',
@@ -1627,7 +1630,8 @@ class NoteListComponent {
1627
1630
  const dialogRef = this.dialog.open(NoteFormComponent, {
1628
1631
  width: "400px",
1629
1632
  data: {
1630
- note: { related_model_id: this.relatedModelId, model_type: this.modelType }
1633
+ note: { related_model_id: this.relatedModelId, model_type: this.modelType },
1634
+ labelText: this.labelText,
1631
1635
  },
1632
1636
  autoFocus: false
1633
1637
  });
@@ -1643,7 +1647,8 @@ class NoteListComponent {
1643
1647
  width: "400px",
1644
1648
  data: {
1645
1649
  note: note,
1646
- update: true
1650
+ update: true,
1651
+ labelText: this.labelText
1647
1652
  },
1648
1653
  autoFocus: false
1649
1654
  });
@@ -1659,8 +1664,8 @@ class NoteListComponent {
1659
1664
  const dialogRef = this.dialog.open(ActionPopupComponent, {
1660
1665
  width: "400px",
1661
1666
  data: {
1662
- title: "Delete Note",
1663
- message: `Are you sure to delete the note?`
1667
+ title: `Delete ${this.labelText}`,
1668
+ message: `Are you sure to delete?`
1664
1669
  },
1665
1670
  autoFocus: false
1666
1671
  });
@@ -1688,19 +1693,19 @@ class NoteListComponent {
1688
1693
  NoteListComponent.decorators = [
1689
1694
  { type: Component, args: [{
1690
1695
  selector: 'app-note-list',
1691
- template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\">\n\n <div fxLayout fxLayoutAlign=\"start center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">Notes</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"addNote()\">+ Add</button>\n </div>\n\n <div class=\"w-00 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> Note </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>",
1696
+ template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\">\n\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"addNote()\">+ Add</button>\n </div>\n\n <div class=\"w-00 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> {{labelText}} </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>",
1692
1697
  styles: [".scroll-container{max-height:400px;overflow-y:auto}"]
1693
1698
  },] }
1694
1699
  ];
1695
1700
  NoteListComponent.ctorParameters = () => [
1696
1701
  { type: NoteService },
1697
- { type: AlertService },
1698
1702
  { type: MatDialog }
1699
1703
  ];
1700
1704
  NoteListComponent.propDecorators = {
1701
1705
  relatedModelId: [{ type: Input }],
1702
1706
  modelType: [{ type: Input }],
1703
- readonly: [{ type: Input }]
1707
+ readonly: [{ type: Input }],
1708
+ labelText: [{ type: Input }]
1704
1709
  };
1705
1710
 
1706
1711
  var SearchableSelectorComponent_1;
@@ -1720,6 +1725,7 @@ let SearchableSelectorComponent = SearchableSelectorComponent_1 = class Searchab
1720
1725
  this.edit = false;
1721
1726
  this.sort = true;
1722
1727
  this.selectionChange = new EventEmitter();
1728
+ this.itemsChange = new EventEmitter();
1723
1729
  this.isLoading = false;
1724
1730
  this.onChange = () => { };
1725
1731
  this.onTouched = () => { };
@@ -1786,7 +1792,10 @@ let SearchableSelectorComponent = SearchableSelectorComponent_1 = class Searchab
1786
1792
  items = [this.selectedValue, ...this.items];
1787
1793
  else
1788
1794
  items = this.items;
1789
- return items.filter((v, i, a) => a.findIndex(v => v[this.valueField] === a[i][this.valueField]) === i);
1795
+ items = items.filter((v, i, a) => a.findIndex(v => v[this.valueField] === a[i][this.valueField]) === i);
1796
+ //Emit the items to any child component
1797
+ this.itemsChange.emit(items);
1798
+ return items;
1790
1799
  }
1791
1800
  ngOnInit() {
1792
1801
  this.selectorForm.get('search').valueChanges
@@ -1950,6 +1959,7 @@ SearchableSelectorComponent.propDecorators = {
1950
1959
  searchField: [{ type: Input }],
1951
1960
  itemComponent: [{ type: Input }],
1952
1961
  selectionChange: [{ type: Output }],
1962
+ itemsChange: [{ type: Output }],
1953
1963
  required: [{ type: Input }],
1954
1964
  disabled: [{ type: Input }],
1955
1965
  value: [{ type: Input }]
@@ -2148,12 +2158,12 @@ NumberSelector.propDecorators = {
2148
2158
  };
2149
2159
 
2150
2160
  function calculateTimeline(value) {
2151
- var data = {
2161
+ const date = new Date();
2162
+ const data = {
2152
2163
  'date_from': date,
2153
2164
  'date_to': date,
2154
2165
  'show_custom_field': false
2155
2166
  };
2156
- var date = new Date();
2157
2167
  switch (value) {
2158
2168
  case 1: { //Custom
2159
2169
  data.show_custom_field = true;
@@ -2268,9 +2278,13 @@ class TimelineFilterComponent {
2268
2278
  { value: 11, viewValue: 'Last Year' },
2269
2279
  { value: 12, viewValue: 'All dates' },
2270
2280
  ];
2281
+ this.labelText = 'Select Timeline';
2282
+ this.dateFrom = 'date_from';
2283
+ this.dateTo = 'date_to';
2271
2284
  this.showCustomDateFields = false;
2272
2285
  }
2273
2286
  set defaultValue(value) {
2287
+ this.timelineValue = value;
2274
2288
  this.changeTimeline(value);
2275
2289
  }
2276
2290
  ngOnInit() {
@@ -2287,8 +2301,8 @@ class TimelineFilterComponent {
2287
2301
  changeTimeline(value) {
2288
2302
  const timeline = calculateTimeline(value);
2289
2303
  if (timeline) {
2290
- this.setFieldValue('date_from', timeline.date_from);
2291
- this.setFieldValue('date_to', timeline.date_to);
2304
+ this.setFieldValue(this.dateFrom, timeline.date_from);
2305
+ this.setFieldValue(this.dateTo, timeline.date_to);
2292
2306
  this.showCustomDateFields = timeline.show_custom_field;
2293
2307
  }
2294
2308
  }
@@ -2296,13 +2310,16 @@ class TimelineFilterComponent {
2296
2310
  TimelineFilterComponent.decorators = [
2297
2311
  { type: Component, args: [{
2298
2312
  selector: 'app-timeline-filter',
2299
- template: "<ng-container [formGroup]=\"form\">\n <mat-form-field>\n <mat-label>Select Timeline</mat-label>\n <mat-select (selectionChange)=\"changeTimeline($event.value)\">\n <mat-option *ngFor=\"let timeline of timelines\" [value]=\"timeline.value\">\n {{timeline.viewValue}}\n </mat-option>\n </mat-select>\n </mat-form-field>\n\n <ng-container *ngIf=\"showCustomDateFields\">\n <mat-form-field>\n <input matInput formControlName=\"date_from\" [matDatepicker]=\"fromPicker\" (click)=\"fromPicker.open()\"\n placeholder=\"From Date\" readonly />\n <mat-datepicker-toggle matSuffix [for]=\"fromPicker\"></mat-datepicker-toggle>\n <mat-datepicker #fromPicker></mat-datepicker>\n <button mat-button *ngIf=\"getFieldValue('date_from')\" matSuffix mat-icon-button\n (click)=\"resetFieldValue('date_from')\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n\n <mat-form-field>\n <input matInput formControlName=\"date_to\" [matDatepicker]=\"toPicker\" (click)=\"toPicker.open()\"\n placeholder=\"To Date\" readonly />\n <mat-datepicker-toggle matSuffix [for]=\"\"></mat-datepicker-toggle>\n <mat-datepicker #toPicker></mat-datepicker>\n <button mat-button *ngIf=\"getFieldValue('date_to')\" matSuffix mat-icon-button\n (click)=\"resetFieldValue('date_to')\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n\n </ng-container>\n</ng-container>",
2313
+ template: "<ng-container [formGroup]=\"form\">\n <mat-form-field>\n <mat-label>{{labelText}}</mat-label>\n <mat-select (selectionChange)=\"changeTimeline($event.value)\" [value]=\"timelineValue\">\n <mat-option *ngFor=\"let timeline of timelines\" [value]=\"timeline.value\">\n {{timeline.viewValue}}\n </mat-option>\n </mat-select>\n </mat-form-field>\n\n <ng-container *ngIf=\"showCustomDateFields\">\n <mat-form-field>\n <input matInput formControlName=\"{{dateFrom}}\" [matDatepicker]=\"fromPicker\" (click)=\"fromPicker.open()\"\n placeholder=\"From Date\" readonly />\n <mat-datepicker-toggle matSuffix [for]=\"fromPicker\"></mat-datepicker-toggle>\n <mat-datepicker #fromPicker></mat-datepicker>\n <button mat-button *ngIf=\"getFieldValue(dateFrom)\" matSuffix mat-icon-button\n (click)=\"resetFieldValue(dateFrom)\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n\n <mat-form-field>\n <input matInput formControlName=\"{{dateTo}}\" [matDatepicker]=\"toPicker\" (click)=\"toPicker.open()\"\n placeholder=\"To Date\" readonly />\n <mat-datepicker-toggle matSuffix [for]=\"\"></mat-datepicker-toggle>\n <mat-datepicker #toPicker></mat-datepicker>\n <button mat-button *ngIf=\"getFieldValue(dateTo)\" matSuffix mat-icon-button\n (click)=\"resetFieldValue(dateTo)\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n\n </ng-container>\n</ng-container>",
2300
2314
  styles: [""]
2301
2315
  },] }
2302
2316
  ];
2303
2317
  TimelineFilterComponent.ctorParameters = () => [];
2304
2318
  TimelineFilterComponent.propDecorators = {
2305
2319
  timelines: [{ type: Input }],
2320
+ labelText: [{ type: Input }],
2321
+ dateFrom: [{ type: Input }],
2322
+ dateTo: [{ type: Input }],
2306
2323
  form: [{ type: Input }],
2307
2324
  defaultValue: [{ type: Input }]
2308
2325
  };