adminizer 4.3.0-build.103 → 4.3.0-build.104
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/assets/{add-1E1UsMVZ.js → add-GU2aUgZb.js} +1 -1
- package/assets/{add-form-CGa9QbwE.js → add-form-eJEMdv04.js} +1 -1
- package/assets/app.js +2 -2
- package/assets/{catalog-B9hdop59.js → catalog-CZ_wUlq2.js} +1 -1
- package/assets/{field-renderer-4obZ_jUo.js → field-renderer-BhrQ1BlC.js} +2 -2
- package/assets/{form-qyuRZEIC.js → form-CbwqHa8P.js} +1 -1
- package/assets/{form-DmBOE8Za.js → form-DMebrwNT.js} +1 -1
- package/assets/{home-DxhSEMhE.js → home-GaTaODxj.js} +2 -2
- package/assets/manifest.json +16 -16
- package/assets/{media-manager-UQT6RhI8.js → media-manager-DyP_37fD.js} +1 -1
- package/controllers/edit.js +4 -2
- package/controllers/form.js +5 -3
- package/controllers/view.js +4 -2
- package/lib/media-manager/AbstractMediaManager.d.ts +5 -3
- package/lib/media-manager/DefaultMediaManager.d.ts +3 -3
- package/lib/media-manager/DefaultMediaManager.js +17 -12
- package/lib/media-manager/helpers/MediaManagerHelper.d.ts +4 -1
- package/lib/media-manager/helpers/MediaManagerHelper.js +5 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as h,ak as kn,al as In,g as Q,w as _i,x as $i,Y as Ln,y as Wi,z as ht,a8 as Mr,a9 as Tr,aa as jr,ab as Rr,am as zn,an as Yt,B as J,a1 as Pn,a2 as Bn,a3 as _t,a4 as oe,a5 as Xn,a6 as se,I as qt,L as Ct,a as bt,ao as Hi,ap as Ui,aq as Fi,a0 as Vi,ar as Gi,f as fr,aj as Ki,D as qi,h as Ji,i as Zi,k as Qr,as as Qi}from"./app.js";import{r as g,e as B}from"./monaco-ICtx6xoc.js";import{r as mt}from"./handsontable-PVakPtJV.js";import{I as Yn,P as $t,p as ea}from"./field-renderer-
|
|
1
|
+
import{j as h,ak as kn,al as In,g as Q,w as _i,x as $i,Y as Ln,y as Wi,z as ht,a8 as Mr,a9 as Tr,aa as jr,ab as Rr,am as zn,an as Yt,B as J,a1 as Pn,a2 as Bn,a3 as _t,a4 as oe,a5 as Xn,a6 as se,I as qt,L as Ct,a as bt,ao as Hi,ap as Ui,aq as Fi,a0 as Vi,ar as Gi,f as fr,aj as Ki,D as qi,h as Ji,i as Zi,k as Qr,as as Qi}from"./app.js";import{r as g,e as B}from"./monaco-ICtx6xoc.js";import{r as mt}from"./handsontable-PVakPtJV.js";import{I as Yn,P as $t,p as ea}from"./field-renderer-BhrQ1BlC.js";import{T as ta,a as ra,b as Ke,c as qe}from"./tabs-BK_5wdPA.js";import{d as na}from"./jsoneditor-D95dIAP2.js";import"./vendor-wzZzN_Jv.js";import"./dynamic-controls-BOYmRX_z.js";function ia(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return g.useMemo(()=>n=>{e.forEach(a=>a(n))},e)}const Jt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function it(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Or(t){return"nodeType"in t}function ee(t){var e,r;return t?it(t)?t:Or(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function Ar(t){const{Document:e}=ee(t);return t instanceof e}function Tt(t){return it(t)?!1:t instanceof ee(t).HTMLElement}function _n(t){return t instanceof ee(t).SVGElement}function at(t){return t?it(t)?t.document:Or(t)?Ar(t)?t:Tt(t)||_n(t)?t.ownerDocument:document:document:document}const pe=Jt?g.useLayoutEffect:g.useEffect;function Zt(t){const e=g.useRef(t);return pe(()=>{e.current=t}),g.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return e.current==null?void 0:e.current(...n)},[])}function aa(){const t=g.useRef(null),e=g.useCallback((n,a)=>{t.current=setInterval(n,a)},[]),r=g.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function St(t,e){e===void 0&&(e=[t]);const r=g.useRef(t);return pe(()=>{r.current!==t&&(r.current=t)},e),r}function jt(t,e){const r=g.useRef();return g.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...e])}function Wt(t){const e=Zt(t),r=g.useRef(null),n=g.useCallback(a=>{a!==r.current&&(e==null||e(a,r.current)),r.current=a},[]);return[r,n]}function Ht(t){const e=g.useRef();return g.useEffect(()=>{e.current=t},[t]),e.current}let or={};function Rt(t,e){return g.useMemo(()=>{if(e)return e;const r=or[t]==null?0:or[t]+1;return or[t]=r,t+"-"+r},[t,e])}function $n(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const s=Object.entries(o);for(const[d,l]of s){const c=i[d];c!=null&&(i[d]=c+t*l)}return i},{...e})}}const et=$n(1),Et=$n(-1);function oa(t){return"clientX"in t&&"clientY"in t}function Ot(t){if(!t)return!1;const{KeyboardEvent:e}=ee(t.target);return e&&t instanceof e}function sa(t){if(!t)return!1;const{TouchEvent:e}=ee(t.target);return e&&t instanceof e}function Ut(t){if(sa(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return oa(t)?{x:t.clientX,y:t.clientY}:null}const ye=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[ye.Translate.toString(t),ye.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),en="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function la(t){return t.matches(en)?t:t.querySelector(en)}const ca={display:"none"};function da(t){let{id:e,value:r}=t;return B.createElement("div",{id:e,style:ca},r)}function ua(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return B.createElement("div",{id:e,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function ha(){const[t,e]=g.useState("");return{announce:g.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Wn=g.createContext(null);function fa(t){const e=g.useContext(Wn);g.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function pa(){const[t]=g.useState(()=>new Set),e=g.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[g.useCallback(n=>{let{type:a,event:i}=n;t.forEach(o=>{var s;return(s=o[a])==null?void 0:s.call(o,i)})},[t]),e]}const ga={draggable:`
|
|
2
2
|
To pick up a draggable item, press the space bar.
|
|
3
3
|
While dragging, use the arrow keys to move the item.
|
|
4
4
|
Press space again to drop the item in its new position, or press escape to cancel.
|
package/controllers/edit.js
CHANGED
|
@@ -143,8 +143,10 @@ export default async function edit(req, res) {
|
|
|
143
143
|
let fieldConfigConfig = fields[field].config;
|
|
144
144
|
if (fieldConfigConfig.type === 'mediamanager') {
|
|
145
145
|
record[field] = await getRelationsMediaManager({
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
mediaManagerId: fieldConfigConfig.options?.id ?? "default",
|
|
147
|
+
model: entity.model.modelname,
|
|
148
|
+
widgetName: field,
|
|
149
|
+
modelId: id
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
}
|
package/controllers/form.js
CHANGED
|
@@ -47,7 +47,7 @@ export default async function form(req, res) {
|
|
|
47
47
|
let options = form[key].options;
|
|
48
48
|
let mediaManager = MediaManagerHandler.get(options?.id ?? "default");
|
|
49
49
|
if (req.body[key])
|
|
50
|
-
await mediaManager.setRelations(req.body[key],
|
|
50
|
+
await mediaManager.setRelations(req.body[key], `${slug}_${key}`, 0, key);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
for (let field of Object.keys(req.body)) {
|
|
@@ -64,8 +64,10 @@ export default async function form(req, res) {
|
|
|
64
64
|
try {
|
|
65
65
|
if (form[key].type === 'mediamanager') {
|
|
66
66
|
form[key].value = await getRelationsMediaManager({
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
mediaManagerId: form[key].options?.id ?? "default",
|
|
68
|
+
model: `${slug}_${key}`,
|
|
69
|
+
widgetName: key,
|
|
70
|
+
modelId: 0
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
73
|
else {
|
package/controllers/view.js
CHANGED
|
@@ -87,8 +87,10 @@ export default async function view(req, res) {
|
|
|
87
87
|
let fieldConfigConfig = fields[field].config;
|
|
88
88
|
if (fieldConfigConfig.type === 'mediamanager') {
|
|
89
89
|
record[field] = await getRelationsMediaManager({
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
mediaManagerId: fieldConfigConfig.options?.id ?? "default",
|
|
91
|
+
model: entity.model.modelname,
|
|
92
|
+
widgetName: field,
|
|
93
|
+
modelId: req.params.id
|
|
92
94
|
});
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -36,8 +36,10 @@ export interface MediaManagerWidgetClientItem extends MediaManagerWidgetItem {
|
|
|
36
36
|
url?: string;
|
|
37
37
|
}
|
|
38
38
|
export interface MediaManagerWidgetJSON {
|
|
39
|
-
list: MediaManagerWidgetItem[];
|
|
40
39
|
mediaManagerId: string;
|
|
40
|
+
model: string;
|
|
41
|
+
widgetName: string;
|
|
42
|
+
modelId: string | number;
|
|
41
43
|
}
|
|
42
44
|
export interface MediaManagerWidgetData {
|
|
43
45
|
id: string;
|
|
@@ -207,8 +209,8 @@ export declare abstract class AbstractMediaManager {
|
|
|
207
209
|
/**
|
|
208
210
|
* widget Id in the model in which the mediafile was added
|
|
209
211
|
*/
|
|
210
|
-
modelId:
|
|
211
|
-
abstract
|
|
212
|
+
modelId: number, widgetName: string): Promise<void>;
|
|
213
|
+
abstract getRelations(model: string, widgetName: string, modelId: string | number): Promise<MediaManagerWidgetClientItem[]>;
|
|
212
214
|
/**
|
|
213
215
|
* Search all items.
|
|
214
216
|
* If not this.allowSearch = true then it will not come here
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractMediaManager, MediaManagerItem, File,
|
|
1
|
+
import { AbstractMediaManager, MediaManagerItem, File, MediaManagerWidgetData, MediaManagerWidgetClientItem, SortCriteria } from "./AbstractMediaManager";
|
|
2
2
|
import { Adminizer } from "../Adminizer";
|
|
3
3
|
export declare class DefaultMediaManager extends AbstractMediaManager {
|
|
4
4
|
readonly itemTypes: File<MediaManagerItem>[];
|
|
@@ -12,6 +12,6 @@ export declare class DefaultMediaManager extends AbstractMediaManager {
|
|
|
12
12
|
next: boolean;
|
|
13
13
|
}>;
|
|
14
14
|
searchAll(s: string, group: string): Promise<MediaManagerItem[]>;
|
|
15
|
-
setRelations(data: MediaManagerWidgetData[], model: string, modelId:
|
|
16
|
-
|
|
15
|
+
setRelations(data: MediaManagerWidgetData[], model: string, modelId: number, widgetName: string): Promise<void>;
|
|
16
|
+
getRelations(model: string, widgetName: string, modelId: string | number): Promise<MediaManagerWidgetClientItem[]>;
|
|
17
17
|
}
|
|
@@ -57,7 +57,7 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
57
57
|
}
|
|
58
58
|
async setRelations(data, model, modelId, widgetName) {
|
|
59
59
|
let modelAssociations = await this.adminizer.modelHandler.model.get(this.modelAssoc)["_find"]({
|
|
60
|
-
where: { modelId: modelId, model: model, widgetName: widgetName },
|
|
60
|
+
where: { modelId: modelId, model: model.toLowerCase(), widgetName: widgetName },
|
|
61
61
|
});
|
|
62
62
|
for (const modelAssociation of modelAssociations) {
|
|
63
63
|
const q = {};
|
|
@@ -69,7 +69,7 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
69
69
|
for (const [key, widgetItem] of data.entries()) {
|
|
70
70
|
await this.adminizer.modelHandler.model.get(this.modelAssoc)["_create"]({
|
|
71
71
|
mediaManagerId: this.id,
|
|
72
|
-
model: model,
|
|
72
|
+
model: model.toLowerCase(),
|
|
73
73
|
modelId: modelId,
|
|
74
74
|
[fieldName]: widgetItem.id,
|
|
75
75
|
widgetName: widgetName,
|
|
@@ -77,18 +77,23 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
async
|
|
80
|
+
async getRelations(model, widgetName, modelId) {
|
|
81
81
|
let widgetItems = [];
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
const fieldName = this.adminizer.ormAdapters[0].ormType === 'sequelize' ? 'fileRef' : 'file';
|
|
83
|
+
let files = await this.adminizer.modelHandler.model.get(this.modelAssoc)['_find']({
|
|
84
|
+
where: {
|
|
85
|
+
model: model.toLowerCase(),
|
|
86
|
+
widgetName: widgetName,
|
|
87
|
+
modelId: +modelId
|
|
88
|
+
},
|
|
89
|
+
sort: "sortOrder ASC"
|
|
90
|
+
}, { populate: [[fieldName, {}]] });
|
|
91
|
+
for (const file of files) {
|
|
87
92
|
widgetItems.push({
|
|
88
|
-
id: file.id,
|
|
89
|
-
mimeType: file.mimeType,
|
|
90
|
-
url: file.url,
|
|
91
|
-
variants:
|
|
93
|
+
id: file[fieldName].id,
|
|
94
|
+
mimeType: file[fieldName].mimeType,
|
|
95
|
+
url: file[fieldName].url,
|
|
96
|
+
variants: []
|
|
92
97
|
});
|
|
93
98
|
}
|
|
94
99
|
return widgetItems;
|
|
@@ -16,14 +16,17 @@ export declare function randomFileName(filenameOrig: string, type: string, prefi
|
|
|
16
16
|
* @param model
|
|
17
17
|
* @param recordId
|
|
18
18
|
*/
|
|
19
|
-
export declare function saveRelationsMediaManager(fields: Fields, reqData: PostParams, model: string, recordId:
|
|
19
|
+
export declare function saveRelationsMediaManager(fields: Fields, reqData: PostParams, model: string, recordId: number): Promise<void>;
|
|
20
20
|
/**
|
|
21
21
|
* Get realtions
|
|
22
22
|
* @param data
|
|
23
|
+
* @param model
|
|
24
|
+
* @param widgetName
|
|
23
25
|
*/
|
|
24
26
|
export declare function getRelationsMediaManager(data: MediaManagerWidgetJSON): Promise<import("../AbstractMediaManager").MediaManagerWidgetClientItem[]>;
|
|
25
27
|
/**
|
|
26
28
|
* Delate Ralations
|
|
29
|
+
* @param adminizer
|
|
27
30
|
* @param model
|
|
28
31
|
* @param record
|
|
29
32
|
*/
|
|
@@ -32,13 +32,16 @@ export async function saveRelationsMediaManager(fields, reqData, model, recordId
|
|
|
32
32
|
/**
|
|
33
33
|
* Get realtions
|
|
34
34
|
* @param data
|
|
35
|
+
* @param model
|
|
36
|
+
* @param widgetName
|
|
35
37
|
*/
|
|
36
38
|
export async function getRelationsMediaManager(data) {
|
|
37
39
|
let mediaManager = MediaManagerHandler.get(data.mediaManagerId);
|
|
38
|
-
return await mediaManager.
|
|
40
|
+
return await mediaManager.getRelations(data.model, data.widgetName, data.modelId);
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Delate Ralations
|
|
44
|
+
* @param adminizer
|
|
42
45
|
* @param model
|
|
43
46
|
* @param record
|
|
44
47
|
*/
|
|
@@ -50,7 +53,7 @@ export async function deleteRelationsMediaManager(adminizer, model, record) {
|
|
|
50
53
|
const option = field.options;
|
|
51
54
|
let mediaManager = MediaManagerHandler.get(option?.id ?? 'default');
|
|
52
55
|
let emptyData = [];
|
|
53
|
-
await mediaManager.setRelations(emptyData, model, record[0].id, key);
|
|
56
|
+
await mediaManager.setRelations(emptyData, model, +record[0].id, key);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|