@steedos/standard-object-database 2.6.1-beta.7 → 2.6.2-beta.3

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 (54) hide show
  1. package/main/default/client/coordtransform.client.js +153 -0
  2. package/main/default/client/object_fields.client.js +150 -44
  3. package/main/default/objectTranslations/object_actions.en/object_actions.en.objectTranslation.yml +2 -0
  4. package/main/default/objectTranslations/object_actions.zh-CN/object_actions.zh-CN.objectTranslation.yml +2 -0
  5. package/main/default/objectTranslations/object_fields.en/object_fields.en.objectTranslation.yml +27 -2
  6. package/main/default/objectTranslations/object_fields.zh-CN/object_fields.zh-CN.objectTranslation.yml +32 -4
  7. package/main/default/objectTranslations/object_layouts.en/object_layouts.en.objectTranslation.yml +2 -0
  8. package/main/default/objectTranslations/object_layouts.zh-CN/object_layouts.zh-CN.objectTranslation.yml +2 -0
  9. package/main/default/objectTranslations/object_listviews.en/object_listviews.en.objectTranslation.yml +29 -1
  10. package/main/default/objectTranslations/object_listviews.zh-CN/object_listviews.zh-CN.objectTranslation.yml +27 -1
  11. package/main/default/objectTranslations/object_triggers.en/object_triggers.en.objectTranslation.yml +7 -1
  12. package/main/default/objectTranslations/object_triggers.zh-CN/object_triggers.zh-CN.objectTranslation.yml +8 -2
  13. package/main/default/objectTranslations/object_validation_rules.en/object_validation_rules.en.objectTranslation.yml +2 -0
  14. package/main/default/objectTranslations/object_validation_rules.zh-CN/object_validation_rules.zh-CN.objectTranslation.yml +2 -0
  15. package/main/default/objects/1.objects.observe.object.js +4 -1
  16. package/main/default/objects/7.object_actions.observe.object.js +7 -1
  17. package/main/default/objects/object_actions.action.js +34 -3
  18. package/main/default/objects/object_actions.object.js +4 -2
  19. package/main/default/objects/object_actions.object.yml +26 -1
  20. package/main/default/objects/object_fields.object.js +33 -19
  21. package/main/default/objects/object_fields.object.yml +129 -83
  22. package/main/default/objects/object_layouts.action.js +4 -4
  23. package/main/default/objects/object_layouts.object.yml +16 -2
  24. package/main/default/objects/object_listviews.object.yml +67 -16
  25. package/main/default/objects/object_triggers.object.yml +13 -4
  26. package/main/default/objects/object_validation_rules.object.yml +10 -0
  27. package/main/default/objects/objects/buttons/custom.button.js +48 -0
  28. package/main/default/objects/objects/buttons/custom.button.yml +6 -0
  29. package/main/default/objects/objects.action.js +26 -3
  30. package/main/default/objects/objects.core.js +17 -1
  31. package/main/default/objects/objects.object.js +3 -2
  32. package/main/default/objects/objects.object.yml +28 -2
  33. package/main/default/objects/objects.tree.js +3 -2
  34. package/main/default/pages/design_field_layout.page.amis.json +418 -0
  35. package/main/default/pages/design_field_layout.page.yml +7 -0
  36. package/main/default/pages/object_detail.page.amis.json +6 -6
  37. package/main/default/pages/object_fields_form.page.amis.json +35 -0
  38. package/main/default/pages/{object_fields.page.yml → object_fields_form.page.yml} +5 -5
  39. package/main/default/pages/object_form.page.amis.json +31 -0
  40. package/main/default/pages/object_form.page.yml +12 -0
  41. package/main/default/routes/amis_button_design.router.js +11 -2
  42. package/main/default/routes/amis_listview_design.router.js +11 -2
  43. package/main/default/services/suggestions.service.js +4 -5
  44. package/main/default/triggers/object_actions.trigger.js +6 -2
  45. package/main/default/triggers/object_fields.trigger.js +67 -10
  46. package/main/default/triggers/object_listviews.trigger.js +11 -4
  47. package/main/default/triggers/objects.trigger.js +4 -26
  48. package/package.json +2 -2
  49. package/package.service.js +132 -3
  50. package/src/triggers/index.js +11 -0
  51. package/src/triggers/object_fields_trigger_create_index.js +58 -0
  52. package/main/default/objects/object_layouts/buttons/standard_edit.button.yml +0 -44
  53. package/main/default/pages/object_fields.page.amis.json +0 -42
  54. package/main/default/services/object_fields.service.js +0 -242
