@xuda.io/runtime-bundle 1.0.1337 → 1.0.1339
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/xuda-runtime-slim.js
CHANGED
|
@@ -9069,6 +9069,7 @@ func.UI.find_field_in_progUi_attributes = function (progUi, field_id, prop, tag_
|
|
|
9069
9069
|
};
|
|
9070
9070
|
|
|
9071
9071
|
func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
9072
|
+
return;
|
|
9072
9073
|
let ret;
|
|
9073
9074
|
const _session = SESSION_OBJ[SESSION_ID];
|
|
9074
9075
|
let _ds_0 = _session.DS_GLB[0];
|
|
@@ -9203,6 +9204,119 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9203
9204
|
|
|
9204
9205
|
return ret;
|
|
9205
9206
|
};
|
|
9207
|
+
|
|
9208
|
+
func.UI.create_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
9209
|
+
let ret;
|
|
9210
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
9211
|
+
let _ds_0 = _session.DS_GLB[0];
|
|
9212
|
+
|
|
9213
|
+
function createWatchedObject(obj, onChange) {
|
|
9214
|
+
const watchers = new WeakMap();
|
|
9215
|
+
|
|
9216
|
+
function createProxy(target, path = []) {
|
|
9217
|
+
if (watchers.has(target)) {
|
|
9218
|
+
return watchers.get(target);
|
|
9219
|
+
}
|
|
9220
|
+
|
|
9221
|
+
const proxy = new Proxy(target, {
|
|
9222
|
+
set(obj, prop, value) {
|
|
9223
|
+
const oldValue = obj[prop];
|
|
9224
|
+
let currentPath = [...path, prop];
|
|
9225
|
+
|
|
9226
|
+
// Set the new value
|
|
9227
|
+
obj[prop] = value;
|
|
9228
|
+
|
|
9229
|
+
// If the new value is an object, make it observable too
|
|
9230
|
+
if (typeof value === 'object' && value !== null) {
|
|
9231
|
+
obj[prop] = createProxy(value, currentPath);
|
|
9232
|
+
}
|
|
9233
|
+
|
|
9234
|
+
// Notify of change
|
|
9235
|
+
// if (oldValue !== value) {
|
|
9236
|
+
if (!_.isEqual(value, oldValue)) {
|
|
9237
|
+
currentPath.shift();
|
|
9238
|
+
onChange({
|
|
9239
|
+
path: currentPath.join('.'),
|
|
9240
|
+
oldValue,
|
|
9241
|
+
newValue: value,
|
|
9242
|
+
type: 'set',
|
|
9243
|
+
timestamp: Date.now(),
|
|
9244
|
+
});
|
|
9245
|
+
}
|
|
9246
|
+
|
|
9247
|
+
return true;
|
|
9248
|
+
},
|
|
9249
|
+
|
|
9250
|
+
deleteProperty(obj, prop) {
|
|
9251
|
+
const oldValue = obj[prop];
|
|
9252
|
+
const currentPath = [...path, prop];
|
|
9253
|
+
|
|
9254
|
+
delete obj[prop];
|
|
9255
|
+
|
|
9256
|
+
onChange({
|
|
9257
|
+
path: currentPath.join('.'),
|
|
9258
|
+
oldValue,
|
|
9259
|
+
newValue: undefined,
|
|
9260
|
+
type: 'delete',
|
|
9261
|
+
timestamp: Date.now(),
|
|
9262
|
+
});
|
|
9263
|
+
|
|
9264
|
+
return true;
|
|
9265
|
+
},
|
|
9266
|
+
});
|
|
9267
|
+
|
|
9268
|
+
// Make nested objects observable
|
|
9269
|
+
for (const [key, value] of Object.entries(target)) {
|
|
9270
|
+
if (typeof value === 'object' && value !== null) {
|
|
9271
|
+
target[key] = createProxy(value, [...path, key]);
|
|
9272
|
+
}
|
|
9273
|
+
}
|
|
9274
|
+
|
|
9275
|
+
watchers.set(target, proxy);
|
|
9276
|
+
return proxy;
|
|
9277
|
+
}
|
|
9278
|
+
|
|
9279
|
+
return createProxy(obj);
|
|
9280
|
+
}
|
|
9281
|
+
|
|
9282
|
+
let _ds = _session.DS_GLB[dsSessionP];
|
|
9283
|
+
|
|
9284
|
+
const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
|
|
9285
|
+
// console.log('Change detected:', change);
|
|
9286
|
+
const { path, newValue, oldValue } = change;
|
|
9287
|
+
|
|
9288
|
+
try {
|
|
9289
|
+
if (_.isEqual(newValue, oldValue)) return;
|
|
9290
|
+
|
|
9291
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
9292
|
+
|
|
9293
|
+
if (_session?.watchers?.[path]) {
|
|
9294
|
+
const fx = _session?.watchers?.[path];
|
|
9295
|
+
fx(change);
|
|
9296
|
+
}
|
|
9297
|
+
} catch (error) {}
|
|
9298
|
+
});
|
|
9299
|
+
|
|
9300
|
+
let obj = { ds: watchedDs._ref, data: {}, props: _ds.in_parameters || {} };
|
|
9301
|
+
try {
|
|
9302
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
9303
|
+
obj.data = _ds?.data_feed?.rows?.[row_idx];
|
|
9304
|
+
} catch (error) {
|
|
9305
|
+
// error normal if find_ROWID_idx fail
|
|
9306
|
+
}
|
|
9307
|
+
|
|
9308
|
+
let SYS_GLOBAL_OBJ_REFS = _ds_0.data_system['SYS_GLOBAL_OBJ_REFS'];
|
|
9309
|
+
|
|
9310
|
+
if ($elm) {
|
|
9311
|
+
const attributes = $elm?.data()?.xuData?.xuPanelProps || $elm?.data()?.xuData?.debug_info?.attribute_stat || {};
|
|
9312
|
+
obj.attributes = attributes;
|
|
9313
|
+
obj.xu_ui_id = $elm.attr('xu-ui-id');
|
|
9314
|
+
}
|
|
9315
|
+
|
|
9316
|
+
SYS_GLOBAL_OBJ_REFS[ref_field_id] = obj;
|
|
9317
|
+
|
|
9318
|
+
return ret;
|
|
9319
|
+
};
|
|
9206
9320
|
func.events = {};
|
|
9207
9321
|
func.events.validate = async function (SESSION_ID, triggerP, dsSessionP, eventIdP, sourceP, argumentsP, return_validation_onlyP) {
|
|
9208
9322
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
@@ -9070,6 +9070,7 @@ func.UI.find_field_in_progUi_attributes = function (progUi, field_id, prop, tag_
|
|
|
9070
9070
|
};
|
|
9071
9071
|
|
|
9072
9072
|
func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
9073
|
+
return;
|
|
9073
9074
|
let ret;
|
|
9074
9075
|
const _session = SESSION_OBJ[SESSION_ID];
|
|
9075
9076
|
let _ds_0 = _session.DS_GLB[0];
|
|
@@ -9204,6 +9205,119 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9204
9205
|
|
|
9205
9206
|
return ret;
|
|
9206
9207
|
};
|
|
9208
|
+
|
|
9209
|
+
func.UI.create_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
9210
|
+
let ret;
|
|
9211
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
9212
|
+
let _ds_0 = _session.DS_GLB[0];
|
|
9213
|
+
|
|
9214
|
+
function createWatchedObject(obj, onChange) {
|
|
9215
|
+
const watchers = new WeakMap();
|
|
9216
|
+
|
|
9217
|
+
function createProxy(target, path = []) {
|
|
9218
|
+
if (watchers.has(target)) {
|
|
9219
|
+
return watchers.get(target);
|
|
9220
|
+
}
|
|
9221
|
+
|
|
9222
|
+
const proxy = new Proxy(target, {
|
|
9223
|
+
set(obj, prop, value) {
|
|
9224
|
+
const oldValue = obj[prop];
|
|
9225
|
+
let currentPath = [...path, prop];
|
|
9226
|
+
|
|
9227
|
+
// Set the new value
|
|
9228
|
+
obj[prop] = value;
|
|
9229
|
+
|
|
9230
|
+
// If the new value is an object, make it observable too
|
|
9231
|
+
if (typeof value === 'object' && value !== null) {
|
|
9232
|
+
obj[prop] = createProxy(value, currentPath);
|
|
9233
|
+
}
|
|
9234
|
+
|
|
9235
|
+
// Notify of change
|
|
9236
|
+
// if (oldValue !== value) {
|
|
9237
|
+
if (!_.isEqual(value, oldValue)) {
|
|
9238
|
+
currentPath.shift();
|
|
9239
|
+
onChange({
|
|
9240
|
+
path: currentPath.join('.'),
|
|
9241
|
+
oldValue,
|
|
9242
|
+
newValue: value,
|
|
9243
|
+
type: 'set',
|
|
9244
|
+
timestamp: Date.now(),
|
|
9245
|
+
});
|
|
9246
|
+
}
|
|
9247
|
+
|
|
9248
|
+
return true;
|
|
9249
|
+
},
|
|
9250
|
+
|
|
9251
|
+
deleteProperty(obj, prop) {
|
|
9252
|
+
const oldValue = obj[prop];
|
|
9253
|
+
const currentPath = [...path, prop];
|
|
9254
|
+
|
|
9255
|
+
delete obj[prop];
|
|
9256
|
+
|
|
9257
|
+
onChange({
|
|
9258
|
+
path: currentPath.join('.'),
|
|
9259
|
+
oldValue,
|
|
9260
|
+
newValue: undefined,
|
|
9261
|
+
type: 'delete',
|
|
9262
|
+
timestamp: Date.now(),
|
|
9263
|
+
});
|
|
9264
|
+
|
|
9265
|
+
return true;
|
|
9266
|
+
},
|
|
9267
|
+
});
|
|
9268
|
+
|
|
9269
|
+
// Make nested objects observable
|
|
9270
|
+
for (const [key, value] of Object.entries(target)) {
|
|
9271
|
+
if (typeof value === 'object' && value !== null) {
|
|
9272
|
+
target[key] = createProxy(value, [...path, key]);
|
|
9273
|
+
}
|
|
9274
|
+
}
|
|
9275
|
+
|
|
9276
|
+
watchers.set(target, proxy);
|
|
9277
|
+
return proxy;
|
|
9278
|
+
}
|
|
9279
|
+
|
|
9280
|
+
return createProxy(obj);
|
|
9281
|
+
}
|
|
9282
|
+
|
|
9283
|
+
let _ds = _session.DS_GLB[dsSessionP];
|
|
9284
|
+
|
|
9285
|
+
const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
|
|
9286
|
+
// console.log('Change detected:', change);
|
|
9287
|
+
const { path, newValue, oldValue } = change;
|
|
9288
|
+
|
|
9289
|
+
try {
|
|
9290
|
+
if (_.isEqual(newValue, oldValue)) return;
|
|
9291
|
+
|
|
9292
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
9293
|
+
|
|
9294
|
+
if (_session?.watchers?.[path]) {
|
|
9295
|
+
const fx = _session?.watchers?.[path];
|
|
9296
|
+
fx(change);
|
|
9297
|
+
}
|
|
9298
|
+
} catch (error) {}
|
|
9299
|
+
});
|
|
9300
|
+
|
|
9301
|
+
let obj = { ds: watchedDs._ref, data: {}, props: _ds.in_parameters || {} };
|
|
9302
|
+
try {
|
|
9303
|
+
const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
|
|
9304
|
+
obj.data = _ds?.data_feed?.rows?.[row_idx];
|
|
9305
|
+
} catch (error) {
|
|
9306
|
+
// error normal if find_ROWID_idx fail
|
|
9307
|
+
}
|
|
9308
|
+
|
|
9309
|
+
let SYS_GLOBAL_OBJ_REFS = _ds_0.data_system['SYS_GLOBAL_OBJ_REFS'];
|
|
9310
|
+
|
|
9311
|
+
if ($elm) {
|
|
9312
|
+
const attributes = $elm?.data()?.xuData?.xuPanelProps || $elm?.data()?.xuData?.debug_info?.attribute_stat || {};
|
|
9313
|
+
obj.attributes = attributes;
|
|
9314
|
+
obj.xu_ui_id = $elm.attr('xu-ui-id');
|
|
9315
|
+
}
|
|
9316
|
+
|
|
9317
|
+
SYS_GLOBAL_OBJ_REFS[ref_field_id] = obj;
|
|
9318
|
+
|
|
9319
|
+
return ret;
|
|
9320
|
+
};
|
|
9207
9321
|
func.UI.screen = {};
|
|
9208
9322
|
func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callingDataSource_objP, $callingContainerP, triggerIdP, rowIdP, jobNoP, is_panelP, parameters_obj_inP, source_functionP, call_screen_propertiesP, refreshed_ds, parameters_raw_obj) {
|
|
9209
9323
|
if (!prog_id) return console.error('program is empty');
|