@steedos/standard-object-database 2.2.55-beta.16

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.
Files changed (90) hide show
  1. package/main/default/applications/.gitkeep +0 -0
  2. package/main/default/client/datasources.client.js +7 -0
  3. package/main/default/client/object_fields.client.js +212 -0
  4. package/main/default/client/object_layouts.client.js +86 -0
  5. package/main/default/objectTranslations/_object_reload_logs.en/_object_reload_logs.en.objectTranslation.yml +16 -0
  6. package/main/default/objectTranslations/_object_reload_logs.zh-CN/_object_reload_logs.zh-CN.objectTranslation.yml +16 -0
  7. package/main/default/objectTranslations/datasources.en/datasources.en.objectTranslation.yml +121 -0
  8. package/main/default/objectTranslations/datasources.zh-CN/datasources.zh-CN.objectTranslation.yml +105 -0
  9. package/main/default/objectTranslations/object_actions.en/object_actions.en.objectTranslation.yml +55 -0
  10. package/main/default/objectTranslations/object_actions.zh-CN/object_actions.zh-CN.objectTranslation.yml +50 -0
  11. package/main/default/objectTranslations/object_fields.en/object_fields.en.objectTranslation.yml +335 -0
  12. package/main/default/objectTranslations/object_fields.zh-CN/object_fields.zh-CN.objectTranslation.yml +312 -0
  13. package/main/default/objectTranslations/object_layouts.en/object_layouts.en.objectTranslation.yml +72 -0
  14. package/main/default/objectTranslations/object_layouts.zh-CN/object_layouts.zh-CN.objectTranslation.yml +116 -0
  15. package/main/default/objectTranslations/object_listviews.en/object_listviews.en.objectTranslation.yml +153 -0
  16. package/main/default/objectTranslations/object_listviews.zh-CN/object_listviews.zh-CN.objectTranslation.yml +146 -0
  17. package/main/default/objectTranslations/object_related_list.en/object_related_list.en.objectTranslation.yml +82 -0
  18. package/main/default/objectTranslations/object_related_list.zh-CN/object_related_list.zh-CN.objectTranslation.yml +82 -0
  19. package/main/default/objectTranslations/object_triggers.en/object_triggers.en.objectTranslation.yml +30 -0
  20. package/main/default/objectTranslations/object_triggers.zh-CN/object_triggers.zh-CN.objectTranslation.yml +29 -0
  21. package/main/default/objectTranslations/object_validation_rules.en/object_validation_rules.en.objectTranslation.yml +40 -0
  22. package/main/default/objectTranslations/object_validation_rules.zh-CN/object_validation_rules.zh-CN.objectTranslation.yml +38 -0
  23. package/main/default/objectTranslations/objects.en/objects.en.objectTranslation.yml +219 -0
  24. package/main/default/objectTranslations/objects.zh-CN/objects.zh-CN.objectTranslation.yml +218 -0
  25. package/main/default/objects/0.datasources.observe.object.js +83 -0
  26. package/main/default/objects/0.objects_reload.object.js +26 -0
  27. package/main/default/objects/1.objects.observe.object.js +61 -0
  28. package/main/default/objects/10.tabs.observe.object.js +36 -0
  29. package/main/default/objects/11.restriction_rules.observe.object.js +37 -0
  30. package/main/default/objects/12.share_rules.observe.object.js +37 -0
  31. package/main/default/objects/13.permission_fields.observe.object.js +37 -0
  32. package/main/default/objects/14.object_fields.observe.object.js +44 -0
  33. package/main/default/objects/15.permission_objects.observe.object.js +44 -0
  34. package/main/default/objects/2.object_triggers.observe.object.js +35 -0
  35. package/main/default/objects/3.permission_objects.observe.object.js +29 -0
  36. package/main/default/objects/4.permission_set.observe.object.js +39 -0
  37. package/main/default/objects/5.holidays.observe.object.js +30 -0
  38. package/main/default/objects/6.business_hours.observe.object.js +33 -0
  39. package/main/default/objects/7.object_actions.observe.object.js +43 -0
  40. package/main/default/objects/7.object_layouts.observe.object.js +33 -0
  41. package/main/default/objects/9.apps.observe.object.js +33 -0
  42. package/main/default/objects/_object_reload_logs.object.yml +10 -0
  43. package/main/default/objects/datasources.action.js +51 -0
  44. package/main/default/objects/datasources.core.js +34 -0
  45. package/main/default/objects/datasources.object.js +168 -0
  46. package/main/default/objects/datasources.object.yml +113 -0
  47. package/main/default/objects/object_actions.object.js +152 -0
  48. package/main/default/objects/object_actions.object.yml +142 -0
  49. package/main/default/objects/object_fields.action.js +128 -0
  50. package/main/default/objects/object_fields.function.js +104 -0
  51. package/main/default/objects/object_fields.object.js +501 -0
  52. package/main/default/objects/object_fields.object.yml +690 -0
  53. package/main/default/objects/object_layouts.action.js +31 -0
  54. package/main/default/objects/object_layouts.layouts.action.js +19 -0
  55. package/main/default/objects/object_layouts.object.yml +356 -0
  56. package/main/default/objects/object_listviews.action.js +93 -0
  57. package/main/default/objects/object_listviews.object.js +100 -0
  58. package/main/default/objects/object_listviews.object.yml +309 -0
  59. package/main/default/objects/object_manager.app.todo.yml +11 -0
  60. package/main/default/objects/object_related_list.object.js +110 -0
  61. package/main/default/objects/object_related_list.object.yml +208 -0
  62. package/main/default/objects/object_triggers.core.js +58 -0
  63. package/main/default/objects/object_triggers.object.js +65 -0
  64. package/main/default/objects/object_triggers.object.yml +124 -0
  65. package/main/default/objects/object_validation_rules.action.js +33 -0
  66. package/main/default/objects/object_validation_rules.object.yml +100 -0
  67. package/main/default/objects/objects.action.js +157 -0
  68. package/main/default/objects/objects.core.js +398 -0
  69. package/main/default/objects/objects.erd.data.function.js +85 -0
  70. package/main/default/objects/objects.lib.js +42 -0
  71. package/main/default/objects/objects.object.js +543 -0
  72. package/main/default/objects/objects.object.yml +512 -0
  73. package/main/default/objects/objects.tree.js +58 -0
  74. package/main/default/objects/permission_objects.core.js +75 -0
  75. package/main/default/permissionsets/.gitkeep +0 -0
  76. package/main/default/profiles/.gitkeep +0 -0
  77. package/main/default/tabs/.gitkeep +0 -0
  78. package/main/default/triggers/datasources.trigger.js +93 -0
  79. package/main/default/triggers/object_actions.trigger.js +98 -0
  80. package/main/default/triggers/object_fields.trigger.js +376 -0
  81. package/main/default/triggers/object_layouts.trigger.js +153 -0
  82. package/main/default/triggers/object_listviews.trigger.js +139 -0
  83. package/main/default/triggers/object_triggers.trigger.js +50 -0
  84. package/main/default/triggers/object_validation_rules.trigger.js +80 -0
  85. package/main/default/triggers/objects.trigger.js +136 -0
  86. package/package.json +16 -0
  87. package/package.service.js +75 -0
  88. package/public/.md +3 -0
  89. package/src/.md +3 -0
  90. package/webapp/.md +1 -0
