@steedos/service-pages 2.2.23 → 2.2.26

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.
@@ -1,210 +1,181 @@
1
1
  /*
2
- * @Author: steedos
3
- * @Date: 2022-03-22 19:13:57
4
- * @Description: 提供自定义page渲染能力, 供内部使用, 内容会迭代调整, 不对用户开放.
5
- */
6
-
7
- Steedos.Page = {
8
- App: {},
9
- Record: {},
10
- Listview: {},
11
- RelatedListview: {},
12
- Form: {
13
- StandardNew: {},
14
- StandardEdit: {}
15
- }
16
- };
17
-
18
- function upperFirst(str) {
19
- return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
20
- };
21
-
22
- function getModalElement(name){
23
- let modalRoot = document.getElementById(`steedos-page-modal-root-${name}`);
24
- if (!modalRoot) {
25
- modalRoot = document.createElement('div');
26
- modalRoot.setAttribute('id', `steedos-page-modal-root-${name}`);
27
- document.body.appendChild(modalRoot)
28
- }
29
- return modalRoot;
30
- }
2
+ * @Author: steedos
3
+ * @Date: 2022-03-22 19:13:57
4
+ * @Description: 提供自定义page渲染能力, 供内部使用, 内容会迭代调整, 不对用户开放.
5
+ */
6
+ ;(function(){
7
+ Steedos.Page = {
8
+ App: {},
9
+ Record: {},
10
+ Listview: {},
11
+ RelatedListview: {},
12
+ Form: {
13
+ StandardNew: {},
14
+ StandardEdit: {}
15
+ },
16
+ Data: {},
17
+ reload: function(){
18
+ FlowRouter.reload();
19
+ }
20
+ };
31
21
 
22
+ function upperFirst(str) {
23
+ return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
24
+ };
32
25
 
33
- Steedos.Page.getPage = function (type, appId, objectApiName, recordId, pageId) {
34
- if (type != 'list' && objectApiName) {
35
- const objectInfo = Creator.getObject(objectApiName);
36
- if (objectInfo && objectInfo.version < 2) {
37
- return;
26
+ function getModalElement(name){
27
+ let modalRoot = document.getElementById(`steedos-page-modal-root-${name}`);
28
+ if (!modalRoot) {
29
+ modalRoot = document.createElement('div');
30
+ modalRoot.setAttribute('id', `steedos-page-modal-root-${name}`);
31
+ document.body.appendChild(modalRoot)
38
32
  }
33
+ return modalRoot;
39
34
  }
40
- if(!objectApiName){
41
- objectApiName = ''
42
- }
43
- if(!recordId){
44
- recordId = ''
45
- }
46
- if(!pageId){
47
- pageId = ''
48
- }
49
- const formFactor = Steedos.isMobile() ? "SMALL" : "LARGE";
50
- const page = Steedos.authRequest(`/api/pageSchema/${type}?app=${appId}&objectApiName=${objectApiName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`, { async: false });
51
- if (page && page.schema) {
52
- return page;
53
- }
54
- }
55
-
56
- Steedos.Page.render = function (root, page, data) {
57
-
58
- const loadingContentData = {
59
- "inputs": [],
60
- // "title": "loading",
61
- "blocks": [
62
- {
63
- "@type": "@builder.io/sdk:Element",
64
- "@version": 2,
65
- "layerName": "Box",
66
- "id": "builder-8070f86b1aed4e78a5878fa5c0d79e49",
67
- "children": [
68
- {
69
- "@type": "@builder.io/sdk:Element",
70
- "@version": 2,
71
- "layerName": "Loading...\n...",
72
- "id": "builder-4b16375a68dc4e49b4844843091bf91d",
73
- "component": {
74
- "name": "Text",
75
- "options": {
76
- "text": "<p>Loading...</p>\n"
77
- }
78
- },
79
- "responsiveStyles": {
80
- "large": {
81
- "display": "flex",
82
- "flexDirection": "column",
83
- "position": "relative",
84
- "flexShrink": "0",
85
- "boxSizing": "border-box",
86
- "marginTop": "20px",
87
- "lineHeight": "normal",
88
- "height": "auto",
89
- "textAlign": "center"
90
- }
91
- }
92
- }
93
- ],
94
- "responsiveStyles": {
95
- "large": {
96
- "display": "flex",
97
- "flexDirection": "column",
98
- "position": "relative",
99
- "flexShrink": "0",
100
- "boxSizing": "border-box"
101
- }
102
- }
103
- }
104
- ]
105
- };
106
35
 
107
- if (page.render_engine && page.render_engine != 'redash') {
108
36
 
109
- let schema = typeof page.schema === 'string' ? JSON.parse(page.schema) : page.schema;
110
- const defData = Object.assign({}, data, {
111
- context: {
112
- rootUrl: __meteor_runtime_config__.ROOT_URL,
113
- tenantId: Creator.USER_CONTEXT.spaceId,
114
- userId: Creator.USER_CONTEXT.userId,
115
- authToken: Creator.USER_CONTEXT.user.authToken
37
+ Steedos.Page.getPage = function (type, appId, objectApiName, recordId, pageId) {
38
+ if (type != 'list' && objectApiName) {
39
+ const objectInfo = Creator.getObject(objectApiName);
40
+ if (objectInfo && objectInfo.version < 2) {
41
+ return;
116
42
  }
117
- })
43
+ }
44
+ if(!objectApiName){
45
+ objectApiName = ''
46
+ }
47
+ if(!recordId){
48
+ recordId = ''
49
+ }
50
+ if(!pageId){
51
+ pageId = ''
52
+ }
53
+ const formFactor = Steedos.isMobile() ? "SMALL" : "LARGE";
54
+ const page = Steedos.authRequest(`/api/pageSchema/${type}?app=${appId}&objectApiName=${objectApiName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`, { async: false });
55
+ if (page && page.schema) {
56
+ return page;
57
+ }
58
+ }
118
59
 
119
- schema = lodash.defaultsDeep(defData , schema);
60
+ Steedos.Page.render = function (root, page, data) {
120
61
 
121
- const pageContentData = {
62
+ const loadingContentData = {
63
+ "inputs": [],
64
+ // "title": "loading",
122
65
  "blocks": [
123
66
  {
124
67
  "@type": "@builder.io/sdk:Element",
125
68
  "@version": 2,
126
- "id": `builder-${page._id}`,
127
- "component": {
128
- "name": upperFirst(page.render_engine),
129
- "options": {
130
- "schema": schema,
131
- "data": data,
132
- "name": page.name
69
+ "layerName": "Box",
70
+ "id": "builder-8070f86b1aed4e78a5878fa5c0d79e49",
71
+ "children": [
72
+ {
73
+ "@type": "@builder.io/sdk:Element",
74
+ "@version": 2,
75
+ "layerName": "Loading...\n...",
76
+ "id": "builder-4b16375a68dc4e49b4844843091bf91d",
77
+ "component": {
78
+ "name": "Text",
79
+ "options": {
80
+ "text": "<p>Loading...</p>\n"
81
+ }
82
+ },
83
+ "responsiveStyles": {
84
+ "large": {
85
+ "display": "flex",
86
+ "flexDirection": "column",
87
+ "position": "relative",
88
+ "flexShrink": "0",
89
+ "boxSizing": "border-box",
90
+ "marginTop": "20px",
91
+ "lineHeight": "normal",
92
+ "height": "auto",
93
+ "textAlign": "center"
94
+ }
95
+ }
96
+ }
97
+ ],
98
+ "responsiveStyles": {
99
+ "large": {
100
+ "display": "flex",
101
+ "flexDirection": "column",
102
+ "position": "relative",
103
+ "flexShrink": "0",
104
+ "boxSizing": "border-box"
133
105
  }
134
- },
106
+ }
135
107
  }
136
- ],
137
- "inputs": [
138
108
  ]
139
- }
109
+ };
140
110
 
141
- const findComponent = (obj, componentName)=>{
142
- return lodash.find(obj, {name : componentName})
143
- }
111
+ if (page.render_engine && page.render_engine != 'redash') {
112
+
113
+ let schema = typeof page.schema === 'string' ? JSON.parse(page.schema) : page.schema;
114
+ const defData = Object.assign({}, data, {
115
+ data: {
116
+ context: {
117
+ rootUrl: __meteor_runtime_config__.ROOT_URL,
118
+ tenantId: Creator.USER_CONTEXT.spaceId,
119
+ userId: Creator.USER_CONTEXT.userId,
120
+ authToken: Creator.USER_CONTEXT.user.authToken
121
+ }
122
+ }
123
+ })
124
+
125
+ schema = lodash.defaultsDeep(defData , schema);
126
+
127
+ const pageContentData = {
128
+ "blocks": [
129
+ {
130
+ "@type": "@builder.io/sdk:Element",
131
+ "@version": 2,
132
+ "id": `builder-${page._id}`,
133
+ "component": {
134
+ "name": upperFirst(page.render_engine),
135
+ "options": {
136
+ "schema": schema,
137
+ "data": data,
138
+ "name": page.name
139
+ }
140
+ },
141
+ }
142
+ ],
143
+ "inputs": [
144
+ ]
145
+ }
144
146
 
145
- //渲染loading
146
- SteedosUI.render(BuilderComponent, {
147
- model: "page", content: {
148
- "data": loadingContentData
147
+ const findComponent = (obj, componentName)=>{
148
+ return lodash.find(obj, {name : componentName})
149
149
  }
150
- }, root)
151
150
 
152
- Promise.all([
153
- waitForThing(window, 'BuilderComponent'),
154
- waitForThing(Builder.components, upperFirst(page.render_engine), findComponent)
155
- ]).then(()=>{
156
- //渲染page
151
+ //渲染loading
157
152
  SteedosUI.render(BuilderComponent, {
158
153
  model: "page", content: {
159
- "data": pageContentData
154
+ "data": loadingContentData
160
155
  }
161
156
  }, root)
162
- });
163
- }
164
-
165
- return root;
166
- };
167
-
168
- Steedos.Page.App.render = function (template, pageName, app_id) {
169
- if (!pageName) {
170
- return;
171
- }
172
- var rootId = "steedosPageRoot";
173
- var modalRoot = document.getElementById(rootId);
174
- // if(modalRoot){
175
- // modalRoot.remove();
176
- // }
177
- if (!modalRoot) {
178
- modalRoot = document.createElement('div');
179
- modalRoot.setAttribute('id', rootId);
180
- $(".page-template-root")[0].appendChild(modalRoot);
181
- }
182
-
183
- const container = $("#" + rootId)[0];
184
157
 
185
- const page = Steedos.Page.getPage('app', app_id, null, null, pageName);
186
- if (page) {
187
- if (page.render_engine && page.render_engine != 'redash') {
188
- return Steedos.Page.render(container, page, {
189
- appId: app_id
158
+ Promise.all([
159
+ waitForThing(window, 'BuilderComponent'),
160
+ waitForThing(Builder.components, upperFirst(page.render_engine), findComponent)
161
+ ]).then(()=>{
162
+ //渲染page
163
+ SteedosUI.render(BuilderComponent, {
164
+ model: "page", content: {
165
+ "data": pageContentData
166
+ }
167
+ }, root)
190
168
  });
191
169
  }
192
- }
193
170
 
194
- SteedosUI.render(stores.ComponentRegistry.components.PublicPage, {
195
- token: pageName
196
- }, container);
197
- return container
198
- };
171
+ return root;
172
+ };
199
173
 
200
- Steedos.Page.Listview.render = function (template, objectApiName) {
201
- try {
202
- if (!template.data.regions || !objectApiName) {
174
+ Steedos.Page.App.render = function (template, pageName, app_id, options) {
175
+ if (!pageName) {
203
176
  return;
204
177
  }
205
- const { page, ...data } = template.data.regions();
206
-
207
- var rootId = "steedosPageRecordRoot";
178
+ var rootId = "steedosPageRoot";
208
179
  var modalRoot = document.getElementById(rootId);
209
180
  // if(modalRoot){
210
181
  // modalRoot.remove();
@@ -212,133 +183,220 @@ Steedos.Page.Listview.render = function (template, objectApiName) {
212
183
  if (!modalRoot) {
213
184
  modalRoot = document.createElement('div');
214
185
  modalRoot.setAttribute('id', rootId);
215
- $(".page-list-view-root")[0].appendChild(modalRoot);
186
+ $(".page-template-root")[0].appendChild(modalRoot);
216
187
  }
217
188
 
218
- if (page.render_engine && page.render_engine != 'redash') {
219
- return Steedos.Page.render($("#" + rootId)[0], page, data);
189
+ const container = $("#" + rootId)[0];
190
+
191
+ const page = Steedos.Page.getPage('app', app_id, null, null, pageName);
192
+ if (page) {
193
+ if (page.render_engine && page.render_engine != 'redash') {
194
+ return Steedos.Page.render(container, page, Object.assign({}, options, {
195
+ appId: app_id
196
+ }));
197
+ }
220
198
  }
221
- } catch (error) {
222
199
 
223
- }
224
- };
200
+ SteedosUI.render(stores.ComponentRegistry.components.PublicPage, {
201
+ token: pageName
202
+ }, container);
203
+ return container
204
+ };
225
205
 
226
- Steedos.Page.Record.render = function (template, objectApiName, recordId) {
227
- try {
228
- if (!template.data.regions || !objectApiName || !recordId) {
229
- return;
230
- }
231
- const { page, ...data } = template.data.regions();
232
- var rootId = "steedosPageRecordRoot";
233
- var modalRoot = document.getElementById(rootId);
234
- // if(modalRoot){
235
- // modalRoot.remove();
236
- // }
237
- if (!modalRoot) {
238
- modalRoot = document.createElement('div');
239
- modalRoot.setAttribute('id', rootId);
240
- $(".page-record-view-root")[0].appendChild(modalRoot);
241
- }
206
+ Steedos.Page.Listview.getDefaultName = function (objectApiName, listViewName) {
207
+ return `listview_${objectApiName}_${listViewName}`;
208
+ };
209
+
210
+ Steedos.Page.Listview.render = function (template, objectApiName, options) {
211
+ try {
212
+ if (!template.data.regions || !objectApiName) {
213
+ return;
214
+ }
215
+ const { page, ...data } = template.data.regions();
216
+
217
+ var rootId = "steedosPageRecordRoot";
218
+ var modalRoot = document.getElementById(rootId);
219
+ // if(modalRoot){
220
+ // modalRoot.remove();
221
+ // }
222
+ if (!modalRoot) {
223
+ modalRoot = document.createElement('div');
224
+ modalRoot.setAttribute('id', rootId);
225
+ $(".page-list-view-root")[0].appendChild(modalRoot);
226
+ }
227
+
228
+ if (page.render_engine && page.render_engine != 'redash') {
229
+ return Steedos.Page.render($("#" + rootId)[0], page, Object.assign({}, options, data));
230
+ }
231
+ } catch (error) {
242
232
 
243
- if (page.render_engine && page.render_engine != 'redash') {
244
- return Steedos.Page.render($("#" + rootId)[0], page, data);
245
233
  }
246
- } catch (error) {
234
+ };
247
235
 
248
- }
249
- };
236
+ Steedos.Page.Record.render = function (template, objectApiName, recordId, options) {
237
+ try {
238
+ if (!template.data.regions || !objectApiName || !recordId) {
239
+ return;
240
+ }
241
+ const { page, ...data } = template.data.regions();
242
+ var rootId = "steedosPageRecordRoot";
243
+ var modalRoot = document.getElementById(rootId);
244
+ // if(modalRoot){
245
+ // modalRoot.remove();
246
+ // }
247
+ if (!modalRoot) {
248
+ modalRoot = document.createElement('div');
249
+ modalRoot.setAttribute('id', rootId);
250
+ $(".page-record-view-root")[0].appendChild(modalRoot);
251
+ }
252
+
253
+ if (page.render_engine && page.render_engine != 'redash') {
254
+ return Steedos.Page.render($("#" + rootId)[0], page, Object.assign({}, options, data));
255
+ }
256
+ } catch (error) {
250
257
 
251
- Steedos.Page.RelatedListview.render = function (template, objectApiName) {
252
- try {
253
- if (!template.data.regions || !objectApiName) {
254
- return;
255
258
  }
256
- const { page, ...data } = template.data.regions();
259
+ };
260
+
261
+ Steedos.Page.RelatedListview.render = function (template, objectApiName, options) {
262
+ try {
263
+ if (!template.data.regions || !objectApiName) {
264
+ return;
265
+ }
266
+ const { page, ...data } = template.data.regions();
267
+
268
+ var rootId = "steedosPageRecordRoot";
269
+ var modalRoot = document.getElementById(rootId);
270
+ // if(modalRoot){
271
+ // modalRoot.remove();
272
+ // }
273
+ if (!modalRoot) {
274
+ modalRoot = document.createElement('div');
275
+ modalRoot.setAttribute('id', rootId);
276
+ $(".page-related-list-view-root")[0].appendChild(modalRoot);
277
+ }
278
+
279
+ if (page.render_engine && page.render_engine != 'redash') {
280
+ return Steedos.Page.render($("#" + rootId)[0], page, Object.assign({}, options, data));
281
+ }
282
+ } catch (error) {
257
283
 
258
- var rootId = "steedosPageRecordRoot";
259
- var modalRoot = document.getElementById(rootId);
260
- // if(modalRoot){
261
- // modalRoot.remove();
262
- // }
263
- if (!modalRoot) {
264
- modalRoot = document.createElement('div');
265
- modalRoot.setAttribute('id', rootId);
266
- $(".page-related-list-view-root")[0].appendChild(modalRoot);
267
284
  }
285
+ };
268
286
 
269
- if (page.render_engine && page.render_engine != 'redash') {
270
- return Steedos.Page.render($("#" + rootId)[0], page, data);
287
+ Steedos.Page.Form.StandardNew.render = function (appId, objectApiName, title, initialValues, options) {
288
+ const page = Steedos.Page.getPage('form', appId, objectApiName);
289
+ if (page && page.schema) {
290
+ const elementId = getModalElement(`${objectApiName}-standard_new`);
291
+ return Steedos.Page.render(elementId, page, Object.assign({}, options, {
292
+ appId: appId,
293
+ objectName: objectApiName,
294
+ title: title,
295
+ initialValues: initialValues,
296
+ }));
271
297
  }
272
- } catch (error) {
273
298
 
274
- }
275
- };
276
-
277
- Steedos.Page.Form.StandardNew.render = function (appId, objectApiName, title, initialValues) {
278
- const page = Steedos.Page.getPage('form', appId, objectApiName);
279
- if (page && page.schema) {
280
- const elementId = getModalElement(`${objectApiName}-standard_new`);
281
- return Steedos.Page.render(elementId, page, {
282
- appId: appId,
283
- objectName: objectApiName,
299
+ SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
300
+ name: `${objectApiName}_standard_new_form`,
301
+ objectApiName: objectApiName,
284
302
  title: title,
285
- initialValues: initialValues
286
- });
287
- }
303
+ initialValues: initialValues,
304
+ afterInsert: function (result) {
305
+ if (result.length > 0) {
306
+ var record = result[0];
307
+ setTimeout(function () {
308
+ var url = `/app/${appId}/${objectApiName}/view/${record._id}`
309
+ FlowRouter.go(url)
310
+ }
311
+ , 1);
312
+ return true;
313
+ }
314
+ }
315
+ }, null, { iconPath: '/assets/icons' });
316
+ };
288
317
 
289
- SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
290
- name: `${objectApiName}_standard_new_form`,
291
- objectApiName: objectApiName,
292
- title: title,
293
- initialValues: initialValues,
294
- afterInsert: function (result) {
295
- if (result.length > 0) {
296
- var record = result[0];
318
+ Steedos.Page.Form.StandardEdit.render = function (appId, objectApiName, title, recordId, options) {
319
+ const page = Steedos.Page.getPage('form', appId, objectApiName, recordId);
320
+ if (page && page.schema) {
321
+ const elementId = getModalElement(`${objectApiName}-standard_edit`);
322
+ return Steedos.Page.render(elementId, page, Object.assign({}, options, {
323
+ appId: appId,
324
+ objectName: objectApiName,
325
+ title: title,
326
+ recordId: recordId
327
+ }));
328
+ }
329
+
330
+ return SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
331
+ name: `${objectApiName}_standard_edit_form`,
332
+ objectApiName: objectApiName,
333
+ recordId: recordId,
334
+ title: title,
335
+ afterUpdate: function () {
297
336
  setTimeout(function () {
298
- var url = `/app/${appId}/${objectApiName}/view/${record._id}`
299
- FlowRouter.go(url)
300
- }
301
- , 1);
337
+ if (FlowRouter.current().route.path.endsWith("/:record_id")) {
338
+ FlowRouter.reload()
339
+ // ObjectForm有缓存,修改子表记录可能会有主表记录的汇总字段变更,需要刷新表单数据
340
+ SteedosUI.reloadRecord(objectApiName, recordId)
341
+ } else {
342
+ window.refreshDxSchedulerInstance()
343
+ window.refreshGrid(options.gridName);
344
+ }
345
+ }, 1);
302
346
  return true;
303
347
  }
348
+ }, null, { iconPath: '/assets/icons' })
349
+ };
350
+
351
+ // Steedos.Page.Form.StandardDelete.render = function(){
352
+
353
+ // };
354
+
355
+
356
+ // creator odata 转 graphql 防腐层
357
+
358
+ function getGraphqlFieldsQuery(objectApiName, selectFields, expandFields){
359
+ const objectConfig = Creator.getObject(objectApiName)
360
+ const objectFields = objectConfig.fields
361
+ if(_.isString(selectFields)){
362
+ selectFields = selectFields.split(',');
304
363
  }
305
- }, null, { iconPath: '/assets/icons' });
306
- };
307
364
 
308
- Steedos.Page.Form.StandardEdit.render = function (appId, objectApiName, title, recordId) {
365
+ if(_.isString(expandFields)){
366
+ expandFields = expandFields.split(',');
367
+ }
309
368
 
310
- const page = Steedos.Page.getPage('form', appId, objectApiName, recordId);
311
- if (page && page.schema) {
312
- const elementId = getModalElement(`${objectApiName}-standard_edit`);
313
- return Steedos.Page.render(elementId, page, {
314
- appId: appId,
315
- objectName: objectApiName,
316
- title: title,
317
- recordId: recordId
369
+ const fieldsName = ['_id'];
370
+
371
+ if(objectConfig.database_name ==='default' || !objectConfig.database_name){
372
+ fieldsName.push('record_permissions')
373
+ }
374
+
375
+ _.each(selectFields, function(fieldName){
376
+ fieldsName.push(`${fieldName}`)
318
377
  });
319
- }
320
378
 
321
- return SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
322
- name: `${objectApiName}_standard_edit_form`,
323
- objectApiName: objectApiName,
324
- recordId: recordId,
325
- title: title,
326
- afterUpdate: function () {
327
- setTimeout(function () {
328
- if (FlowRouter.current().route.path.endsWith("/:record_id")) {
329
- FlowRouter.reload()
330
- // ObjectForm有缓存,修改子表记录可能会有主表记录的汇总字段变更,需要刷新表单数据
331
- SteedosUI.reloadRecord(objectApiName, recordId)
332
- } else {
333
- window.refreshDxSchedulerInstance()
334
- window.refreshGrid();
379
+ _.each(expandFields, function(fieldName){
380
+ if(fieldName && _.isString(objectFields[fieldName].reference_to)){
381
+ let spaceUsersCompanyIdsExpand = '';
382
+ if(objectApiName === 'space_users' && fieldName === 'company_ids'){
383
+ spaceUsersCompanyIdsExpand = ',name,admins'
335
384
  }
336
- }, 1);
337
- return true;
338
- }
339
- }, null, { iconPath: '/assets/icons' })
340
- };
385
+ const refObject = Creator.getObject(objectFields[fieldName].reference_to)
386
+ if(_.includes(fieldsName, fieldName)){
387
+ fieldsName[_.indexOf(fieldsName, fieldName)] = `${fieldName}:${fieldName}__expand{_id, _NAME_FIELD_VALUE:${refObject.NAME_FIELD_KEY}${spaceUsersCompanyIdsExpand}}`
388
+ }else{
389
+ fieldsName.push(`${fieldName}:${fieldName}__expand{_id, _NAME_FIELD_VALUE:${refObject.NAME_FIELD_KEY}${spaceUsersCompanyIdsExpand}}`)
390
+ }
391
+ }
392
+ })
341
393
 
342
- // Steedos.Page.Form.StandardDelete.render = function(){
394
+ return fieldsName;
395
+ }
343
396
 
344
- // };
397
+ Steedos.Page.Data.getRecord = function(objectApiName, recordId, selectFields, expandFields){
398
+ return stores.API.client.sobject(objectApiName).record(recordId, null, {
399
+ graphqlFieldsQuery: getGraphqlFieldsQuery(objectApiName, selectFields, expandFields)
400
+ })
401
+ }
402
+ })();
@@ -5,4 +5,6 @@ reference_to: apps
5
5
  reference_to_field: code
6
6
  filters:
7
7
  - ['code','!=','admin']
8
- sort_no: 120
8
+ sort_no: 120
9
+ required: "{{(formData.type == 'appDefault' || formData.type == 'appRecordProfile') ? true : false}}"
10
+ visible_on: "{{(formData.type == 'appDefault' || formData.type == 'appRecordProfile') ? true : false}}"
@@ -1,6 +1,7 @@
1
1
  name: is_system
2
2
  type: boolean
3
- label: System
4
- omit: true
3
+ label: 系统
4
+ visible_on: "{{global.mode ==='read' ? true : false}}"
5
5
  readonly: true
6
- disabled: true
6
+ disabled: true
7
+ sort_no: 999
@@ -2,4 +2,5 @@ name: page
2
2
  label: 页面
3
3
  type: master_detail
4
4
  reference_to: pages
5
- sort_no: 110
5
+ sort_no: 110
6
+ required: true
@@ -4,5 +4,6 @@ label: 简档
4
4
  reference_to: permission_set
5
5
  filters:
6
6
  - ["type","=","profile"]
7
- visible_on: "{{formData.app ? true: false}}"
8
- sort_no: 125
7
+ sort_no: 125
8
+ required: "{{formData.type == 'appRecordProfile' ? true : false}}"
9
+ visible_on: "{{formData.type == 'appRecordProfile' ? true : false}}"
@@ -0,0 +1,12 @@
1
+ name: type
2
+ label: 授权类型
3
+ type: select
4
+ required: true
5
+ defaultValue: orgDefault
6
+ options:
7
+ - label: 组织默认设置
8
+ value: orgDefault
9
+ - label: 应用程序默认设置
10
+ value: appDefault
11
+ - label: 应用程序和简档
12
+ value: appRecordProfile
@@ -1,8 +1,9 @@
1
1
  name: all
2
2
  columns:
3
+ - field: type
3
4
  - field: app
4
5
  - field: profile
5
- - field: record_type
6
+ # - field: record_type
6
7
  - field: mobile
7
8
  - field: desktop
8
9
  - field: is_system
@@ -1,8 +1,9 @@
1
1
  name: recent
2
2
  columns:
3
+ - field: type
3
4
  - field: app
4
5
  - field: profile
5
- - field: record_type
6
+ # - field: record_type
6
7
  - field: mobile
7
8
  - field: desktop
8
9
  - field: is_system
@@ -7,7 +7,7 @@ enable_chatter: false
7
7
  enable_enhanced_lookup: false
8
8
  enable_events: false
9
9
  enable_files: false
10
- enable_inline_edit: true
10
+ enable_inline_edit: false
11
11
  enable_instances: false
12
12
  enable_notes: false
13
13
  enable_search: false
@@ -2,5 +2,4 @@ name: is_active
2
2
  label: 已发布
3
3
  sort_no: 130
4
4
  readonly: true
5
- omit: true
6
5
  type: boolean
@@ -0,0 +1,7 @@
1
+ name: is_system
2
+ type: boolean
3
+ label: 系统
4
+ visible_on: "{{global.mode ==='read' ? true : false}}"
5
+ readonly: true
6
+ disabled: true
7
+ sort_no: 999
@@ -2,5 +2,4 @@ name: version
2
2
  type: number
3
3
  label: 版本号
4
4
  scale: 0
5
- omit: true
6
5
  readonly: true
@@ -1,6 +1,7 @@
1
1
  name: is_system
2
2
  type: boolean
3
3
  label: 系统
4
- omit: true
4
+ visible_on: "{{global.mode ==='read' ? true : false}}"
5
5
  readonly: true
6
- disabled: true
6
+ disabled: true
7
+ sort_no: 999
@@ -10,6 +10,37 @@ module.exports = {
10
10
  throw new Error('禁止给应用程序页面分配权限');
11
11
  }
12
12
  }
13
+
14
+ if(doc.type === 'orgDefault'){
15
+ delete doc.app;
16
+ delete doc.profile;
17
+ }
18
+
19
+ if(doc.type === 'appDefault'){
20
+ delete doc.profile;
21
+ }
22
+
23
+ if(doc.type === 'orgDefault'){
24
+ const count = await objectql.getObject('page_assignments').count({filters: [['page', '=', doc.page], ['type', '=', doc.type]]})
25
+ if(count > 0){
26
+ throw new Error("已存在「组织默认设置」授权")
27
+ }
28
+ }
29
+
30
+ if(doc.type === 'appDefault'){
31
+ const count = await objectql.getObject('page_assignments').count({filters: [['page', '=', doc.page], ['type', '=', doc.type], ['app', '=', doc.app]]})
32
+ if(count > 0){
33
+ throw new Error("已存在「应用程序默认设置」授权")
34
+ }
35
+ }
36
+
37
+ if(doc.type === 'appRecordProfile'){
38
+ const count = await objectql.getObject('page_assignments').count({filters: [['page', '=', doc.page], ['type', '=', doc.type], ['app', '=', doc.app], ['profile', '=', doc.profile]]})
39
+ if(count > 0){
40
+ throw new Error("已存在「应用程序和简档」授权")
41
+ }
42
+ }
43
+
13
44
  },
14
45
  beforeUpdate: async function(){
15
46
  const {object_name, doc, spaceId, id} = this;
@@ -19,5 +50,35 @@ module.exports = {
19
50
  throw new Error('禁止给应用程序页面分配权限');
20
51
  }
21
52
  }
53
+
54
+ if(doc.type === 'orgDefault'){
55
+ doc.app = null;
56
+ doc.profile = null;
57
+ }
58
+
59
+ if(doc.type === 'appDefault'){
60
+ doc.profile = null;
61
+ }
62
+
63
+ if(doc.type === 'orgDefault'){
64
+ const count = await objectql.getObject('page_assignments').count({filters: [['_id', '!=', id], ['page', '=', doc.page], ['type', '=', doc.type]]})
65
+ if(count > 0){
66
+ throw new Error("已存在「组织默认设置」授权")
67
+ }
68
+ }
69
+
70
+ if(doc.type === 'appDefault'){
71
+ const count = await objectql.getObject('page_assignments').count({filters: [['_id', '!=', id], ['page', '=', doc.page], ['type', '=', doc.type], ['app', '=', doc.app]]})
72
+ if(count > 0){
73
+ throw new Error("已存在「应用程序默认设置」授权")
74
+ }
75
+ }
76
+
77
+ if(doc.type === 'appRecordProfile'){
78
+ const count = await objectql.getObject('page_assignments').count({filters: [['_id', '!=', id], ['page', '=', doc.page], ['type', '=', doc.type], ['app', '=', doc.app], ['profile', '=', doc.profile]]})
79
+ if(count > 0){
80
+ throw new Error("已存在「应用程序和简档」授权")
81
+ }
82
+ }
22
83
  }
23
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-pages",
3
- "version": "2.2.23",
3
+ "version": "2.2.26",
4
4
  "main": "package.service.js",
5
5
  "scripts": {},
6
6
  "license": "MIT",
@@ -11,5 +11,5 @@
11
11
  "dependencies": {
12
12
  "@builder.io/react": "^1.1.50"
13
13
  },
14
- "gitHead": "830698bdc5c848858d24ba536d9eff0fa51c22f0"
14
+ "gitHead": "77fa3c2b6bdfebaccb4b7f0886f32eb347cbdd35"
15
15
  }