@maro-tech/card 0.0.7 → 0.0.9

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.
@@ -1843,8 +1843,12 @@ class CardTableComponent {
1843
1843
  refreshTable() {
1844
1844
  this.loadTable();
1845
1845
  }
1846
- onFormCompleted() {
1846
+ onFormCompleted(response) {
1847
1847
  this.refreshAfterFormCompleted = true;
1848
+ this.applyFormResultToRow(response);
1849
+ this.editableColumnsLoaded = false;
1850
+ this.editableColumnOptionsSignal.set({});
1851
+ this.loadEditableColumnOptions(true);
1848
1852
  }
1849
1853
  onFormClosed() {
1850
1854
  this.activeFormTargetSignal.set(null);
@@ -1854,6 +1858,33 @@ class CardTableComponent {
1854
1858
  this.refreshAfterFormCompleted = false;
1855
1859
  this.loadTable();
1856
1860
  }
1861
+ applyFormResultToRow(response) {
1862
+ const target = this.activeFormTargetSignal();
1863
+ if (!target || !response || typeof response !== 'object')
1864
+ return;
1865
+ const responseData = response.data;
1866
+ if (!responseData || typeof responseData !== 'object')
1867
+ return;
1868
+ const data = responseData;
1869
+ const warehouse = data['warehouse'];
1870
+ const warehouseData = warehouse && typeof warehouse === 'object'
1871
+ ? warehouse
1872
+ : null;
1873
+ const warehouseId = String(warehouseData?.['id'] ?? data['warehouseId'] ?? '').trim();
1874
+ const warehouseItemId = String(data['id'] ?? '').trim();
1875
+ if (!warehouseId || !warehouseItemId)
1876
+ return;
1877
+ this.tableRowsSignal.update((rows) => rows.map((row) => {
1878
+ if (String(row['id'] ?? '').trim() !== target.recordId)
1879
+ return row;
1880
+ return {
1881
+ ...row,
1882
+ warehouse_id: warehouseId,
1883
+ warehouse_item_id: warehouseItemId,
1884
+ warehouse_position: String(warehouseData?.['name'] ?? data['name'] ?? '').trim(),
1885
+ };
1886
+ }));
1887
+ }
1857
1888
  loadTable() {
1858
1889
  const table = this.resolveTableSource();
1859
1890
  this.isTableLoadingSignal.set(true);
@@ -2093,8 +2124,8 @@ class CardTableComponent {
2093
2124
  },
2094
2125
  });
2095
2126
  }
2096
- loadEditableColumnOptions() {
2097
- if (this.editableColumnsLoaded) {
2127
+ loadEditableColumnOptions(force = false) {
2128
+ if (this.editableColumnsLoaded && !force) {
2098
2129
  return;
2099
2130
  }
2100
2131
  const editableColumns = this.resolveEditableColumnsConfig();
@@ -2279,7 +2310,7 @@ class CardTableComponent {
2279
2310
  this.host?.notify(message, variant, 2800);
2280
2311
  }
2281
2312
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: CardTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2282
- 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()\"\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"] }] });
2313
+ 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"] }] });
2283
2314
  }
2284
2315
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImport: i0, type: CardTableComponent, decorators: [{
2285
2316
  type: Component,
@@ -2288,7 +2319,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.20", ngImpo
2288
2319
  UiTableComponent,
2289
2320
  UiButtonComponent,
2290
2321
  UiActionFormModalComponent,
2291
- ], 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()\"\n ></forms-action-form-modal>\n }\n</section>\n" }]
2322
+ ], 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" }]
2292
2323
  }], propDecorators: { tab: [{
2293
2324
  type: Input,
2294
2325
  args: [{ required: true }]