add screensnew and tpldatanew
This commit is contained in:
parent
608661495b
commit
ff27e8a4ea
@ -18,12 +18,17 @@ const Wwws = {};
|
|||||||
Wwws.getwco = (wconame, ctx) => {
|
Wwws.getwco = (wconame, ctx) => {
|
||||||
/**
|
/**
|
||||||
* In a webpage to add a wco
|
* In a webpage to add a wco
|
||||||
* <script src="/api/adminapi/wwws/getwco/wco.js?wcotribe=adminapi&tribe=adminapi&xapp=admin&pagename=apxid&code=enjoy"></script>
|
* <script src="/api/adminapi/wwws/getwco/wco.js?wcotribe=adminapi&tribe=adminapi&xapp=admin&pagename=apxid&code=enjoy&tagid=id"></script>
|
||||||
* This will update /tribe/objects/wwws/itm/xapp.json
|
* <div id="tagid" add tag here to customize if needded></div>
|
||||||
* A wco has a /adminapi/objects/wco/itm/wconame.json
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
|
* The script request will update /tribe/objects/wwws/itm/xapp.json with
|
||||||
|
* tpl, schema, tpldata, ...
|
||||||
|
* A wco has a /adminapi/objects/wco/itm/wconame.json that contain tpl options, ref, schema, ...
|
||||||
|
* The dynamic content is store in <div id="ctx.tagid">
|
||||||
|
* so tpldata:{${tagid}_${wco.tpldatamodel.key}:"..."}
|
||||||
|
* When the script request is done, it checks if exist file in wwws/${app}/src/tpldata/${pagename}/${tagid}_${wco.tpldatamodel.key}_lg.json
|
||||||
|
* if not it create with the wco example tpldatamodel ${wco.tpldatamodel.key}
|
||||||
|
* Check also if exist in localdb.pagename.tpldata
|
||||||
*/
|
*/
|
||||||
const filereq = `../${ctx.wcotribe}/objects/wco/${wconame}/${wconame}.js`;
|
const filereq = `../${ctx.wcotribe}/objects/wco/${wconame}/${wconame}.js`;
|
||||||
const wcoconf = `../${ctx.wcotribe}/objects/wco/itm/${wconame}.json`;
|
const wcoconf = `../${ctx.wcotribe}/objects/wco/itm/${wconame}.json`;
|
||||||
@ -63,20 +68,24 @@ Wwws.getwco = (wconame, ctx) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// check that tpldata exist for the wco, if not create them with template data example into the project
|
// check that tpldata exist for the wco, if not create them with template data example into the project
|
||||||
if (wcoinfo.tpldatamodel && Object.keys(wcoinfo.tpldatamodel).length > 0) {
|
if (ctx.tagid && wcoinfo.tpldatamodel && Object.keys(wcoinfo.tpldatamodel).length > 0) {
|
||||||
Object.keys(wcoinfo.tpldatamodel).forEach((t) => {
|
Object.keys(wcoinfo.tpldatamodel).forEach((t) => {
|
||||||
const pathtpldata = `../${ctx.tribe}/objects/wwws/${ctx.xapp}/src/tpldata/${wconame}/${t}`;
|
const pathtpldata = `${ctx.tribe}/objects/wwws/${ctx.xapp}/src/tpldata/${ctx.pagename}/${ctx.tagid}_${t}`;
|
||||||
if (!Object.keys(webpage.pages[ctx.pagename].tpldata).includes(t)) {
|
const localdbname=`${ctx.pagename}_${ctx.tagid}_${t}`
|
||||||
webpage.pages[ctx.pagename].tpldata[t] = pathtpldata;
|
if (!Object.keys(webpage.pages[ctx.pagename].tpldata).includes(localdbname)) {
|
||||||
|
webpage.pages[ctx.pagename].tpldata[localdbname] = pathtpldata;
|
||||||
}
|
}
|
||||||
wcoinfo.lang.forEach((l) => {
|
wcoinfo.lang.forEach((l) => {
|
||||||
if (
|
if (
|
||||||
!fs.existsSync(`${pathtpldata}_${l}.json`) &&
|
!fs.existsSync(`../${pathtpldata}_${l}.json`) &&
|
||||||
fs.existsSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`)
|
fs.existsSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`)
|
||||||
) {
|
) {
|
||||||
fs.copySync(
|
const tpldataexample=fs.readJSONSync(`../${wcoinfo.tpldatamodel[t]}_${l}.json`)
|
||||||
`../${wcoinfo.tpldatamodel[t]}_${l}.json`,
|
Object.keys(ctx).forEach(k=>{
|
||||||
`${pathtpldata}_${l}.json`
|
tpldataexample[k]=ctx[k]
|
||||||
|
})
|
||||||
|
fs.outputJSONSync(
|
||||||
|
`../${pathtpldata}_${l}.json`,tpldataexample
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -96,7 +105,7 @@ Wwws.getwco = (wconame, ctx) => {
|
|||||||
[
|
[
|
||||||
wcoinfo.schema.forEach((s) => {
|
wcoinfo.schema.forEach((s) => {
|
||||||
s = s.replace("{{tribe}}", ctx.tribe);
|
s = s.replace("{{tribe}}", ctx.tribe);
|
||||||
if (webpage.pages[ctx.pagename].schema.includes(s)) {
|
if (!webpage.pages[ctx.pagename].schema.includes(s)) {
|
||||||
webpage.pages[ctx.pagename].schema.push(s);
|
webpage.pages[ctx.pagename].schema.push(s);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@ -414,9 +423,11 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
options: {},
|
options: {},
|
||||||
tpl: {},
|
tpl: {},
|
||||||
tpldata: {},
|
tpldata: {},
|
||||||
|
tdatanew,
|
||||||
ref: {},
|
ref: {},
|
||||||
schema: {},
|
schema: {},
|
||||||
screens:{}
|
screens:{},
|
||||||
|
screensnew:{}
|
||||||
};
|
};
|
||||||
localstorage.headers.xlang = lg;
|
localstorage.headers.xlang = lg;
|
||||||
// A faire plus tard charger tous les referentiele et les data pour une page adminpage
|
// A faire plus tard charger tous les referentiele et les data pour une page adminpage
|
||||||
@ -471,6 +482,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
if (!loc.tpl) loc.tpl = {};
|
if (!loc.tpl) loc.tpl = {};
|
||||||
if (!loc.tpldata) loc.tpldata = {};
|
if (!loc.tpldata) loc.tpldata = {};
|
||||||
|
if (!loc.tpldatanew) loc.tpldatanew = {};
|
||||||
// remove loc.components (this is now in tpldata and tpl)
|
// remove loc.components (this is now in tpldata and tpl)
|
||||||
if (loc.components) {
|
if (loc.components) {
|
||||||
loc.components.forEach((c) => {
|
loc.components.forEach((c) => {
|
||||||
@ -512,6 +524,22 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (loc.tpldatanew) {
|
||||||
|
Object.keys(loc.tpldatanew).forEach((r) => {
|
||||||
|
let src = `../${loc.tpldatanew[r]}`;
|
||||||
|
//console.log(path.resolve(src))
|
||||||
|
if (!fs.existsSync(src)) {
|
||||||
|
src += `_${lg}.json`;
|
||||||
|
}
|
||||||
|
if (fs.existsSync(src)) {
|
||||||
|
localstorage.tpldatanew[r] = fs.readJSONSync(src);
|
||||||
|
} else {
|
||||||
|
localstorage.tpldatanew[
|
||||||
|
r
|
||||||
|
] = `Check your ${fileparam} for template in ${pagename} profil and ${r} in tpldatanew`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!loc.screens) loc.screens={}
|
if (!loc.screens) loc.screens={}
|
||||||
if (loc.screens) {
|
if (loc.screens) {
|
||||||
Object.keys(loc.screens).forEach((r) => {
|
Object.keys(loc.screens).forEach((r) => {
|
||||||
@ -529,6 +557,23 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (!loc.screensnew) loc.screensnew={}
|
||||||
|
if (loc.screensnew) {
|
||||||
|
Object.keys(loc.screensnew).forEach((r) => {
|
||||||
|
let src = `../${loc.screensnew[r]}`;
|
||||||
|
//console.log(path.resolve(src))
|
||||||
|
if (!fs.existsSync(src)) {
|
||||||
|
src += `_${lg}.json`;
|
||||||
|
}
|
||||||
|
if (fs.existsSync(src)) {
|
||||||
|
localstorage.screensnew[r] = fs.readJSONSync(src);
|
||||||
|
} else {
|
||||||
|
localstorage.screensnew[
|
||||||
|
r
|
||||||
|
] = `Check your ${fileparam} for template in ${pagename} profil and ${r} in screensnew`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (loc.schema) {
|
if (loc.schema) {
|
||||||
loc.schema.forEach((objpath) => {
|
loc.schema.forEach((objpath) => {
|
||||||
const name = path.basename(objpath);
|
const name = path.basename(objpath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user