@@ -1,242 +0,0 @@
1
- /*
2
- * @Description: 提供action_field_updates(字段更新对象)需要的数据接口
3
- */
4
-
5
- const register = require("@steedos/metadata-registrar");
6
- const steedosI18n = require("@steedos/i18n");
7
- const _ = require("lodash");
8
- const clone = require("clone");
9
-
10
-
11
- module.exports = {
12
- name: "object_fields",
13
- mixins: [],
14
- /**
15
- * Settings
16
- */
17
- settings: {
18
-
19
- },
20
-
21
- /**
22
- * Dependencies
23
- */
24
- dependencies: [],
25
-
26
- /**
27
- * Actions
28
- */
29
- actions: {
30
- getDefaultValueSchema: {
31
- // 需要传 objectName, targetObject(非必填), field_name 参数进来。
32
- rest: {
33
- method: "GET",
34
- path: "/defaultValue/schema"
35
- },
36
- async handler(ctx) {
37
- const data = await this.getDefaultValueSchema(ctx);
38
- return { status: 0, msg: "", data: data }
39
- }
40
- }
41
- },
42
-
43
- /**
44
- * Events
45
- */
46
- events: {
47
-
48
- },
49
-
50
- /**
51
- * Methods
52
- */
53
- methods: {
54
- /* defaultValue 字段使用*/
55
- getDefaultValueSchema: {
56
- async handler(ctx) {
57
- const userSession = ctx.meta.user;
58
- const lng = userSession.language || 'zh-CN';
59
- const type = ctx.params.type || 'text';
60
- const objectName = ctx.params.object;
61
- const fieldName = ctx.params.name;
62
- const reference_to = ctx.params.reference_to;
63
- const options = ctx.params.options;
64
- const multiple = ctx.params.multiple;
65
- const filtersFunction = ctx.params.filtersFunction;
66
- const reference_to_field = ctx.params.reference_to_field || '_id';
67
- const _id = ctx.params._id;
68
- const mode = ctx.params.mode;
69
- // const mode = global.mode;
70
-
71
- const partialType = ['text','textarea','html','code','markdown','boolean','toggle','date','datetime','time','number','currency','percent','password','url','email'];
72
- // const fieldType = partialType.indexOf(type) > -1 ? type : 'text';
73
-
74
- let targetField = null;
75
- let NAME_FIELD_KEY = null;
76
- if (mode === 'read') {
77
- const objectConfig = await register.getObjectConfig(objectName);
78
- NAME_FIELD_KEY = objectConfig.NAME_FIELD_KEY || 'name';
79
- targetField = objectConfig.fields[fieldName];
80
- }
81
- const value = (targetField && targetField.defaultValue) || '';
82
- const translatedLabel = lng === 'zh-CN' ? "默认值" : 'DefaultValue';
83
- let defaultValue_schema = {
84
- "type": "text",
85
- "name": "defaultValue",
86
- "label": translatedLabel,
87
- "labelClassName": "text-left"
88
- }
89
-
90
- if(partialType.indexOf(type) > -1){
91
- defaultValue_schema.type = type;
92
- }else if(type === 'select' && options){
93
- defaultValue_schema.type = type;
94
- defaultValue_schema.options = options;
95
- defaultValue_schema.multiple = multiple;
96
- }else if(['lookup','master_detail'].includes(type) && reference_to){
97
- defaultValue_schema.type = type;
98
- defaultValue_schema.reference_to = reference_to;
99
- defaultValue_schema.multiple = multiple;
100
- defaultValue_schema.filtersFunction = filtersFunction;
101
- defaultValue_schema.reference_to_field = reference_to_field;
102
- }
103
-
104
- let steedos_field = {
105
- type:'steedos-field',
106
- name:'defaultValue',
107
- clearValueOnHidden: true,
108
- fieldName: 'defaultValue',
109
- field: defaultValue_schema,
110
- value: value,
111
- readonly: mode === 'read' ? true : false
112
- };
113
- if(mode === 'read'){
114
- const baseFieldConfig = {
115
- "name": "defaultValue",
116
- "label": translatedLabel,
117
- "labelClassName": "text-left",
118
- "clearValueOnHidden": true,
119
- "fieldName": "defaultValue"
120
- }
121
- if(_.isString(value) && value.indexOf('{')>-1){
122
- // 只读时值是公式就显示公式
123
- steedos_field = {
124
- "type": "control",
125
- "label": translatedLabel,
126
- "body": {
127
- "name": "defaultValue",
128
- "label": translatedLabel,
129
- "labelClassName": "text-left",
130
- "type": "tpl",
131
- "tpl": value.indexOf('$') > -1 ? "\\"+value : value
132
- }
133
- }
134
- }else if(['number','currency','percent'].includes(type)){
135
- steedos_field = {
136
- ...baseFieldConfig,
137
- "type": "static-tpl",
138
- "tpl": `<div>${value}</div>`,
139
- "className": "m-1 md:border-b steedos-static-tpl-readonly",
140
- "quickEdit": false,
141
- }
142
- }else if(['date','datetime','time'].includes(type)){
143
- let fieldTypeConfig ={};
144
- if(type==='date'){
145
- fieldTypeConfig = {
146
- "type": "input-date",
147
- "inputFormat": "YYYY-MM-DD",
148
- "format": "YYYY-MM-DDT00:00:00.000[Z]",
149
- "className": "m-1 steedos-input-date-edit",
150
- }
151
- }else if(type==='datetime'){
152
- fieldTypeConfig = {
153
- "type": "input-datetime",
154
- "inputFormat": "YYYY-MM-DD HH:mm",
155
- "format": "YYYY-MM-DDTHH:mm:ss.SSSZ",
156
- "className": "m-1 steedos-input-datetime-edit",
157
- }
158
- }else if(type==='time'){
159
- fieldTypeConfig = {
160
- "type": "input-time",
161
- "inputFormat": "HH:mm",
162
- "format": "1970-01-01THH:mm:00.000[Z]",
163
- "className": "m-1 steedos-input-time-edit",
164
- }
165
- }
166
- steedos_field = {
167
- ...baseFieldConfig,
168
- ...fieldTypeConfig,
169
- value: value,
170
- static: true
171
- }
172
- }else if(['boolean'].includes(type)){
173
- steedos_field = {
174
- ...baseFieldConfig,
175
- value: value,
176
- "type": "static",
177
- "tpl": `${value}`,
178
- "className": "m-1 md:border-b steedos-static-readonly"
179
- }
180
- }else if(['lookup','master_detail'].includes(type)){
181
- // console.log('t==>', type, reference_to, NAME_FIELD_KEY, targetField)
182
- if(value && value.length && _.isString(reference_to)){
183
- const query = {
184
- fields: [NAME_FIELD_KEY],
185
- filters: [reference_to_field, '=', value]
186
- }
187
- const res = await this.broker.call(
188
- 'objectql.find',
189
- {
190
- objectName: reference_to,
191
- query
192
- }
193
- );
194
- // console.log('res==>', res, reference_to, NAME_FIELD_KEY, targetField);
195
- const tpl = _.map(res, NAME_FIELD_KEY).join('、')
196
- steedos_field = {
197
- "type": "control",
198
- "label": translatedLabel,
199
- "body": {
200
- "name": "defaultValue",
201
- "label": translatedLabel,
202
- "labelClassName": "text-left",
203
- "type": "tpl",
204
- "tpl": tpl
205
- },
206
- value: value
207
- }
208
- }
209
- }
210
- }
211
- let body = [
212
- steedos_field
213
- ]
214
- if(mode === 'edit'){
215
- body[0].field.amis = {
216
- // disabledOn: "!!this.defaultValue_formula",
217
- "className": {
218
- "defaultValue_field_hidden": "!this.defaultValue && (!this.defaultValue || '').toString() && !!this.defaultValue_formula"
219
- }
220
- }
221
- body.push({
222
- "name": "defaultValue_formula",
223
- "label": translatedLabel,
224
- "evalMode": false,
225
- "type": "input-formula",
226
- "placeholder": "公式",
227
- // "disabledOn": "!!this.defaultValue && !!this.defaultValue.toString()",
228
- "className": {
229
- "defaultValue_field_formula": true,
230
- "defaultValue_field_formula_visible": "!!this.defaultValue_formula",
231
- "defaultValue_field_formula_hidden": "(!!this.defaultValue && !!this.defaultValue.toString()) || (!this.defaultValue && !this.defaultValue_formula)"
232
- }
233
- })
234
- }
235
- // console.log('body==>', body);
236
- return {
237
- body
238
- }
239
- }
240
- }
241
- }
242
- };