mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:36:44 +00:00
feat: support disassociate action (#3761)
* feat: support Disassociate action * chore: add translation * chore: fix error * chore: fix settings * Update available-action.ts --------- Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
ecb7c5dca6
commit
ac2796dbfd
@ -929,6 +929,34 @@ export const useRemoveActionProps = (associationName) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const useDisassociateActionProps = () => {
|
||||
const filterByTk = useFilterByTk();
|
||||
const { resource, service, block, __parent } = useBlockRequestContext();
|
||||
const { setVisible } = useActionContext();
|
||||
return {
|
||||
async onClick() {
|
||||
await resource.remove({
|
||||
values: [filterByTk],
|
||||
});
|
||||
|
||||
const { count = 0, page = 0, pageSize = 0 } = service?.data?.meta || {};
|
||||
if (count % pageSize === 1 && page !== 1) {
|
||||
service.run({
|
||||
...service?.params?.[0],
|
||||
page: page - 1,
|
||||
});
|
||||
} else {
|
||||
service?.refresh?.();
|
||||
}
|
||||
|
||||
if (block && block !== 'TableField') {
|
||||
__parent?.service?.refresh?.();
|
||||
setVisible?.(false);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const useDetailPrintActionProps = () => {
|
||||
const { formBlockRef } = useFormBlockContext();
|
||||
|
||||
|
@ -53,6 +53,9 @@
|
||||
"Insert right": "Insert right",
|
||||
"Insert inner": "Insert inner",
|
||||
"Delete": "Delete",
|
||||
"Disassociate": "Disassociate",
|
||||
"Disassociate record": "Disassociate record",
|
||||
"Are you sure you want to disassociate it?": "Are you sure you want to disassociate it?",
|
||||
"UI editor": "UI editor",
|
||||
"Collection": "Collection",
|
||||
"Collection selector": "Collection selector",
|
||||
|
@ -52,6 +52,9 @@
|
||||
"Insert right": "Insertar a la derecha",
|
||||
"Insert inner": "Insertar al interior",
|
||||
"Delete": "Borrar",
|
||||
"Disassociate": "Desasociar",
|
||||
"Disassociate record": "Desasociar registro",
|
||||
"Are you sure you want to disassociate it?": "¿Seguro que quieres desasociarlo?",
|
||||
"UI editor": "IU editor",
|
||||
"Collection": "Colección",
|
||||
"Collections & Fields": "Colección & Campos",
|
||||
|
@ -52,6 +52,9 @@
|
||||
"Insert right": "Insérer à droite",
|
||||
"Insert inner": "Insérer à l'intérieur",
|
||||
"Delete": "Supprimer",
|
||||
"Disassociate": "Dissocier",
|
||||
"Disassociate record": "Dissocier l'enregistrement",
|
||||
"Are you sure you want to disassociate it?": "Êtes-vous sûr de vouloir le dissocier ?",
|
||||
"UI editor": "Éditeur d'interface utilisateur",
|
||||
"Collection": "Collection",
|
||||
"Collections & Fields": "Collections et champs",
|
||||
|
@ -52,6 +52,9 @@
|
||||
"Insert right": "右に挿入",
|
||||
"Insert inner": "中に挿入",
|
||||
"Delete": "削除",
|
||||
"Disassociate": "関連付けを解除",
|
||||
"Disassociate record": "レコードの関連付けを解除",
|
||||
"Are you sure you want to disassociate it?": "本当に関連付けを解除しますか?",
|
||||
"UI editor": "UI エディタ",
|
||||
"Collection": "コレクション",
|
||||
"Enable child collections": "启用子表",
|
||||
|
@ -60,6 +60,9 @@
|
||||
"Insert right": "오른쪽에 삽입",
|
||||
"Insert inner": "내부에 삽입",
|
||||
"Delete": "삭제",
|
||||
"Disassociate": "연결 해제",
|
||||
"Disassociate record": "레코드 연결 해제",
|
||||
"Are you sure you want to disassociate it?": "정말로 연결을 해제하시겠습니까?",
|
||||
"UI editor": "UI 편집기",
|
||||
"Collection": "컬렉션",
|
||||
"Collection selector": "컬렉션 선택기",
|
||||
|
@ -32,6 +32,9 @@
|
||||
"Insert right": "Inserir à direita",
|
||||
"Insert inner": "Inserir interno",
|
||||
"Delete": "Excluir",
|
||||
"Disassociate": "Desassociar",
|
||||
"Disassociate record": "Desassociar registro",
|
||||
"Are you sure you want to disassociate it?": "Tem certeza de que deseja desassociá-lo?",
|
||||
"UI editor": "Editor de UI",
|
||||
"Collection": "Coleção",
|
||||
"Collections & Fields": "Coleções e campos",
|
||||
|
@ -52,6 +52,9 @@
|
||||
"Insert right": "Вставить справа",
|
||||
"Insert inner": "Вставить внутрь",
|
||||
"Delete": "Удалить",
|
||||
"Disassociate": "Разъединить",
|
||||
"Disassociate record": "Разъединить запись",
|
||||
"Are you sure you want to disassociate it?": "Вы уверены, что хотите разъединить это?",
|
||||
"UI editor": "UI редактор",
|
||||
"Collection": "Коллекция",
|
||||
"Collections & Fields": "Коллекции & Поля",
|
||||
|
@ -52,6 +52,9 @@
|
||||
"Insert right": "Sağa yerleştir",
|
||||
"Insert inner": "İçine yerleştir",
|
||||
"Delete": "Sil",
|
||||
"Disassociate": "Bağlantıyı kes",
|
||||
"Disassociate record": "Kaydı bağlantıyı kes",
|
||||
"Are you sure you want to disassociate it?": "Bağlantıyı kesmek istediğinizden emin misiniz?",
|
||||
"UI editor": "UI editor",
|
||||
"Collection": "Koleksiyonlar",
|
||||
"Collections & Fields": "Koleksiyonlar & Alanlar",
|
||||
|
@ -52,6 +52,9 @@
|
||||
"Insert right": "Вставити справа",
|
||||
"Insert inner": "Вставити всередину",
|
||||
"Delete": "Видалити",
|
||||
"Disassociate": "Роз'єднати",
|
||||
"Disassociate record": "Роз'єднати запис",
|
||||
"Are you sure you want to disassociate it?": "Ви впевнені, що хочете роз'єднати це?",
|
||||
"UI editor": "Редактор UI",
|
||||
"Collection": "Колекція",
|
||||
"Collections & Fields": "Колекції та поля",
|
||||
|
@ -60,6 +60,9 @@
|
||||
"Insert right": "在右边插入",
|
||||
"Insert inner": "在里面插入",
|
||||
"Delete": "删除",
|
||||
"Disassociate": "解除关联",
|
||||
"Disassociate record": "解除关联记录",
|
||||
"Are you sure you want to disassociate it?": "你确定要解除关联吗?",
|
||||
"UI editor": "界面配置",
|
||||
"Collection": "数据表",
|
||||
"Collection selector": "数据表选择器",
|
||||
|
@ -60,6 +60,9 @@
|
||||
"Insert right": "從右邊插入",
|
||||
"Insert inner": "從裡面插入",
|
||||
"Delete": "刪除",
|
||||
"Disassociate": "解除關聯",
|
||||
"Disassociate record": "解除關聯記錄",
|
||||
"Are you sure you want to disassociate it?": "你確定要解除關聯嗎?",
|
||||
"UI editor": "介面編輯",
|
||||
"Collection": "資料表",
|
||||
"Collection selector": "資料表選擇器",
|
||||
|
@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
|
||||
import { ActionInitializer } from '../../../schema-initializer/items/ActionInitializer';
|
||||
|
||||
export const DisassociateActionInitializer = (props) => {
|
||||
const schema = {
|
||||
title: '{{ t("Disassociate") }}',
|
||||
'x-action': 'disassociate',
|
||||
'x-component': 'Action',
|
||||
'x-toolbar': 'ActionSchemaToolbar',
|
||||
'x-designer': 'Action.Designer',
|
||||
'x-component-props': {
|
||||
icon: 'DeleteOutlined',
|
||||
confirm: {
|
||||
title: "{{t('Disassociate record')}}",
|
||||
content: "{{t('Are you sure you want to disassociate it?')}}",
|
||||
},
|
||||
useProps: '{{ useDisassociateActionProps }}',
|
||||
},
|
||||
'x-action-settings': {
|
||||
triggerWorkflows: [],
|
||||
},
|
||||
};
|
||||
return <ActionInitializer {...props} schema={schema} />;
|
||||
};
|
@ -9,6 +9,7 @@ import { SchemaInitializer } from '../../application/schema-initializer/SchemaIn
|
||||
import { useCollection } from '../../collection-manager';
|
||||
import { createDesignable, useDesignable } from '../../schema-component';
|
||||
import { useGetAriaLabelOfDesigner } from '../../schema-settings/hooks/useGetAriaLabelOfDesigner';
|
||||
import { useBlockRequestContext } from '../../block-provider/BlockProvider';
|
||||
|
||||
export const Resizable = () => {
|
||||
const { t } = useTranslation();
|
||||
@ -151,6 +152,27 @@ export const tableActionColumnInitializers = new SchemaInitializer({
|
||||
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
title: '{{t("Disassociate")}}',
|
||||
name: 'disassociate',
|
||||
Component: 'DisassociateActionInitializer',
|
||||
schema: {
|
||||
'x-component': 'Action.Link',
|
||||
'x-action': 'disassociate',
|
||||
'x-acl-action': 'destroy',
|
||||
'x-decorator': 'ACLActionProvider',
|
||||
},
|
||||
useVisible() {
|
||||
const { props } = useBlockRequestContext();
|
||||
const collection = useCollection();
|
||||
return (
|
||||
!!props?.association &&
|
||||
(collection.template !== 'view' || collection?.writableView) &&
|
||||
collection.template !== 'sql'
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'item',
|
||||
title: '{{t("Add child")}}',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Plugin } from '../application/Plugin';
|
||||
import { DisassociateActionInitializer } from '../modules/actions/disassociate/DisassociateActionInitializer';
|
||||
import {
|
||||
blockInitializers,
|
||||
createFormActionInitializers,
|
||||
@ -56,6 +57,7 @@ export class SchemaInitializerPlugin extends Plugin {
|
||||
this.app.addComponents({
|
||||
...initializerComponents,
|
||||
...items,
|
||||
DisassociateActionInitializer,
|
||||
} as any);
|
||||
|
||||
this.app.schemaInitializerManager.add(blockInitializers);
|
||||
|
@ -33,6 +33,7 @@ const availableActions: {
|
||||
},
|
||||
destroy: {
|
||||
displayName: '{{t("Delete")}}',
|
||||
aliases: ['destroy', 'remove'],
|
||||
type: 'old-data',
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user