adminforth 1.3.11 → 1.3.13

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.
@@ -57,25 +57,28 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
57
57
  throw new Error('Method not implemented.');
58
58
  }
59
59
 
60
- createRecord({ resource, record, adminUser }: {
60
+ async createRecord({ resource, record, adminUser }: {
61
61
  resource: AdminForthResource; record: any; adminUser: any;
62
- }): Promise<void> {
62
+ }): Promise<any> {
63
63
  // transform value using setFieldValue and call createRecordOriginalValues
64
- const newRecord = {...record};
65
-
64
+ const filledRecord = {...record};
65
+ const recordWithOriginalValues = {...record};
66
+
66
67
  for (const col of resource.dataSourceColumns) {
67
68
  if (col.fillOnCreate) {
68
- if (record[col.name] === undefined) {
69
- record[col.name] = col.fillOnCreate({
70
- initialRecord: record, adminUser
71
- });
69
+ if (filledRecord[col.name] === undefined) {
70
+ filledRecord[col.name] = col.fillOnCreate({
71
+ initialRecord: record,
72
+ adminUser
73
+ });
72
74
  }
73
75
  }
74
-
75
- newRecord[col.name] = this.setFieldValue(col, record[col.name]);
76
+ recordWithOriginalValues[col.name] = this.setFieldValue(col, filledRecord[col.name]);
76
77
  }
77
- process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record', newRecord);
78
- return this.createRecordOriginalValues({ resource, record: newRecord });
78
+ process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record', recordWithOriginalValues);
79
+ await this.createRecordOriginalValues({ resource, record: recordWithOriginalValues });
80
+
81
+ return recordWithOriginalValues;
79
82
  }
80
83
 
81
84
  updateRecord({ resource, recordId, newValues }: { resource: AdminForthResource; recordId: string; newValues: any; }): Promise<void> {
@@ -50,21 +50,26 @@ export default class AdminForthBaseConnector {
50
50
  createRecordOriginalValues({ resource, record }) {
51
51
  throw new Error('Method not implemented.');
52
52
  }
53
- createRecord({ resource, record, adminUser }) {
54
- // transform value using setFieldValue and call createRecordOriginalValues
55
- const newRecord = Object.assign({}, record);
56
- for (const col of resource.dataSourceColumns) {
57
- if (col.fillOnCreate) {
58
- if (record[col.name] === undefined) {
59
- record[col.name] = col.fillOnCreate({
60
- initialRecord: record, adminUser
61
- });
53
+ createRecord(_a) {
54
+ return __awaiter(this, arguments, void 0, function* ({ resource, record, adminUser }) {
55
+ // transform value using setFieldValue and call createRecordOriginalValues
56
+ const filledRecord = Object.assign({}, record);
57
+ const recordWithOriginalValues = Object.assign({}, record);
58
+ for (const col of resource.dataSourceColumns) {
59
+ if (col.fillOnCreate) {
60
+ if (filledRecord[col.name] === undefined) {
61
+ filledRecord[col.name] = col.fillOnCreate({
62
+ initialRecord: record,
63
+ adminUser
64
+ });
65
+ }
62
66
  }
67
+ recordWithOriginalValues[col.name] = this.setFieldValue(col, filledRecord[col.name]);
63
68
  }
64
- newRecord[col.name] = this.setFieldValue(col, record[col.name]);
65
- }
66
- process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record', newRecord);
67
- return this.createRecordOriginalValues({ resource, record: newRecord });
69
+ process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record', recordWithOriginalValues);
70
+ yield this.createRecordOriginalValues({ resource, record: recordWithOriginalValues });
71
+ return recordWithOriginalValues;
72
+ });
68
73
  }
69
74
  updateRecord({ resource, recordId, newValues }) {
70
75
  throw new Error('Method not implemented.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -70,7 +70,7 @@
70
70
  </td>
71
71
  </tr>
72
72
 
73
- <tr @click="onClick($event,row)" v-else v-for="(row, rowI) in rows" :key="row.id"
73
+ <tr @click="onClick($event,row)" v-else v-for="(row, rowI) in rows" :key="`row_${row._primaryKeyValue}`"
74
74
  class="bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover cursor-pointer"
75
75
  :class="{'border-b': rowI !== rows.length - 1}"
76
76
  >
@@ -80,8 +80,8 @@
80
80
  @click="(e)=>{e.stopPropagation()}"
81
81
  id="checkbox-table-search-1"
82
82
  type="checkbox"
83
- :checked="checkboxesInternal.includes(row.id)"
84
- @change="(e)=>{addToCheckedValues(row.id)}"
83
+ :checked="checkboxesInternal.includes(row._primaryKeyValue)"
84
+ @change="(e)=>{addToCheckedValues(row._primaryKeyValue)}"
85
85
  class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 cursor-pointer">
86
86
  <label for="checkbox-table-search-1" class="sr-only">checkbox</label>
87
87
  </div>
@@ -299,6 +299,7 @@ watch(() => props.sort, (newSort) => {
299
299
  });
300
300
 
301
301
  function addToCheckedValues(id) {
302
+ console.log('checking', checkboxesInternal.value, 'id', id)
302
303
  if (checkboxesInternal.value.includes(id)) {
303
304
  checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== id);
304
305
  } else {
@@ -312,13 +313,13 @@ const columnsListed = computed(() => props.resource?.columns?.filter(c => c.show
312
313
  async function selectAll(value) {
313
314
  if (!allFromThisPageChecked.value) {
314
315
  props.rows.forEach((r) => {
315
- if (!checkboxesInternal.value.includes(r.id)) {
316
- checkboxesInternal.value.push(r.id)
316
+ if (!checkboxesInternal.value.includes(r._primaryKeyValue)) {
317
+ checkboxesInternal.value.push(r._primaryKeyValue)
317
318
  }
318
319
  });
319
320
  } else {
320
321
  props.rows.forEach((r) => {
321
- checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== r.id);
322
+ checkboxesInternal.value = checkboxesInternal.value.filter((item) => item !== r._primaryKeyValue);
322
323
  });
323
324
  }
324
325
  checkboxesInternal.value = [ ...checkboxesInternal.value ];
@@ -328,7 +329,7 @@ const totalPages = computed(() => Math.ceil(props.totalRows / props.pageSize));
328
329
 
329
330
  const allFromThisPageChecked = computed(() => {
330
331
  if (!props.rows) return false;
331
- return props.rows.every((r) => checkboxesInternal.value.includes(r.id));
332
+ return props.rows.every((r) => checkboxesInternal.value.includes(r._primaryKeyValue));
332
333
  });
333
334
  const ascArr = computed(() => sort.value.filter((s) => s.direction === 'asc').map((s) => s.field));
334
335
  const descArr = computed(() => sort.value.filter((s) => s.direction === 'desc').map((s) => s.field));
@@ -226,7 +226,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
226
226
  resource: AdminForthResource,
227
227
  record: any
228
228
  adminUser: AdminUser
229
- }): Promise<void>;
229
+ }): Promise<any>;
230
230
 
231
231
  getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
232
232
  }