Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-frontend-base into dev

This commit is contained in:
wangwenchen 2024-03-18 10:47:48 +08:00
commit c96753b6ad
211 changed files with 2171 additions and 1856 deletions

View File

@ -14,7 +14,11 @@ export declare class CacheStore<ED extends EntityDict & BaseEntityDict, Cxt exte
protected cascadeUpdate<T extends keyof ED, OP extends CachStoreOperation>(entity: T, operation: ED[T]['Operation'], context: SyncContext<ED>, option: OP): OperationResult<ED>;
operate<T extends keyof ED, OP extends CachStoreOperation>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): OperationResult<ED>;
sync<Cxt extends SyncContext<ED>>(opRecords: Array<OpRecord<ED>>, context: Cxt): void;
check<T extends keyof ED>(entity: T, operation: Omit<ED[T]['Operation'], 'id'>, context: Cxt, checkerTypes?: CheckerType[]): void;
check<T extends keyof ED>(entity: T, operation: {
action: ED[T]['Action'];
data?: ED[T]['Operation']['data'];
filter?: ED[T]['Operation']['filter'];
}, context: Cxt, checkerTypes?: CheckerType[]): void;
select<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Partial<ED[T]["Schema"]>[];
registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>): void;
count<T extends keyof ED, OP extends SelectOption>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: SyncContext<ED>, option: OP): number;

View File

