@maro-tech/card 0.0.6 → 0.0.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.
@@ -1632,6 +1632,7 @@ class CardTableComponent {
1632
1632
  sortDirection = '';
1633
1633
  tableViewColumns = [];
1634
1634
  editableColumnsLoaded = false;
1635
+ refreshAfterFormCompleted = false;
1635
1636
  ngOnChanges() {
1636
1637
  this.pageIndex = 0;
1637
1638
  this.pageSize = this.resolvePageSize();
@@ -1842,11 +1843,45 @@ class CardTableComponent {
1842
1843
  refreshTable() {
1843
1844
  this.loadTable();
1844
1845
  }
1845
- onFormCompleted() {
1846
+ onFormCompleted(response) {
1847
+ this.refreshAfterFormCompleted = true;
1848
+ this.applyFormResultToRow(response);
1849
+ }
1850
+ onFormClosed() {
1846
1851
  this.activeFormTargetSignal.set(null);
1847
1852
  this.activeEditableCellSignal.set(null);
1853
+ if (!this.refreshAfterFormCompleted)
1854
+ return;
1855
+ this.refreshAfterFormCompleted = false;
1848
1856
  this.loadTable();
1849
1857
  }
1858
+ applyFormResultToRow(response) {
1859
+ const target = this.activeFormTargetSignal();
1860
+ if (!target || !response || typeof response !== 'object')
1861
+ return;
1862
+ const responseData = response.data;
1863
+ if (!responseData || typeof responseData !== 'object')
1864
+ return;
1865
+ const data = responseData;
1866
+ const warehouse = data['warehouse'];
1867
+ const warehouseData = warehouse && typeof warehouse === 'object'
1868
+ ? warehouse
1869
+ : null;
1870
+ const warehouseId = String(warehouseData?.['id'] ?? data['warehouseId'] ?? '').trim();
1871
+ const warehouseItemId = String(data['id'] ?? '').trim();
1872
+ if (!warehouseId || !warehouseItemId)
1873
+ return;
1874
+ this.tableRowsSignal.update((rows) => rows.map((row) => {
1875
+ if (String(row['id'] ?? '').trim() !== target.recordId)
1876
+ return row;
1877
+ return {
1878
+ ...row,
1879
+ warehouse_id: warehouseId,
1880
+ warehouse_item_id: warehouseItemId,
1881
+ warehouse_position: String(warehouseData?.['name'] ?? data['name'] ?? '').trim(),
1882
+ };
1883
+ }));
1884
+ }
1850
1885
  loadTable() {
1851
1886
  const table = this.resolveTableSource();
1852
1887
  this.isTableLoadingSignal.set(true);
@@ -2272,7 +2307,7 @@ class CardTableComponent {
2272
2307
  this.host?.notify(message, variant, 2800);
2273
2308
  }
2274
2309
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: CardTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2275
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.20", type: CardTableComponent, isStandalone: true, selector: "app-card-table", inputs: { tab: "tab", data: "data" }, usesOnChanges: true, ngImport: i0, template: "<section class=\"space-y-4\">\n @if (tableHeaderActions.length) {\n <div class=\"flex justify-end gap-2\">\n @for (action of tableHeaderActions; track action.id) {\n <ui-button\n [variant]=\"action.variant || 'ghost'\"\n [icon]=\"action.icon || ''\"\n size=\"sm\"\n type=\"button\"\n (click)=\"onHeaderAction(action)\"\n >\n {{ action.label }}\n </ui-button>\n }\n </div>\n }\n\n <app-ui-table\n [data]=\"tableData()\"\n [columns]=\"tableColumns\"\n [isLoading]=\"isTableLoading\"\n [disablePaging]=\"disablePaging\"\n [rowClickable]=\"rowClickable\"\n (pageChange)=\"onTablePageChange($event)\"\n (actionClick)=\"onTableAction($event)\"\n (rowClick)=\"onTableRowClick($event)\"\n (cellChange)=\"onTableCellChange($event)\"\n ></app-ui-table>\n\n @if (activeFormTarget(); as target) {\n <forms-action-form-modal\n [isOpen]=\"true\"\n [formId]=\"target.formId\"\n [recordId]=\"target.recordId\"\n [initialValue]=\"target.initialValue\"\n (closed)=\"closeFormAction()\"\n (completed)=\"onFormCompleted()\"\n ></forms-action-form-modal>\n }\n</section>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: UiTableComponent, selector: "app-ui-table", inputs: ["columns", "isLoading", "data", "disablePaging", "rowClickable", "imageResolver"], outputs: ["pageChange", "rowClick", "actionClick", "cellChange"] }, { kind: "component", type: UiButtonComponent, selector: "ui-button", inputs: ["variant", "size", "disabled", "fullWidth", "type", "withShadow", "icon", "iconOnly", "ariaLabel"] }, { kind: "component", type: UiActionFormModalComponent, selector: "forms-action-form-modal", inputs: ["formId", "recordId", "size", "isOpen", "cancelLabel", "initialValue"], outputs: ["closed", "completed"] }] });
2310
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.20", type: CardTableComponent, isStandalone: true, selector: "app-card-table", inputs: { tab: "tab", data: "data" }, usesOnChanges: true, ngImport: i0, template: "<section class=\"space-y-4\">\n @if (tableHeaderActions.length) {\n <div class=\"flex justify-end gap-2\">\n @for (action of tableHeaderActions; track action.id) {\n <ui-button\n [variant]=\"action.variant || 'ghost'\"\n [icon]=\"action.icon || ''\"\n size=\"sm\"\n type=\"button\"\n (click)=\"onHeaderAction(action)\"\n >\n {{ action.label }}\n </ui-button>\n }\n </div>\n }\n\n <app-ui-table\n [data]=\"tableData()\"\n [columns]=\"tableColumns\"\n [isLoading]=\"isTableLoading\"\n [disablePaging]=\"disablePaging\"\n [rowClickable]=\"rowClickable\"\n (pageChange)=\"onTablePageChange($event)\"\n (actionClick)=\"onTableAction($event)\"\n (rowClick)=\"onTableRowClick($event)\"\n (cellChange)=\"onTableCellChange($event)\"\n ></app-ui-table>\n\n @if (activeFormTarget(); as target) {\n <forms-action-form-modal\n [isOpen]=\"true\"\n [formId]=\"target.formId\"\n [recordId]=\"target.recordId\"\n [initialValue]=\"target.initialValue\"\n (closed)=\"onFormClosed()\"\n (completed)=\"onFormCompleted($event)\"\n ></forms-action-form-modal>\n }\n</section>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: UiTableComponent, selector: "app-ui-table", inputs: ["columns", "isLoading", "data", "disablePaging", "rowClickable", "imageResolver"], outputs: ["pageChange", "rowClick", "actionClick", "cellChange"] }, { kind: "component", type: UiButtonComponent, selector: "ui-button", inputs: ["variant", "size", "disabled", "fullWidth", "type", "withShadow", "icon", "iconOnly", "ariaLabel"] }, { kind: "component", type: UiActionFormModalComponent, selector: "forms-action-form-modal", inputs: ["formId", "recordId", "size", "isOpen", "cancelLabel", "initialValue"], outputs: ["closed", "completed"] }] });
2276
2311
  }
2277
2312
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: CardTableComponent, decorators: [{
2278
2313
  type: Component,
@@ -2281,7 +2316,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImpo
2281
2316
  UiTableComponent,
2282
2317
  UiButtonComponent,
2283
2318
  UiActionFormModalComponent,
2284
- ], template: "<section class=\"space-y-4\">\n @if (tableHeaderActions.length) {\n <div class=\"flex justify-end gap-2\">\n @for (action of tableHeaderActions; track action.id) {\n <ui-button\n [variant]=\"action.variant || 'ghost'\"\n [icon]=\"action.icon || ''\"\n size=\"sm\"\n type=\"button\"\n (click)=\"onHeaderAction(action)\"\n >\n {{ action.label }}\n </ui-button>\n }\n </div>\n }\n\n <app-ui-table\n [data]=\"tableData()\"\n [columns]=\"tableColumns\"\n [isLoading]=\"isTableLoading\"\n [disablePaging]=\"disablePaging\"\n [rowClickable]=\"rowClickable\"\n (pageChange)=\"onTablePageChange($event)\"\n (actionClick)=\"onTableAction($event)\"\n (rowClick)=\"onTableRowClick($event)\"\n (cellChange)=\"onTableCellChange($event)\"\n ></app-ui-table>\n\n @if (activeFormTarget(); as target) {\n <forms-action-form-modal\n [isOpen]=\"true\"\n [formId]=\"target.formId\"\n [recordId]=\"target.recordId\"\n [initialValue]=\"target.initialValue\"\n (closed)=\"closeFormAction()\"\n (completed)=\"onFormCompleted()\"\n ></forms-action-form-modal>\n }\n</section>\n" }]
2319
+ ], template: "<section class=\"space-y-4\">\n @if (tableHeaderActions.length) {\n <div class=\"flex justify-end gap-2\">\n @for (action of tableHeaderActions; track action.id) {\n <ui-button\n [variant]=\"action.variant || 'ghost'\"\n [icon]=\"action.icon || ''\"\n size=\"sm\"\n type=\"button\"\n (click)=\"onHeaderAction(action)\"\n >\n {{ action.label }}\n </ui-button>\n }\n </div>\n }\n\n <app-ui-table\n [data]=\"tableData()\"\n [columns]=\"tableColumns\"\n [isLoading]=\"isTableLoading\"\n [disablePaging]=\"disablePaging\"\n [rowClickable]=\"rowClickable\"\n (pageChange)=\"onTablePageChange($event)\"\n (actionClick)=\"onTableAction($event)\"\n (rowClick)=\"onTableRowClick($event)\"\n (cellChange)=\"onTableCellChange($event)\"\n ></app-ui-table>\n\n @if (activeFormTarget(); as target) {\n <forms-action-form-modal\n [isOpen]=\"true\"\n [formId]=\"target.formId\"\n [recordId]=\"target.recordId\"\n [initialValue]=\"target.initialValue\"\n (closed)=\"onFormClosed()\"\n (completed)=\"onFormCompleted($event)\"\n ></forms-action-form-modal>\n }\n</section>\n" }]
2285
2320
  }], propDecorators: { tab: [{
2286
2321
  type: Input,
2287
2322
  args: [{ required: true }]