@steedos/standard-object-database 2.6.8-beta.3 → 2.6.8-beta.5

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.
@@ -209,4 +209,43 @@ Steedos.ObjectFieldManager.getSummaryFiltersOperation = function(field_type) {
209
209
  operations.push(optionals.equal, optionals.unequal);
210
210
  }
211
211
  return operations;
212
- };
212
+ };
213
+
214
+ (function () {
215
+ try {
216
+ var styleCss = $(`<style>
217
+ .defaultValue_field div:first-child{
218
+ flex-grow: 1;
219
+ }
220
+ .defaultValue_field .defaultValue_field_formula{
221
+ // margin: 4px;
222
+ }
223
+ .defaultValue_field .defaultValue_field_formula .antd-Form-label{
224
+ visibility: visible;
225
+ }
226
+
227
+ .defaultValue_field .defaultValue_field_formula_visible{
228
+ flex-grow: 1;
229
+ }
230
+ .defaultValue_field .defaultValue_field_formula_visible .antd-Form-label .antd-TplField{
231
+ visibility: visible;
232
+ }
233
+ .defaultValue_field .defaultValue_field_hidden{
234
+ display: none;
235
+ }
236
+ .defaultValue_field .defaultValue_field_formula_hidden{
237
+ flex-grow: 0;
238
+ }
239
+ .defaultValue_field .defaultValue_field_formula_hidden .antd-Form-label{
240
+ display: none;
241
+ }
242
+ .defaultValue_field .defaultValue_field_formula_hidden .antd-FormulaPicker-input{
243
+ display: none;
244
+ }
245
+
246
+ </style>`);
247
+ $("head").append(styleCss);
248
+ } catch (error) {
249
+ console.log(error);
250
+ }
251
+ })();
@@ -315,6 +315,10 @@ fields:
315
315
  label: Readonly
316
316
  help:
317
317
  description:
318
+ static:
319
+ label: Static
320
+ help: Static mode, displayed as read-only, but the field value can be set by default, autofill, or custom scripts.
321
+ description:
318
322
  hidden:
319
323
  label: Hidden
320
324
  help:
@@ -299,6 +299,10 @@ fields:
299
299
  label: 只读
300
300
  help:
301
301
  description:
302
+ static:
303
+ label: 静态模式
304
+ help: 显示为只读,但是可以通过默认值,自动填充或自定义脚本设置该字段值
305
+ description:
302
306
  hidden:
303
307
  label: 隐藏
304
308
  help:
@@ -199,9 +199,49 @@ fields:
199
199
  amis:
200
200
  disabledOn: "${is_system == true}"
201
201
  defaultValue:
202
- type: text
202
+ type: object
203
+ blackbox: true
203
204
  label: Default Value
204
205
  sort_no: 160
206
+ visible_on: "{{['autonumber','formula','summary','image','file'].indexOf(formData.type) > -1 ? false: true}}"
207
+ amis:
208
+ type: service
209
+ className:
210
+ antd-Form-item: true
211
+ antd-Form-item--normal: true
212
+ m-0: true
213
+ "md:border-b": global.mode === "read"
214
+ defaultValue_field: true
215
+ flex: true
216
+ schemaApi:
217
+ url: "${context.rootUrl}/service/api/object_fields/defaultValue/schema"
218
+ method: post
219
+ data:
220
+ object: ${object}
221
+ name: ${name}
222
+ options: ${options}
223
+ type: ${type}
224
+ reference_to: ${reference_to}
225
+ multiple: ${multiple}
226
+ filtersFunction: ${filtersFunction}
227
+ reference_to_field: ${reference_to_field}
228
+ mode: ${global.mode}
229
+ scale: ${scale}
230
+ _id: ${_id}
231
+ trackExpression: "${object},${options},${type},${reference_to},${reference_to_field},${multiple},${filtersFunction},${_id},${scale}"
232
+ headers:
233
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
234
+ # sendOn: "!!this.type"
235
+ onEvent:
236
+ fetchSchemaInited:
237
+ weight: 0
238
+ actions:
239
+ - actionType: "setValue"
240
+ componentId: "service_detail_page"
241
+ args:
242
+ value:
243
+ defaultValue: "${event.data.body[0].value}"
244
+ expression: "global.mode ==='read' && event.data.body[0].value"
205
245
  group:
