-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix 对象添加重置按钮, 重置对象时,将字段也重置. 重置:将db中的当前对象信息、字段信息全部清理掉. #6537
- Loading branch information
1 parent
5bda246
commit e243f8a
Showing
3 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
services/standard-object-database/main/default/objects/objects/buttons/reset.button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-03-29 20:33:44 | ||
* @LastEditors: [email protected] | ||
* @LastEditTime: 2024-03-21 10:45:57 | ||
* @Description: | ||
*/ | ||
module.exports = { | ||
resetVisible: function (object_name, record_id, permission, data) { | ||
if(Meteor.settings.public.enable_saas){ | ||
return false; | ||
} | ||
var record = data && data.record; | ||
return record && record.is_system && record.is_customize && record.created; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
services/standard-object-database/main/default/objects/objects/buttons/reset.button.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: reset | ||
amis_schema: |- | ||
{ | ||
"type": "service", | ||
"body": [ | ||
{ | ||
"type": "button", | ||
"label": "重置", | ||
"id": "u:delete_object", | ||
"onEvent": { | ||
"click": { | ||
"actions": [ | ||
{ | ||
"actionType": "dialog", | ||
"dialog": { | ||
"type": "dialog", | ||
"title": "重置对象: ${record.label}", | ||
"body": [ | ||
{ | ||
"type": "tpl", | ||
"tpl": "<div>\n<div style=\"text-align: left;\">重置一个自定义对象进行以下操作:</div>\n<ul>\n<li style=\"text-align: left;\">删除自定义的对象</li>\n<li style=\"text-align: left;\">删除自定义对象的字段</li>\n</ul>\n</div>", | ||
"inline": true, | ||
"id": "u:6d0819fc0bda" | ||
} | ||
], | ||
"id": "u:b5c0f98dc113", | ||
"closeOnEsc": false, | ||
"closeOnOutside": false, | ||
"showCloseButton": true, | ||
"data": { | ||
"&": "$$", | ||
"recordId": "${recordId}" | ||
}, | ||
"onEvent": { | ||
"confirm": { | ||
"weight": 0, | ||
"actions": [ | ||
{ | ||
"componentId": "", | ||
"args": { | ||
"api": { | ||
"url": "/service/api/~database-objects/reset", | ||
"method": "post", | ||
"data": { | ||
"objectName": "${record.name}" | ||
} | ||
}, | ||
"messages": {} | ||
}, | ||
"actionType": "ajax" | ||
}, | ||
{ | ||
"actionType": "custom", | ||
"script": "window.location.reload();" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"weight": 0 | ||
} | ||
} | ||
} | ||
], | ||
"regions": [ | ||
"body" | ||
], | ||
"data": { | ||
}, | ||
"bodyClassName": "p-0", | ||
"id": "u:46d1821365fc" | ||
} | ||
is_enable: true | ||
label: 重置 | ||
'on': record_only_more | ||
type: amis_button | ||
visible: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,15 @@ | |
* @Author: [email protected] | ||
* @Date: 2023-04-21 16:25:07 | ||
* @LastEditors: [email protected] | ||
* @LastEditTime: 2023-05-18 09:26:18 | ||
* @LastEditTime: 2024-03-21 11:58:43 | ||
* @Description: | ||
*/ | ||
var packageServiceName = '~database-objects' | ||
|
||
const { getObject } = require('@steedos/objectql'); | ||
|
||
const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms)); | ||
|
||
function isPatternTrigger(data){ | ||
const {listenTo} = data; | ||
if(listenTo === '*'){ | ||
|
@@ -36,7 +41,19 @@ module.exports = { | |
* Actions | ||
*/ | ||
actions: { | ||
|
||
resetObject: { | ||
rest: { | ||
method: "POST", | ||
path: "/reset" | ||
}, | ||
async handler(ctx) { | ||
const { objectName } = ctx.params; | ||
await getObject('objects').directDelete({filters: ['name','=', objectName]}); | ||
await getObject('object_fields').directDelete({filters: ['object','=', objectName]}); | ||
await sleep(2 * 1000) | ||
return true; | ||
} | ||
} | ||
}, | ||
|
||
/** | ||
|