@bexis2/bexis2-core-ui 0.4.42 → 0.4.43

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.
package/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # bexis-core-ui
2
+ ## 0.4.43
3
+ - Table
4
+ - fix header names with dots breaks the table
5
+
2
6
  ## 0.4.42
3
7
  ## 0.4.41
4
8
  - Multiselect
@@ -509,7 +509,7 @@ $: $hiddenColumnIds = shownColumns.filter((col) => !col.visible).map((col) => co
509
509
  ? `Remove sorting by ${cell.label} column`
510
510
  : `Sort by ${cell.label} column in ascending order`}
511
511
  >
512
- {cell.render()}
512
+ {cell.render().replaceAll("%%%", '.')}
513
513
  </span>
514
514
  <div class="w-2">
515
515
  {#if props.sort.order === 'asc'}
@@ -23,7 +23,7 @@ export declare const missingValuesFn: (key: number | string, missingValues: {
23
23
  }) => string | number;
24
24
  export declare const updateTable: (pageSize: number, pageIndex: number, server: ServerConfig | undefined, filters: {
25
25
  [key: string]: { [key in FilterOptionsEnum]?: number | string | Date; };
26
- }, data: Writable<any[]>, serverItems: Writable<number> | undefined, columns: Columns | undefined, dispatch: any, order?: OrderBy[]) => Promise<Receive>;
26
+ }, data: Writable<any[]>, serverItems: Writable<number> | undefined, columns: Columns | undefined, dispatch: any, order?: OrderBy[]) => Promise<Receive | Writable<any[]>>;
27
27
  export declare const convertServerColumns: (serverColumns: ServerColumn[], columns: Columns | undefined) => Columns;
