@adminforth/upload 1.0.14 β 1.0.15
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/dist/index.js +9 -9
- package/index.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
95
95
|
modifyResourceConfig: { get: () => super.modifyResourceConfig }
|
|
96
96
|
});
|
|
97
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
var _a, _b, _c, _d, _e;
|
|
98
|
+
var _a, _b, _c, _d, _e, _f;
|
|
99
99
|
_super.modifyResourceConfig.call(this, adminforth, resourceConfig);
|
|
100
100
|
// after column to store the path of the uploaded file, add new VirtualColumn,
|
|
101
101
|
// show only in edit and create views
|
|
@@ -156,7 +156,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
156
156
|
virtualColumn.editingNote = pathColumn.editingNote;
|
|
157
157
|
// ** HOOKS FOR CREATE **//
|
|
158
158
|
// add beforeSave hook to save virtual column to path column
|
|
159
|
-
resourceConfig.hooks.create.beforeSave.push((
|
|
159
|
+
resourceConfig.hooks.create.beforeSave.push((_g) => __awaiter(this, [_g], void 0, function* ({ record }) {
|
|
160
160
|
if (record[virtualColumn.name]) {
|
|
161
161
|
record[pathColumnName] = record[virtualColumn.name];
|
|
162
162
|
delete record[virtualColumn.name];
|
|
@@ -164,7 +164,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
164
164
|
return { ok: true };
|
|
165
165
|
}));
|
|
166
166
|
// in afterSave hook, aremove tag adminforth-not-yet-used from the file
|
|
167
|
-
resourceConfig.hooks.create.afterSave.push((
|
|
167
|
+
resourceConfig.hooks.create.afterSave.push((_h) => __awaiter(this, [_h], void 0, function* ({ record }) {
|
|
168
168
|
process.env.HEAVY_DEBUG && console.log('πΎπΎ after save ', record === null || record === void 0 ? void 0 : record.id);
|
|
169
169
|
if (record[pathColumnName]) {
|
|
170
170
|
const s3 = new S3({
|
|
@@ -188,7 +188,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
188
188
|
}));
|
|
189
189
|
// ** HOOKS FOR SHOW **//
|
|
190
190
|
// add show hook to get presigned URL
|
|
191
|
-
resourceConfig.hooks.show.afterDatasourceResponse.push((
|
|
191
|
+
resourceConfig.hooks.show.afterDatasourceResponse.push((_j) => __awaiter(this, [_j], void 0, function* ({ response }) {
|
|
192
192
|
const record = response[0];
|
|
193
193
|
if (!record) {
|
|
194
194
|
return { ok: true };
|
|
@@ -206,8 +206,8 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
206
206
|
return { ok: true };
|
|
207
207
|
}));
|
|
208
208
|
// ** HOOKS FOR LIST **//
|
|
209
|
-
if ((_e = this.options.preview) === null || _e === void 0 ? void 0 : _e.showInList) {
|
|
210
|
-
resourceConfig.hooks.list.afterDatasourceResponse.push((
|
|
209
|
+
if (((_e = this.options.preview) === null || _e === void 0 ? void 0 : _e.showInList) || ((_f = this.options.preview) === null || _f === void 0 ? void 0 : _f.showInList) === undefined) {
|
|
210
|
+
resourceConfig.hooks.list.afterDatasourceResponse.push((_k) => __awaiter(this, [_k], void 0, function* ({ response }) {
|
|
211
211
|
const s3 = new S3({
|
|
212
212
|
credentials: {
|
|
213
213
|
accessKeyId: this.options.s3AccessKeyId,
|
|
@@ -225,7 +225,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
225
225
|
}
|
|
226
226
|
// ** HOOKS FOR DELETE **//
|
|
227
227
|
// add delete hook which sets tag adminforth-candidate-for-cleanup to true
|
|
228
|
-
resourceConfig.hooks.delete.afterSave.push((
|
|
228
|
+
resourceConfig.hooks.delete.afterSave.push((_l) => __awaiter(this, [_l], void 0, function* ({ record }) {
|
|
229
229
|
if (record[pathColumnName]) {
|
|
230
230
|
const s3 = new S3({
|
|
231
231
|
credentials: {
|
|
@@ -257,7 +257,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
257
257
|
}));
|
|
258
258
|
// ** HOOKS FOR EDIT **//
|
|
259
259
|
// beforeSave
|
|
260
|
-
resourceConfig.hooks.edit.beforeSave.push((
|
|
260
|
+
resourceConfig.hooks.edit.beforeSave.push((_m) => __awaiter(this, [_m], void 0, function* ({ record }) {
|
|
261
261
|
// null is when value is removed
|
|
262
262
|
if (record[virtualColumn.name] || record[virtualColumn.name] === null) {
|
|
263
263
|
record[pathColumnName] = record[virtualColumn.name];
|
|
@@ -265,7 +265,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
265
265
|
return { ok: true };
|
|
266
266
|
}));
|
|
267
267
|
// add edit postSave hook to delete old file and remove tag from new file
|
|
268
|
-
resourceConfig.hooks.edit.afterSave.push((
|
|
268
|
+
resourceConfig.hooks.edit.afterSave.push((_o) => __awaiter(this, [_o], void 0, function* ({ record, oldRecord }) {
|
|
269
269
|
if (record[virtualColumn.name] || record[virtualColumn.name] === null) {
|
|
270
270
|
const s3 = new S3({
|
|
271
271
|
credentials: {
|
package/index.ts
CHANGED
|
@@ -224,7 +224,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
224
224
|
// ** HOOKS FOR LIST **//
|
|
225
225
|
|
|
226
226
|
|
|
227
|
-
if (this.options.preview?.showInList) {
|
|
227
|
+
if (this.options.preview?.showInList || this.options.preview?.showInList === undefined) {
|
|
228
228
|
resourceConfig.hooks.list.afterDatasourceResponse.push(async ({ response }: { response: any }) => {
|
|
229
229
|
const s3 = new S3({
|
|
230
230
|
credentials: {
|