@ -1,4 +1,3 @@
import { readOnlyActions } from 'oak-domain/lib/actions/action';
import { TreeStore } from 'oak-memory-tree-store';
import { assert } from 'oak-domain/lib/utils/assert';
import SyncTriggerExecutor from './SyncTriggerExecutor';
@ -54,15 +53,8 @@ export class CacheStore extends TreeStore {
}
check(entity, operation, context, checkerTypes) {
assert(context.getCurrentTxnId());
const { action } = operation;
if (readOnlyActions.includes(action)) {
// 只读查询的checker只能在根部入口执行
this.triggerExecutor.check(entity, operation, context, undefined, checkerTypes);
return;
}
this.operate(entity, operation, context, {
checkerTypes,
});
// check不再支持CascadeOperation了不然处理不了data为undefined通过filter来check create
this.triggerExecutor.check(entity, operation, context, undefined, checkerTypes);
}
select(entity, selection, context, option) {
const autoCommit = !context.getCurrentTxnId();
@ -85,7 +77,7 @@ export class CacheStore extends TreeStore {
return result;
}
registerChecker(checker) {
this.triggerExecutor.registerChecker(checker);
this.triggerExecutor.registerChecker(checker, this.getSchema());
}
/* registerTrigger<T extends keyof ED>(trigger: Trigger<ED, T, Cxt>) {
this.triggerExecutor.registerTrigger(trigger);

View File

@ -1,11 +1,15 @@
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { Checker, CheckerType } from 'oak-domain/lib/types';
import { Checker, CheckerType, StorageSchema } from 'oak-domain/lib/types';
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
export default class SyncTriggerExecutor<ED extends EntityDict & BaseEntityDict, Cxt extends SyncContext<ED>> {
static All_Checker_Types: CheckerType[];
private checkerMap;
private addToCheckerMap;
registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>): void;
check<T extends keyof ED>(entity: T, operation: Omit<ED[T]['Operation'], 'id'>, context: Cxt, when?: 'before' | 'after', checkerTypes?: CheckerType[]): void;
registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>, schema: StorageSchema<ED>): void;
check<T extends keyof ED>(entity: T, operation: {
action: ED[T]['Action'];
data?: ED[T]['Operation']['data'];
filter?: ED[T]['Operation']['filter'];
}, context: Cxt, when?: 'before' | 'after', checkerTypes?: CheckerType[]): void;
}

View File

@ -4,7 +4,7 @@ import { CHECKER_PRIORITY_MAP } from 'oak-domain/lib/types';
import { translateCheckerInSyncContext } from 'oak-domain/lib/store/checker';
import { checkFilterRepel } from 'oak-domain/lib/store/filter';
export default class SyncTriggerExecutor {
static All_Checker_Types = ['data', 'logical', 'logicalRelation', 'relation', 'row'];
static All_Checker_Types = ['data', 'logical', 'row'];
checkerMap = {};
addToCheckerMap(action, entity, priority, when, fn, type, filter) {
if (this.checkerMap[entity] && this.checkerMap[entity][action]) {
@ -48,9 +48,9 @@ export default class SyncTriggerExecutor {
});
}
}
registerChecker(checker) {
registerChecker(checker, schema) {
let { entity, action, priority, type, conditionalFilter } = checker;
const { fn, when } = translateCheckerInSyncContext(checker);
const { fn, when } = translateCheckerInSyncContext(checker, schema);
if (action instanceof Array) {
action.forEach(a => this.addToCheckerMap(a, entity, priority || CHECKER_PRIORITY_MAP[type], when, fn, type, conditionalFilter));
}

View File

@ -1,9 +1,7 @@
/// <reference types="react" />
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ED, OakExtraActionProps } from '../../types/AbstractComponent';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { ActionDef } from '../../types/Page';
declare const _default: (props: import("../../types/Page").ReactComponentProps<EntityDict & BaseEntityDict, string | number, false, {
declare const _default: (props: import("../../types/Page").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, false, {
entity: string | number;
extraActions: OakExtraActionProps[];
actions: ActionDef<ED, string | number>[];

View File

@ -25,7 +25,7 @@ export default OakComponent({
this.setState({
schema,
});
}
},
},
methods: {
makeItems(isMobile) {
@ -40,7 +40,7 @@ export default OakComponent({
column = 2;
}
if (extraActions?.length || actions?.length) {
const actions2 = actions && [...actions] || [];
const actions2 = (actions && [...actions]) || [];
if (extraActions) {
// 用户传的action默认排在前面
const extraActions2 = extraActions.filter((ele) => ele.show) || [];
@ -54,24 +54,35 @@ export default OakComponent({
onClick: () => onAction &&
onAction(typeof ele !== 'string' ? ele.action : ele, undefined),
}));
cascadeActions && Object.keys(cascadeActions).map((key, index) => {
const cascadeActionArr = cascadeActions[key];
if (cascadeActionArr && cascadeActionArr.length) {
cascadeActionArr.forEach((ele) => {
items.push({
action: typeof ele !== 'string' ? ele.action : ele,
path: key,
label: this.getLabel2(schema, key, ele, entity),
onClick: () => onAction && onAction(undefined, { path: key, action: typeof ele !== 'string' ? ele.action : ele }),
cascadeActions &&
Object.keys(cascadeActions).map((key, index) => {
const cascadeActionArr = cascadeActions[key];
if (cascadeActionArr &&
cascadeActionArr.length) {
cascadeActionArr.forEach((ele) => {
items.push({
action: typeof ele !== 'string'
? ele.action
: ele,
path: key,
label: this.getLabel2(schema, key, ele, entity),
onClick: () => onAction &&
onAction(undefined, {
path: key,
action: typeof ele !==
'string'
? ele.action
: ele,
}),
});
});
});
}
});
}
});
// 根据column显示几个裁剪出在更多里显示的item
const moreItems = items.splice(column);
this.setState({
items,
moreItems
moreItems,
});
}
}
@ -91,32 +102,38 @@ export default OakComponent({
cascadeAction: {
path,
action,
}
},
});
return;
}
this.triggerEvent('onAction', { action, cascadeAction: undefined });
},
getLabel(actionItem, entity) {
let action = actionItem;
if (typeof actionItem !== 'string') {
return actionItem.label;
}
else {
if (['update', 'create', 'detail', 'remove'].includes(actionItem)) {
return this.t(`common::action.${actionItem}`);
}
else {
return this.t(`${entity}:action.${actionItem}`);
if (actionItem.label) {
return actionItem.label;
}
action = actionItem.action;
}
if (this.features.locales.hasKey(`${entity}:action.${action}`)) {
return this.t(`${entity}:action.${action}`);
}
return this.t(`common::action.${action}`);
},
getLabel2(schema, path, actionItem, entity) {
let action = actionItem;
if (typeof actionItem !== 'string') {
return actionItem.label;
if (actionItem.label) {
return actionItem.label;
}
action = actionItem.action;
}
const { entity: entityI18n } = resolvePath(schema, entity, path);
const label = this.t(`${entityI18n}:action.${actionItem}`);
return label;
if (this.features.locales.hasKey(`${entityI18n}:action.${action}`)) {
return this.t(`${entityI18n}:action.${action}`);
}
return this.t(`common::action.${action}`);
}
},
});

View File

@ -1,8 +1,7 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
import { EntityDict } from 'oak-domain/lib/types/Entity';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
width: string;
i18n: any;
items: {

View File

@ -5,28 +5,27 @@ import Style from './mobile.module.less';
export default function Render(props) {
const { methods, data } = props;
const { t, makeItems } = methods;
const { width, items, moreItems, i18n, } = data;
const { width, items, moreItems, i18n } = data;
const isMobile = width.includes('xs');
const zhCNKeys = i18n?.store?.data?.zh_CN && Object.keys(i18n.store.data.zh_CN).length;
useEffect(() => {
makeItems(isMobile);
}, [zhCNKeys]);
return (<div className={Style.container}>
{items && items.map((ele, index) => (<>
<div className={Style.btn} onClick={ele.onClick}>
<Typography.Link>
{ele.label}
</Typography.Link>
</div>
{index !== items.length - 1 && (<Divider type="vertical"></Divider>)}
</>))}
{moreItems && moreItems.length > 0 && (<Divider type="vertical"/>)}
{moreItems && moreItems.length > 0 && (<Popover placement='topRight' content={<Space direction="vertical">
{items &&
items.map((ele, index) => (<>
<div className={Style.btn} onClick={ele.onClick}>
<Typography.Link>{ele.label}</Typography.Link>
</div>
{index !== items.length - 1 && (<Divider type="vertical"></Divider>)}
</>))}
{moreItems && moreItems.length > 0 && <Divider type="vertical"/>}
{moreItems && moreItems.length > 0 && (<Popover placement="topRight" content={<Space direction="vertical">
{moreItems.map((ele, index) => (<Button key={`btn${index}`} size="small" type="link" onClick={ele.onClick}>
{ele.label}
</Button>))}
</Space>} trigger="click">
<Button type="link" icon={(<MoreOutlined />)}/>
<Button type="link" icon={<MoreOutlined />}/>
</Popover>)}
</div>);
}

View File

@ -1,14 +1,8 @@
import React from 'react';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { ActionDef, WebComponentProps } from '../../types/Page';
import { ED, OakExtraActionProps } from '../../types/AbstractComponent';
import { CascadeActionProps } from '../../types/AbstractComponent';
type CascadeActionDef = {
[K in keyof EntityDict[keyof EntityDict]['Schema']]?: ActionDef<EntityDict & BaseEntityDict, keyof EntityDict>[];
};
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
import { ED, OakExtraActionProps, CascadeActionProps, CascadeActionDef } from '../../types/AbstractComponent';
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
i18n: any;
items: {
action: string;
@ -18,11 +12,10 @@ export default function Render(props: WebComponentProps<ED, keyof EntityDict, fa
}[];
schema: StorageSchema<ED>;
entity: string;
actions: ActionDef<ED, keyof EntityDict>[];
actions: ActionDef<ED, keyof ED>[];
cascadeActions: CascadeActionDef;
extraActions: OakExtraActionProps[];
onAction: (action?: string, cascadeAction?: CascadeActionProps) => void;
}, {
makeItems: () => void;
}>): React.JSX.Element;
export {};

View File

@ -25,7 +25,7 @@ export default function Render(props) {
makeItems();
}, [zhCNKeys, actions, cascadeActions, extraActions]);
return (<div className={Style.panelContainer}>
<Space align='center' size={12} style={{ width: '100%' }} wrap>
<Space align="center" size={12} style={{ width: '100%' }} wrap>
{items?.map((ele, index) => {
return (<ItemComponent key={ele.action} label={ele.label} type="a" onClick={ele.onClick}/>);
})}

View File

@ -1,9 +1,9 @@
import React from 'react';
import { SpaceProps } from 'antd';
import { WebComponentProps } from '../../types/Page';
import { EntityDict } from 'oak-domain/lib/base-app-domain';
import { ED } from '../../types/AbstractComponent';
import { Item } from './types';
export default function Render(props: WebComponentProps<EntityDict, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
entity: string;
actions: string[];
items: Item[];

View File

@ -1,8 +1,8 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { EntityDict } from 'oak-domain/lib/base-app-domain';
import { ED } from '../../types/AbstractComponent';
import { IMode, Item } from './type';
export default function Render(props: WebComponentProps<EntityDict, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
entity: string;
actions: string[];
items: Item[];

View File

@ -1,4 +1,4 @@
/// <reference types="wechat-miniprogram" />
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, true, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, false, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,4 +1,4 @@
export default OakComponent({
isList: true,
isList: false,
methods: {},
});

View File

@ -1,5 +1,4 @@
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { ED } from '../../../types/AbstractComponent';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {}, {}>): React.JSX.Element;
export default function Render(props: WebComponentProps<ED, keyof ED, false, {}, {}>): React.JSX.Element;

View File

@ -1,10 +1,7 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../types/Page';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ColorDict } from 'oak-domain/lib/types/Style';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { AttrRender, OakAbsAttrJudgeDef } from '../../types/AbstractComponent';
import { AttrRender, OakAbsAttrJudgeDef, ED } from '../../types/AbstractComponent';
export type ColSpanType = 1 | 2 | 3 | 4;
type ColumnMapType = {
xxl: ColSpanType;
@ -14,15 +11,14 @@ type ColumnMapType = {
sm: ColSpanType;
xs: ColSpanType;
};
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
entity: string;
title: string;
bordered: boolean;
layout: 'horizontal' | 'vertical';
data: any;
handleClick?: (id: string, action: string) => void;
colorDict: ColorDict<EntityDict & BaseEntityDict>;
dataSchema: StorageSchema<EntityDict>;
colorDict: ColorDict<ED>;
column: ColumnMapType;
renderData: AttrRender[];
judgeAttributes: OakAbsAttrJudgeDef[];

View File

@ -1,7 +1,6 @@
import React from 'react';
import { Space, Image } from 'antd-mobile';
import styles from './mobile.module.less';
// type Width = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
import { getLabel, getType, getValue } from '../../utils/usefulFn';
function RenderRow(props) {
const { type, label, value } = props;
@ -37,22 +36,21 @@ function RenderRow(props) {
export default function Render(props) {
const { methods, data: oakData } = props;
const { t } = methods;
const { title, renderData, entity, judgeAttributes, data, } = oakData;
const { title, renderData, entity, judgeAttributes, data } = oakData;
return (<div className={styles.panel}>
{title && (<div className={styles.title}>
{title}
</div>)}
{title && <div className={styles.title}>{title}</div>}
<div className={styles.panel_content}>
<Space direction="vertical" style={{ '--gap': '10px' }}>
{judgeAttributes && judgeAttributes.map((ele) => {
let renderValue = getValue(data, ele.path, ele.entity, ele.attr, ele.attrType, t);
let renderLabel = getLabel(ele.attribute, ele.entity, ele.attr, t);
const renderType = getType(ele.attribute, ele.attrType);
if ([null, '', undefined].includes(renderValue)) {
renderValue = t('not_filled_in');
}
return (<RenderRow label={renderLabel} value={renderValue} type={renderType}/>);
})}
{judgeAttributes &&
judgeAttributes.map((ele) => {
let renderValue = getValue(data, ele.path, ele.entity, ele.attr, ele.attrType, t);
let renderLabel = getLabel(ele.attribute, ele.entity, ele.attr, t);
const renderType = getType(ele.attribute, ele.attrType);
if ([null, '', undefined].includes(renderValue)) {
renderValue = t('not_filled_in');
}
return (<RenderRow label={renderLabel} value={renderValue} type={renderType}/>);
})}
</Space>
</div>
</div>);

View File

@ -1,20 +1,16 @@
import React from 'react';
import { Breakpoint } from 'antd';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../types/Page';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ColorDict } from 'oak-domain/lib/types/Style';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { AttrRender, OakAbsAttrJudgeDef } from '../../types/AbstractComponent';
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
import { AttrRender, OakAbsAttrJudgeDef, ED } from '../../types/AbstractComponent';
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
entity: string;
title: string;
bordered: boolean;
layout: 'horizontal' | 'vertical';
data: any;
handleClick?: (id: string, action: string) => void;
colorDict: ColorDict<EntityDict & BaseEntityDict>;
dataSchema: StorageSchema<EntityDict>;
colorDict: ColorDict<ED>;
column: number | Record<Breakpoint, number>;
renderData: AttrRender[];
judgeAttributes: OakAbsAttrJudgeDef[];

View File

@ -26,7 +26,7 @@ function RenderRow(props) {
export default function Render(props) {
const { methods, data: oakData } = props;
const { t } = methods;
const { entity, title, colorDict, bordered, column, renderData, layout = "horizontal", judgeAttributes, data, } = oakData;
const { entity, title, colorDict, bordered, column, renderData, layout = 'horizontal', judgeAttributes, data, } = oakData;
return (<Descriptions title={title} column={column} bordered={bordered} layout={layout}>
{judgeAttributes?.map((ele) => {
let renderValue = getValue(data, ele.path, ele.entity, ele.attr, ele.attrType, t);
@ -36,7 +36,9 @@ export default function Render(props) {
renderValue = t('not_filled_in');
}
const stateValue = get(data, ele.path);
const color = colorDict && colorDict[ele.entity]?.[ele.attr]?.[stateValue] || 'default';
const color = (colorDict &&
colorDict[ele.entity]?.[ele.attr]?.[stateValue]) ||
'default';
return (<Descriptions.Item label={renderLabel} span={ele.attribute.span || 1}>
<RenderRow type={renderType} value={renderValue} color={color}/>
</Descriptions.Item>);

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, keyof ED, true, {
data: Array<{
name: string;
@ -15,5 +13,4 @@ export default function render(props: WebComponentProps<ED, keyof ED, true, {
}>;
}, {
onEntityClicked: (entity: string) => void;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,7 +1,6 @@
import React from 'react';
import Styles from './web.module.less';
export default function render(props) {
const { t } = props.methods;
return (<div className={Styles.container}>
{t('useWideScreen')}
</div>);
return <div className={Styles.container}>{t('useWideScreen')}</div>;
}

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import React from 'react';
import { ED } from '../../../types/AbstractComponent';
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, keyof ED, true, {
data: Array<{
name: string;
@ -15,5 +13,4 @@ export default function render(props: WebComponentProps<ED, keyof ED, true, {
}>;
}, {
onEntityClicked: (entity: string) => void;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Switch, Input, Form } from 'antd';
import ReactEcharts from 'echarts-for-react';
import { useState } from 'react';
import { uniq } from 'oak-domain/lib/utils/lodash';
import Styles from './web.pc.module.less';
export default function render(props) {
@ -13,23 +13,25 @@ export default function render(props) {
let links2 = links;
if (keywords) {
if (!strict) {
links2 = links.filter(ele => {
if (keywords.find(k => ele.source.includes(k) || ele.target.includes(k))) {
links2 = links.filter((ele) => {
if (keywords.find((k) => ele.source.includes(k) || ele.target.includes(k))) {
return true;
}
return false;
});
data2 = uniq(links2.map(ele => ele.source).concat(links2.map(ele => ele.target))).map(ele => ({ name: ele }));
data2 = uniq(links2
.map((ele) => ele.source)
.concat(links2.map((ele) => ele.target))).map((ele) => ({ name: ele }));
}
else {
links2 = links.filter(ele => {
if (keywords.find(k => ele.source.includes(k) && ele.target.includes(k))) {
links2 = links.filter((ele) => {
if (keywords.find((k) => ele.source.includes(k) && ele.target.includes(k))) {
return true;
}
return false;
});
data2 = data.filter(ele => {
if (keywords.find(k => ele.name.includes(k))) {
data2 = data.filter((ele) => {
if (keywords.find((k) => ele.name.includes(k))) {
return true;
}
return false;
@ -61,17 +63,17 @@ export default function render(props) {
initLayout: 'circular',
gravity: 0,
repulsion: [10, 80],
edgeLength: [10, 50]
edgeLength: [10, 50],
},
data: data2,
links: links2,
lineStyle: {
opacity: 0.9,
width: 2,
curveness: 0
curveness: 0,
},
label: {
show: true
show: true,
},
autoCurveness: true,
roam: true,
@ -85,9 +87,9 @@ export default function render(props) {
},
focus: 'adjacency',
lineStyle: {
width: 10
}
}
width: 10,
},
},
},
],
}} notMerge={true} lazyUpdate={false} onEvents={{

View File

@ -1,8 +1,7 @@
/// <reference types="react" />
import { ED } from '../../types/AbstractComponent';
import { ColumnProps } from '../../types/Filter';
import { ReactComponentProps } from '../../types/Page';
declare const _default: (props: ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, true, {
declare const _default: (props: import("../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, true, {
entity: string | number;
column: ColumnProps<ED, string | number>;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;

View File

@ -1,8 +1,7 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import React from 'react';
import { ED } from '../../../types/AbstractComponent';
import { WebComponentProps } from '../../../types/Page';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
actionss: Array<{
icon: {
name: string;
@ -11,4 +10,4 @@ export default function Render(props: WebComponentProps<ED, keyof EntityDict, fa
action: string;
}>;
onActionClick: (action: string) => void;
}>): import("react").JSX.Element | null;
}>): React.JSX.Element | null;

View File

@ -1,3 +1,4 @@
import React from 'react';
import { Button, Space } from 'antd-mobile';
import Style from './mobile.module.less';
export default function Render(props) {

View File

@ -1,8 +1,7 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import React from 'react';
import { ED } from '../../../types/AbstractComponent';
import { WebComponentProps } from '../../../types/Page';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
actionss: Array<{
icon: {
name: string;
@ -11,4 +10,4 @@ export default function Render(props: WebComponentProps<ED, keyof EntityDict, fa
action: string;
}>;
onActionClick: (action: string) => void;
}>): import("react").JSX.Element | null;
}>): React.JSX.Element | null;

View File

@ -1,3 +1,4 @@
import React from 'react';
import { Button, Space } from 'antd';
export default function Render(props) {
const { actionss, onActionClick } = props.data;

View File

@ -1,8 +1,7 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../../types/Page';
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, keyof EntityDict, true, {
export default function render(props: WebComponentProps<ED, keyof ED, true, {
placement: 'top' | 'bottom' | 'left' | 'right';
style: Record<string, any>;
}, {

View File

@ -1,8 +1,8 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { EntityDict } from 'oak-domain/lib/base-app-domain';
import { ED } from '../../types/AbstractComponent';
import './web.less';
export default function Render(props: WebComponentProps<EntityDict, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
name: string;
color?: 'primary' | 'success' | 'error' | 'waring' | 'info' | string;
size?: string;

View File

@ -2,7 +2,7 @@ import React from 'react';
import './web.less';
export default function Render(props) {
const { data } = props;
const { name, color = '', size, className, style = {}, } = data;
const { name, color = '', size, className, style = {} } = data;
const isColor = ['primary', 'info', 'success', 'error', 'warning'].includes(color);
let class_name = 'oak-icon ' + 'oak-icon-' + name;
if (isColor || color === '') {

View File

@ -1,7 +1,6 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { ListButtonProps, ED } from '../../../types/AbstractComponent';
import { WebComponentProps } from '../../../types/Page';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
items: ListButtonProps[];
}, {}>): React.JSX.Element | null;

View File

@ -1,7 +1,6 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../../types/Page';
import { ListButtonProps, ED } from '../../../types/AbstractComponent';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
items: ListButtonProps[];
}, {}>): React.JSX.Element | null;

View File

@ -7,7 +7,8 @@ export default function Render(props) {
return null;
}
return (<Space>
{items?.filter((ele) => ele.show)
{items
?.filter((ele) => ele.show)
.map((ele, index) => (<Button key={`c_buttonGroup_${index}`} type={ele.type} onClick={ele.onClick} icon={ele.icon}>
{ele.label}
</Button>))}

View File

@ -3,7 +3,7 @@ import { TableProps } from 'antd';
import { RowWithActions, ReactComponentProps } from '../../types/Page';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
entity: T2;
extraActions: OakExtraActionProps[] | ((row: ED2[T2]["Schema"]) => OakExtraActionProps[]);
extraActions: OakExtraActionProps[] | ((row: RowWithActions<ED2, T2>) => OakExtraActionProps[]);
onAction: onActionFnDef;
disabledOp: boolean;
attributes: OakAbsAttrDef[];
@ -18,5 +18,6 @@ declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactCompo
}) => void;
} | undefined;
hideHeader: boolean;
size?: "small" | "large" | "middle" | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -13,6 +13,7 @@ export default OakComponent({
tablePagination: {},
rowSelection: {},
hideHeader: false,
size: 'large',
},
formData({ props }) {
const { converter } = this.state;
@ -40,7 +41,7 @@ export default OakComponent({
const { attributes, entity, data } = this.props;
const schema = this.features.cache.getSchema();
const colorDict = this.features.style.getColorDict();
assert(!!data, 'data不能为空');
// assert(!!data, 'data不能为空');
assert(!!entity, 'list属性entity不能为空');
// assert(attributes?.length, 'attributes不能为空');
const ttt = this.t.bind(this);

View File

@ -1,9 +1,7 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../../types/Page';
import { OakAbsDerivedAttrDef } from '../../../types/AbstractComponent';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
import { OakAbsDerivedAttrDef, ED } from '../../../types/AbstractComponent';
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
value: string | string[];
type: OakAbsDerivedAttrDef['type'];
color: string;

View File

@ -6,7 +6,7 @@ export default function Render(props) {
const { methods, data: oakData } = props;
const { value, type, color } = oakData;
if (value === null || value === '' || value === undefined) {
return (<>--</>);
return <>--</>;
}
else if (type === 'image') {
if (value instanceof Array) {
@ -14,7 +14,7 @@ export default function Render(props) {
{value.map((ele) => (<ImgBox src={ele} width={100} height={60}/>))}
</Space>);
}
return (<ImgBox src={value} width={100} height={60}/>);
return <ImgBox src={value} width={100} height={60}/>;
}
else if (type === 'link') {
if (value instanceof Array) {
@ -28,7 +28,5 @@ export default function Render(props) {
{value}
</Link>);
}
return (<Text ellipsis>
{value}
</Text>);
return <Text ellipsis>{value}</Text>;
}

View File

@ -1,9 +1,7 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../../types/Page';
import { OakAbsDerivedAttrDef } from '../../../types/AbstractComponent';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
import { OakAbsDerivedAttrDef, ED } from '../../../types/AbstractComponent';
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
value: string | string[];
type: OakAbsDerivedAttrDef['type'];
color: string;

View File

@ -6,7 +6,7 @@ export default function Render(props) {
const { methods, data: oakData } = props;
const { value, type, color, linkUrl } = oakData;
if (value === null || value === '' || value === undefined) {
return (<>--</>);
return <>--</>;
}
// 属性类型是enum要使用标签
else if (type === 'enum') {
@ -18,9 +18,7 @@ export default function Render(props) {
if (renderColor === 'danger') {
renderColor = 'error';
}
return (<Tag color={renderColor}>
{value}
</Tag>);
return <Tag color={renderColor}>{value}</Tag>;
}
else if (type === 'image') {
if (value instanceof Array) {
@ -28,7 +26,7 @@ export default function Render(props) {
{value.map((ele) => (<ImgBox src={ele} width={120} height={70}/>))}
</Space>);
}
return (<ImgBox src={value} width={120} height={70}/>);
return <ImgBox src={value} width={120} height={70}/>;
}
else if (type === 'link') {
let href = linkUrl;
@ -39,15 +37,11 @@ export default function Render(props) {
if (linkUrl) {
href = linkUrl;
}
return (<Link href={href}>
{ele}
</Link>);
return <Link href={href}>{ele}</Link>;
})}
</Space>);
}
return (<Link href={href}>
{value}
</Link>);
return <Link href={href}>{value}</Link>;
}
return (<Tooltip placement="topLeft" title={value}>
{value}

View File

@ -9,7 +9,7 @@ type ToolBarProps = {
title?: React.ReactNode;
buttonGroup?: buttonProps[];
extraContent?: React.ReactNode;
reload: () => void;
reload?: () => void;
};
declare function ToolBar(props: ToolBarProps): React.JSX.Element;
export default ToolBar;

View File

@ -14,13 +14,14 @@ function ToolBar(props) {
<Space align='center'>
{extraContent}
{buttonGroup && buttonGroup.length > 0 && (<ButtonGroup items={buttonGroup}/>)}
<Tooltip title={features.locales.t('reload')}>
<div className={Style.reloadIconBox} onClick={() => {
reload();
}}>
<ReloadOutlined />
</div>
</Tooltip>
{reload &&
<Tooltip title={features.locales.t('reload')}>
<div className={Style.reloadIconBox} onClick={() => {
reload();
}}>
<ReloadOutlined />
</div>
</Tooltip>}
<ColumnSetting />
</Space>
</div>

View File

@ -1,11 +1,8 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { RowWithActions, WebComponentProps } from '../../types/Page';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { onActionFnDef, OakExtraActionProps } from '../../types/AbstractComponent';
import { onActionFnDef, OakExtraActionProps, ED } from '../../types/AbstractComponent';
import { DataType } from 'oak-domain/lib/types/schema/DataTypes';
type ED = EntityDict & BaseEntityDict;
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
entity: string;
extraActions: OakExtraActionProps[];
mobileData: {
@ -26,4 +23,3 @@ export default function Render(props: WebComponentProps<EntityDict & BaseEntityD
}) => void;
};
}, {}>): React.JSX.Element;
export {};

View File

@ -7,58 +7,83 @@ import RenderCell from './renderCell';
export default function Render(props) {
const { methods, data } = props;
const { t } = methods;
const { oakLoading, entity, extraActions, mobileData, onAction, disabledOp = false, rowSelection } = data;
const { oakLoading, entity, extraActions, mobileData, onAction, disabledOp = false, rowSelection, } = data;
const useSelect = !!rowSelection?.type;
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
return (<div className={styles.container}>
{oakLoading ? (<div className={styles.loadingView}>
<Spin size='large'/>
<Spin size="large"/>
</div>) : (<>
{mobileData && mobileData.map((ele) => (<div style={{ display: 'flex', alignItems: 'center', flex: 1 }}>
{useSelect && (<Checkbox checked={selectedRowKeys.includes(ele.record.id)} onChange={(checked) => {
if (checked) {
selectedRowKeys.push(ele.record.id);
setSelectedRowKeys([...selectedRowKeys]);
{mobileData &&
mobileData.map((ele) => (<div style={{
display: 'flex',
alignItems: 'center',
flex: 1,
}}>
{useSelect && (<Checkbox checked={selectedRowKeys.includes(ele.record.id)} onChange={(checked) => {
if (checked) {
selectedRowKeys.push(ele.record.id);
setSelectedRowKeys([
...selectedRowKeys,
]);
}
else {
const index = selectedRowKeys.findIndex((ele2) => ele2 ===
ele.record.id);
selectedRowKeys.splice(index, 1);
setSelectedRowKeys([
...selectedRowKeys,
]);
}
}}/>)}
<div className={styles.card} onClick={() => {
const index = selectedRowKeys.findIndex((ele2) => ele2 === ele.record?.id);
let keys = selectedRowKeys;
if (rowSelection?.type === 'checkbox') {
if (index !== -1) {
keys.splice(index, 1);
}
else {
keys.push(ele.record?.id);
}
setSelectedRowKeys([
...selectedRowKeys,
]);
}
else {
const index = selectedRowKeys.findIndex((ele2) => ele2 === ele.record.id);
selectedRowKeys.splice(index, 1);
setSelectedRowKeys([...selectedRowKeys]);
keys = [ele.record?.id];
setSelectedRowKeys([
ele.record?.id,
]);
}
}}/>)}
<div className={styles.card} onClick={() => {
const index = selectedRowKeys.findIndex((ele2) => ele2 === ele.record?.id);
let keys = selectedRowKeys;
if (rowSelection?.type === 'checkbox') {
if (index !== -1) {
keys.splice(index, 1);
}
else {
keys.push(ele.record?.id);
}
setSelectedRowKeys([...selectedRowKeys]);
}
else {
keys = [ele.record?.id];
setSelectedRowKeys([ele.record?.id]);
}
rowSelection?.onChange && rowSelection?.onChange(keys, ele.record, { type: rowSelection.type === 'checkbox' ? 'multiple' : 'single' });
}}>
<div className={styles.cardContent}>
{ele.data.map((ele2) => (<div className={styles.textView}>
<div className={styles.label}>
{ele2.label}
</div>
<div className={styles.value}>
<RenderCell value={ele2.value} type={ele2.type}/>
</div>
</div>))}
rowSelection?.onChange &&
rowSelection?.onChange(keys, ele.record, {
type: rowSelection.type ===
'checkbox'
? 'multiple'
: 'single',
});
}}>
<div className={styles.cardContent}>
{ele.data.map((ele2) => (<div className={styles.textView}>
<div className={styles.label}>
{ele2.label}
</div>
<div className={styles.value}>
<RenderCell value={ele2.value} type={ele2.type}/>
</div>
</div>))}
</div>
{!disabledOp && (<div style={{
display: 'flex',
alignItems: 'center',
padding: 10,
}}>
<ActionBtn entity={entity} extraActions={extraActions} actions={ele.record?.['#oakLegalActions']} cascadeActions={ele.record?.['#oakLegalCascadeActions']} onAction={(action, cascadeAction) => onAction &&
onAction(ele.record, action, cascadeAction)}/>
</div>)}
</div>
{!disabledOp && (<div style={{ display: 'flex', alignItems: 'center', padding: 10 }}>
<ActionBtn entity={entity} extraActions={extraActions} actions={ele.record?.['#oakLegalActions']} cascadeActions={ele.record?.['#oakLegalCascadeActions']} onAction={(action, cascadeAction) => onAction && onAction(ele.record, action, cascadeAction)}/>
</div>)}
</div>
</div>))}
</div>))}
</>)}
</div>);
}

View File

@ -1,25 +1,24 @@
import React from 'react';
import { TableProps } from 'antd';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { WebComponentProps } from '../../types/Page';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ColorDict } from 'oak-domain/lib/types/Style';
import { StorageSchema } from 'oak-domain/lib/types/Storage';
import { OakAbsAttrDef, onActionFnDef, OakExtraActionProps, OakAbsAttrJudgeDef } from '../../types/AbstractComponent';
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
import { OakAbsAttrDef, onActionFnDef, OakExtraActionProps, OakAbsAttrJudgeDef, ED } from '../../types/AbstractComponent';
import { WebComponentProps } from '../../types/Page';
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
width: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
loading: boolean;
extraActions: OakExtraActionProps[] | ((row: any) => OakExtraActionProps[]);
entity: string;
schema: StorageSchema<EntityDict & BaseEntityDict>;
schema: StorageSchema<ED>;
attributes: OakAbsAttrDef[];
data: any[];
disabledOp: boolean;
colorDict: ColorDict<EntityDict & BaseEntityDict>;
colorDict: ColorDict<ED>;
tablePagination?: TableProps<any[]>['pagination'];
onAction?: onActionFnDef;
rowSelection?: TableProps<any[]>['rowSelection'];
i18n: any;
hideHeader?: boolean;
judgeAttributes: OakAbsAttrJudgeDef[];
size?: 'large' | 'middle' | 'small';
}, {}>): React.JSX.Element;

View File

@ -2,15 +2,15 @@ import React, { useState, useEffect, useContext } from 'react';
import { Table } from 'antd';
import { assert } from 'oak-domain/lib/utils/assert';
import { get } from 'oak-domain/lib/utils/lodash';
import { getWidth, getValue, getLabel, getType, getAlign, getLinkUrl, getFixed } from '../../utils/usefulFn';
import ActionBtn from '../actionBtn';
import { getWidth, getValue, getLabel, getType, getAlign, getLinkUrl } from '../../utils/usefulFn';
import TableCell from './renderCell';
import { TableContext } from '../listPro';
export default function Render(props) {
const { methods, data: oakData } = props;
const { t } = methods;
const { loading, entity, schema, extraActions, data, colorDict, disabledOp = false, tablePagination, onAction, rowSelection, attributes, i18n, hideHeader, judgeAttributes, } = oakData;
const [tableColumns, setTabelColumns] = useState([]);
const { loading, entity, schema, extraActions, data, colorDict, disabledOp = false, tablePagination, onAction, rowSelection, attributes, i18n, hideHeader, judgeAttributes, size = 'large', } = oakData;
const [tableColumns, setTableColumns] = useState([]);
const { tableAttributes, setSchema } = useContext(TableContext);
// 为了i18更新时能够重新渲染
const zhCNKeys = i18n?.store?.data?.zh_CN && Object.keys(i18n.store.data.zh_CN).length;
@ -22,55 +22,63 @@ export default function Render(props) {
setSchema && setSchema(schema);
let showAttributes = judgeAttributes;
if (tableAttributes) {
showAttributes = tableAttributes.filter((ele) => ele.show).map((ele) => ele.attribute);
showAttributes = tableAttributes
.filter((ele) => ele.show)
.map((ele) => ele.attribute);
}
const tableColumns = showAttributes && showAttributes.map((ele) => {
if (ele.entity === 'notExist') {
assert(ele.attribute.width, `非schema属性${ele.attr}需要自定义width`);
assert(ele.attribute.type, `非schema属性${ele.attr}需要自定义type`);
assert(ele.attribute.label, `非schema属性${ele.attr}需要自定义label`);
}
const title = getLabel(ele.attribute, ele.entity, ele.attr, t);
const width = getWidth(ele.attribute, ele.attrType);
const type = getType(ele.attribute, ele.attrType);
const align = getAlign(ele.attrType);
const column = {
key: ele.path,
title,
align,
render: (v, row) => {
if (typeof ele.attribute !== 'string' && ele.attribute.render) {
return ele.attribute.render(row);
}
const value = getValue(row, ele.path, ele.entity, ele.attr, ele.attrType, t);
const stateValue = get(row, ele.path);
let href = '';
if ([null, undefined, ''].includes(stateValue)) {
return <></>;
}
const color = colorDict && colorDict[ele.entity]?.[ele.attr]?.[stateValue];
if (type === 'enum' && !color) {
console.warn(color, `${ele.entity}实体${ele.attr}颜色定义缺失`);
}
if (type === 'link') {
href = getLinkUrl(ele.attribute, { oakId: row?.id });
}
return (<TableCell color={color} value={value} type={type} linkUrl={href}/>);
const tableColumns = showAttributes &&
showAttributes.map((ele) => {
if (ele.entity === 'notExist') {
assert(ele.attribute.width, `非schema属性${ele.attr}需要自定义width`);
assert(ele.attribute.type, `非schema属性${ele.attr}需要自定义type`);
assert(ele.attribute.label, `非schema属性${ele.attr}需要自定义label`);
}
};
if (width) {
Object.assign(column, { width });
}
else {
// 没有宽度的设置ellipsis
Object.assign(column, {
ellipsis: {
showTitle: false,
}
});
}
return column;
});
const title = getLabel(ele.attribute, ele.entity, ele.attr, t);
const width = getWidth(ele.attribute, ele.attrType);
const type = getType(ele.attribute, ele.attrType);
const align = getAlign(ele.attrType);
const column = {
key: ele.path,
title,
align,
fixed: getFixed(ele.attribute),
render: (v, row) => {
if (typeof ele.attribute !== 'string' &&
ele.attribute.render) {
return ele.attribute.render(row);
}
const value = getValue(row, ele.path, ele.entity, ele.attr, ele.attrType, t);
const stateValue = get(row, ele.path);
let href = '';
if ([null, undefined, ''].includes(stateValue)) {
return <></>;
}
const color = colorDict &&
colorDict[ele.entity]?.[ele.attr]?.[stateValue];
if (type === 'enum' && !color) {
console.warn(color, `${ele.entity}实体${ele.attr}颜色定义缺失`);
}
if (type === 'link') {
href = getLinkUrl(ele.attribute, {
oakId: row?.id,
});
}
return (<TableCell color={color} value={value} type={type} linkUrl={href}/>);
},
};
if (width) {
Object.assign(column, { width });
}
else {
// 没有宽度的设置ellipsis
Object.assign(column, {
ellipsis: {
showTitle: false,
},
});
}
return column;
});
if (!disabledOp && tableColumns) {
tableColumns.push({
fixed: 'right',
@ -88,11 +96,12 @@ export default function Render(props) {
else {
extraActions2 = extraActions;
}
return (<ActionBtn entity={entity} extraActions={extraActions2} actions={oakActions || []} cascadeActions={row?.['#oakLegalCascadeActions']} onAction={(action, cascadeAction) => onAction && onAction(row, action, cascadeAction)}/>);
}
return (<ActionBtn entity={entity} extraActions={extraActions2} actions={oakActions || []} cascadeActions={row?.['#oakLegalCascadeActions']} onAction={(action, cascadeAction) => onAction &&
onAction(row, action, cascadeAction)}/>);
},
});
}
setTabelColumns(tableColumns);
setTableColumns(tableColumns);
}
}, [data, zhCNKeys, schema, tableAttributes]);
return (<Table rowKey="id" rowSelection={rowSelection?.type && {
@ -102,7 +111,7 @@ export default function Render(props) {
rowSelection?.onChange &&
rowSelection?.onChange(selectedRowKeys, row, info);
},
}} loading={loading} dataSource={data} columns={tableColumns} pagination={tablePagination} scroll={showScroll
}} size={size} loading={loading} dataSource={data} columns={tableColumns} pagination={tablePagination} scroll={showScroll
? {
scrollToFirstRowOnChange: true,
x: 1200,

View File

@ -10,7 +10,7 @@ type Props<ED2 extends ED, T extends keyof ED2> = {
buttonGroup?: ListButtonProps[];
onReload?: () => void;
entity: T;
extraActions?: OakExtraActionProps[] | ((row: any) => OakExtraActionProps[]);
extraActions?: OakExtraActionProps[] | ((row: RowWithActions<ED2, T>) => OakExtraActionProps[]);
onAction?: onActionFnDef;
disabledOp?: boolean;
attributes: OakAbsAttrDef[];
@ -25,6 +25,7 @@ type Props<ED2 extends ED, T extends keyof ED2> = {
}) => void;
};
disableSerialNumber?: boolean;
size?: 'large' | 'middle' | 'small';
};
export type TableAttributeType = {
attribute: OakAbsAttrJudgeDef;

View File

@ -15,7 +15,7 @@ export const TableContext = createContext({
onReset: undefined,
});
const ProList = (props) => {
const { buttonGroup, entity, extraActions, onAction, disabledOp, attributes, data, loading, tablePagination, rowSelection, onReload, disableSerialNumber, title, hideDefaultButtons = false, extraContent, } = props;
const { buttonGroup, entity, extraActions, onAction, disabledOp, attributes, data, loading, tablePagination, rowSelection, onReload, disableSerialNumber, title, hideDefaultButtons = false, extraContent, size = 'large', } = props;
const features = useFeatures();
const [tableAttributes, setTableAttributes] = useState([]);
const [schema, setSchema] = useState(undefined);
@ -68,9 +68,7 @@ const ProList = (props) => {
},
}}>
<div className={Style.container}>
{!isMobile && !hideDefaultButtons && (<ToolBar title={title} extraContent={extraContent} buttonGroup={buttonGroup} reload={() => {
onReload && onReload();
}}/>)}
{!isMobile && !hideDefaultButtons && (<ToolBar title={title} extraContent={extraContent} buttonGroup={buttonGroup} reload={onReload}/>)}
{isMobile && <ButtonGroup items={buttonGroup}/>}
<List entity={entity} extraActions={extraActions} onAction={onAction} disabledOp={disabledOp} attributes={attributes} data={!disableSerialNumber
? data?.map((ele, index) => {
@ -84,7 +82,7 @@ const ProList = (props) => {
}
return ele;
})
: data} loading={loading} tablePagination={Object.assign({
: data} loading={loading} size={size} tablePagination={Object.assign({
showTotal,
}, tablePagination)} rowSelection={rowSelection}/>
</div>

View File

@ -1,8 +1,7 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ReactComponentProps } from '../../types/Page';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
title?: React.ReactNode;

View File

@ -1,7 +1,6 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ED } from '../../types/AbstractComponent';
import './index.less';
type PageHeaderProps = {
style?: React.CSSProperties;
@ -20,7 +19,6 @@ type PageHeaderProps = {
children?: React.ReactNode;
showHeader?: boolean;
};
type ED = EntityDict & BaseEntityDict;
export default function Render(props: WebComponentProps<ED, keyof ED, false, PageHeaderProps, {
goBack: (delta?: number) => void;
}>): React.JSX.Element;

View File

@ -1,8 +1,7 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ReactComponentProps } from '../../types/Page';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
showHeader?: boolean | undefined;
@ -16,5 +15,9 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
extra?: React.ReactNode;
children?: React.ReactNode;
content: React.ReactNode;
contentStyle?: import("react").CSSProperties | undefined;
contentClassName?: string | undefined;
bodyStyle?: import("react").CSSProperties | undefined;
bodyClassName?: string | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -9,12 +9,13 @@ export default OakComponent({
const menus = features.contextMenuFactory.menus;
const namespace = features.navigator.getNamespace();
const location = features.navigator.getLocation();
const currentPath = location.pathname; //当前路由path
const pathname = location.pathname; //当前路由path
// const pathname2 = pathname.endsWith('/') ? pathname.substring(0, pathname.length - 1) : pathname
const allowBack = !menus?.find((ele) => features.navigator
.getPathname(ele.url || '', namespace)
?.toLocaleLowerCase() === currentPath?.toLocaleLowerCase());
?.toLocaleLowerCase() === pathname?.toLocaleLowerCase());
return {
allowBack,
};
}
},
});

View File

@ -1,7 +1,6 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ED } from '../../types/AbstractComponent';
import './index.less';
type PageHeaderProps = {
style?: React.CSSProperties;
@ -17,9 +16,12 @@ type PageHeaderProps = {
extra?: React.ReactNode;
children?: React.ReactNode;
content?: React.ReactNode;
contentStyle?: React.CSSProperties;
contentClassName?: string;
bodyStyle?: React.CSSProperties;
bodyClassName?: string;
allowBack: boolean;
};
type ED = EntityDict & BaseEntityDict;
export default function Render(props: WebComponentProps<ED, keyof ED, false, PageHeaderProps, {
goBack: (delta?: number) => void;
}>): React.JSX.Element;

View File

@ -5,13 +5,7 @@ import classNames from 'classnames';
import './index.less';
export default function Render(props) {
const { data, methods } = props;
const { style, className, showHeader = true, showBack = false, onBack, backIcon, delta, title, subTitle, extra, tags, children, content,
// contentStyle,
// contentClassName,
// bodyStyle,
// bodyClassName,
allowBack = true, //state取
} = data;
const { style, className, showHeader = true, showBack = false, onBack, backIcon, delta, title, subTitle, extra, tags, children, content, contentStyle, contentClassName, bodyStyle, bodyClassName, allowBack = true, } = data;
const { t, goBack } = methods;
const prefixCls = 'oak-new';
const back = data.hasOwnProperty('showBack')
@ -42,19 +36,11 @@ export default function Render(props) {
</div>
</div>)}
{content ? (<div
// style={contentStyle}
className={classNames(`${prefixCls}-pageHeader-content`
// contentClassName
)}>
{content ? (<div style={contentStyle} className={classNames(`${prefixCls}-pageHeader-content`, contentClassName)}>
{content}
</div>) : null}
<div
// style={bodyStyle}
className={classNames(`${prefixCls}-pageHeader-body`
// bodyClassName
)}>
<div style={bodyStyle} className={classNames(`${prefixCls}-pageHeader-body`, bodyClassName)}>
{children}
</div>
</div>);

View File

@ -1,8 +1,7 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { ReactComponentProps } from '../../types/Page';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
entity: T2;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;

View File

@ -1,8 +1,7 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import type { PaginationProps as RcPaginationProps } from 'rc-pagination';
import { WebComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
export interface PaginationProps extends RcPaginationProps {
showQuickJumper?: boolean | {
goButton?: React.ReactNode;
@ -18,7 +17,6 @@ export interface PaginationProps extends RcPaginationProps {
showTotal?: (total: number, range: [number, number]) => React.ReactNode;
total1: number;
}
type ED = EntityDict & BaseEntityDict;
export default function Render(props: WebComponentProps<ED, keyof ED, true, PaginationProps, {
onChange?: (page: number, pageSize: number) => void;
onShowSizeChange?: (current: number, size: number) => void;
@ -26,4 +24,3 @@ export default function Render(props: WebComponentProps<ED, keyof ED, true, Pagi
setTotal: () => void;
setPage: (value: number) => void;
}>): "" | React.JSX.Element | undefined;
export {};

View File

@ -1,11 +1,8 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { OakAbsRefAttrPickerRender } from '../../types/AbstractComponent';
import { OakAbsRefAttrPickerRender, ED } from '../../types/AbstractComponent';
import { WebComponentProps } from '../../types/Page';
import { StorageSchema } from 'oak-domain/lib/types';
type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function render(props: WebComponentProps<ED, keyof ED, false, {
entityId: string;
entityIds: string[];
multiple: boolean;
@ -16,6 +13,5 @@ export default function render(props: WebComponentProps<ED, keyof EntityDict, fa
}[];
pickerRender: OakAbsRefAttrPickerRender<ED, keyof ED>;
onChange: (value: string[]) => void;
schema: StorageSchema<EntityDict & BaseEntityDict>;
schema: StorageSchema<ED>;
}>): React.JSX.Element;
export {};

View File

@ -1,11 +1,8 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { OakAbsRefAttrPickerRender } from '../../types/AbstractComponent';
import { OakAbsRefAttrPickerRender, ED } from '../../types/AbstractComponent';
import { WebComponentProps } from '../../types/Page';
import { StorageSchema } from 'oak-domain/lib/types';
type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function render(props: WebComponentProps<ED, keyof ED, false, {
entityIds: string[];
multiple: boolean;
renderValue: string;
@ -16,6 +13,5 @@ export default function render(props: WebComponentProps<ED, keyof EntityDict, fa
pickerRender: OakAbsRefAttrPickerRender<ED, keyof ED>;
onChange: (value: string[]) => void;
placeholder: string;
schema: StorageSchema<EntityDict & BaseEntityDict>;
schema: StorageSchema<ED>;
}>): React.JSX.Element;
export {};

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
import React from 'react';
export default function render(props: WebComponentProps<ED, 'actionAuth', true, {
cascadeEntityActions: Array<{
path: any;
@ -19,10 +17,9 @@ export default function render(props: WebComponentProps<ED, 'actionAuth', true,
}>;
}>;
actions: string[];
entity: keyof EntityDict;
entity: keyof ED;
}, {
onChange: (checked: boolean, relationId: string, path: string, actionAuth?: ED['actionAuth']['Schema'][]) => void;
onChange2: (checked: boolean, relationId: string, paths: string[], actionAuths: ED['actionAuth']['Schema'][], actionAuth?: ED['actionAuth']['Schema']) => void;
confirm: () => void;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,6 +1,6 @@
import { Table, Checkbox, Button, Row, Typography, Space } from 'antd';
const { Title, Text } = Typography;
import { Table, Checkbox, Button, Row, Space, } from 'antd';
import { difference, intersection } from 'oak-domain/lib/utils/lodash';
import React from 'react';
import ActionAuthListSingle from '../../relation/single';
export default function render(props) {
const { cascadeEntityActions, oakDirty, actions, entity, actionAuthList } = props.data;
@ -28,7 +28,10 @@ export default function render(props) {
return ele;
}
else {
return <><br />{ele}</>;
return (<>
<br />
{ele}
</>);
}
});
},
@ -91,29 +94,34 @@ export default function render(props) {
{relationSelections.map((ele) => {
let checked = false, indeterminate = false;
if (actions && actions.length > 0) {
const relation = relations.find((ele2) => ele2.relationId === ele.id && !ele2.$$deleteAt$$);
const relation = relations.find((ele2) => ele2.relationId ===
ele.id &&
!ele2.$$deleteAt$$);
if (relation) {
const { deActions } = relation;
checked = difference(actions, deActions).length === 0;
indeterminate = !checked && intersection(actions, deActions).length > 0;
checked =
difference(actions, deActions).length === 0;
indeterminate =
!checked &&
intersection(actions, deActions).length > 0;
}
}
return <Checkbox disabled={actions.length === 0} checked={checked} indeterminate={indeterminate} onChange={({ target }) => {
return (<Checkbox disabled={actions.length === 0} checked={checked} indeterminate={indeterminate} onChange={({ target }) => {
onChange2(target.checked, ele.id, record.paths, relations);
}}>
{ele.name}
</Checkbox>;
{ele.name}
</Checkbox>);
})}
</div>);
}
}
},
},
]} dataSource={actionAuthList} pagination={false}/>
<Row justify="end" style={{ marginTop: 20, padding: 5 }}>
<Button style={{ marginRight: 10 }} type='primary' disabled={!oakDirty} onClick={() => confirm()}>
{t("confirm")}
<Button style={{ marginRight: 10 }} type="primary" disabled={!oakDirty} onClick={() => confirm()}>
{t('confirm')}
</Button>
<Button disabled={!oakDirty} onClick={() => clean()}>
{t("reset")}
{t('reset')}
</Button>
</Row>
</Space>);

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, 'actionAuth', true, {
entity: string;
relationName: string;
@ -14,5 +12,4 @@ export default function render(props: WebComponentProps<ED, 'actionAuth', true,
}, {
onChange: (actions: string[], path: any, actionAuth?: ED['actionAuth']['OpSchema']) => void;
confirm: () => void;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,3 +1,4 @@
import React from 'react';
import { Table, Checkbox, Button, Row } from 'antd';
import { Typography } from 'antd';
const { Title, Text } = Typography;

View File

@ -1,6 +1,5 @@
/// <reference types="react" />
import { EntityDict } from "oak-domain/lib/types";
declare const _default: (props: import("../../..").ReactComponentProps<EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "actionAuth", true, {
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "actionAuth", true, {
path: string;
openTip: boolean;
entity: string | number;

View File

@ -39,7 +39,7 @@ export default OakComponent({
},
formData({ data: rows }) {
return {
rows
rows,
};
},
data: {
@ -61,19 +61,21 @@ export default OakComponent({
'#name': 'path'
}, true) */
}
}
},
},
lifetimes: {
async ready() {
this.getRelationAndActions();
}
},
},
methods: {
async getRelationAndActions() {
const { path, entity } = this.props;
const entities = path.split('.');
const sourceEntity = entities[entities?.length - 1];
const source = sourceEntity.includes('$') ? sourceEntity.split('$')[0] : sourceEntity;
const source = sourceEntity.includes('$')
? sourceEntity.split('$')[0]
: sourceEntity;
// 获取actions
const actions = this.features.relationAuth.getActions(entity);
// 获取relation
@ -104,6 +106,6 @@ export default OakComponent({
relations,
actions,
});
}
}
},
},
});

