@steedos/service-pages 2.3.5 → 2.4.0-beta.10

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.
@@ -18,6 +18,7 @@
18
18
  }else{
19
19
  thing = lodash.get(obj, path);
20
20
  }
21
+ // console.log(`_innerWaitForThing`, path)
21
22
  if (thing) {
22
23
  return resolve(thing);
23
24
  }
@@ -58,7 +59,7 @@
58
59
  if (window.define)
59
60
  window.define.amd = undefined;
60
61
 
61
- window.ReactDOM = ReactDom;
62
+ // window.ReactDOM = ReactDom;
62
63
  window.React17 = window.React;
63
64
  window.ReactDOM17 = window.ReactDOM;
64
65
 
@@ -4,10 +4,33 @@
4
4
  * @Description: 提供自定义page渲染能力, 供内部使用, 内容会迭代调整, 不对用户开放.
5
5
  */
6
6
  ;(function(){
7
+
8
+
9
+ const withModalWrap = (component, provideProps) => {
10
+ return (props) => {
11
+ const ModalComponent = component;
12
+ return React.createElement(ModalComponent, props);
13
+ }
14
+ }
15
+ const render = (component, componentProps, container, provideProps = {} ) => {
16
+ try {
17
+ const wrapComponent = withModalWrap(component, provideProps);
18
+ const contentEle = React.createElement(wrapComponent,{
19
+ ...componentProps
20
+ });
21
+ setTimeout(()=>{
22
+ ReactDOM.render(contentEle, container);
23
+ }, 100)
24
+ } catch (error) {
25
+ console.log(`error`, error)
26
+ }
27
+ }
28
+
7
29
  Steedos.Page = {
8
30
  App: {},
9
31
  Record: {},
10
32
  Listview: {},
33
+ Header: {},
11
34
  RelatedListview: {},
12
35
  Form: {
13
36
  StandardNew: {},
@@ -33,10 +56,10 @@
33
56
  return modalRoot;
34
57
  }
35
58
 
36
-
37
59
  Steedos.Page.getPage = function (type, appId, objectApiName, recordId, pageId) {
60
+ let objectInfo = null;
38
61
  if (type != 'list' && objectApiName) {
39
- const objectInfo = Creator.getObject(objectApiName);
62
+ objectInfo = Creator.getObject(objectApiName);
40
63
  if (objectInfo && objectInfo.version < 2) {
41
64
  return;
42
65
  }
@@ -55,6 +78,182 @@
55
78
  if (page && page.schema) {
56
79
  return page;
57
80
  }
81
+ else if(type === 'list'){
82
+ return {
83
+ render_engine: 'amis',
84
+ name: 'steedosListviewPage',
85
+ schema: {
86
+ "type": "page",
87
+ name: `amis-${appId}-${objectApiName}-listview`,
88
+ "title": "Welcome to Steedos",
89
+ bodyClassName: 'steedos-listview p-0 sm:border bg-white sm:shadow sm:rounded border-slate-300 border-solid sm:m-3 flex flex-1 flex-col',
90
+ "body": [
91
+ {
92
+ "type": "steedos-object-listview",
93
+ showHeader: true,
94
+ "label": "列表视图",
95
+ "objectApiName": "${objectName}",
96
+ "columnsTogglable": false,
97
+ "listName": "all",
98
+ "id": "u:be7c6341cd11"
99
+ }
100
+ ],
101
+ "regions": [
102
+ "body"
103
+ ],
104
+ "id": "u:7b47b6042b0d"
105
+ }
106
+ }
107
+ }else if(type === 'record'){
108
+ return {
109
+ render_engine: 'amis',
110
+ name: 'steedosRecordPage',
111
+ schema: {
112
+ "type": "service",
113
+ "className": 'sm:p-3',
114
+ "name": `amis-${appId}-${objectApiName}-detail`,
115
+ "title": "Welcome to Steedos",
116
+ "body": [
117
+ {
118
+ "type": "steedos-record-detail",
119
+ "objectApiName": "${objectName}",
120
+ "recordId": "${recordId}",
121
+ appId: appId,
122
+ "id": "u:48d2c28eb755",
123
+ onEvent: {
124
+ "recordLoaded": {
125
+ "actions": [
126
+ {
127
+ "actionType": "reload",
128
+ "data": {
129
+ "name": `\${record.${objectInfo?.NAME_FIELD_KEY || 'name'}}`
130
+ }
131
+ }
132
+ ]
133
+ }
134
+ },
135
+ }
136
+ ],
137
+ "regions": [
138
+ "body"
139
+ ],
140
+ "id": "u:d138f5276481"
141
+ }
142
+ }
143
+
144
+ }else if(type === 'related_list'){
145
+ const relatedKey = FlowRouter._current.queryParams.related_field_name;
146
+ const masterObject = Creator.getObject(FlowRouter.getParam("object_name"))
147
+ const object = Creator.getObject(objectApiName)
148
+ const idFieldName = masterObject.idFieldName;
149
+ return {
150
+ render_engine: 'amis',
151
+ name: 'steedosRelatedListPage',
152
+ schema: {
153
+ type: 'service',
154
+ name: `amis-${appId}-${FlowRouter.getParam("object_name")}-related-${objectApiName}`,
155
+ api: {
156
+ method: "post",
157
+ url: `\${context.rootUrl}/graphql`,
158
+ requestAdaptor: `
159
+ api.data = {
160
+ query: \`{
161
+ data: ${masterObject.name}(filters:["${idFieldName}", "=", "${FlowRouter.getParam("record_id")}"]){
162
+ ${idFieldName}
163
+ ${masterObject.NAME_FIELD_KEY},
164
+ recordPermissions: _permissions{
165
+ allowCreate,
166
+ allowCreateFiles,
167
+ allowDelete,
168
+ allowDeleteFiles,
169
+ allowEdit,
170
+ allowEditFiles,
171
+ allowRead,
172
+ allowReadFiles,
173
+ disabled_actions,
174
+ disabled_list_views,
175
+ field_permissions,
176
+ modifyAllFiles,
177
+ modifyAllRecords,
178
+ modifyAssignCompanysRecords,
179
+ modifyCompanyRecords,
180
+ uneditable_fields,
181
+ unreadable_fields,
182
+ unrelated_objects,
183
+ viewAllFiles,
184
+ viewAllRecords,
185
+ viewAssignCompanysRecords,
186
+ viewCompanyRecords,
187
+ }
188
+ }
189
+ }\`
190
+ }
191
+ return api;
192
+ `,
193
+ adaptor: `
194
+ if(payload.data.data){
195
+ var data = payload.data.data[0];
196
+ payload.data = data;
197
+ }
198
+ payload.data.$breadcrumb = [
199
+ {
200
+ "label": "${masterObject.label}",
201
+ "href": "/app/${appId}/${masterObject.name}"
202
+ },
203
+ {
204
+ "label": payload.data.${masterObject.NAME_FIELD_KEY},
205
+ "href": "/app/${appId}/${masterObject.name}/view/${FlowRouter.getParam("record_id")}",
206
+ },
207
+ {
208
+ "label": "相关 ${object.label}"
209
+ },
210
+ ]
211
+ payload.data.$loaded = true;
212
+ return payload;
213
+ `,
214
+ headers: {
215
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
216
+ }
217
+ },
218
+ "data": {
219
+ "&": "$$",
220
+ "$breadcrumb": [], //先给一个空数组, 防止breadcrumb组件报错
221
+ },
222
+ body: [
223
+ {
224
+ "type": "panel",
225
+ "title": {
226
+ "type": "breadcrumb",
227
+ "source": "${$breadcrumb}"
228
+ },
229
+ "body": [
230
+ {
231
+ type: 'steedos-object-related-listview',
232
+ objectApiName: masterObject.name,
233
+ recordId: FlowRouter.getParam("record_id"),
234
+ relatedObjectApiName: objectApiName,
235
+ foreign_key: relatedKey,
236
+ relatedKey: relatedKey,
237
+ hiddenOn: "!!!this.$loaded"
238
+ // top: 5
239
+ }
240
+ ]
241
+ }
242
+ ,
243
+ // {
244
+ // type: 'steedos-object-related-listview',
245
+ // objectApiName: masterObject.name,
246
+ // recordId: FlowRouter.getParam("record_id"),
247
+ // relatedObjectApiName: objectApiName,
248
+ // foreign_key: relatedKey,
249
+ // relatedKey: relatedKey,
250
+ // hiddenOn: "!!!this.$loaded"
251
+ // // top: 5
252
+ // }
253
+ ]
254
+ }
255
+ }
256
+ }
58
257
  }
59
258
 
60
259
  Steedos.Page.render = function (root, page, data, options = {}) {
@@ -111,8 +310,11 @@
111
310
 
112
311
  let schema = typeof page.schema === 'string' ? JSON.parse(page.schema) : page.schema;
113
312
 
114
- const defData = lodash.defaultsDeep({}, data , {
313
+ const defData = lodash.defaultsDeep({}, data , {data: data} , {
115
314
  data: {
315
+ app_id: data.appId,
316
+ object_name: data.objectName,
317
+ record_id: data.recordId,
116
318
  context: {
117
319
  rootUrl: __meteor_runtime_config__.ROOT_URL,
118
320
  tenantId: Creator.USER_CONTEXT.spaceId,
@@ -126,7 +328,8 @@
126
328
  user: Creator.USER_CONTEXT.user,
127
329
  now: new Date(),
128
330
  // mode: mode //由表单提供
129
- }
331
+ },
332
+ scopeId: schema.name || schema.id
130
333
  }
131
334
  });
132
335
 
@@ -159,7 +362,7 @@
159
362
 
160
363
  if(!lodash.isFunction(root)){
161
364
  //渲染loading
162
- SteedosUI.render(BuilderComponent, {
365
+ render(BuilderComponent, {
163
366
  model: "page", content: {
164
367
  "data": loadingContentData
165
368
  }
@@ -172,7 +375,7 @@
172
375
  ]).then(()=>{
173
376
  //渲染page
174
377
  if(!lodash.isFunction(root)){
175
- SteedosUI.render(BuilderComponent, {
378
+ render(BuilderComponent, {
176
379
  model: "page", content: {
177
380
  "data": pageContentData
178
381
  }
@@ -274,6 +477,7 @@
274
477
  }
275
478
 
276
479
  if (page.render_engine && page.render_engine != 'redash') {
480
+ data.listName = data.listViewId;
277
481
  return Steedos.Page.render($("#" + rootId)[0], page, Object.assign({}, options, data));
278
482
  }
279
483
  } catch (error) {
@@ -393,20 +597,6 @@
393
597
  // data: initialValues,
394
598
  // }));
395
599
  }
396
-
397
- SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
398
- name: `${objectApiName}_standard_new_form`,
399
- objectApiName: objectApiName,
400
- title: title,
401
- initialValues: initialValues,
402
- afterInsert: function (result) {
403
- if (result.length > 0) {
404
- var record = result[0];
405
- SteedosUI.router.go({objectName: objectApiName, recordId: record._id, type: 'new'});
406
- return true;
407
- }
408
- }
409
- }, null, { iconPath: '/assets/icons' });
410
600
  };
411
601
 
412
602
  Steedos.Page.Form.StandardEdit.render = function (appId, objectApiName, title, recordId, options) {
@@ -470,32 +660,6 @@
470
660
  // recordId: recordId
471
661
  // }));
472
662
  }
473
-
474
- return SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
475
- name: `${objectApiName}_standard_edit_form`,
476
- objectApiName: objectApiName,
477
- recordId: recordId,
478
- title: title,
479
- afterUpdate: function () {
480
- setTimeout(function () {
481
- if(["/app/:app_id/:object_name/view/:record_id", "/app/:app_id/:object_name/:record_id/:related_object_name/grid"].indexOf(FlowRouter.current().route.pathDef) > -1){
482
- // 记录详细界面编辑子表记录,或相关子表列表界面编辑子表记录
483
- var params = FlowRouter.current().params;
484
- if(params.record_id !== recordId){
485
- // ObjectForm有缓存,修改子表记录可能会有主表记录的汇总字段变更,需要刷新主表记录
486
- SteedosUI.reloadRecord(params.object_name, params.record_id)
487
- }
488
- }
489
- if (FlowRouter.current().route.path.endsWith("/:record_id")) {
490
- FlowRouter.reload()
491
- } else {
492
- window.refreshDxSchedulerInstance()
493
- window.refreshGrid(options.gridName);
494
- }
495
- }, 1);
496
- return true;
497
- }
498
- }, null, { iconPath: '/assets/icons' })
499
663
  };
500
664
 
501
665
  // Steedos.Page.Form.StandardDelete.render = function(){
@@ -558,4 +722,207 @@
558
722
  graphqlFieldsQuery: getGraphqlFieldsQuery(objectApiName, selectFields, expandFields)
559
723
  })
560
724
  }
725
+
726
+ const getSpaceLogo = function(){
727
+ let logoSrc = '';
728
+ const space = db.spaces.findOne(Steedos.getSpaceId())
729
+ if(space?.avatar){
730
+ logoSrc = Steedos.absoluteUrl(space.avatar)
731
+ }else if(space?.avatar_square){
732
+ logoSrc = Steedos.absoluteUrl(space.avatar_square)
733
+ }else{
734
+ var settings = Session.get("tenant_settings");
735
+ if(settings){
736
+ avatar_url = settings?.logo_square_url;
737
+ }
738
+ if(!avatar_url || !settings){
739
+ avatar_url = "/images/logo_platform.png"
740
+ if(Meteor.user()?.locale != 'zh-cn'){
741
+ avatar_url = "/images/logo_platform.en-us.png"
742
+ }
743
+ }
744
+ logoSrc = Steedos.absoluteUrl(avatar_url)
745
+ }
746
+ return logoSrc
747
+ }
748
+
749
+ Steedos.Page.Header.render = function(appId, tabId){
750
+ let app = _.find(Session.get('app_menus'), {id: appId}) || {}
751
+ if (app.id === 'admin' || (window.innerWidth < 768))
752
+ app.showSidebar = true;
753
+ if (app.showSidebar)
754
+ document.body.classList.add('sidebar')
755
+ else
756
+ document.body.classList.remove("sidebar")
757
+ if (window.innerWidth >= 768)
758
+ document.body.classList.add('sidebar-open')
759
+ if(app.showSidebar && window.location.pathname.startsWith("/workflow")){
760
+ app = {id: 'workflow'}
761
+ }
762
+ try {
763
+ const data = {
764
+ app
765
+ };
766
+ const page = Steedos.Page.Header.getPage(appId, tabId);
767
+ var rootId = "steedosGlobalHeaderRoot";
768
+ var modalRoot = document.getElementById(rootId);
769
+ if (!modalRoot) {
770
+ modalRoot = document.createElement('div');
771
+ modalRoot.setAttribute('id', rootId);
772
+ $(".steedos-global-header-root")[0].appendChild(modalRoot);
773
+ }
774
+ if (page.render_engine && page.render_engine != 'redash') {
775
+ return Steedos.Page.render($("#" + rootId)[0], page, Object.assign({}, data));
776
+ }
777
+ } catch (error) {
778
+ console.error(`Steedos.Page.Header.render`, error)
779
+ }
780
+ }
781
+ Steedos.Page.Header.getPage = function(appId, tabId){
782
+ const logoSrc = getSpaceLogo()
783
+ return {
784
+ render_engine: 'amis',
785
+ name: 'steedosGlobalHeaderPage',
786
+ schema: {
787
+ "type": "service",
788
+ name: "globalHeader",
789
+ body: [
790
+ {
791
+ "type": "wrapper",
792
+ "className": 'p-0',
793
+ body: [
794
+ {
795
+ "type": "wrapper",
796
+ "className": "p-0 slds-global-header_container sticky top-0 z-40 w-full flex-none backdrop-blur transition-colors duration-500 lg:z-50 sm:shadow border-b-[3px] border-sky-500 border-solid",
797
+ body: [
798
+ {
799
+ "type": "wrapper",
800
+ "className": 'flex w-full px-4 h-[50px] p-0 justify-between items-center',
801
+ "body": [
802
+ {
803
+ type: "wrapper",
804
+ className: 'p-0 flex flex-1 items-center',
805
+ body: [
806
+ {
807
+ "type": "steedos-logo",
808
+ "src": "/logo.png",
809
+ "className": 'block h-7 w-auto mr-4',
810
+ "hiddenOn": "window.innerWidth < 768",
811
+ },
812
+ {
813
+ "type": "steedos-app-launcher",
814
+ hiddenOn: "${app.showSidebar != true}",
815
+ "showAppName": true
816
+ },
817
+ ],
818
+ },
819
+ {
820
+ "type": "steedos-global-header",
821
+ "label": "Global Header",
822
+ className: 'flex flex-nowrap gap-x-3 items-center',
823
+ logoutScript: "window.Steedos.logout();",
824
+ customButtons: [
825
+ {
826
+ "type": "button",
827
+ "className": "toggle-sidebar",
828
+ "hiddenOn": "${app.showSidebar != true}",
829
+ "onEvent": {
830
+ "click": {
831
+ "actions": [
832
+ {
833
+ "actionType": "custom",
834
+ "script": "document.body.classList.toggle('sidebar-open')",
835
+ }
836
+ ]
837
+ }
838
+ },
839
+ "body": [
840
+ {
841
+ "type": "steedos-icon",
842
+ "category": "utility",
843
+ "name": "rows",
844
+ "colorVariant": "default",
845
+ "id": "u:afc3a08e8cf3",
846
+ "className": "slds-button_icon slds-global-header__icon"
847
+ }
848
+ ],
849
+ },]
850
+ }
851
+ ],
852
+ },
853
+
854
+ {
855
+ "type": "grid",
856
+ hiddenOn: "${app.showSidebar === true}",
857
+ "className": 'steedos-context-bar hidden sm:flex h-10 leading-5 pl-4 mb-[-3px]',
858
+ "columns": [
859
+ {
860
+ "columnClassName": "items-center hidden sm:flex pb-0",
861
+ "body": [
862
+ {
863
+ "type": "steedos-app-launcher",
864
+ "showAppName": true,
865
+ "appId": "${app.id}",
866
+ }
867
+ ],
868
+ "md": "auto",
869
+ "valign": "middle"
870
+ },
871
+ {
872
+ "columnClassName": "flex ",
873
+ "body": [
874
+ {
875
+ "type": "steedos-app-menu",
876
+ "stacked": false,
877
+ showIcon: false,
878
+ "appId": "${app.id}",
879
+ overflow: {
880
+ enable: false,
881
+ itemWidth: 80,
882
+ },
883
+ "id": "u:77851eb4aa89",
884
+ }
885
+ ],
886
+ "id": "u:5367229505d8",
887
+ "md": "",
888
+ "valign": "middle",
889
+ }
890
+ ],
891
+ },
892
+ ],
893
+ },
894
+
895
+ {
896
+
897
+ "type": "button",
898
+ "className": 'p-0 absolute inset-0 mt-[50px]',
899
+ hiddenOn: "${app.showSidebar != true}",
900
+ body: [{
901
+ type: "wrapper",
902
+ className: 'sidebar-wrapper px-0 pt-4 pb-16 fixed z-20 h-full ease-in-out duration-300 flex flex-col border-r overflow-y-auto bg-white border-slate-200 block -translate-x-0 sm:w-[220px] w-64',
903
+ body: [
904
+ {
905
+ "type": "steedos-app-menu",
906
+ "stacked": true,
907
+ "appId": "${app.id}",
908
+ },
909
+ ]
910
+ }],
911
+ "onEvent": {
912
+ "click": {
913
+ "actions": [
914
+ {
915
+ "actionType": "custom",
916
+ "script": "console.log(event.target); if(window.innerWidth < 768){ document.body.classList.remove('sidebar-open'); }",
917
+ }
918
+ ]
919
+ }
920
+ },
921
+ }
922
+ ],
923
+ },
924
+ ]
925
+ }
926
+ }
927
+ }
561
928
  })();
@@ -17,15 +17,4 @@ hidden: true
17
17
  icon: contract
18
18
  is_enable: true
19
19
  label: 微页面
20
- version: 2
21
- form:
22
- afterView: !!js/function |
23
- function(){
24
- if(this.doc.name && (this.doc.render_engine === 'redash' || !this.doc.render_engine)){
25
- return SteedosUI.render(stores.ComponentRegistry.components.Page, { pageId: this.doc.name }, $(".slds-template__container")[0])
26
- }
27
- if(this.doc.type === 'app'){
28
- $('[data-object-name="page_assignments"]').hide()
29
- }
30
- $('[data-object-name="page_versions"]').hide()
31
- }
20
+ version: 2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-pages",
3
- "version": "2.3.5",
3
+ "version": "2.4.0-beta.10",
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": "a817e9bda1620c21a3da1876d01238b1fc1df828",
11
+ "gitHead": "7f75a50d8d5ac875eb577d586981ba654a5180ff",
12
12
  "dependencies": {
13
13
  "ejs": "^3.1.8"
14
14
  }
Binary file