@@ -0,0 +1,65 @@
1
+
2
+ function isRepeatedName(doc, name) {
3
+ var other = Creator.getCollection("object_triggers").find({
4
+ object: doc.object,
5
+ space: doc.space,
6
+ _id: {
7
+ $ne: doc._id
8
+ },
9
+ name: name || doc.name
10
+ }, {
11
+ fields: {
12
+ _id: 1
13
+ }
14
+ });
15
+ if (other.count() > 0) {
16
+ return true;
17
+ }
18
+ return false;
19
+ };
20
+
21
+ function check(userId, doc) {
22
+ // if (Steedos.isSpaceAdmin(userId, doc.space)) {
23
+ // throw new Meteor.Error(500, "只有工作区管理员才能配置触发器");
24
+ // }
25
+ // //TODO 校验关键字:remove、 drop、delete、db、collection、eval等,然后取消 企业版版限制
26
+ // if (doc.on === 'server' && !Steedos.isLegalVersion(doc.space, "workflow.enterprise")) {
27
+ // throw new Meteor.Error(500, "只有企业版支持配置服务端的触发器");
28
+ // }
29
+ return true;
30
+ };
31
+
32
+ Creator.Objects.object_triggers.triggers = {
33
+
34
+ "before.delete.server.object_triggers": {
35
+ on: "server",
36
+ when: "before.remove",
37
+ todo: function(userId, doc) {
38
+ check(userId, doc);
39
+ }
40
+ },
41
+ "before.update.server.object_triggers": {
42
+ on: "server",
43
+ when: "before.update",
44
+ todo: function(userId, doc, fieldNames, modifier, options) {
45
+ var ref;
46
+ check(userId, doc);
47
+ if ((modifier != null ? (ref = modifier.$set) != null ? ref.name : void 0 : void 0) && isRepeatedName(doc, modifier.$set.name)) {
48
+ throw new Meteor.Error(500, `名称不能重复${doc.name}`);
49
+ }
50
+ }
51
+ },
52
+ "before.insert.server.object_triggers": {
53
+ on: "server",
54
+ when: "before.insert",
55
+ todo: function(userId, doc) {
56
+ check(userId, doc);
57
+ if(true){
58
+ throw new Meteor.Error(500, "请在代码中定义trigger");
59
+ }
60
+ if (isRepeatedName(doc)) {
61
+ throw new Meteor.Error(500, "名称不能重复");
62
+ }
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,124 @@
1
+ name: object_triggers
2
+ icon: apex
3
+ label: Object Triggers
4
+ hidden: true
5
+ fields:
6
+ name:
7
+ type: text
8
+ label: Name
9
+ searchable: true
10
+ index: true
11
+ required: true
12
+ # label:
13
+ # label: 显示名称
14
+ # type: text
15
+ object:
16
+ label: Object
17
+ type: master_detail
18
+ reference_to: objects
19
+ reference_to_field: name
20
+ required: true
21
+ optionsFunction: !<tag:yaml.org,2002:js/function> |-
22
+ function () {
23
+ var _options;
24
+
25
+ _options = [];
26
+
27
+ _.forEach(Creator.objectsByName, function (o, k) {
28
+ return _options.push({
29
+ label: o.label,
30
+ value: k,
31
+ icon: o.icon
32
+ });
33
+ });
34
+
35
+ return _options;
36
+ }
37
+ # on:
38
+ # label: 运行于
39
+ # type: lookup
40
+ # required: true
41
+ # optionsFunction: !<tag:yaml.org,2002:js/function> |-
42
+ # function () {
43
+ # return [{
44
+ # label: "客户端",
45
+ # value: "client",
46
+ # icon: "address"
47
+ # }, {
48
+ # label: "服务端",
49
+ # value: "server",
50
+ # icon: "address"
51
+ # }];
52
+ # }
53
+ when:
54
+ label: Execution Time Option
55
+ type: lookup
56
+ required: true
57
+ optionsFunction: !<tag:yaml.org,2002:js/function> |-
58
+ function () {
59
+ return [{
60
+ label: "新增记录之前",
61
+ value: "beforeInsert",
62
+ icon: "asset_relationship"
63
+ }, {
64
+ label: "新增记录之后",
65
+ value: "afterInsert",
66
+ icon: "asset_relationship"
67
+ }, {
68
+ label: "修改记录之前",
69
+ value: "beforeUpdate",
70
+ icon: "asset_relationship"
71
+ }, {
72
+ label: "修改记录之后",
73
+ value: "afterUpdate",
74
+ icon: "asset_relationship"
75
+ }, {
76
+ label: "删除记录之前",
77
+ value: "beforeDelete",
78
+ icon: "asset_relationship"
79
+ }, {
80
+ label: "删除记录之后",
81
+ value: "afterDelete",
82
+ icon: "asset_relationship"
83
+ }, {
84
+ label: "查下记录之前",
85
+ value: "beforeFind",
86
+ icon: "asset_relationship"
87
+ }];
88
+ }
89
+ is_enable:
90
+ label: Enable
91
+ type: boolean
92
+ todo:
93
+ label: Execute Script <a target="_blank" href="https://developer.steedos.com/developer/object_trigger">View Help</a>
94
+ type: textarea
95
+ required: true
96
+ is_wide: true
97
+ paging:
98
+ enabled: false
99
+ list_views:
100
+ all:
101
+ columns:
102
+ - name
103
+ # - label
104
+ - object
105
+ # - 'on'
106
+ - when
107
+ - is_enable
108
+ label: All
109
+ filter_scope: space
110
+ permission_set:
111
+ user:
112
+ allowCreate: false
113
+ allowDelete: false
114
+ allowEdit: false
115
+ allowRead: false
116
+ modifyAllRecords: false
117
+ viewAllRecords: false
118
+ admin:
119
+ allowCreate: true
120
+ allowDelete: true
121
+ allowEdit: true
122
+ allowRead: true
123
+ modifyAllRecords: true
124
+ viewAllRecords: true
@@ -0,0 +1,33 @@
1
+ const _ = require("underscore");
2
+ module.exports = {
3
+ customize: function (object_name, record_id, fields) {
4
+ var doc = Creator.odata.get(object_name, record_id);
5
+ var newDoc = {}
6
+ _.each(Creator.getObject(object_name).fields, function(v, k){
7
+ if(_.has(doc, k)){
8
+ newDoc[k] = doc[k]
9
+ }
10
+ })
11
+ delete newDoc.is_system;
12
+
13
+ let docName = doc.name
14
+ let docObjectName = doc.object_name
15
+
16
+ Creator.odata.insert(object_name, Object.assign(newDoc, {name: docName, object_name: docObjectName}), function(result, error){
17
+ if(result){
18
+ if(Session.get("object_name") === 'object_validation_rules'){
19
+ FlowRouter.go(`/app/-/${object_name}/view/${result._id}`)
20
+ }else{
21
+ href = Creator.getObjectUrl(object_name, result._id);
22
+ window.open(href,'_blank','width=800, height=600, left=50, top= 50, toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes')
23
+ }
24
+ }
25
+ });
26
+ },
27
+ customizeVisible: function(object_name, record_id, record_permissions, record){
28
+ if(!record){
29
+ record = {}
30
+ }
31
+ return Creator.baseObject.actions.standard_new.visible() && record.is_system;
32
+ }
33
+ }
@@ -0,0 +1,100 @@
1
+ name: object_validation_rules
2
+ icon: textbox
3
+ hidden: true
4
+ label: Object Validation Rules
5
+ version: 2
6
+ fields:
7
+ name:
8
+ type: text
9
+ label: Name
10
+ required: true
11
+
12
+ object_name:
13
+ type: master_detail
14
+ label: Object
15
+ reference_to: objects
16
+ write_requires_master_read: true
17
+ reference_to_field: name
18
+ required: true
19
+ optionsFunction: !<tag:yaml.org,2002:js/function> |-
20
+ function () {
21
+ return Steedos.getObjectsOptions();
22
+ }
23
+
24
+ active:
25
+ type: boolean
26
+ label: Active
27
+ inlineHelpText: Indicates whether this validation rule is active, (true), or not active (false).
28
+
29
+ description:
30
+ type: textarea
31
+ is_wide: true
32
+ label: description
33
+
34
+ error_condition_formula:
35
+ type: textarea
36
+ is_wide: true
37
+ label: errorConditionFormula
38
+ inlineHelpText: The formula defined in the validation rule. If the formula returns a value of true, an error message is displayed.
39
+ required: true
40
+
41
+ error_message:
42
+ type: textarea
43
+ is_wide: true
44
+ label: errorMessage
45
+ inlineHelpText: The message that appears if the validation rule fails. The message must be 255 characters or less.
46
+
47
+ # error_display_field:
48
+ # type: lookup
49
+ # label: errorDisplayField
50
+ # inlineHelpText: The fully specified name of a field in the application. If a value is supplied, the error message appears next to the specified field. If you do not specify a value or the field isn’t visible on the page layout, the value changes automatically to Top of Page.
51
+ # showIcon: false
52
+ # is_wide: true
53
+ # depend_on:
54
+ # - object_name
55
+ # optionsFunction: !!js/function |
56
+ # function (doc) {
57
+ # var mainObjectName = doc.object_name;
58
+ # var object = Creator.objectsByName[mainObjectName];
59
+ # if(object){
60
+ # var _options = [];
61
+ # _.forEach(object.fields, function (field, fname) {
62
+ # _options.push({
63
+ # label: field.label,
64
+ # value: field.name,
65
+ # });
66
+ # });
67
+ # return _options;
68
+ # }
69
+ # return [];
70
+ # }
71
+ paging:
72
+ enabled: false
73
+ list_views:
74
+ all:
75
+ columns:
76
+ - name
77
+ - active
78
+ - description
79
+ - object_name
80
+ label: All
81
+ filter_scope: space
82
+ permission_set:
83
+ user:
84
+ allowCreate: false
85
+ allowDelete: false
86
+ allowEdit: false
87
+ allowRead: false
88
+ modifyAllRecords: false
89
+ viewAllRecords: false
90
+ admin:
91
+ allowCreate: true
92
+ allowDelete: true
93
+ allowEdit: true
94
+ allowRead: true
95
+ modifyAllRecords: true
96
+ viewAllRecords: true
97
+ actions:
98
+ customize:
99
+ label: Customize
100
+ on: record
@@ -0,0 +1,157 @@
1
+ module.exports = {
2
+ show_object: function (object_name, record_id, item_element) {
3
+ var record = this.record || Creator.getObjectById(record_id);
4
+ if(!record){
5
+ return toastr.error("未找到记录");
6
+ }
7
+
8
+ if(record.is_enable === false){
9
+ return toastr.warning("请先启动对象");
10
+ }
11
+
12
+ if(record.datasource && record.datasource != 'default' && record.datasource != 'meteor'){
13
+ var datasource = Creator.odata.get('datasources', record.datasource, 'is_enable');
14
+ if(!datasource){
15
+ return toastr.error("未找到数据源");
16
+ }
17
+ if(!datasource.is_enable){
18
+ return toastr.warning("请先启动数据源");
19
+ }
20
+ }
21
+
22
+ window.stores.API.client.sobject(record.name).getConfig().then((res)=>{
23
+ if(res.idFieldName){
24
+ window.open(Creator.getRelativeUrl("/app/-/" + record.name));
25
+ }else{
26
+ return toastr.error("请配置主键字段");
27
+ }
28
+ }).catch(function(err){
29
+ return window.toastr.error(err.message);
30
+ })
31
+
32
+
33
+
34
+ // var allViews = Creator.odata.query('object_listviews', { $select: '_id', $filter: `((object_name eq '${record.name}') and (name eq 'all'))` }, true);
35
+ // if(allViews && allViews.length > 0){
36
+ // Steedos.openWindow(Creator.getRelativeUrl("/app/-/" + record.name + "/grid/" + allViews[0]._id))
37
+ // }else{
38
+ // Steedos.openWindow(Creator.getRelativeUrl("/app/-/" + record.name + "/grid/all"))
39
+ // }
40
+ },
41
+ show_objectVisible: function(object_name, record_id, record_permissions, record){
42
+ if(!Creator.isSpaceAdmin()){
43
+ return false
44
+ }
45
+ if(!record){
46
+ record = Creator.odata.get("objects", record_id, "is_deleted");
47
+ }
48
+
49
+ if(record && !record.is_deleted){
50
+ return true;
51
+ }
52
+ },
53
+ copy_odata: function (object_name, record_id, item_element) {
54
+ var clipboard, o_name, path, record;
55
+ record = this.record || Creator.getObjectById(record_id);
56
+ //enable_api 属性未开放
57
+ if ((record != null ? record.enable_api : void 0) || true) {
58
+ o_name = record != null ? record.name : void 0;
59
+ path = SteedosOData.getODataPath(Session.get("spaceId"), o_name);
60
+ item_element.attr('data-clipboard-text', path);
61
+ if (!item_element.attr('data-clipboard-new')) {
62
+ clipboard = new Clipboard(item_element[0]);
63
+ item_element.attr('data-clipboard-new', true);
64
+ clipboard.on('success', function (e) {
65
+ return toastr.success('复制成功');
66
+ });
67
+ clipboard.on('error', function (e) {
68
+ toastr.error('复制失败');
69
+ return console.error("e");
70
+ });
71
+ if (item_element[0].tagName === 'LI' || item_element.hasClass('view-action')) {
72
+ return item_element.trigger("click");
73
+ }
74
+ }
75
+ } else {
76
+ return toastr.error('复制失败: 未启用API');
77
+ }
78
+ },
79
+ copy_odataVisible: function(object_name, record_id, record_permissions, record){
80
+ if(!Creator.isSpaceAdmin()){
81
+ return false
82
+ }
83
+ if(!record){
84
+ record = Creator.odata.get("objects", record_id, "is_deleted");
85
+ }
86
+ if(record && !record.is_deleted){
87
+ return true;
88
+ }
89
+ },
90
+ delete_object: function (object_name, record_id, fields) {
91
+ var record = Creator.getObjectRecord(object_name, record_id, 'name');
92
+ SteedosUI.showModal(stores.ComponentRegistry.components.ObjectForm, {
93
+ name: "remove-object",
94
+ title: '删除对象',
95
+ width: '540px',
96
+ layout: 'horizontal',
97
+ modalProps: {
98
+ width: "540px",
99
+ style: {
100
+ width: "540px",
101
+ maxWidth: "540px",
102
+ minWidth: "480px"
103
+ }
104
+ },
105
+ initialValues:{
106
+ md: "删除一个自定义对象进行以下操作:\n\n* 删除对象的字段和按钮\n* 删除对象的选项卡和列表视图\n* 删除对象的页面布局\n* 删除对象的权限\n* 删除对象的验证规则\n* 删除对象的限制规则\n* 删除对象的共享规则\n* 删除使用该对象的流程映射\n* 删除使用该对象的开放流程\n* 删除使用该对象的页面。\n\n\\\n"
107
+ },
108
+ objectSchema: {
109
+ fields: {
110
+ md: {
111
+ type: 'html',
112
+ label: ' ',
113
+ is_wide: true,
114
+ readonly: true,
115
+ }
116
+ }
117
+ },
118
+ onFinish: async (values = {}) => {
119
+ return new Promise((resolve, reject) => {
120
+ window.$("body").addClass("loading");
121
+ Creator.odata.delete(object_name, record_id, function() {
122
+ var info= t('creator_record_remove_swal_suc');
123
+ window.toastr.success(info);
124
+ resolve(true)
125
+ if(FlowRouter.current().route.path.endsWith("/:record_id")){
126
+ var app_id = Session.get("app_id")
127
+ var object_name = Session.get("object_name")
128
+ FlowRouter.go(Creator.getListViewUrl(object_name, app_id, 'all'));
129
+ }else{
130
+ FlowRouter.reload();
131
+ }
132
+ window.$("body").removeClass("loading");
133
+
134
+ }, function(error) {
135
+ toastr.error(error.message);
136
+ window.$("body").removeClass("loading");
137
+ reject(false);
138
+ });
139
+ })
140
+ }
141
+ }, null, { iconPath: '/assets/icons' })
142
+ },
143
+ delete_objectVisible: function(object_name, record_id, record_permissions, record){
144
+ if(!Creator.isSpaceAdmin()){
145
+ return false
146
+ }
147
+ if(!record){
148
+ record = Creator.odata.get("objects", record_id, "is_deleted");
149
+ }
150
+ if(record && !record.is_deleted){
151
+ return Creator.baseObject.actions.standard_delete.visible.apply(this, arguments);
152
+ }
153
+ }
154
+ // export: function(object_name, record_id, fields){
155
+ // return window.open(Steedos.absoluteUrl("/api/v4/objects/" + record_id + "/export_yml"), '_blank');
156
+ // }
157
+ }