@steedos/standard-object-database 2.7.10-beta.4 → 2.7.10-beta.6

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,4 +1,5 @@
1
1
  name: design_field_layout
2
2
  is_enable: true
3
3
  label: 设计字段布局
4
- 'on': record_only
4
+ 'on': record_more
5
+ sort: 80
@@ -1,5 +1,4 @@
1
1
  name: design_fields_layout
2
2
  is_enable: true
3
- label: 设计对象(Beta)
4
- 'on': record_more
5
- sort: 80
3
+ label: 设计对象
4
+ 'on': record_only
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-06-02 17:45:15
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2024-09-11 11:49:37
5
+ * @LastEditTime: 2024-10-10 10:20:19
6
6
  * @Description:
7
7
  -->
8
8
  <html>
@@ -11,6 +11,15 @@
11
11
  <script src="/unpkg.com/axios@0.26.1/dist/axios.min.js"></script>
12
12
  <script src="https://unpkg.steedos.cn/flowbite@2.3.0/dist/flowbite.min.js"></script>
13
13
  <script src="https://cdn.tailwindcss.com"></script>
14
+ <link href="/toast/toastr.min.css" rel="stylesheet" />
15
+ <script src="/jquery.min.js" ></script>
16
+ <script src="/toast/toastr.min.js"></script>
17
+ <style>
18
+ #toast-container.toast-bottom-center>div, #toast-container.toast-top-center>div {
19
+ width: 450px;
20
+ opacity: 1;
21
+ }
22
+ </style>
14
23
  </head>
15
24
 
16
25
  <body>
@@ -185,7 +194,7 @@
185
194
 
186
195
  }
187
196
 
188
- return await axios.post(
197
+ const result = await axios.post(
189
198
  `${rootUrl}/service/api/object_fields/amis/design/schema?oid=${oid}`,
190
199
  {
191
200
  withCredentials: true,
@@ -199,6 +208,43 @@
199
208
  // handle error
200
209
  console.log(error);
201
210
  });
211
+ const actionNames = ['insert', 'update', 'delete'];
212
+
213
+ toastr.options = {
214
+ "closeButton": true,
215
+ "debug": false,
216
+ "newestOnTop": false,
217
+ "progressBar": false,
218
+ "positionClass": "toast-top-center",
219
+ "preventDuplicates": false,
220
+ "onclick": null,
221
+ "showDuration": "300",
222
+ "hideDuration": "1000",
223
+ "timeOut": "5000",
224
+ "extendedTimeOut": "1000",
225
+ "showEasing": "swing",
226
+ "hideEasing": "linear",
227
+ "showMethod": "fadeIn",
228
+ "hideMethod": "fadeOut"
229
+ }
230
+
231
+ actionNames.forEach(function(actionName){
232
+ const actionData = result.data.data[actionName];
233
+ let actionLabel = '';
234
+ if(actionName === 'insert'){
235
+ actionLabel = '新增';
236
+ }else if(actionName === 'update'){
237
+ actionLabel = '更新';
238
+ }else if(actionName === 'delete'){
239
+ actionLabel = '删除';
240
+ }
241
+ if(actionData.error && actionData.error.length > 0){
242
+ actionData.error.forEach((error)=>{
243
+ toastr.warning(error.message, `${actionLabel}字段「${error.fieldLabel}(${error.fieldName})」失败:`);
244
+ })
245
+ }
246
+ })
247
+ return result;
202
248
  };
