From 36c8bc85ba71f8afb70240c508502679c7a90192 Mon Sep 17 00:00:00 2001 From: wkj <278599135@qq.com> Date: Tue, 21 Feb 2023 15:17:18 +0800 Subject: [PATCH] =?UTF-8?q?entityactionbtn=20=E5=B7=B2=E6=94=B9=E6=88=90?= =?UTF-8?q?=20acttionBtnPanel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/entityActionBtn/index.d.ts | 3 - lib/components/entityActionBtn/index.js | 14 -- lib/components/entityActionBtn/index.json | 4 - lib/components/entityActionBtn/index.less | 2 - lib/components/entityActionBtn/index.xml | 3 - lib/components/entityActionBtn/web.d.ts | 27 ---- lib/components/entityActionBtn/web.js | 70 ---------- .../entityActionBtn/web.module.less | 0 src/components/entityActionBtn/index.json | 5 - src/components/entityActionBtn/index.less | 2 - src/components/entityActionBtn/index.ts | 14 -- src/components/entityActionBtn/index.xml | 3 - .../entityActionBtn/web.module.less | 0 src/components/entityActionBtn/web.tsx | 132 ------------------ 14 files changed, 279 deletions(-) delete mode 100644 lib/components/entityActionBtn/index.d.ts delete mode 100644 lib/components/entityActionBtn/index.js delete mode 100644 lib/components/entityActionBtn/index.json delete mode 100644 lib/components/entityActionBtn/index.less delete mode 100644 lib/components/entityActionBtn/index.xml delete mode 100644 lib/components/entityActionBtn/web.d.ts delete mode 100644 lib/components/entityActionBtn/web.js delete mode 100644 lib/components/entityActionBtn/web.module.less delete mode 100644 src/components/entityActionBtn/index.json delete mode 100644 src/components/entityActionBtn/index.less delete mode 100644 src/components/entityActionBtn/index.ts delete mode 100644 src/components/entityActionBtn/index.xml delete mode 100644 src/components/entityActionBtn/web.module.less delete mode 100644 src/components/entityActionBtn/web.tsx diff --git a/lib/components/entityActionBtn/index.d.ts b/lib/components/entityActionBtn/index.d.ts deleted file mode 100644 index 42765aac1..000000000 --- a/lib/components/entityActionBtn/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -declare const _default: import("react").ComponentType; -export default _default; diff --git a/lib/components/entityActionBtn/index.js b/lib/components/entityActionBtn/index.js deleted file mode 100644 index b63554cfd..000000000 --- a/lib/components/entityActionBtn/index.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = OakComponent({ - entity: function () { - var entity = this.props.entity; - return entity; - }, - isList: false, - actions: function () { - var actions = this.props.actions; - return actions; - }, - methods: {}, -}); diff --git a/lib/components/entityActionBtn/index.json b/lib/components/entityActionBtn/index.json deleted file mode 100644 index 59a1db6be..000000000 --- a/lib/components/entityActionBtn/index.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "component": true, - "usingComponents": {} -} diff --git a/lib/components/entityActionBtn/index.less b/lib/components/entityActionBtn/index.less deleted file mode 100644 index 139597f9c..000000000 --- a/lib/components/entityActionBtn/index.less +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/lib/components/entityActionBtn/index.xml b/lib/components/entityActionBtn/index.xml deleted file mode 100644 index 195942142..000000000 --- a/lib/components/entityActionBtn/index.xml +++ /dev/null @@ -1,3 +0,0 @@ - - 待开发 - \ No newline at end of file diff --git a/lib/components/entityActionBtn/web.d.ts b/lib/components/entityActionBtn/web.d.ts deleted file mode 100644 index d0d3368b6..000000000 --- a/lib/components/entityActionBtn/web.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// -import { ButtonProps, SpaceProps } from 'antd'; -import { WebComponentProps } from 'oak-frontend-base'; -import { EntityDict } from '../../general-app-domain'; -declare type Item = { - label?: string; - action?: string; - auth: boolean; - type?: 'a' | 'button'; - index?: number; - alerted?: boolean; - alertTitle?: string; - alertContent?: string; - confirmText?: string; - cancelText?: string; - custom?: any; - callBack?: (index: number) => void; - onClick?: () => void; - buttonProps?: Omit; -}; -export default function Render(props: WebComponentProps): JSX.Element; -export {}; diff --git a/lib/components/entityActionBtn/web.js b/lib/components/entityActionBtn/web.js deleted file mode 100644 index 51746be7e..000000000 --- a/lib/components/entityActionBtn/web.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); -var jsx_runtime_1 = require("react/jsx-runtime"); -var antd_1 = require("antd"); -var confirm = antd_1.Modal.confirm; -var commonAction = ['create', 'update', 'remove', 'confirm', 'cancel', 'grant', 'revoke']; -function ItemComponent(props) { - var type = props.type, entity = props.entity, label = props.label, action = props.action, buttonProps = props.buttonProps, custom = props.custom, t = props.t, onClick = props.onClick; - var text; - if (action) { - if (commonAction.includes(action)) { - text = t("common:action.".concat(action)); - } - else { - text = t("".concat(entity, ":action.").concat(action)); - } - } - else { - text = label; - } - if (type === 'button') { - return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({}, buttonProps, { onClick: onClick }, { children: text }))); - } - if (custom) { - return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: onClick }, { children: custom }))); - } - return ((0, jsx_runtime_1.jsx)("a", tslib_1.__assign({ onClick: onClick }, { children: text }))); -} -function Render(props) { - var methods = props.methods, data = props.data; - var t = methods.t; - var items = data.items, oakLegalActions = data.oakLegalActions, spaceProps = data.spaceProps, entity = data.entity; - return ((0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({}, spaceProps, { children: items && items.map(function (ele, index) { - var _a = ele.auth, auth = _a === void 0 ? true : _a; - if (!auth || - (auth && - (oakLegalActions === null || oakLegalActions === void 0 ? void 0 : oakLegalActions.includes(ele.action)))) { - var onClick = function () { - if (ele.onClick) { - ele.onClick(); - return; - } - methods.execute(ele.action); - }; - if (ele.alerted) { - onClick = function () { - confirm({ - title: ele.alertTitle, - content: ele.alertContent, - okText: ele.confirmText || '确定', - cancelText: ele.cancelText || '取消', - onOk: function () { - if (ele.onClick) { - ele.onClick(); - return; - } - methods.execute(ele.action); - if (ele.callBack) { - ele.callBack(index); - } - }, - }); - }; - } - return ((0, jsx_runtime_1.jsx)(ItemComponent, tslib_1.__assign({}, ele, { entity: entity, t: t, onClick: onClick }))); - } - }) }))); -} -exports.default = Render; diff --git a/lib/components/entityActionBtn/web.module.less b/lib/components/entityActionBtn/web.module.less deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/components/entityActionBtn/index.json b/src/components/entityActionBtn/index.json deleted file mode 100644 index ada75a6b3..000000000 --- a/src/components/entityActionBtn/index.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "component": true, - "usingComponents": { - } -} \ No newline at end of file diff --git a/src/components/entityActionBtn/index.less b/src/components/entityActionBtn/index.less deleted file mode 100644 index 139597f9c..000000000 --- a/src/components/entityActionBtn/index.less +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/components/entityActionBtn/index.ts b/src/components/entityActionBtn/index.ts deleted file mode 100644 index ad5ea86cf..000000000 --- a/src/components/entityActionBtn/index.ts +++ /dev/null @@ -1,14 +0,0 @@ - -export default OakComponent({ - entity() { - const { entity } = this.props; - return entity; - }, - isList: false, - actions() { - const { actions } = this.props; - return actions - }, - methods: { - }, -}); diff --git a/src/components/entityActionBtn/index.xml b/src/components/entityActionBtn/index.xml deleted file mode 100644 index 195942142..000000000 --- a/src/components/entityActionBtn/index.xml +++ /dev/null @@ -1,3 +0,0 @@ - - 待开发 - \ No newline at end of file diff --git a/src/components/entityActionBtn/web.module.less b/src/components/entityActionBtn/web.module.less deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/components/entityActionBtn/web.tsx b/src/components/entityActionBtn/web.tsx deleted file mode 100644 index 225a430cb..000000000 --- a/src/components/entityActionBtn/web.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import React, {useEffect} from 'react'; -import { Space, Button, Modal, ButtonProps, SpaceProps } from 'antd'; -import { WebComponentProps } from 'oak-frontend-base'; -import { EntityDict } from '../../general-app-domain'; -import { DefaultOptionType } from 'antd/es/select'; -const { confirm } = Modal; -type Item = { - label?: string; - action?: string; - auth: boolean; - type?: 'a' | 'button'; - index?: number; - alerted?: boolean; - alertTitle?: string; - alertContent?: string; - confirmText?: string; - cancelText?: string; - custom?: any; - callBack?: (index: number) => void; - onClick?: () => void; - buttonProps?: Omit; -} - -const commonAction = ['create', 'update', 'remove', 'confirm', 'cancel', 'grant', 'revoke']; -function ItemComponent(props: Item & { entity: string; t: (value: string) => string; onClick: () => void }) { - const { type, entity, label, action, buttonProps, custom, t, onClick } = props; - let text: string | undefined; - if (action) { - if (commonAction.includes(action)) { - text = t(`common:action.${action}`); - } - else { - text = t(`${entity}:action.${action}`); - } - } - else { - text = label; - } - if (type === 'button') { - return ( - - ) - } - if (custom) { - return ( -
- {custom} -
- ) - } - return ( - - {text} - - ) -} - -export default function Render( - props: WebComponentProps< - EntityDict, - keyof EntityDict, - false, - { - entity: string; - actions: string[]; - items: Item[]; - spaceProps: SpaceProps, - }, - { - } - > -) { - const { methods, data } = props; - const { t } = methods; - const { items, oakLegalActions, spaceProps, entity } = data; - return ( - - {items && items.map((ele, index: number) => { - const { auth = true} = ele; - if ( - !auth || - (auth && - oakLegalActions?.includes( - ele.action as EntityDict[keyof EntityDict]['Action'] - )) - ) { - let onClick = () => { - if (ele.onClick) { - ele.onClick(); - return; - } - methods.execute( - ele.action as EntityDict[keyof EntityDict]['Action'] - ); - }; - if (ele.alerted) { - onClick = () => { - confirm({ - title: ele.alertTitle, - content: ele.alertContent, - okText: ele.confirmText || '确定', - cancelText: ele.cancelText || '取消', - onOk: () => { - if (ele.onClick) { - ele.onClick(); - return; - } - methods.execute( - ele.action as EntityDict[keyof EntityDict]['Action'] - ); - if (ele.callBack) { - ele.callBack(index); - } - }, - }); - }; - } - return ( - - ); - } - })} - - ); -}