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<
|
|
62
|
+
}): Promise<any> {
|
|
63
63
|
// transform value using setFieldValue and call createRecordOriginalValues
|
|
64
|
-
const
|
|
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 (
|
|
69
|
-
|
|
70
|
-
|
|
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',
|
|
78
|
-
|
|
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(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
@@ -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.
|
|
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.
|
|
84
|
-
@change="(e)=>{addToCheckedValues(row.
|
|
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.
|
|
316
|
-
checkboxesInternal.value.push(r.
|
|
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.
|
|
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.
|
|
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<
|
|
229
|
+
}): Promise<any>;
|
|
230
230
|
|
|
231
231
|
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
|
|
232
232
|
}
|