206
246
  type: text
207
247
  label: Group
@@ -448,7 +488,7 @@ fields:
448
488
  amis:
449
489
  showIndex: true
450
490
  disabledOn: "${is_system == true}"
451
- inlineEditMode: true
491
+ enableDialog: false
452
492
  columns:
453
493
  - label
454
494
  - value
@@ -481,9 +521,10 @@ fields:
481
521
  label: Auto Fill Mapping
482
522
  is_wide: true
483
523
  inlineHelpText: When the data is selected, the field values in the reference object are automatically filled into the current form field according to the following mapping.
484
- visible_on: "{{formData.type === 'lookup' || formData.type === 'master_detail'}}"
524
+ visible_on: "{{(formData.type === 'lookup' || formData.type === 'master_detail') && formData.reference_to && !!!formData.multiple}}"
485
525
  sort_no: 280
486
526
  amis:
527
+ enableDialog: false
487
528
  disabledOn: "${is_system == true}"
488
529
  auto_fill_mapping.$:
489
530
  label: Auto Fill Mapping
@@ -780,6 +821,11 @@ fields:
780
821
  type: boolean
781
822
  label: Readonly
782
823
  group: ui
824
+ static:
825
+ type: boolean
826
+ label: Static
827
+ group: Advanced
828
+ inlineHelpText: Static mode, displayed as read-only, but the field value can be set by default, autofill, or custom scripts.
783
829
  hidden:
784
830
  type: boolean
785
831
  label: Hidden