203
249
  window.addEventListener('message', function (event) {
204
250
  const { data } = event;
@@ -208,6 +254,34 @@
208
254
  onDndAccept: function(event){
209
255
  return true;
210
256
  },
257
+ beforeDelete: function(event){
258
+ const toastConfig = {
259
+ "closeButton": true,
260
+ "debug": false,
261
+ "newestOnTop": false,
262
+ "progressBar": false,
263
+ "positionClass": "toast-top-center",
264
+ "preventDuplicates": false,
265
+ "onclick": null,
266
+ "showDuration": "300",
267
+ "hideDuration": "1000",
268
+ "timeOut": "5000",
269
+ "extendedTimeOut": "1000",
270
+ "showEasing": "swing",
271
+ "hideEasing": "linear",
272
+ "showMethod": "fadeIn",
273
+ "hideMethod": "fadeOut"
274
+ }
275
+ if(event.context.schema.type.startsWith('sfield') && event.context.schema.config.is_system){
276
+ parent.toastr.warning('禁止删除系统字段', '', toastConfig)
277
+ return event.preventDefault();
278
+ };
279
+
280
+ if(event.context.schema.type.startsWith('sfield') && event.context.schema.config.name === 'name'){
281
+ parent.toastr.warning('禁止删除名称字段', '', toastConfig)
282
+ return event.preventDefault();
283
+ }
284
+ },
211
285
  onInit: function(){
212
286
  // 创建一个新的 style 元素
213
287
  var style = document.createElement('style');
@@ -315,7 +315,15 @@ module.exports = {
315
315
  _.map(objectFields, (objectField)=>{
316
316
  if(!objectField.group){
317
317
  objectField.group = '通用'
318
- }
318
+ };
319
+ delete objectField.owner;
320
+ delete objectField.space;
321
+ delete objectField.created;
322
+ delete objectField.modified;
323
+ delete objectField.created_by;
324
+ delete objectField.modified_by;
325
+ delete objectField.company_id;
326
+ delete objectField.company_ids;
319
327
  })
320
328
 
321
329
  return {
@@ -326,12 +334,13 @@ module.exports = {
326
334
  data: {
327
335
  objectName
328
336
  },
329
- className: "steedos-amis-form steedos-field-layout-page m-4",
337
+ className: "steedos-amis-form steedos-field-layout-page",
330
338
  body: _.map(_.groupBy(_.orderBy(objectFields, function(o) { return o.sort_no || 100 }), 'group'), (items, groupName)=>{
331
339
  const group = getGroup(groupName)
332
340
  return {
333
341
  type: 'steedos-field-group',
334
342
  title: group.group_name,
343
+ collapsable: true,
335
344
  collapsed: group.collapsed,
336
345
  visible_on: group.visible_on,
337
346
  body: _.map(items, (field)=>{
@@ -381,6 +390,12 @@ module.exports = {
381
390
  const groupName = bodyItem.title;
382
391
  _.each(bodyItem.body, (field)=>{
383
392
  if(_.startsWith(field.type, 'sfield-')){
393
+
394
+ if(field.config && field.config.amis){
395
+ delete field.config.amis.name
396
+ delete field.config.amis.mode
397
+ }
398
+
384
399
  fields.push(Object.assign({}, field.config, {group: groupName, sort_no, _name: field.name}));
385
400
  sort_no += 50;
386
401
  }
@@ -391,6 +406,10 @@ module.exports = {
391
406
  visible_on: bodyItem.visible_on
392
407
  })
393
408
  }else if(_.startsWith(bodyItem.type, 'sfield-')){
409
+ if(bodyItem.config && bodyItem.config.amis){
410
+ delete bodyItem.config.amis.name
411
+ delete bodyItem.config.amis.mode
412
+ }
394
413
  fields.push(Object.assign({}, bodyItem.config, {sort_no, _name: bodyItem.name}));
395
414
  sort_no += 50;
396
415
  }
@@ -423,10 +442,11 @@ module.exports = {
423
442
 
424
443
  // 循环需要增加的字段
425
444
  for (const fieldName of insertFields) {
445
+ const newId = await object_fields._makeNewID();
446
+ const now = new Date();
447
+ const field = _.find(fields, { name: fieldName });
426
448
  try {
427
- const newId = await object_fields._makeNewID();
428
- const now = new Date();
429
- const field = _.find(fields, { name: fieldName });
449
+
430
450
  const doc = Object.assign({}, field, {
431
451
  _id: newId,
432
452
  owner: userSession.userId,
@@ -445,7 +465,11 @@ module.exports = {
445
465
  await object_fields.directInsert(doc);
446
466
  log.insert.success.push(fieldName);
447
467
  } catch (e) {
448
- log.insert.error.push(fieldName);
468
+ log.insert.error.push({
469
+ fieldName: fieldName,
470
+ fieldLabel: field.label,
471
+ message: steedosI18n.t(e.message, null, 'zh-CN')
472
+ });
449
473
  console.error(`新增字段 ${fieldName} 时出错:`, e);
450
474
  }
451
475
  }
@@ -453,8 +477,8 @@ module.exports = {
453
477
  // 循环需要修改的字段
454
478
  const now = new Date();
455
479
  for (const fieldName of updateFields) {
480
+ const field = _.find(fields, { name: fieldName });
456
481
  try {
457
- const field = _.find(fields, { name: fieldName });
458
482
  const id = _.find(dbFields, { name: fieldName })._id;
459
483
  const submitField = _.omit(field, ['name', '_name']);
460
484
 
@@ -470,18 +494,28 @@ module.exports = {
470
494
  }));
471
495
  log.update.success.push(fieldName);
472
496
  } catch (e) {
473
- log.update.error.push(fieldName);
497
+ log.update.error.push({
498
+ fieldName: fieldName,
499
+ fieldLabel: field.label,
500
+ message: steedosI18n.t(e.message, null, 'zh-CN')
501
+ });
474
502
  console.log(`dbFields`, fieldName, dbFields)
475
503
  console.error(`更新字段 ${fieldName} 时出错:`, e);
476
504
  }
477
505
  }
478
506
  // 循环需要删除的字段
479
507
  for (const fieldName of deleteFields) {
508
+ const field = _.find(dbFields, { name: fieldName })._id;
480
509
  try {
481
- const id = _.find(dbFields, { name: fieldName })._id;
510
+ const id = field._id;
482
511
  await object_fields.directDelete(id);
483
512
  log.delete.success.push(fieldName);
484
513
  } catch (e) {
514
+ log.delete.error.push({
515
+ fieldName: fieldName,
516
+ fieldLabel: field.label,
517
+ message: steedosI18n.t(e.message, null, 'zh-CN')
518
+ });
485
519
  log.delete.error.push(fieldName);
486
520
  console.error(`删除字段 ${fieldName} 时出错:`, e);
487
521
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.7.10-beta.4",
3
+ "version": "2.7.10-beta.6",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -12,14 +12,14 @@
12
12
  "description": "steedos package",
13
13
  "dependencies": {
14
14
  "@steedos-widgets/amis-lib": "^1.0.22",
15
- "@steedos/metadata-core": "2.7.10-beta.4",
16
- "@steedos/service-object-mixin": "2.7.10-beta.4",
17
- "@steedos/standard-objects": "2.7.10-beta.4",
15
+ "@steedos/metadata-core": "2.7.10-beta.6",
16
+ "@steedos/service-object-mixin": "2.7.10-beta.6",
17
+ "@steedos/standard-objects": "2.7.10-beta.6",
18
18
  "amis-formula": "~6.3.0",
19
19
  "clone": "^2.1.2",
20
20
  "moleculer-bullmq": "3.0.0"
21
21
  },
22
22
  "repository": {},
23
23
  "license": "MIT",
24
- "gitHead": "7f5a2208e589252449048916357fdb22d379bc82"
24
+ "gitHead": "1f01f0093a985e6e4f3d20ca8989e178c5f71133"
25
25
  }
@@ -2,7 +2,7 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 1985-10-26 16:15:00
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2024-09-24 15:00:31
5
+ * @LastEditTime: 2024-10-09 15:24:35
6
6
  * @Description:
7
7
  */
8
8
  "use strict";