relation/path/list的修正

This commit is contained in:
Xu Chang 2025-05-16 16:51:06 +08:00
parent bcfb7d5706
commit d19e7c59a9
13 changed files with 69 additions and 42 deletions

View File

@ -1,3 +1,4 @@
import { OakUniqueViolationException } from 'oak-domain/lib/types/Exception';
import { difference } from 'oak-domain/lib/utils/lodash';
export default OakComponent({
entity: 'path',
@ -55,5 +56,22 @@ export default OakComponent({
},
properties: {
entity: '',
},
methods: {
async onConfirmed() {
try {
await this.execute();
}
catch (err) {
if (err instanceof OakUniqueViolationException) {
this.setMessage({
type: 'error',
content: this.t('error.existed'),
});
return;
}
throw err;
}
}
}
});

View File

@ -1,3 +1,6 @@
{
"addPath": "新增路径"
"addPath": "新增路径",
"error": {
"existed": "本条关系路径已经存在"
}
}

View File

@ -6,4 +6,6 @@ export default function render(props: WebComponentProps<EntityDict, 'path', true
allowCreate: boolean;
actions: string[];
entity: string;
}, {
onConfirmed: () => Promise<void>;
}>): React.JSX.Element | null;

View File

@ -5,7 +5,7 @@ import PathDetail from '../detail';
const { Title } = Typography;
export default function render(props) {
const { paths, oakPagination, oakFullpath, allowCreate, actions, entity } = props.data;
const { t, execute, addItem, clean, navigateTo } = props.methods;
const { t, execute, addItem, clean, onConfirmed } = props.methods;
if (oakFullpath) {
const [upsertId, setUpsertId] = useState('');
const isCreate = upsertId && paths.find(ele => ele.id === upsertId)?.$$createAt$$ === 1;
@ -35,7 +35,10 @@ export default function render(props) {
clean();
setUpsertId('');
}} closeIcon={null} footer={null}>
<PathUpsert oakPath={`${oakFullpath}.${upsertId}`} entity={entity}/>
<PathUpsert oakPath={`${oakFullpath}.${upsertId}`} entity={entity} onConfirmed={async () => {
await onConfirmed();
setUpsertId('');
}}/>
</Modal>
</>);
}

View File

@ -1,6 +1,5 @@
import assert from 'assert';
import { unset } from 'oak-domain/lib/utils/lodash';
import { OakUniqueViolationException } from 'oak-domain/lib/types/Exception';
const SystemEntities = [
'modi',
'modiEntity',
@ -187,21 +186,9 @@ export default OakComponent({
value,
});
}
try {
await this.execute();
}
catch (err) {
if (err instanceof OakUniqueViolationException) {
this.setMessage({
type: 'error',
content: this.t('error.existed'),
});
return;
}
throw err;
}
const { onConfirmed } = this.props;
onConfirmed && onConfirmed();
assert(onConfirmed);
onConfirmed();
}
}
});

View File

@ -4,8 +4,5 @@
"sourceEntity": "源对象必须指向user或者存在Relation关系",
"desc": "请用自然语言准确描述两者之间的关系,以便用户理解",
"value": "选择路径上的下一级对象"
},
"error": {
"existed": "本条关系路径已经存在"
}
}

View File

@ -358,7 +358,9 @@ export class Cache extends Feature {
}
const filter2 = typeof filter === 'function' ? filter({
action,
data: {},
data: {
[attr]: 'void', // 这里里面应该不会用到更新的值,这样写不要紧……
},
filter: { id }
}, this.context) : filter;
if (!filter2 || this.checkFilterContains(entity, filter2, { id }, true)) {

View File

@ -361,7 +361,9 @@ class Cache extends Feature_1.Feature {
}
const filter2 = typeof filter === 'function' ? filter({
action,
data: {},
data: {
[attr]: 'void', // 这里里面应该不会用到更新的值,这样写不要紧……
},
filter: { id }
}, this.context) : filter;
if (!filter2 || this.checkFilterContains(entity, filter2, { id }, true)) {

View File

@ -1,4 +1,5 @@
import { EntityDict } from 'oak-domain/lib/base-app-domain';
import { OakUniqueViolationException } from 'oak-domain/lib/types/Exception';
import { difference } from 'oak-domain/lib/utils/lodash';
export default OakComponent({
@ -59,5 +60,22 @@ export default OakComponent({
},
properties: {
entity: '',
},
methods: {
async onConfirmed() {
try {
await this.execute();
}
catch (err) {
if (err instanceof OakUniqueViolationException) {
this.setMessage({
type: 'error',
content: this.t('error.existed'),
});
return;
}
throw err;
}
}
}
});

View File

@ -1,3 +1,6 @@
{
"addPath": "新增路径"
"addPath": "新增路径",
"error": {
"existed": "本条关系路径已经存在"
}
}

View File

@ -26,11 +26,14 @@ export default function render(
actions: string[];
// relations: string[];
entity: string;
},
{
onConfirmed: () => Promise<void>;
}
>
) {
const { paths, oakPagination, oakFullpath, allowCreate, actions, entity } = props.data;
const { t, execute, addItem, clean, navigateTo } = props.methods;
const { t, execute, addItem, clean, onConfirmed } = props.methods;
if (oakFullpath) {
const [upsertId, setUpsertId] = useState('');
@ -83,6 +86,10 @@ export default function render(
<PathUpsert
oakPath={`${oakFullpath}.${upsertId}`}
entity={entity}
onConfirmed={async () => {
await onConfirmed();
setUpsertId('');
}}
/>
</Modal>
</>

View File

@ -215,22 +215,10 @@ export default OakComponent({
value,
});
}
try {
await this.execute();
}
catch (err) {
if (err instanceof OakUniqueViolationException) {
this.setMessage({
type: 'error',
content: this.t('error.existed'),
});
return;
}
throw err;
}
const { onConfirmed } = this.props;
onConfirmed && onConfirmed();
assert(onConfirmed);
onConfirmed();
}
}
});

View File

@ -4,8 +4,5 @@
"sourceEntity": "源对象必须指向user或者存在Relation关系",
"desc": "请用自然语言准确描述两者之间的关系,以便用户理解",
"value": "选择路径上的下一级对象"
},
"error": {
"existed": "本条关系路径已经存在"
}
}