28
28
  export declare const getMaxCellHeightInRow: (tableRef: HTMLTableElement, resizable: "columns" | "rows" | "none" | "both", optionsComponent: typeof SvelteComponent | undefined, rowHeights: Writable<{
29
29
  [key: number]: {
@@ -46,7 +46,7 @@ export const normalizeFilters = (filters) => {
46
46
  .filter((k) => filters[key][k] !== undefined)
47
47
  .forEach((k) => {
48
48
  filter.push({
49
- column: key,
49
+ column: key.replaceAll('%%%', '.'),
50
50
  filterBy: k,
51
51
  value: filters[key][k]
52
52
  });
@@ -151,6 +151,15 @@ export const updateTable = async (pageSize, pageIndex, server, filters, data, se
151
151
  sendModel.id = entityId || -1;
152
152
  sendModel.filter = normalizeFilters(filters);
153
153
  sendModel.order = order;
154
+ // remove %%% from the columns object
155
+ if (sendModel.order) {
156
+ sendModel.order.forEach((order) => {
157
+ if (order.column.includes("%%%")) {
158
+ const newKey = order.column.replaceAll('%%%', '.');
159
+ order.column = newKey;
160
+ }
161
+ });
162
+ }
154
163
  let fetchData;
155
164
  try {
156
165
  fetchData = await fetch(baseUrl || '', {
@@ -170,24 +179,37 @@ export const updateTable = async (pageSize, pageIndex, server, filters, data, se
170
179
  const response = await fetchData.json();
171
180
  // Format server columns to the client columns
172
181
  if (response.columns !== undefined) {
182
+ console.log('Server columns', response.columns);
173
183
  columns = convertServerColumns(response.columns, columns);
174
184
  const clientCols = response.columns.reduce((acc, col) => {
185
+ console.log(col.key, col.column);
186
+ // replace the . with empty string
187
+ //const key = col.key.replaceAll('.' ,'');
188
+ ///console.log(key, col.column);
189
+ // set the key to the columns object
190
+ col.column = col.column.replaceAll('.', "%%%");
191
+ col.key = col.key.replaceAll('.', "%%%");
175
192
  acc[col.key] = col.column;
193
+ //acc[col.column] = col.column;
176
194
  return acc;
177
195
  }, {});
178
196
  const tmpArr = [];
197
+ // tmp[clientCols["['" + key.replaceAll('.', ",") +"']"]] = row[key];
179
198
  response.data.forEach((row, index) => {
180
199
  const tmp = {};
181
200
  Object.keys(row).forEach((key) => {
182
- tmp[clientCols[key]] = row[key];
201
+ tmp[clientCols[key.replaceAll('.', "%%%")]] = row[key];
183
202
  });
184
203
  tmpArr.push(tmp);
185
204
  });
186
205
  dispatch('fetch', columns);
187
206
  data.set(tmpArr);
207
+ console.log('Server data', tmpArr);
208
+ return data;
188
209
  }
189
210
  serverItems?.set(response.count);
190
211
  console.log('Server data updated');
212
+ // log the columns object
191
213
  console.log(response);
192
214
  return response;
193
215
  };
@@ -231,17 +253,18 @@ export const convertServerColumns = (serverColumns, columns) => {
231
253
  };
232
254
  }
233
255
  if (columns && col.column in columns) {
234
- columnsConfig[col.column] = {
235
- ...columns[col.column],
256
+ columnsConfig[col.column.replaceAll('.', "%%%")] = {
257
+ ...columns[col.column.replaceAll('.', "%%%")],
236
258
  instructions
237
259
  };
238
260
  }
239
261
  else {
240
- columnsConfig[col.column] = {
262
+ columnsConfig[col.column.replaceAll('.', "%%%")] = {
241
263
  instructions
242
264
  };
243
265
  }
244
266
  });
267
+ console.log('Columns config', columnsConfig);
245
268
  return columnsConfig;
246
269
  };
247
270
  // Calculates the maximum height of the cells in each row
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.42",
3
+ "version": "0.4.43",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -589,7 +589,7 @@
589
589
  ? `Remove sorting by ${cell.label} column`
590
590
  : `Sort by ${cell.label} column in ascending order`}
591
591
  >
592
- {cell.render()}
592
+ {cell.render().replaceAll("%%%", '.')}
593
593
  </span>
594
594
  <div class="w-2">
595
595
  {#if props.sort.order === 'asc'}
@@ -60,7 +60,7 @@ export const normalizeFilters = (filters: {
60
60
  .filter((k) => filters[key][k] !== undefined)
61
61
  .forEach((k) => {
62
62
  filter.push({
63
- column: key,
63
+ column: key.replaceAll('%%%', '.'),
64
64
  filterBy: k as FilterOptionsEnum,
65
65
  value: filters[key][k]
66
66
  });
@@ -199,6 +199,16 @@ export const updateTable = async (
199
199
  sendModel.filter = normalizeFilters(filters);
200
200
  sendModel.order = order;
201
201
 
202
+ // remove %%% from the columns object
203
+ if (sendModel.order) {
204
+ sendModel.order.forEach((order) => {
205
+ if (order.column.includes("%%%")) {
206
+ const newKey = order.column.replaceAll('%%%', '.');
207
+ order.column = newKey;
208
+ }
209
+ });
210
+ }
211
+
202
212
  let fetchData;
203
213
 
204
214
  try {
@@ -221,28 +231,43 @@ export const updateTable = async (
221
231
 
222
232
  // Format server columns to the client columns
223
233
  if (response.columns !== undefined) {
234
+ console.log('Server columns', response.columns);
224
235
  columns = convertServerColumns(response.columns, columns);
225
236
 
226
237
  const clientCols = response.columns.reduce((acc, col) => {
227
- acc[col.key] = col.column;
238
+ console.log(col.key, col.column);
239
+ // replace the . with empty string
240
+ //const key = col.key.replaceAll('.' ,'');
241
+ ///console.log(key, col.column);
242
+ // set the key to the columns object
243
+ col.column = col.column.replaceAll('.', "%%%");
244
+ col.key = col.key.replaceAll('.', "%%%");
245
+ acc[col.key] = col.column
246
+ //acc[col.column] = col.column;
247
+
228
248
  return acc;
229
249
  }, {});
230
250
 
231
251
  const tmpArr: any[] = [];
232
-
252
+ // tmp[clientCols["['" + key.replaceAll('.', ",") +"']"]] = row[key];
233
253
  response.data.forEach((row, index) => {
234
254
  const tmp: { [key: string]: any } = {};
235
255
  Object.keys(row).forEach((key) => {
236
- tmp[clientCols[key]] = row[key];
256
+ tmp[clientCols[key.replaceAll('.', "%%%") ]] = row[key]
237
257
  });
238
258
  tmpArr.push(tmp);
239
259
  });
240
260
  dispatch('fetch', columns);
241
261
  data.set(tmpArr);
262
+ console.log('Server data', tmpArr);
263
+ return data;
242
264
  }
243
265
 
244
266
  serverItems?.set(response.count);
245
267
  console.log('Server data updated');
268
+
269
+
270
+ // log the columns object
246
271
  console.log(response);
247
272
  return response;
248
273
  };
@@ -291,17 +316,17 @@ export const convertServerColumns = (
291
316
  }
292
317
 
293
318
  if (columns && col.column in columns) {
294
- columnsConfig[col.column] = {
295
- ...columns[col.column],
319
+ columnsConfig[col.column.replaceAll('.', "%%%")] = {
320
+ ...columns[col.column.replaceAll('.', "%%%")],
296
321
  instructions
297
322
  };
298
323
  } else {
299
- columnsConfig[col.column] = {
324
+ columnsConfig[col.column.replaceAll('.', "%%%") ] = {
300
325
  instructions
301
326
  };
302
327
  }
303
328
  });
304
-
329
+ console.log('Columns config', columnsConfig);
305
330
  return columnsConfig;
306
331
  };
307
332
  // Calculates the maximum height of the cells in each row