@ghentcdh/json-forms-vue 0.5.1 → 0.6.1
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/index.d.ts +1 -0
- package/index.js +54 -0
- package/index.mjs +54 -0
- package/package.json +19 -5
- package/repository/crud.repository.d.ts +31 -0
- package/repository/index.d.ts +1 -0
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1371,6 +1371,59 @@ class FormModalService {
|
|
|
1371
1371
|
});
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
+
const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
1375
|
+
const notificationEntity = options.notification?.entityType || "entity";
|
|
1376
|
+
const notificationStore = options.notification?.notification ?? null;
|
|
1377
|
+
const getDataUri = (...suffix) => {
|
|
1378
|
+
return [formSchemaModel.uri, ...suffix].join("/");
|
|
1379
|
+
};
|
|
1380
|
+
const handleSuccess = (message) => {
|
|
1381
|
+
notificationStore?.success(message);
|
|
1382
|
+
};
|
|
1383
|
+
const handleError = (error, message) => {
|
|
1384
|
+
console.error(error);
|
|
1385
|
+
notificationStore?.error(message);
|
|
1386
|
+
throw new Error(error);
|
|
1387
|
+
};
|
|
1388
|
+
const create = (object, options2) => {
|
|
1389
|
+
return httpRequest.post(getDataUri(), object, options2).then((response) => {
|
|
1390
|
+
handleSuccess(`Created ${notificationEntity}`);
|
|
1391
|
+
return response;
|
|
1392
|
+
}).catch((response) => {
|
|
1393
|
+
handleError(response, `Failed to create ${notificationEntity}`);
|
|
1394
|
+
});
|
|
1395
|
+
};
|
|
1396
|
+
const patch = (id, object, options2) => {
|
|
1397
|
+
return httpRequest.patch(getDataUri(id), object, options2).then((response) => {
|
|
1398
|
+
handleSuccess(`Saved ${notificationEntity}`);
|
|
1399
|
+
return response;
|
|
1400
|
+
}).catch((response) => {
|
|
1401
|
+
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1402
|
+
});
|
|
1403
|
+
};
|
|
1404
|
+
const get = (id, options2) => {
|
|
1405
|
+
return httpRequest.get(getDataUri(id), options2);
|
|
1406
|
+
};
|
|
1407
|
+
const _delete = (id, options2) => {
|
|
1408
|
+
return httpRequest.delete(getDataUri(id), options2).then((response) => {
|
|
1409
|
+
handleSuccess(`${notificationEntity} deleted`);
|
|
1410
|
+
return response;
|
|
1411
|
+
}).catch((response) => {
|
|
1412
|
+
handleError(response, `Failed to delete ${notificationEntity}`);
|
|
1413
|
+
});
|
|
1414
|
+
};
|
|
1415
|
+
const createMulti = (objects, options2) => {
|
|
1416
|
+
return Promise.all(
|
|
1417
|
+
objects.map((object) => httpRequest.post(getDataUri(), object, options2))
|
|
1418
|
+
).then((response) => {
|
|
1419
|
+
handleSuccess(`Created ${notificationEntity}`);
|
|
1420
|
+
return response;
|
|
1421
|
+
}).catch((response) => {
|
|
1422
|
+
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1423
|
+
});
|
|
1424
|
+
};
|
|
1425
|
+
return { create, patch, createMulti, delete: _delete, get };
|
|
1426
|
+
};
|
|
1374
1427
|
exports.ArrayRenderer = ArrayRenderer;
|
|
1375
1428
|
exports.AutocompleteControlRenderer = AutocompleteControlRenderer;
|
|
1376
1429
|
exports.BooleanControlRenderer = BooleanControlRenderer;
|
|
@@ -1387,6 +1440,7 @@ exports.StringControlRenderer = StringControlRenderer;
|
|
|
1387
1440
|
exports.TableComponent = _sfc_main$4;
|
|
1388
1441
|
exports.arrayRenderers = arrayRenderers;
|
|
1389
1442
|
exports.controlRenderers = controlRenderers;
|
|
1443
|
+
exports.createRepository = createRepository;
|
|
1390
1444
|
exports.isArrayRenderer = isArrayRenderer;
|
|
1391
1445
|
exports.isAutoCompleteControl = isAutoCompleteControl;
|
|
1392
1446
|
exports.isCustomControl = isCustomControl;
|
package/index.mjs
CHANGED
|
@@ -1369,6 +1369,59 @@ class FormModalService {
|
|
|
1369
1369
|
});
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
|
+
const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
1373
|
+
const notificationEntity = options.notification?.entityType || "entity";
|
|
1374
|
+
const notificationStore = options.notification?.notification ?? null;
|
|
1375
|
+
const getDataUri = (...suffix) => {
|
|
1376
|
+
return [formSchemaModel.uri, ...suffix].join("/");
|
|
1377
|
+
};
|
|
1378
|
+
const handleSuccess = (message) => {
|
|
1379
|
+
notificationStore?.success(message);
|
|
1380
|
+
};
|
|
1381
|
+
const handleError = (error, message) => {
|
|
1382
|
+
console.error(error);
|
|
1383
|
+
notificationStore?.error(message);
|
|
1384
|
+
throw new Error(error);
|
|
1385
|
+
};
|
|
1386
|
+
const create = (object, options2) => {
|
|
1387
|
+
return httpRequest.post(getDataUri(), object, options2).then((response) => {
|
|
1388
|
+
handleSuccess(`Created ${notificationEntity}`);
|
|
1389
|
+
return response;
|
|
1390
|
+
}).catch((response) => {
|
|
1391
|
+
handleError(response, `Failed to create ${notificationEntity}`);
|
|
1392
|
+
});
|
|
1393
|
+
};
|
|
1394
|
+
const patch = (id, object, options2) => {
|
|
1395
|
+
return httpRequest.patch(getDataUri(id), object, options2).then((response) => {
|
|
1396
|
+
handleSuccess(`Saved ${notificationEntity}`);
|
|
1397
|
+
return response;
|
|
1398
|
+
}).catch((response) => {
|
|
1399
|
+
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1400
|
+
});
|
|
1401
|
+
};
|
|
1402
|
+
const get = (id, options2) => {
|
|
1403
|
+
return httpRequest.get(getDataUri(id), options2);
|
|
1404
|
+
};
|
|
1405
|
+
const _delete = (id, options2) => {
|
|
1406
|
+
return httpRequest.delete(getDataUri(id), options2).then((response) => {
|
|
1407
|
+
handleSuccess(`${notificationEntity} deleted`);
|
|
1408
|
+
return response;
|
|
1409
|
+
}).catch((response) => {
|
|
1410
|
+
handleError(response, `Failed to delete ${notificationEntity}`);
|
|
1411
|
+
});
|
|
1412
|
+
};
|
|
1413
|
+
const createMulti = (objects, options2) => {
|
|
1414
|
+
return Promise.all(
|
|
1415
|
+
objects.map((object) => httpRequest.post(getDataUri(), object, options2))
|
|
1416
|
+
).then((response) => {
|
|
1417
|
+
handleSuccess(`Created ${notificationEntity}`);
|
|
1418
|
+
return response;
|
|
1419
|
+
}).catch((response) => {
|
|
1420
|
+
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1421
|
+
});
|
|
1422
|
+
};
|
|
1423
|
+
return { create, patch, createMulti, delete: _delete, get };
|
|
1424
|
+
};
|
|
1372
1425
|
export {
|
|
1373
1426
|
ArrayRenderer,
|
|
1374
1427
|
AutocompleteControlRenderer,
|
|
@@ -1386,6 +1439,7 @@ export {
|
|
|
1386
1439
|
_sfc_main$4 as TableComponent,
|
|
1387
1440
|
arrayRenderers,
|
|
1388
1441
|
controlRenderers,
|
|
1442
|
+
createRepository,
|
|
1389
1443
|
isArrayRenderer,
|
|
1390
1444
|
isAutoCompleteControl,
|
|
1391
1445
|
isCustomControl,
|
package/package.json
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghentcdh/json-forms-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
|
+
"module": "./index.mjs",
|
|
5
6
|
"types": "./index.d.ts",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"import": "./index.mjs",
|
|
9
|
-
"require": "./index.js"
|
|
10
|
+
"require": "./index.js",
|
|
11
|
+
"types": "./index.d.ts"
|
|
10
12
|
},
|
|
11
|
-
"./index.css":
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
"./index.css": "./index.css"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@ghentcdh/authentication-vue": ">=0.6.0",
|
|
17
|
+
"@ghentcdh/json-forms-core": ">=0.0.1",
|
|
18
|
+
"@ghentcdh/tools-vue": ">=0.6.0",
|
|
19
|
+
"@ghentcdh/ui": ">=0.6.0",
|
|
20
|
+
"@jsonforms/core": "^3.4.0",
|
|
21
|
+
"@jsonforms/vue": "^3.4.0",
|
|
22
|
+
"@jsonforms/vue-vanilla": "^3.4.0",
|
|
23
|
+
"@toast-ui/editor": "^3.2.0",
|
|
24
|
+
"@vueuse/core": "^14.0.0",
|
|
25
|
+
"lodash-es": "^4.17.0",
|
|
26
|
+
"vue": "^3.5.0",
|
|
27
|
+
"vue-router": "^5.0.0"
|
|
14
28
|
},
|
|
15
29
|
"repository": {
|
|
16
30
|
"type": "git",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AxiosRequestInterceptorUse } from 'axios';
|
|
2
|
+
import { FormSchemaModel } from '../../../core/src/index.ts';
|
|
3
|
+
type RequestOptions = {
|
|
4
|
+
skipAuth?: boolean;
|
|
5
|
+
queryParams?: Record<string, any>;
|
|
6
|
+
contentType?: string;
|
|
7
|
+
};
|
|
8
|
+
export type HttpRequest<T> = AxiosRequestInterceptorUse<any>;
|
|
9
|
+
export type NotificationStore = {
|
|
10
|
+
info: (message: string) => void;
|
|
11
|
+
error: (message: string) => void;
|
|
12
|
+
warning: (message: string) => void;
|
|
13
|
+
success: (message: string) => void;
|
|
14
|
+
};
|
|
15
|
+
type RepositoryOptions = {
|
|
16
|
+
notification?: {
|
|
17
|
+
show: true;
|
|
18
|
+
entityType: string;
|
|
19
|
+
notification: NotificationStore;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const createRepository: <T extends {
|
|
23
|
+
id?: string;
|
|
24
|
+
}>(formSchemaModel: Pick<FormSchemaModel, "uri">, httpRequest: HttpRequest<T>, options?: RepositoryOptions) => {
|
|
25
|
+
create: (object: T, options?: RequestOptions) => any;
|
|
26
|
+
patch: (id: string, object: T, options?: RequestOptions) => any;
|
|
27
|
+
createMulti: (objects: T[], options?: RequestOptions) => Promise<any>;
|
|
28
|
+
delete: (id: string, options?: RequestOptions) => any;
|
|
29
|
+
get: (id: string, options?: RequestOptions) => any;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './crud.repository';
|