@xuda.io/runtime-bundle 1.0.250 → 1.0.252
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/js/modules/xuda-api-library.min.mjs +1 -1
- package/js/modules/xuda-api-library.mjs +4 -2
- package/js/xuda-runtime-bundle.js +32 -51
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +32 -51
- package/js/xuda-runtime-slim.min.es.js +32 -51
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +2 -2
- package/js/xuda-worker-bundle.js +2 -2
- package/js/xuda-worker-bundle.min.js +1 -1
- package/js/xuda_common-bundle.js +2 -2
- package/js/xuda_common-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export class XudaModule{constructor(e){this.func=e.func;this.glb=e.glb;this.SESSION_OBJ=e.SESSION_OBJ;this.SESSION_ID=e.SESSION_ID;this.APP_OBJ=e.APP_OBJ;this.dsSession=e.dsSession;this.job_id=e.job_id;this._session=this.SESSION_OBJ[this.SESSION_ID];return this}async get_field_value(field_id){if(!field_id){console.error("xu.getFieldValue: field_id cannot be empty");return false}let ret_get_value=await this.func.datasource.get_value(this.SESSION_ID,field_id,this.dsSession);if(!ret_get_value.found){console.error(`xu.getFieldValue: ${field_id} field not found`);return false}return ret_get_value.ret.value}async set_field_value(field_id,value){if(!field_id){console.error("xu.setFieldValue: field_id cannot be empty");return false}if(typeof value==="undefined"){console.error(`xu.setFieldValue: ${field_id} - value cannot be undefined`);return false}let ret_get_value=await this.func.datasource.get_value(this.SESSION_ID,field_id,this.dsSession);if(!ret_get_value.found){console.error(`xu.setFieldValue: ${field_id} field not found`);return false}let _ds=this._session.DS_GLB[ret_get_value.dsSessionP];const datasource_changes={[_ds.dsSession]:{[ret_get_value.currentRecordId]:{[field_id]:value}}};return await this.func.datasource.update(this.SESSION_ID,datasource_changes)}async invoke_event(event_id){if(!event_id){console.error("xu.invokeEvent: event_id cannot be empty");return false}let ds;for await(const[key,val]of Object.entries(Object.assign([],this._session.DS_GLB).reverse())){let ds_val=val;let ds_key=ds_val.dsSession;const _view_obj=await this.func.utils.VIEWS_OBJ.get(this.SESSION_ID,ds_val.prog_id);if(_.isEmpty(_view_obj.progEvents))continue;if(ds)break;for await(const[key,val]of Object.entries(_view_obj.progEvents)){if(val?.data?.type==="user_defined"&&val.data.event_name===event_id){ds=ds_key;break}}}if(typeof ds==="undefined"){this.reject("xu.invokeEvent error",`${event_id} event_id not found`,this.job_id);return false}return this.func.events.validate(this.SESSION_ID,"user_defined",ds,event_id)}async read_drive(filename,cb){try{const response=await fetch(`https://${this._session.domain}/workspace-drive/`+filename+"&"+this._session.gtp_token);if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.readDrive error",e,this.job_id)}}async write_drive(stream,filename,make_public,cb){var data={app_id:this._session.app_id,gtp_token:this._session.gtp_token,app_token:this._session.app_token,req_from_api:"true",public:make_public?"true":""};const form=new FormData;for(const[key,val]of Object.entries(data)){form.append(key,val)}form.append("file",stream,filename);try{const response=await fetch(this.func.common.get_url(this.SESSION_ID,"rpi","runtime_upload_file"),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(form)});if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.writeDrive error",e,this.job_id)}}resolve(cb,job_id){if(job_id){this.func.events.delete_job(this.SESSION_ID,job_id)}if(cb){cb()}}reject(msg,details,job_id){if(job_id){this.func.events.delete_job(this.SESSION_ID,job_id)}this.log("E",msg,details)}log(type,msg,details){this.func.utils.debug_report(this.SESSION_ID,msg,details,type)}alert(type,display,msg,details){this.func.utils.alerts.execute(this.SESSION_ID,type,display,details,msg)}async call_project_api(prog_id,params,cb){const _prog_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,prog_id);if(_prog_obj?.properties?.menuType!=="api"){return this.reject("xu.callApiProgram error",`${prog_id} is not an API program`,this.job_id)}if(this._session.engine_mode==="live_preview"||typeof IS_PROCESS_SERVER!=="undefined"){const ret=await this.func.datasource.prepare(this.SESSION_ID,prog_id,null,0,null,null,null,null,null,null,"api",null,null,null,params);try{const _ds=this._session.DS_GLB[ret.dsSessionP];if(typeof _ds.api_rendered_output==="undefined"||typeof _ds.tree_obj.apiOutput==="undefined"||!_ds.tree_obj.apiOutput){throw new Error("undefined api_rendered_output/apiOutput")}if(_ds.tree_obj.apiOutput==="json"){try{return JSON5.parse(_ds.api_rendered_output)}catch(err){console.error(err);return{}}}return _ds.api_rendered_output}catch(e){this.reject("xu.call_project_api error",e.message||e,this.job_id)}}try{const response=await fetch(`https://${this._session.domain}/execute_api_program`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({...params,...{prog_id:prog_id}})});if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.get_table_data error",e,this.job_id)}}async call_system_api(api_method,payload={},cb){try{let body={...{app_id:this._session.app_id,app_id_query:this._session.app_id,app_token:this._session.app_token},...payload};const response=await fetch(`https://${this._session.domain}/cpi/${api_method}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(body)});const json=await response.json();if(cb){return cb(json)}return json}catch(e){console.error(e);this.reject("xu.call_system_api error",e,this.job_id)}}async call_external_api(method,url,payload={},cb){try{let json={...{app_id:this._session.app_id,app_id_query:this._session.app_id,app_token:this._session.app_token},...payload};const response=await fetch(`https://${url}`,{method:method,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(json)});if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.call_external_api error",e,this.job_id)}}async call_javascript(prog_id,params={},evaluate=false){try{const module=await this.func.common.get_module(this.SESSION_ID,"xuda-event-javascript-module.mjs");const result=await module.call_javascript(this.SESSION_ID,this.job_id,{prog:prog_id,parameters:params},this.dsSession,evaluate);return result}catch(e){console.error(e);this.reject("xu.call_javascript error",e,this.job_id)}}async dbs_create(table_id,data,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsCreate error",`${table_id} is not a table`,this.job_id)}try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_create",{table_id:table_id,table_data:data});if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_create error",e,this.job_id)}}async dbs_read(table_id,selector={},fields=[],sort,limit=999,skip,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsRead error",`${table_id} is not a table`,this.job_id)}let data={fields:fields,table_id:table_id,dataSourceFilterModelType:"query",filterModelMongo:selector,limit:limit,skip:skip,sort:sort};try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_read",data);if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_read error",e,this.job_id)}}async dbs_update(table_id,row_id,data,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsUpdate error",`${table_id} is not a table`,this.job_id)}if(!row_id){return this.reject("xu.dbsDelete error",`row_id is a mandatory field`,this.job_id)}try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_update",{table_id:table_id,row_id:row_id,table_data:data});if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_update error",e,this.job_id)}}async dbs_delete(table_id,row_id,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsDelete error",`${table_id} is not a table`,this.job_id)}if(!row_id){return this.reject("xu.dbsDelete error",`row_id is a mandatory field`,this.job_id)}try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_delete",{table_id:table_id,ids:[row_id]});if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_delete error",e,this.job_id)}}}
|
|
1
|
+
export class XudaModule{constructor(e){this.func=e.func;this.glb=e.glb;this.SESSION_OBJ=e.SESSION_OBJ;this.SESSION_ID=e.SESSION_ID;this.APP_OBJ=e.APP_OBJ;this.dsSession=e.dsSession;this.job_id=e.job_id;this._session=this.SESSION_OBJ[this.SESSION_ID];return this}async get_field_value(field_id){if(!field_id){console.error("xu.getFieldValue: field_id cannot be empty");return false}let ret_get_value=await this.func.datasource.get_value(this.SESSION_ID,field_id,this.dsSession);if(!ret_get_value.found){console.error(`xu.getFieldValue: ${field_id} field not found`);return false}return ret_get_value.ret.value}async set_field_value(field_id,value,avoid_refresh){if(!field_id){console.error("xu.setFieldValue: field_id cannot be empty");return false}if(typeof value==="undefined"){console.error(`xu.setFieldValue: ${field_id} - value cannot be undefined`);return false}let ret_get_value=await this.func.datasource.get_value(this.SESSION_ID,field_id,this.dsSession);if(!ret_get_value.found){console.error(`xu.setFieldValue: ${field_id} field not found`);return false}let _ds=this._session.DS_GLB[ret_get_value.dsSessionP];const datasource_changes={[_ds.dsSession]:{[ret_get_value.currentRecordId]:{[field_id]:value}}};return await this.func.datasource.update(this.SESSION_ID,datasource_changes,null,avoid_refresh)}async invoke_event(event_id){if(!event_id){console.error("xu.invokeEvent: event_id cannot be empty");return false}let ds;for await(const[key,val]of Object.entries(Object.assign([],this._session.DS_GLB).reverse())){let ds_val=val;let ds_key=ds_val.dsSession;const _view_obj=await this.func.utils.VIEWS_OBJ.get(this.SESSION_ID,ds_val.prog_id);if(_.isEmpty(_view_obj.progEvents))continue;if(ds)break;for await(const[key,val]of Object.entries(_view_obj.progEvents)){if(val?.data?.type==="user_defined"&&val.data.event_name===event_id){ds=ds_key;break}}}if(typeof ds==="undefined"){this.reject("xu.invokeEvent error",`${event_id} event_id not found`,this.job_id);return false}return this.func.events.validate(this.SESSION_ID,"user_defined",ds,event_id)}async read_drive(filename,cb){try{const response=await fetch(`https://${this._session.domain}/workspace-drive/`+filename+"&"+this._session.gtp_token);if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.readDrive error",e,this.job_id)}}async write_drive(stream,filename,make_public,cb){var data={app_id:this._session.app_id,gtp_token:this._session.gtp_token,app_token:this._session.app_token,req_from_api:"true",public:make_public?"true":""};const form=new FormData;for(const[key,val]of Object.entries(data)){form.append(key,val)}form.append("file",stream,filename);try{const response=await fetch(this.func.common.get_url(this.SESSION_ID,"rpi","runtime_upload_file"),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(form)});if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.writeDrive error",e,this.job_id)}}resolve(cb,job_id){if(job_id){this.func.events.delete_job(this.SESSION_ID,job_id)}if(cb){cb()}}reject(msg,details,job_id){if(job_id){this.func.events.delete_job(this.SESSION_ID,job_id)}this.log("E",msg,details)}log(type,msg,details){this.func.utils.debug_report(this.SESSION_ID,msg,details,type)}alert(type,display,msg,details){this.func.utils.alerts.execute(this.SESSION_ID,type,display,details,msg)}async call_project_api(prog_id,params,cb){const _prog_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,prog_id);if(_prog_obj?.properties?.menuType!=="api"){return this.reject("xu.callApiProgram error",`${prog_id} is not an API program`,this.job_id)}if(this._session.engine_mode==="live_preview"||typeof IS_PROCESS_SERVER!=="undefined"){const ret=await this.func.datasource.prepare(this.SESSION_ID,prog_id,null,0,null,null,null,null,null,null,"api",null,null,null,params);try{const _ds=this._session.DS_GLB[ret.dsSessionP];if(typeof _ds.api_rendered_output==="undefined"||typeof _ds.tree_obj.apiOutput==="undefined"||!_ds.tree_obj.apiOutput){throw new Error("undefined api_rendered_output/apiOutput")}if(_ds.tree_obj.apiOutput==="json"){try{return JSON5.parse(_ds.api_rendered_output)}catch(err){console.error(err);return{}}}return _ds.api_rendered_output}catch(e){this.reject("xu.call_project_api error",e.message||e,this.job_id)}}try{const response=await fetch(`https://${this._session.domain}/execute_api_program`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({...params,...{prog_id:prog_id}})});if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.get_table_data error",e,this.job_id)}}async call_system_api(api_method,payload={},cb){try{let body={...{app_id:this._session.app_id,app_id_query:this._session.app_id,app_token:this._session.app_token},...payload};const response=await fetch(`https://${this._session.domain}/cpi/${api_method}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(body)});const json=await response.json();if(cb){return cb(json)}return json}catch(e){console.error(e);this.reject("xu.call_system_api error",e,this.job_id)}}async call_external_api(method,url,payload={},cb){try{let json={...{app_id:this._session.app_id,app_id_query:this._session.app_id,app_token:this._session.app_token},...payload};const response=await fetch(`https://${url}`,{method:method,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(json)});if(cb){return cb(await response.json())}return await response.json()}catch(e){console.error(e);this.reject("xu.call_external_api error",e,this.job_id)}}async call_javascript(prog_id,params={},evaluate=false){try{const module=await this.func.common.get_module(this.SESSION_ID,"xuda-event-javascript-module.mjs");const result=await module.call_javascript(this.SESSION_ID,this.job_id,{prog:prog_id,parameters:params},this.dsSession,evaluate);return result}catch(e){console.error(e);this.reject("xu.call_javascript error",e,this.job_id)}}async dbs_create(table_id,data,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsCreate error",`${table_id} is not a table`,this.job_id)}try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_create",{table_id:table_id,table_data:data});if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_create error",e,this.job_id)}}async dbs_read(table_id,selector={},fields=[],sort,limit=999,skip,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsRead error",`${table_id} is not a table`,this.job_id)}let data={fields:fields,table_id:table_id,dataSourceFilterModelType:"query",filterModelMongo:selector,limit:limit,skip:skip,sort:sort};try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_read",data);if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_read error",e,this.job_id)}}async dbs_update(table_id,row_id,data,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsUpdate error",`${table_id} is not a table`,this.job_id)}if(!row_id){return this.reject("xu.dbsDelete error",`row_id is a mandatory field`,this.job_id)}try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_update",{table_id:table_id,row_id:row_id,table_data:data});if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_update error",e,this.job_id)}}async dbs_delete(table_id,row_id,cb){const _table_obj=await this.func.utils.DOCS_OBJ.get(this.SESSION_ID,table_id);if(_table_obj?.properties?.menuType!=="table"){return this.reject("xu.dbsDelete error",`${table_id} is not a table`,this.job_id)}if(!row_id){return this.reject("xu.dbsDelete error",`row_id is a mandatory field`,this.job_id)}try{const ret=await this.func.common.db(this.SESSION_ID,"dbs_delete",{table_id:table_id,ids:[row_id]});if(cb){return cb(ret)}return ret}catch(e){console.error(e);this.reject("xu.dbs_delete error",e,this.job_id)}}}
|
|
@@ -31,7 +31,7 @@ export class XudaModule {
|
|
|
31
31
|
return ret_get_value.ret.value;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async set_field_value(field_id, value) {
|
|
34
|
+
async set_field_value(field_id, value, avoid_refresh) {
|
|
35
35
|
if (!field_id) {
|
|
36
36
|
console.error("xu.setFieldValue: field_id cannot be empty");
|
|
37
37
|
return false;
|
|
@@ -64,7 +64,9 @@ export class XudaModule {
|
|
|
64
64
|
};
|
|
65
65
|
return await this.func.datasource.update(
|
|
66
66
|
this.SESSION_ID,
|
|
67
|
-
datasource_changes
|
|
67
|
+
datasource_changes,
|
|
68
|
+
null,
|
|
69
|
+
avoid_refresh
|
|
68
70
|
);
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -24608,7 +24608,7 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
24608
24608
|
};
|
|
24609
24609
|
|
|
24610
24610
|
func.api = {};
|
|
24611
|
-
func.api.set_field_value = async function (field_id, value) {
|
|
24611
|
+
func.api.set_field_value = async function (field_id, value, avoid_refresh) {
|
|
24612
24612
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
24613
24613
|
const api_utils = await func.common.get_module(
|
|
24614
24614
|
SESSION_ID,
|
|
@@ -24623,7 +24623,7 @@ func.api.set_field_value = async function (field_id, value) {
|
|
|
24623
24623
|
}
|
|
24624
24624
|
);
|
|
24625
24625
|
|
|
24626
|
-
return await api_utils.set_field_value(field_id, value);
|
|
24626
|
+
return await api_utils.set_field_value(field_id, value, avoid_refresh);
|
|
24627
24627
|
};
|
|
24628
24628
|
func.api.get_field_value = async function (field_id) {
|
|
24629
24629
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
@@ -33767,6 +33767,9 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
33767
33767
|
let is_dynamic_field = false
|
|
33768
33768
|
let field_prop
|
|
33769
33769
|
|
|
33770
|
+
const iterate_info = $elm?.data()?.xuData?.iterate_info
|
|
33771
|
+
const reference_source_obj = iterate_info?.reference_source_obj
|
|
33772
|
+
|
|
33770
33773
|
if (["_FOR_VAL", "_FOR_KEY"].includes(view_field_id)) {
|
|
33771
33774
|
is_dynamic_field = true
|
|
33772
33775
|
field_prop = _ds.dynamic_fields[view_field_id]
|
|
@@ -34047,12 +34050,12 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34047
34050
|
"xu-for": async function ($elm, data) {
|
|
34048
34051
|
if (parent_infoP?.iterate_info || !data.value) return {};
|
|
34049
34052
|
try {
|
|
34050
|
-
|
|
34053
|
+
// data.value (xu-for) can store actual values such as an array, a CSV, or a field_id that references a specific field within the dataset, initialized with values for the iteration.
|
|
34051
34054
|
let arr = data.value;
|
|
34052
34055
|
|
|
34053
34056
|
// find reference source field
|
|
34054
34057
|
let reference_source_obj
|
|
34055
|
-
|
|
34058
|
+
|
|
34056
34059
|
const _progFields = await func.datasource.get_progFields(
|
|
34057
34060
|
SESSION_ID,
|
|
34058
34061
|
paramsP.dsSessionP
|
|
@@ -34063,28 +34066,13 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34063
34066
|
"field_id",
|
|
34064
34067
|
data.value
|
|
34065
34068
|
);
|
|
34069
|
+
// detect if data.value (xu-for) is reference field_id by checking if exist in the dataset
|
|
34066
34070
|
if (view_field_obj) {
|
|
34067
|
-
//
|
|
34068
|
-
// try {
|
|
34069
|
-
// const row_idx = func.common.find_ROWID_idx(
|
|
34070
|
-
// _ds,
|
|
34071
|
-
// currentRecordId
|
|
34072
|
-
// );
|
|
34073
|
-
// reference_source_field = data.value
|
|
34074
|
-
|
|
34075
|
-
// arr = await func.datasource.get_value(SESSION_ID, paramsP.dsSessionP, reference_source_field)
|
|
34076
|
-
// } catch (err) {
|
|
34077
|
-
|
|
34078
|
-
// }
|
|
34079
|
-
// reference_source_field_id = data.value
|
|
34080
|
-
// reference_source_field_type=
|
|
34081
|
-
|
|
34071
|
+
// xu-for is reference field_id
|
|
34082
34072
|
reference_source_obj = await func.datasource.get_value(SESSION_ID, data.value, paramsP.dsSessionP)
|
|
34083
34073
|
arr = reference_source_obj?.ret?.value
|
|
34084
34074
|
} else {
|
|
34085
|
-
//
|
|
34086
|
-
|
|
34087
|
-
|
|
34075
|
+
// xu-for is actual data
|
|
34088
34076
|
if (typeof data.value === "string") {
|
|
34089
34077
|
arr = eval(data.value.replaceAll("\\", ""));
|
|
34090
34078
|
}
|
|
@@ -34092,43 +34080,41 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34092
34080
|
arr = Array.from(Array(arr).keys());
|
|
34093
34081
|
}
|
|
34094
34082
|
}
|
|
34095
|
-
// } catch (err) {
|
|
34096
|
-
|
|
34097
|
-
// }
|
|
34098
|
-
|
|
34099
|
-
|
|
34100
|
-
|
|
34101
34083
|
|
|
34084
|
+
const custom_iterator_key = $elm.data().xuData.iterator_key
|
|
34085
|
+
const custom_iterator_val = $elm.data().xuData.iterator_val
|
|
34102
34086
|
|
|
34087
|
+
let iterator_key = custom_iterator_key
|
|
34088
|
+
let iterator_val = custom_iterator_val
|
|
34103
34089
|
|
|
34090
|
+
// custom FOR_VAL name or namespaced default name
|
|
34091
|
+
if (!custom_iterator_key) {
|
|
34092
|
+
is_key_dynamic_field = true
|
|
34093
|
+
iterator_key = (reference_source_obj?.fieldIdP || "") + "_FOR_KEY";
|
|
34094
|
+
}
|
|
34104
34095
|
|
|
34096
|
+
if (!custom_iterator_val) {
|
|
34097
|
+
is_val_dynamic_field = true
|
|
34098
|
+
iterator_val = (reference_source_obj?.fieldIdP || "") + "_FOR_VAL";
|
|
34099
|
+
}
|
|
34105
34100
|
|
|
34106
|
-
// if (typeof data.value === "string") {
|
|
34107
|
-
// arr = eval(data.value.replaceAll("\\", ""));
|
|
34108
|
-
// }
|
|
34109
|
-
// if (typeof arr === "number") {
|
|
34110
|
-
// arr = Array.from(Array(arr).keys());
|
|
34111
|
-
// }
|
|
34112
|
-
let iterator_val = $elm.data().xuData.iterator_val;
|
|
34113
|
-
let iterator_key = $elm.data().xuData.iterator_key;
|
|
34114
34101
|
var i = 0;
|
|
34115
34102
|
for await (let [_key, _val] of Object.entries(arr)) {
|
|
34116
34103
|
|
|
34117
34104
|
if (_.isArray(arr)) { _key = Number(_key) }
|
|
34118
34105
|
|
|
34119
|
-
const set_value = async function (currentRecordId, field_id, value) {
|
|
34120
|
-
let is_dynamic_field = false;
|
|
34106
|
+
const set_value = async function (is_dynamic_field, currentRecordId, field_id, value) {
|
|
34121
34107
|
|
|
34122
34108
|
|
|
34109
|
+
if (is_dynamic_field) {
|
|
34123
34110
|
|
|
34124
|
-
if (["_FOR_VAL", "_FOR_KEY"].includes(field_id)) {
|
|
34125
|
-
is_dynamic_field = true;
|
|
34126
34111
|
func.datasource.add_dynamic_field_to_ds(
|
|
34127
34112
|
SESSION_ID,
|
|
34128
34113
|
paramsP.dsSessionP,
|
|
34129
34114
|
field_id,
|
|
34130
34115
|
value
|
|
34131
34116
|
);
|
|
34117
|
+
|
|
34132
34118
|
} else {
|
|
34133
34119
|
|
|
34134
34120
|
const _progFields = await func.datasource.get_progFields(
|
|
@@ -34157,7 +34143,7 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34157
34143
|
}
|
|
34158
34144
|
}
|
|
34159
34145
|
|
|
34160
|
-
|
|
34146
|
+
|
|
34161
34147
|
};
|
|
34162
34148
|
|
|
34163
34149
|
var currentRecordId =
|
|
@@ -34165,17 +34151,16 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34165
34151
|
paramsP.dsSessionP
|
|
34166
34152
|
].currentRecordId.toString();
|
|
34167
34153
|
|
|
34168
|
-
|
|
34169
|
-
|
|
34170
|
-
|
|
34154
|
+
await set_value(is_key_dynamic_field, currentRecordId, iterator_key, _key);
|
|
34155
|
+
await set_value(is_val_dynamic_field, currentRecordId, iterator_val, _val);
|
|
34171
34156
|
|
|
34172
34157
|
var iterate_info = {
|
|
34173
34158
|
_val,
|
|
34174
34159
|
_key,
|
|
34175
|
-
iterator_key
|
|
34176
|
-
iterator_val
|
|
34177
|
-
is_val_dynamic_field,
|
|
34160
|
+
iterator_key,
|
|
34161
|
+
iterator_val,
|
|
34178
34162
|
is_key_dynamic_field,
|
|
34163
|
+
is_val_dynamic_field,
|
|
34179
34164
|
reference_source_obj
|
|
34180
34165
|
};
|
|
34181
34166
|
if (parent_infoP) {
|
|
@@ -34205,10 +34190,6 @@ func.UI.screen.execute_xu_functions = async function (
|
|
|
34205
34190
|
$(val).data().xuData.iterate_info = iterate_info;
|
|
34206
34191
|
}
|
|
34207
34192
|
});
|
|
34208
|
-
// // set values in _FOR record
|
|
34209
|
-
// currentRecordId = $divP.data().xuData.ui_id;
|
|
34210
|
-
// set_value(currentRecordId, iterator_key || "_FOR_KEY", _key);
|
|
34211
|
-
// set_value(currentRecordId, iterator_val || "_FOR_VAL", _val);
|
|
34212
34193
|
|
|
34213
34194
|
i++;
|
|
34214
34195
|
}
|