@@ -62,11 +62,11 @@ module.exports = {
62
62
  var data = newRecord || { _filters_type_controller: 'conditions' };
63
63
  //数据格式转换
64
64
  if (data) {
65
- data.columns = lodash.map(data.columns, 'field');
66
65
  data.sort = lodash.map(data.sort, (item) => {
67
66
  return `${item.field_name}:${item.order || 'asc'}`
68
67
  });
69
- data.mobile_columns = lodash.map(data.mobile_columns, 'field');
68
+
69
+ data.searchable_fields = lodash.map(data.searchable_fields, 'field');
70
70
 
71
71
  if (data.filters && lodash.isString(data.filters)) {
72
72
  try {
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutaon@hotoa.com
3
3
  * @Date: 2022-03-29 20:33:44
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-11-19 17:06:18
5
+ * @LastEditTime: 2024-02-23 13:37:49
6
6
  * @Description:
7
7
  */
8
8
  module.exports = {
@@ -23,7 +23,6 @@ module.exports = {
23
23
  query: `mutation{objects__upsert(id: "${obj.name}", doc: ${JSON.stringify(JSON.stringify(obj))}){_id,name}}`
24
24
  }),
25
25
  success: function (data) {
26
- console.log(`data====>`, data)
27
26
  SteedosUI.notification.success({
28
27
  message: '对象已自定义。'
29
28
  });
@@ -42,6 +41,9 @@ module.exports = {
42
41
  Steedos.authRequest(url, options);
43
42
  },
44
43
  customVisible: function (object_name, record_id, permission, data) {
44
+ if(Meteor.settings.public.enable_saas){
45
+ return false;
46
+ }
45
47
  var record = data && data.record;
46
48
  return record && record.is_system && !record.created;
47
49
  }
@@ -177,6 +177,9 @@ module.exports = {
177
177
  if(!record){
178
178
  record = Creator.odata.get("objects", record_id, "is_deleted");
179
179
  }
180
+ if(record.is_system){
181
+ return false;
182
+ }
180
183
  if(record && !record.is_deleted){
181
184
  return Creator.baseObject.actions.standard_delete.visible.apply(this, arguments);
182
185
  }
@@ -10,7 +10,23 @@
10
10
  "enableTabs": true,
11
11
  "mode": "edit",
12
12
  "layout": "horizontal",
13
- "apiRequestAdaptor": "api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
13
+ "onEvent": {
14
+ "change": {
15
+ "actions": [
16
+ {
17
+ "actionType": "setValue",
18
+ "args": {
19
+ "value": {
20
+ "defaultValue": ""
21
+ }
22
+ },
23
+ "expression": "${!!event.data.defaultValue_formula}"
24
+ }
25
+ ]
26
+ }
27
+ },
28
+ "initApiAdaptor": "const defaultValue_field_value = payload.data.defaultValue; if(defaultValue_field_value && _.isString(defaultValue_field_value) && defaultValue_field_value.indexOf('{')>-1 ){ payload.data.defaultValue_formula = defaultValue_field_value; delete payload.data.defaultValue; } return payload;",
29
+ "apiRequestAdaptor": "if(formData.defaultValue_formula){ formData.defaultValue = formData.defaultValue_formula } __saveData = JSON.stringify(JSON.stringify(formData)); api.data = {query: query.replace('{__saveData}', __saveData)}; api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
14
30
  "submitSuccActions": [
15
31
  {
16
32
  "actionType": "custom",
@@ -0,0 +1,248 @@
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
+ // 默认值字段代码:services/standard-object-database/main/default/services/object_fields.service.js
11
+
12
+ module.exports = {
13
+ name: "object_fields",
14
+ mixins: [],
15
+ /**
16
+ * Settings
17
+ */
18
+ settings: {
19
+
20
+ },
21
+
22
+ /**
23
+ * Dependencies
24
+ */
25
+ dependencies: [],
26
+
27
+ /**
28
+ * Actions
29
+ */
30
+ actions: {
31
+ getDefaultValueSchema: {
32
+ // 需要传 objectName, targetObject(非必填), field_name 参数进来。
33
+ rest: {
34
+ method: "POST",
35
+ path: "/defaultValue/schema"
36
+ },
37
+ async handler(ctx) {
38
+ const data = await this.getDefaultValueSchema(ctx);
39
+ return { status: 0, msg: "", data: data }
40
+ }
41
+ }
42
+ },
43
+
44
+ /**
45
+ * Events
46
+ */
47
+ events: {
48
+
49
+ },
50
+
51
+ /**
52
+ * Methods
53
+ */
54
+ methods: {
55
+ /* defaultValue 字段使用*/
56
+ getDefaultValueSchema: {
57
+ async handler(ctx) {
58
+ // console.log('ctx==>', ctx);
59
+ const userSession = ctx.meta.user;
60
+ const lng = userSession.language || 'zh-CN';
61
+ const type = ctx.params.type || 'text';
62
+ const objectName = ctx.params.object;
63
+ const fieldName = ctx.params.name;
64
+ const reference_to = ctx.params.reference_to;
65
+ const options = ctx.params.options;
66
+ const multiple = ctx.params.multiple;
67
+ const filtersFunction = ctx.params.filtersFunction;
68
+ const reference_to_field = ctx.params.reference_to_field || '_id';
69
+ const _id = ctx.params._id;
70
+ const mode = ctx.params.mode;
71
+ const scale = ctx.params.scale;
72
+ // const mode = global.mode;
73
+
74
+ const partialType = ['text','textarea','html','code','markdown','boolean','toggle','date','datetime','time','password','url','email','color','location'];
75
+ // const fieldType = partialType.indexOf(type) > -1 ? type : 'text';
76
+
77
+ let targetField = null;
78
+ let NAME_FIELD_KEY = null;
79
+ if (mode === 'read') {
80
+ const objectConfig = await register.getObjectConfig(objectName);
81
+ NAME_FIELD_KEY = objectConfig.NAME_FIELD_KEY || 'name';
82
+ targetField = objectConfig.fields[fieldName];
83
+ }
84
+ // console.log('targetField==>', targetField);
85
+ const value = (targetField && targetField.defaultValue) || '';
86
+ const translatedLabel = lng === 'zh-CN' ? "默认值" : 'DefaultValue';
87
+ let defaultValue_schema = {
88
+ "type": "text",
89
+ "name": "defaultValue",
90
+ "label": translatedLabel,
91
+ "labelClassName": "text-left"
92
+ }
93
+
94
+ if(partialType.indexOf(type) > -1){
95
+ defaultValue_schema.type = type;
96
+ }else if(type === 'select' && options){
97
+ defaultValue_schema.type = type;
98
+ defaultValue_schema.options = options;
99
+ defaultValue_schema.multiple = multiple;
100
+ }else if(['lookup','master_detail'].includes(type) && reference_to){
101
+ defaultValue_schema.type = type;
102
+ defaultValue_schema.reference_to = reference_to;
103
+ defaultValue_schema.multiple = multiple;
104
+ defaultValue_schema.filtersFunction = filtersFunction;
105
+ defaultValue_schema.reference_to_field = reference_to_field;
106
+ } else if(['number','currency','percent'].includes(type)){
107
+ defaultValue_schema.type = type;
108
+ defaultValue_schema.scale = scale;
109
+ }
110
+ let body = [];
111
+ let steedos_field = {
112
+ type:'steedos-field',
113
+ name:'defaultValue',
114
+ clearValueOnHidden: true,
115
+ fieldName: 'defaultValue',
116
+ field: defaultValue_schema,
117
+ value: value,
118
+ readonly: mode === 'read' ? true : false
119
+ };
120
+ if(mode === 'read'){
121
+ const baseFieldConfig = {
122
+ "name": "defaultValue",
123
+ "label": translatedLabel,
124
+ "labelClassName": "text-left",
125
+ "clearValueOnHidden": true,
126
+ "fieldName": "defaultValue"
127
+ }
128
+ if(_.isString(value) && value.indexOf('{')>-1){
129
+ // 只读时值是公式就显示公式
130
+ steedos_field = {
131
+ "type": "control",
132
+ "label": translatedLabel,
133
+ "body": {
134
+ "name": "defaultValue",
135
+ "label": translatedLabel,
136
+ "labelClassName": "text-left",
137
+ "type": "tpl",
138
+ "tpl": value.indexOf('$') > -1 ? "\\"+value : value
139
+ }
140
+ }
141
+ }else if(['number','currency','percent'].includes(type)){
142
+ steedos_field = {
143
+ ...baseFieldConfig,
144
+ "type": "static-tpl",
145
+ "tpl": `<div>${value}</div>`,
146
+ "className": "m-1 md:border-b steedos-static-tpl-readonly",
147
+ "quickEdit": false,
148
+ }
149
+ }else if(['date','datetime','time'].includes(type)){
150
+ let fieldTypeConfig ={};
151
+ if(type==='date'){
152
+ fieldTypeConfig = {
153
+ "type": "input-date",
154
+ "inputFormat": "YYYY-MM-DD",
155
+ "format": "YYYY-MM-DDT00:00:00.000[Z]",
156
+ "className": "m-1 steedos-input-date-edit",
157
+ }
158
+ }else if(type==='datetime'){
159
+ fieldTypeConfig = {
160
+ "type": "input-datetime",
161
+ "inputFormat": "YYYY-MM-DD HH:mm",
162
+ "format": "YYYY-MM-DDTHH:mm:ss.SSSZ",
163
+ "className": "m-1 steedos-input-datetime-edit",
164
+ }
165
+ }else if(type==='time'){
166
+ fieldTypeConfig = {
167
+ "type": "input-time",
168
+ "inputFormat": "HH:mm",
169
+ "format": "1970-01-01THH:mm:00.000[Z]",
170
+ "className": "m-1 steedos-input-time-edit",
171
+ }
172
+ }
173
+ steedos_field = {
174
+ ...baseFieldConfig,
175
+ ...fieldTypeConfig,
176
+ value: value,
177
+ static: true
178
+ }
179
+ }else if(['boolean'].includes(type)){
180
+ steedos_field = {
181
+ ...baseFieldConfig,
182
+ value: value,
183
+ "type": "static",
184
+ "tpl": `${value}`,
185
+ "className": "m-1 md:border-b steedos-static-readonly"
186
+ }
187
+ }else if(['lookup','master_detail'].includes(type)){
188
+ // console.log('t==>', type, reference_to, NAME_FIELD_KEY, targetField)
189
+ if(value && value.length && _.isString(reference_to)){
190
+ const query = {
191
+ fields: [NAME_FIELD_KEY],
192
+ filters: [reference_to_field, '=', value]
193
+ }
194
+ const res = await this.broker.call(
195
+ 'objectql.find',
196
+ {
197
+ objectName: reference_to,
198
+ query
199
+ }
200
+ );
201
+ // console.log('res==>', res, reference_to, NAME_FIELD_KEY, targetField);
202
+ const tpl = _.map(res, NAME_FIELD_KEY).join('、')
203
+ steedos_field = {
204
+ "type": "control",
205
+ "label": translatedLabel,
206
+ "body": {
207
+ "name": "defaultValue",
208
+ "label": translatedLabel,
209
+ "labelClassName": "text-left",
210
+ "type": "tpl",
211
+ "tpl": tpl
212
+ },
213
+ value: value
214
+ }
215
+ }
216
+ }
217
+ body = [steedos_field];
218
+ }else{
219
+ body = [steedos_field];
220
+ body[0].field.amis = {
221
+ // disabledOn: "!!this.defaultValue_formula",
222
+ "clearable": true,
223
+ "className": {
224
+ "defaultValue_field_hidden": "!this.defaultValue && (!this.defaultValue || '').toString() && !!this.defaultValue_formula"
225
+ }
226
+ }
227
+ body.push({
228
+ "name": "defaultValue_formula",
229
+ "label": translatedLabel,
230
+ "evalMode": false,
231
+ "type": "input-formula",
232
+ "placeholder": "公式",
233
+ // "disabledOn": "!!this.defaultValue && !!this.defaultValue.toString()",
234
+ "className": {
235
+ "defaultValue_field_formula": true,
236
+ "defaultValue_field_formula_visible": "!!this.defaultValue_formula",
237
+ "defaultValue_field_formula_hidden": "(!!this.defaultValue && !!this.defaultValue.toString()) || (!this.defaultValue && !this.defaultValue_formula)"
238
+ }
239
+ })
240
+ }
241
+ // console.log('body==>', body);
242
+ return {
243
+ body
244
+ }
245
+ }
246
+ }
247
+ }
248
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.6.8-beta.3",
3
+ "version": "2.6.8-beta.5",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -12,10 +12,10 @@
12
12
  "description": "steedos package",
13
13
  "dependencies": {
14
14
  "@steedos-widgets/amis-lib": "^1.0.22",
15
- "@steedos/metadata-core": "2.6.8-beta.3",
16
- "@steedos/standard-objects": "2.6.8-beta.3"
15
+ "@steedos/metadata-core": "2.6.8-beta.5",
16
+ "@steedos/standard-objects": "2.6.8-beta.5"
17
17
  },
18
18
  "repository": {},
19
19
  "license": "MIT",
20
- "gitHead": "fc0c3488501254ec402e770673de858e8d76df5a"
20
+ "gitHead": "f46cd843d1195295a4f6a8f4e5cbe3c0930023a4"
21
21
  }