View File

@ -1,15 +1,13 @@
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
type TableData = {
relationId: string;
relation: string;
actions: string[];
};
export default function render(props: WebComponentProps<ED, 'actionAuth', true, {
relations: EntityDict['relation']['Schema'][];
relations: ED['relation']['Schema'][];
actions: string[];
datasource: TableData[];
rows: ED['actionAuth']['Schema'][];

View File

@ -4,7 +4,7 @@ import { Typography } from 'antd';
const { Title, Text } = Typography;
export default function render(props) {
const { data, methods } = props;
const { rows, relations, actions, path, entity, openTip, oakExecutable, onClose } = data;
const { rows, relations, actions, path, entity, openTip, oakExecutable, onClose, } = data;
const [datasource, setDatasource] = useState([]);
useEffect(() => {
const tableRows = relations.map((ele) => ({

View File

@ -1,7 +1,5 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
declare const _default: (props: import("../../..").ReactComponentProps<EntityDict & BaseEntityDict, string | number, false, {
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, false, {
entity: string | number;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, keyof ED, false, {
entity: keyof ED;
actions: string[];
@ -17,5 +15,4 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
}, {
onActionsSelected: (actions: string[]) => void;
onRelationsSelected: (relationIds: string[]) => void;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,35 +1,38 @@
import React, { useState } from 'react';
import { Row, Col, Tabs, Checkbox } from 'antd';
import { Typography } from 'antd';
const { Title, Text } = Typography;
import ActionAuth from '../actionAuth';
import { useState } from 'react';
import Styles from './web.pc.module.less';
const { Title, Text } = Typography;
export default function render(props) {
const { oakFullpath, entity, actions, checkedActions, hasDirectActionAuth, hasDirectRelationAuth, dras, daas, relationIds, relations, deduceRelationAttr } = props.data;
const { oakFullpath, entity, actions, checkedActions, hasDirectActionAuth, hasDirectRelationAuth, dras, daas, relationIds, relations, deduceRelationAttr, } = props.data;
const { onActionsSelected, onRelationsSelected, t } = props.methods;
const [tab, setTab] = useState('actionAuth');
const items = deduceRelationAttr ? [
{
label: 'deduceRelation',
key: 'deduceRelation',
children: (<div style={{
width: '100%',
height: '100%',
minHeight: 600,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}>
对象的actionAuth已被deduce到[<b>{deduceRelationAttr}</b>]
</div>)
},
] : [
{
label: 'actionAuth',
key: 'actionAuth',
children: (<ActionAuth entity={entity} oakPath={oakFullpath && `${oakFullpath}.actionAuths`} actions={checkedActions}/>)
}
];
const items = deduceRelationAttr
? [
{
label: 'deduceRelation',
key: 'deduceRelation',
children: (<div style={{
width: '100%',
height: '100%',
minHeight: 600,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}>
对象的actionAuth已被deduce到[
<b>{deduceRelationAttr}</b>]
</div>),
},
]
: [
{
label: 'actionAuth',
key: 'actionAuth',
children: (<ActionAuth entity={entity} oakPath={oakFullpath && `${oakFullpath}.actionAuths`} actions={checkedActions}/>),
},
];
/* if (hasDirectActionAuth) {
items.push(
{
@ -89,24 +92,34 @@ export default function render(props) {
const RelationSelector = relations && (<Row style={{ width: '100%' }} justify="center" align="middle">
<Text strong>{t('relation')}:</Text>
<Row style={{ flex: 1, marginLeft: 10 }} justify="start" align="middle" wrap>
<Checkbox.Group options={relations.map(ele => ({ label: ele.name, value: ele.id }))} value={relationIds} onChange={(value) => onRelationsSelected(value)} style={{
<Checkbox.Group options={relations.map((ele) => ({
label: ele.name,
value: ele.id,
}))} value={relationIds} onChange={(value) => onRelationsSelected(value)} style={{
display: 'flex',
flexWrap: 'wrap',
}}/>
</Row>
</Row>);
const showActionSelector = ['actionAuth', 'directActionAuth'].includes(tab);
const showRelationSelector = ['relationAuth', 'directRelationAuth'].includes(tab);
const showRelationSelector = [
'relationAuth',
'directRelationAuth',
].includes(tab);
return (<div className={Styles.container}>
<Row justify="center" style={{ margin: 20, padding: 10, minHeight: 100 }} align="middle">
<Col span={8}>
<Row style={{ width: '100%' }} justify="center" align="middle">
<Text strong>{t('actionAuth:attr.destEntity')}:</Text>
<Text code style={{ marginLeft: 10 }}>{entity}</Text>
<Text code style={{ marginLeft: 10 }}>
{entity}
</Text>
</Row>
</Col>
<Col span={12}>
{showActionSelector ? ActionSelector : (showRelationSelector && RelationSelector)}
{showActionSelector
? ActionSelector
: showRelationSelector && RelationSelector}
</Col>
</Row>
<Tabs defaultActiveKey="1" type="card" size="large" items={items} onChange={(key) => setTab(key)}/>

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, keyof ED, true, {
data: Array<{
name: string;
@ -15,5 +13,4 @@ export default function render(props: WebComponentProps<ED, keyof ED, true, {
}>;
}, {
onEntityClicked: (entity: string) => void;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Switch, Input, Form } from 'antd';
import ReactEcharts from 'echarts-for-react';
import { useState } from 'react';
import { uniq } from 'oak-domain/lib/utils/lodash';
import Styles from './web.pc.module.less';
export default function render(props) {
@ -13,23 +13,25 @@ export default function render(props) {
let links2 = links;
if (keywords) {
if (!strict) {
links2 = links.filter(ele => {
if (keywords.find(k => ele.source.includes(k) || ele.target.includes(k))) {
links2 = links.filter((ele) => {
if (keywords.find((k) => ele.source.includes(k) || ele.target.includes(k))) {
return true;
}
return false;
});
data2 = uniq(links2.map(ele => ele.source).concat(links2.map(ele => ele.target))).map(ele => ({ name: ele }));
data2 = uniq(links2
.map((ele) => ele.source)
.concat(links2.map((ele) => ele.target))).map((ele) => ({ name: ele }));
}
else {
links2 = links.filter(ele => {
if (keywords.find(k => ele.source.includes(k) && ele.target.includes(k))) {
links2 = links.filter((ele) => {
if (keywords.find((k) => ele.source.includes(k) && ele.target.includes(k))) {
return true;
}
return false;
});
data2 = data.filter(ele => {
if (keywords.find(k => ele.name.includes(k))) {
data2 = data.filter((ele) => {
if (keywords.find((k) => ele.name.includes(k))) {
return true;
}
return false;
@ -61,17 +63,17 @@ export default function render(props) {
initLayout: 'circular',
gravity: 0,
repulsion: [10, 80],
edgeLength: [10, 50]
edgeLength: [10, 50],
},
data: data2,
links: links2,
lineStyle: {
opacity: 0.9,
width: 2,
curveness: 0
curveness: 0,
},
label: {
show: true
show: true,
},
autoCurveness: true,
roam: true,
@ -85,9 +87,9 @@ export default function render(props) {
},
focus: 'adjacency',
lineStyle: {
width: 10
}
}
width: 10,
},
},
},
],
}} notMerge={true} lazyUpdate={false} onEvents={{

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import { RowWithActions, WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, 'relation', true, {
relations: RowWithActions<ED, 'relation'>[];
entity: string;
@ -11,4 +9,3 @@ export default function render(props: WebComponentProps<ED, 'relation', true, {
}, {
setEntityFilter: (filter: string) => void;
}>): import("react").JSX.Element | null;
export {};

View File

@ -1,8 +1,6 @@
import React from 'react';
import { RowWithActions, WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, 'relation', true, {
relations: RowWithActions<ED, 'relation'>[];
entity: string;
@ -11,4 +9,3 @@ export default function render(props: WebComponentProps<ED, 'relation', true, {
}, {
setEntityFilter: (filter: string) => void;
}>): React.JSX.Element | null;
export {};

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, 'relationAuth', true, {
relationIds: string[];
relationAuths: ED['relationAuth']['OpSchema'][];
@ -12,4 +10,3 @@ export default function render(props: WebComponentProps<ED, 'relationAuth', true
onChange: (checked: boolean, relationId: string, path: string, relationAuths?: ED['relationAuth']['OpSchema'][]) => void;
confirm: () => void;
}>): import("react").JSX.Element;
export {};

View File

@ -1,6 +1,4 @@
import { Table, Checkbox, Button, Row } from 'antd';
import { Typography } from 'antd';
const { Title, Text } = Typography;
import { intersection, difference } from 'oak-domain/lib/utils/lodash';
export default function render(props) {
const { relationIds, relationAuths, oakDirty, auths, sourceRelations } = props.data;

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, 'relationAuth', true, {
entity: string;
relationName: string;
@ -16,4 +14,3 @@ export default function render(props: WebComponentProps<ED, 'relationAuth', true
onChange: (relationId: string, checked: boolean, relationAuthId?: string, path?: string) => void;
confirm: () => void;
}>): import("react").JSX.Element;
export {};

View File

@ -1,7 +1,5 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
declare const _default: (props: import("../../..").ReactComponentProps<EntityDict & BaseEntityDict, string | number, false, {
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, false, {
entity: string | number;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,8 +1,6 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import React from 'react';
import { WebComponentProps } from '../../../types/Page';
type ED = EntityDict & BaseEntityDict;
import { ED } from '../../../types/AbstractComponent';
export default function render(props: WebComponentProps<ED, keyof ED, false, {
entity: keyof ED;
entityDNode: string[];
@ -11,5 +9,4 @@ export default function render(props: WebComponentProps<ED, keyof ED, false, {
getNodes: (entity: keyof ED) => void;
checkSelectRelation: () => boolean;
resolveP: (path: string) => string;
}>): import("react").JSX.Element;
export {};
}>): React.JSX.Element;

View File

@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { Row, Col, Space, Button, Modal, Breadcrumb, Tag } from 'antd';
import { Typography } from 'antd';
const { Title, Text } = Typography;
import { useState } from 'react';
import ActionAuthList from '../actionAuthList';
const { Title, Text } = Typography;
export default function render(props) {
const { methods, data } = props;
const { entity, entityDNode, entitySNode, oakFullpath } = data;

View File

@ -1,7 +1,5 @@
/// <reference types="react" />
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { EntityDict } from 'oak-domain/lib/types/Entity';
declare const _default: (props: import("../../types/Page").ReactComponentProps<EntityDict & BaseEntityDict, string | number, true, {
declare const _default: (props: import("../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, true, {
entity: string | number;
attributes: string[];
placeholder: string;

View File

@ -1,8 +1,7 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
import { EntityDict } from 'oak-domain/lib/types/Entity';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
searchValue: string;
placeholder: string;
}, {

View File

@ -1,8 +1,7 @@
import React from 'react';
import { WebComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
import { EntityDict } from 'oak-domain/lib/types/Entity';
export default function Render(props: WebComponentProps<ED, keyof EntityDict, false, {
export default function Render(props: WebComponentProps<ED, keyof ED, false, {
searchValue: string;
}, {
searchChange: (value: string) => void;

View File

@ -4,6 +4,6 @@ const { Search } = Input;
export default function Render(props) {
const { methods, data } = props;
const { t, searchChange, searchConfirm } = methods;
const { searchValue, oakLoading, } = data;
const { searchValue, oakLoading } = data;
return (<Search loading={oakLoading} value={searchValue} onChange={({ target: { value } }) => searchChange(value)} onSearch={(value) => searchConfirm(value)} placeholder="" allowClear/>);
}

View File

@ -1,9 +1,6 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
type ED = EntityDict & BaseEntityDict;
import { WebComponentProps } from '../../types/Page';
import { AttrUpsertRender } from '../../types/AbstractComponent';
import { AttrUpsertRender, ED } from '../../types/AbstractComponent';
export default function render<T extends keyof ED>(props: WebComponentProps<ED, T, false, {
entity: T;
renderData: AttrUpsertRender<ED, T>[];
@ -12,4 +9,3 @@ export default function render<T extends keyof ED>(props: WebComponentProps<ED,
mode?: 'default' | 'card';
children: any;
}>): React.JSX.Element;
export {};

View File

@ -1,9 +1,6 @@
import React from 'react';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { AttrUpsertRender } from '../../types/AbstractComponent';
import { AttrUpsertRender, ED } from '../../types/AbstractComponent';
import { WebComponentProps } from '../../types/Page';
type ED = EntityDict & BaseEntityDict;
export default function render<T extends keyof ED>(props: WebComponentProps<ED, T, false, {
entity: keyof ED;
renderData: AttrUpsertRender<ED, T>[];
@ -11,4 +8,3 @@ export default function render<T extends keyof ED>(props: WebComponentProps<ED,
layout?: 'horizontal' | 'vertical';
children: any;
}>): React.JSX.Element;
export {};

View File

@ -15,7 +15,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
getSubscriberId(): string | undefined;
getBriefEnvironment(): BriefEnv | undefined;
protected getSerializedData(): Promise<SerializedData>;
initialize(data?: SerializedData): Promise<void>;
initialize(data?: SerializedData, later?: boolean): Promise<void>;
/**
* event中带id的占位符saveOpRecord时再动态注入 by Xc
* @param operationId

View File

@ -22,7 +22,7 @@ export class BackendRuntimeContext extends AsyncContext {
ns: this.ns,
};
}
async initialize(data) {
async initialize(data, later) {
if (data?.sid) {
this.subscriberId = data.sid;
}

View File

@ -117,7 +117,7 @@ export class DebugStore extends TreeStore {
this.executor.registerTrigger(trigger);
}
registerChecker(checker) {
this.executor.registerChecker(checker);
this.executor.registerChecker(checker, this.getSchema());
}
resetInitialData(initialData, stat) {
super.resetInitialData(initialData, stat);

View File

@ -2,9 +2,9 @@ import { DebugStore } from './DebugStore';
import { Checker, Trigger, StorageSchema, EntityDict, ActionDictOfEntityDict, Watcher, Routine, Timer, AuthDeduceRelationMap } from "oak-domain/lib/types";
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
export declare function clearMaterializedData(): void;
import { LocalStorage } from '../features/localStorage';
export declare function createDebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>, triggers: Array<Trigger<ED, keyof ED, Cxt>>, checkers: Array<Checker<ED, keyof ED, Cxt>>, watchers: Array<Watcher<ED, keyof ED, Cxt>>, timers: Array<Timer<ED, keyof ED, Cxt>>, startRoutines: Array<Routine<ED, keyof ED, Cxt>>, initialData: {
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
}, actionDict: ActionDictOfEntityDict<ED>, authDeduceRelationMap: AuthDeduceRelationMap<ED>, saveFn: (key: string, data: any) => Promise<void>, loadFn: (key: string) => Promise<any>, selectFreeEntities?: (keyof ED)[], updateFreeDict?: {
}, actionDict: ActionDictOfEntityDict<ED>, authDeduceRelationMap: AuthDeduceRelationMap<ED>, localStorage: LocalStorage, selectFreeEntities?: (keyof ED)[], updateFreeDict?: {
[A in keyof ED]?: string[];
}): DebugStore<ED, Cxt>;

View File

@ -6,10 +6,10 @@ import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
async function initDataInStore(store, initialData, stat) {
store.resetInitialData(initialData, stat);
}
async function getMaterializedData(loadFn) {
async function getMaterializedData(localStorage) {
try {
const data = await loadFn(LOCAL_STORAGE_KEYS.debugStore);
const stat = await loadFn(LOCAL_STORAGE_KEYS.debugStoreStat);
const data = await localStorage.load(LOCAL_STORAGE_KEYS.debugStore);
const stat = await localStorage.load(LOCAL_STORAGE_KEYS.debugStoreStat);
if (data && stat) {
return {
data,
@ -23,10 +23,10 @@ async function getMaterializedData(loadFn) {
}
}
let lastMaterializedVersion = 0;
async function materializeData(data, stat, saveFn) {
async function materializeData(data, stat, localStorage) {
try {
await saveFn(LOCAL_STORAGE_KEYS.debugStore, data);
await saveFn(LOCAL_STORAGE_KEYS.debugStoreStat, stat);
await localStorage.save(LOCAL_STORAGE_KEYS.debugStore, data);
await localStorage.save(LOCAL_STORAGE_KEYS.debugStoreStat, stat);
lastMaterializedVersion = stat.commit;
console.log('物化数据', data);
}
@ -34,40 +34,6 @@ async function materializeData(data, stat, saveFn) {
console.error(e);
}
}
export function clearMaterializedData() {
if (process.env.OAK_PLATFORM === 'wechatMp') {
try {
wx.removeStorageSync(LOCAL_STORAGE_KEYS.debugStore);
wx.removeStorageSync(LOCAL_STORAGE_KEYS.debugStoreStat);
lastMaterializedVersion = 0;
wx.showToast({
title: '数据已清除',
icon: 'success',
});
console.log('清空数据');
}
catch (e) {
console.error(e);
wx.showToast({
title: '清空数据失败',
icon: 'error',
});
}
}
else if (process.env.OAK_PLATFORM === 'web') {
try {
window.localStorage.removeItem(LOCAL_STORAGE_KEYS.debugStore);
window.localStorage.removeItem(LOCAL_STORAGE_KEYS.debugStoreStat);
lastMaterializedVersion = 0;
console.log('清空数据');
// alert('数据已物化');
}
catch (e) {
console.error(e);
// alert('物化数据失败');
}
}
}
async function execWatcher(store, watcher, context) {
await context.begin();
try {
@ -197,14 +163,14 @@ async function doRoutines(store, contextBuilder, routines) {
}
}
}
export function createDebugStore(storageSchema, contextBuilder, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDeduceRelationMap, saveFn, loadFn, selectFreeEntities, updateFreeDict) {
export function createDebugStore(storageSchema, contextBuilder, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDeduceRelationMap, localStorage, selectFreeEntities, updateFreeDict) {
const store = new DebugStore(storageSchema, contextBuilder, authDeduceRelationMap, selectFreeEntities, updateFreeDict);
triggers.forEach(ele => store.registerTrigger(ele));
checkers.forEach(ele => store.registerChecker(ele));
assert(actionDict);
// 如果没有物化数据则使用initialData初始化debugStore
const loadInitialData = async () => {
const data = await getMaterializedData(loadFn);
const data = await getMaterializedData(localStorage);
if (!data) {
initDataInStore(store, initialData);
console.log('使用初始化数据建立debugStore', initialData);
@ -227,7 +193,7 @@ export function createDebugStore(storageSchema, contextBuilder, triggers, checke
if (Object.keys(result).length > 0) {
const stat = store.getStat();
const data = store.getCurrentData();
await materializeData(data, stat, saveFn);
await materializeData(data, stat, localStorage);
}
});
// 启动watcher

View File

@ -79,7 +79,11 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends A
operation: ED[T]['Operation'];
entity: T;
})[]): true | Error;
checkOperation<T extends keyof ED>(entity: T, action: ED[T]['Action'], data?: ED[T]['Update']['data'], filter?: ED[T]['Update']['filter'], checkerTypes?: CheckerType[]): boolean;
checkOperation<T extends keyof ED>(entity: T, operation: {
action: ED[T]['Action'];
data?: ED[T]['Operation']['data'];
filter?: ED[T]['Operation']['filter'];
}, checkerTypes?: CheckerType[]): boolean;
redoOperation(opers: Array<{
entity: keyof ED;
operation: ED[keyof ED]['Operation'];

View File

@ -288,17 +288,12 @@ export class Cache extends Feature {
return err;
}
}
checkOperation(entity, action, data, filter, checkerTypes) {
checkOperation(entity, operation, checkerTypes) {
let autoCommit = false;
if (!this.context) {
this.begin();
autoCommit = true;
}
const operation = {
action,
filter,
data
};
try {
this.cacheStore.check(entity, operation, this.context, checkerTypes);
if (autoCommit) {

View File

@ -98,13 +98,13 @@ export class ContextMenuFactory extends Feature {
// action有一个满足就行了
const checkResult = this.relationAuth.checkRelation(destEntity, {
action: action[i],
data: undefined,
filter,
}) &&
this.cache.checkOperation(destEntity, action[i], undefined, filter, [
this.cache.checkOperation(destEntity, {
action: action[i],
filter: filter,
}, [
'logical',
'relation',
'logicalRelation',
'row',
]);
if (checkResult) {
@ -116,13 +116,13 @@ export class ContextMenuFactory extends Feature {
}
return (this.relationAuth.checkRelation(destEntity, {
action,
data: undefined,
filter,
}) &&
this.cache.checkOperation(destEntity, action, undefined, filter, [
this.cache.checkOperation(destEntity, {
action,
filter: filter,
}, [
'logical',
'relation',
'logicalRelation',
'row',
]));
});

View File

@ -9,7 +9,7 @@ import { Environment } from './environment';
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
import { Scope, TranslateOptions } from 'i18n-js';
export declare class Locales<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Feature {
static MINIMAL_LOADING_GAP: number;
static REFRESH_STALE_INTERVAL: number;
private cache;
private localStorage;
private environment;

View File

@ -3,7 +3,7 @@ import { assert } from 'oak-domain/lib/utils/assert';
import { I18n } from 'i18n-js';
import { LOCAL_STORAGE_KEYS } from '../constant/constant';
export class Locales extends Feature {
static MINIMAL_LOADING_GAP = 600 * 10000; // 最小加载间歇
static REFRESH_STALE_INTERVAL = 30 * 24 * 3600 * 1000; // 正式环境下的主动刷新缓存策略
cache;
localStorage;
environment;
@ -61,6 +61,7 @@ export class Locales extends Feature {
data: 1,
namespace: 1,
language: 1,
$$updateAt$$: 1,
},
});
const dataset = {};
@ -76,10 +77,23 @@ export class Locales extends Feature {
});
this.i18n.store(dataset);
if (i18ns.length > 0) {
// 启动时刷新数据策略
// 先不处理了这样似乎会导致如果key不miss就不会更新所以i18n的更新要确保这点
/* const nss = i18ns.map(ele => ele.namespace!);
await this.loadServerData(nss); */
/**
* 前台启动时的数据刷新策略
* dev环境无条件刷新production环境只会主动刷新超过REFRESH_STALE_INTERVAL(30)的i18n数据
* 这样会导致在此期间内如果不发生key miss数据不会更新
* 程序员要谨慎对待这一特性对于重要的i18n在版本间尽量不要更新原有的key值
*/
if (process.env.NODE_ENV === 'development') {
const nss = i18ns.map(ele => ele.namespace);
await this.loadServerData(nss);
}
else {
const now = Date.now();
const nss = i18ns.filter(ele => now - ele.$$updateAt$$ > Locales.REFRESH_STALE_INTERVAL).map(ele => ele.namespace);
if (nss.length > 0) {
await this.loadServerData(nss);
}
}
}
}
async loadServerData(nss) {

View File

@ -72,12 +72,17 @@ export class Navigator extends Feature {
}
constructNamespace(url, namespace) {
if (namespace) {
// url传入空字符串经过urlParse处理后pathname返回"/"
const urlParse = this.urlParse(url);
const { pathname } = urlParse;
let pathname2 = pathname;
if (namespace === '/') {
pathname2 = pathname;
}
else if (pathname === '/') {
// 出现这个情况 直接返回根路由
pathname2 = namespace;
}
else if (pathname === namespace) {
pathname2 = pathname;
}

View File

@ -168,6 +168,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
addChild(path: string, node: SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, keyof ED, Cxt, FrontCxt, AD>): void;
removeChild(path: string): void;
getFreshValue(inModi?: boolean): Partial<ED[T]['Schema']> | undefined;
private refreshListChildren;
create(data: Partial<Omit<ED[T]['CreateSingle']['data'], 'id'>>): void;
update(data: ED[T]['Update']['data'], action?: ED[T]['Action']): void;
remove(): void;
@ -298,7 +299,6 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict, Cxt ext
removeNamedSorter<T extends keyof ED>(path: string, sorter: NamedSorterItem<ED, T>, refresh?: boolean): void;
removeNamedSorterByName(path: string, name: string, refresh?: boolean): void;
getIntrinsticFilters(path: string): ED[keyof ED]["Selection"]["filter"] | undefined;
tryExecute(path: string): boolean | Error;
getOperations(path: string): {
entity: keyof ED;
operation: ED[keyof ED]["Operation"];

View File

@ -668,6 +668,7 @@ class ListNode extends Node {
});
if (withParent && this.parent) {
if (this.parent instanceof SingleNode) {
// @ts-ignore
const filterOfParent = this.parent.getParentFilter(this, ignoreNewParent);
if (filterOfParent) {
filters.push(filterOfParent);
@ -787,6 +788,7 @@ class ListNode extends Node {
}
else {
// 不刷新也publish一下触发页面reRender不然有可能导致页面不进入formData
this.sr = {};
this.publish();
}
}
@ -831,6 +833,7 @@ class SingleNode extends Node {
filters;
operation;
constructor(entity, schema, cache, relationAuth, projection, parent, path, id, filters, actions, cascadeActions) {
// @ts-ignore
super(entity, schema, cache, relationAuth, projection, parent, path, actions, cascadeActions);
this.children = {};
this.sr = {};
@ -913,12 +916,14 @@ class SingleNode extends Node {
}
assert(!this.dirty, 'setId时结点是dirty在setId之前应当处理掉原有的update');
this.id = id;
this.refreshListChildren();
this.publish();
}
}
unsetId() {
if (this.id) {
this.id = undefined;
this.refreshListChildren();
this.publish();
}
}
@ -963,6 +968,15 @@ class SingleNode extends Node {
return result[0];
}
}
// 当node的id重置时其一对多的儿子结点都应当刷新数据条件已经改变
refreshListChildren() {
for (const k in this.children) {
const child = this.children[k];
if (child instanceof ListNode) {
child.refresh();
}
}
}
create(data) {
const id = generateNewId();
assert(!this.id && !this.dirty, 'create前要保证singleNode为空');
@ -979,6 +993,7 @@ class SingleNode extends Node {
action: 'create',
data: Object.assign({}, data, { id }),
};
this.refreshListChildren();
this.setDirty();
}
update(data, action) {
@ -1294,7 +1309,7 @@ class SingleNode extends Node {
*/
getParentFilter(childNode, ignoreNewParent) {
const value = this.getFreshValue();
if (value && value.$$createAt$$ === 1 && ignoreNewParent) {
if (!value || (value && value.$$createAt$$ === 1 && ignoreNewParent)) {
return;
}
for (const key in this.children) {
@ -1567,6 +1582,7 @@ export class RunningTree extends Feature {
}
if (!parentNode) {
assert(!parent && !this.root[path]);
// @ts-ignore
this.root[path] = node;
}
node.subscribe(() => {
@ -1888,14 +1904,14 @@ export class RunningTree extends Feature {
assert(node instanceof ListNode || node instanceof SingleNode);
return node.getIntrinsticFilters();
}
tryExecute(path) {
/* tryExecute(path: string) {
const node = this.findNode(path);
const operations = node?.composeOperations();
if (operations && operations.length > 0) {
return this.cache.tryRedoOperations(operations);
}
return false;
}
} */
getOperations(path) {
const node = this.findNode(path);
const operations = node?.composeOperations();

View File

@ -1,4 +1,4 @@
import { makeIntrinsicCTWs } from 'oak-domain/lib/store/actionDef';
import { makeIntrinsicCTWs } from 'oak-domain/lib/store/IntrinsicLogics';
import { createDebugStore } from './debugStore';
import { initializeStep1 as initBasicFeaturesStep1, initializeStep2 as initBasicFeaturesStep2 } from './features';
import { cloneDeep, intersection } from 'oak-domain/lib/utils/lodash';
@ -29,7 +29,7 @@ export function initialize(storageSchema, frontendContextBuilder, backendContext
const triggers2 = triggers.concat(intTriggers);
const watchers2 = watchers.concat(intWatchers);
const features1 = initBasicFeaturesStep1();
const debugStore = createDebugStore(storageSchema, backendContextBuilder, triggers2, checkers2, watchers2, timers, startRoutines, initialData, actionDict, authDeduceRelationMap, (key, data) => features1.localStorage.save(key, data), (key) => features1.localStorage.load(key), selectFreeEntities, updateFreeDict);
const debugStore = createDebugStore(storageSchema, backendContextBuilder, triggers2, checkers2, watchers2, timers, startRoutines, initialData, actionDict, authDeduceRelationMap, features1.localStorage, selectFreeEntities, updateFreeDict);
const wrapper = {
exec: async (name, params, ignoreContext) => {
const context = features2.cache.buildContext();

View File

@ -1,5 +1,5 @@
import { initializeStep1 as initBasicFeaturesStep1, initializeStep2 as initBasicFeaturesStep2 } from './features';
import { makeIntrinsicCTWs } from 'oak-domain/lib/store/actionDef';
import { makeIntrinsicCheckers } from 'oak-domain/lib/store/IntrinsicCheckers';
/**
* @param storageSchema
* @param createFeatures
@ -15,8 +15,8 @@ import { makeIntrinsicCTWs } from 'oak-domain/lib/store/actionDef';
*/
export function initialize(storageSchema, frontendContextBuilder, connector, checkers, option) {
const { authDeduceRelationMap, actionDict, selectFreeEntities, updateFreeDict, colorDict, cacheKeepFreshPeriod, cacheSavedEntities } = option;
const { checkers: intCheckers } = makeIntrinsicCTWs(storageSchema, actionDict);
const checkers2 = checkers.concat(intCheckers);
const intrinsicCheckers = makeIntrinsicCheckers(storageSchema, actionDict);
const checkers2 = checkers.concat(intrinsicCheckers);
const features1 = initBasicFeaturesStep1();
const wrapper = {
exec: async (name, params, ignoreContext) => {

Some files were not shown because too many files have changed in this diff Show More