@steedos/service-pages 2.5.0-beta.7 → 2.5.0-beta.9
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.
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
;(function(){
|
|
7
7
|
Steedos.Page = {
|
|
8
8
|
App: {},
|
|
9
|
+
Object: {
|
|
10
|
+
Template: {}
|
|
11
|
+
},
|
|
9
12
|
Record: {},
|
|
10
13
|
Listview: {},
|
|
11
14
|
Header: {},
|
|
@@ -35,6 +38,23 @@
|
|
|
35
38
|
return modalRoot;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
Steedos.Page.getDisplay = (objectName)=>{
|
|
42
|
+
|
|
43
|
+
let display = FlowRouter.current().queryParams.display;
|
|
44
|
+
// console.log('=====getDisplay====>', display)
|
|
45
|
+
// const key = `tab.${objectName}.display`;
|
|
46
|
+
const key = 'page_display'
|
|
47
|
+
if(display){
|
|
48
|
+
// console.log('=====getDisplay===setItem=>', key, display)
|
|
49
|
+
localStorage.setItem(key, display)
|
|
50
|
+
}else{
|
|
51
|
+
display = localStorage.getItem(key);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return display;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
38
58
|
Steedos.Page.getPage = function (type, appId, objectApiName, recordId, pageId) {
|
|
39
59
|
let objectInfo = null;
|
|
40
60
|
let searchParams = FlowRouter.current().queryParams;
|
|
@@ -65,32 +85,42 @@
|
|
|
65
85
|
if(type === 'list'){
|
|
66
86
|
return {
|
|
67
87
|
render_engine: 'amis',
|
|
68
|
-
name:
|
|
69
|
-
schema:{
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"showHeader": true,
|
|
73
|
-
"objectApiName": objectApiName,
|
|
74
|
-
"appId": appId,
|
|
75
|
-
"display": display,
|
|
76
|
-
"columnsTogglable": false,
|
|
77
|
-
// "listName": "all",
|
|
88
|
+
name: "steedosPageObjectControl",
|
|
89
|
+
schema: {
|
|
90
|
+
"type": "steedos-page-object-control",
|
|
91
|
+
"name": "steedosPageObjectControl"
|
|
78
92
|
}
|
|
93
|
+
// name: 'steedosListviewPage',
|
|
94
|
+
// schema:{
|
|
95
|
+
// "name": `${objectApiName}-listview-${listViewId}`,
|
|
96
|
+
// "type": "steedos-page-listview",
|
|
97
|
+
// "showHeader": true,
|
|
98
|
+
// "objectApiName": objectApiName,
|
|
99
|
+
// "appId": appId,
|
|
100
|
+
// "display": display,
|
|
101
|
+
// "columnsTogglable": false,
|
|
102
|
+
// // "listName": "all",
|
|
103
|
+
// }
|
|
79
104
|
}
|
|
80
105
|
}else if(type === 'record'){
|
|
81
106
|
return {
|
|
82
107
|
render_engine: 'amis',
|
|
83
|
-
name:
|
|
108
|
+
name: "steedosPageObjectControl",
|
|
84
109
|
schema: {
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"objectApiName": objectApiName,
|
|
88
|
-
"sideObject": sideObject,
|
|
89
|
-
"sideListviewId": sideListviewId,
|
|
90
|
-
// "recordId": recordId,
|
|
91
|
-
"display": display,
|
|
92
|
-
"appId": appId,
|
|
110
|
+
"type": "steedos-page-object-control",
|
|
111
|
+
"name": "steedosPageObjectControl"
|
|
93
112
|
}
|
|
113
|
+
// name: 'steedosRecordPage',
|
|
114
|
+
// schema: {
|
|
115
|
+
// "name": `${objectApiName}-recordDetail-${recordId}`,
|
|
116
|
+
// "type": "steedos-page-record-detail",
|
|
117
|
+
// "objectApiName": objectApiName,
|
|
118
|
+
// "sideObject": sideObject,
|
|
119
|
+
// "sideListviewId": sideListviewId,
|
|
120
|
+
// // "recordId": recordId,
|
|
121
|
+
// "display": display,
|
|
122
|
+
// "appId": appId,
|
|
123
|
+
// }
|
|
94
124
|
}
|
|
95
125
|
|
|
96
126
|
}else if(type === 'related_list'){
|
|
@@ -301,6 +331,134 @@
|
|
|
301
331
|
return container
|
|
302
332
|
};
|
|
303
333
|
|
|
334
|
+
Steedos.Page.Object.Template.onRendered = function(){
|
|
335
|
+
var objectName, recordId, self;
|
|
336
|
+
self = this;
|
|
337
|
+
objectName = Session.get("object_name");
|
|
338
|
+
this.containerList = [];
|
|
339
|
+
this.pageName = null;
|
|
340
|
+
return this.autorun(function(computation) {
|
|
341
|
+
// console.log('autorun=====>computation:', computation)
|
|
342
|
+
// Session.get("record_id");
|
|
343
|
+
var container, e, lastData, ref, ref1, ref2, regions, schema, updateProps, updatePropsData;
|
|
344
|
+
regions = self.data.regions();
|
|
345
|
+
// console.log('regions====>', regions, this.lastRegions);
|
|
346
|
+
updateProps = true;
|
|
347
|
+
if (regions.objectName !== ((ref = this.lastRegions) != null ? ref.objectName : void 0)) {
|
|
348
|
+
updateProps = false;
|
|
349
|
+
}
|
|
350
|
+
this.lastRegions = regions;
|
|
351
|
+
if (updateProps && self.pageName) {
|
|
352
|
+
try {
|
|
353
|
+
if (SteedosUI.refs[self.pageName]) {
|
|
354
|
+
updatePropsData = {
|
|
355
|
+
objectName: objectName,
|
|
356
|
+
pageType: regions.pageType,
|
|
357
|
+
listViewId: regions.listViewId,
|
|
358
|
+
...FlowRouter.current().queryParams
|
|
359
|
+
};
|
|
360
|
+
if(FlowRouter.current().queryParams.side_listview_id){
|
|
361
|
+
updatePropsData.listName=FlowRouter.current().queryParams.side_listview_id
|
|
362
|
+
}else if(regions.listViewId){
|
|
363
|
+
updatePropsData.listName=regions.listViewId
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
updatePropsData.display = Steedos.Page.getDisplay()
|
|
367
|
+
|
|
368
|
+
updatePropsData.recordId = Tracker.nonreactive(function() {
|
|
369
|
+
return Session.get("record_id");
|
|
370
|
+
});
|
|
371
|
+
lastData = ((ref1 = SteedosUI.refs[self.pageName]) != null ? (ref2 = ref1.__$schema) != null ? ref2.data : void 0 : void 0) || {};
|
|
372
|
+
// console.log("page_object Steedos.Page.Record.updateProps", {
|
|
373
|
+
// data: window._.defaultsDeep(updatePropsData, lastData)
|
|
374
|
+
// });
|
|
375
|
+
return SteedosUI.refs[self.pageName].updateProps({
|
|
376
|
+
data: window._.defaultsDeep(updatePropsData, lastData)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
} catch (error) {
|
|
380
|
+
e = error;
|
|
381
|
+
console.error(self.pageName + ": " + e);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!updateProps && self.pageName && SteedosUI.refs[self.pageName]) {
|
|
385
|
+
try {
|
|
386
|
+
SteedosUI.refs[self.pageName].unmount();
|
|
387
|
+
} catch (error) {
|
|
388
|
+
e = error;
|
|
389
|
+
console.error(self.pageName + ": " + e);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (self.data.regions) {
|
|
393
|
+
regions = Tracker.nonreactive(self.data.regions);
|
|
394
|
+
this.lastRegions = regions;
|
|
395
|
+
if (regions && regions.page && regions.page.schema) {
|
|
396
|
+
schema = regions.page.schema;
|
|
397
|
+
if (_.isString(schema)) {
|
|
398
|
+
schema = JSON.parse(schema);
|
|
399
|
+
}
|
|
400
|
+
self.pageName = schema.name;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
objectName = Tracker.nonreactive(function() {
|
|
404
|
+
return Session.get("object_name");
|
|
405
|
+
});
|
|
406
|
+
recordId = Tracker.nonreactive(function() {
|
|
407
|
+
return Session.get("record_id");
|
|
408
|
+
});
|
|
409
|
+
container = Steedos.Page.Object.render(self, objectName, recordId);
|
|
410
|
+
// console.log("page_object Steedos.Page.Object.render");
|
|
411
|
+
if (container) {
|
|
412
|
+
return self.containerList.push(container);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
Steedos.Page.Object.Template.onDestroyed = function(){
|
|
417
|
+
var e, self;
|
|
418
|
+
self = this;
|
|
419
|
+
try {
|
|
420
|
+
SteedosUI.refs[this.pageName].unmount();
|
|
421
|
+
} catch (error) {
|
|
422
|
+
e = error;
|
|
423
|
+
console.error(this.pageName + ": " + e);
|
|
424
|
+
}
|
|
425
|
+
return _.each(this.containerList, function(container) {
|
|
426
|
+
if (container) {
|
|
427
|
+
return ReactDOM.unmountComponentAtNode(container);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
Steedos.Page.Object.render = function(template, objectApiName, recordId = null, options){
|
|
432
|
+
try {
|
|
433
|
+
if (!template.data.regions || !objectApiName) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const { page, ...data } = Tracker.nonreactive(template.data.regions);
|
|
437
|
+
var rootId = "steedosPageObjetRoot";
|
|
438
|
+
var modalRoot = document.getElementById(rootId);
|
|
439
|
+
// if(modalRoot){
|
|
440
|
+
// modalRoot.remove();
|
|
441
|
+
// }
|
|
442
|
+
if (!modalRoot) {
|
|
443
|
+
modalRoot = document.createElement('div');
|
|
444
|
+
modalRoot.setAttribute('id', rootId);
|
|
445
|
+
modalRoot.setAttribute('class', 'h-full')
|
|
446
|
+
$(".page-object-root")[0].appendChild(modalRoot);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (page.render_engine && page.render_engine != 'redash') {
|
|
450
|
+
if(FlowRouter.current().queryParams.side_listview_id){
|
|
451
|
+
data.listName = FlowRouter.current().queryParams.side_listview_id;
|
|
452
|
+
}else if(data.listViewId){
|
|
453
|
+
data.listName = data.listViewId;
|
|
454
|
+
}
|
|
455
|
+
return Steedos.Page.render($("#" + rootId)[0], page, Object.assign({}, options, data, {recordId}));
|
|
456
|
+
}
|
|
457
|
+
} catch (error) {
|
|
458
|
+
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
304
462
|
Steedos.Page.Listview.getDefaultName = function (objectApiName, listViewName) {
|
|
305
463
|
return `listview_${objectApiName}_${listViewName}`;
|
|
306
464
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-pages",
|
|
3
|
-
"version": "2.5.0-beta.
|
|
3
|
+
"version": "2.5.0-beta.9",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {},
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
-
"gitHead": "
|
|
11
|
+
"gitHead": "a2623b433dd42632dc54d23c51b718bd4d1a2fdc",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"ejs": "^3.1.8"
|
|
14
14
|
}
|