Junyi 238af440e3
feat(plugin-workflow): loop (#1787)
* feat(plugin-workflow): add loop instruction

* fix(plugin-workflow): fix lint error

* feat(plugin-workflow): add loop variable in client

* feat(plugin-workflow): refactor and add job list to nodes in execution

* feat(plugin-workflow): allow to query multiple records

* fix(plugin-workflow): fix i18n

* fix(plugin-workflow): fix undefined value in component

* fix(plugin-workflow): fix parse context value with current node

* fix(plugin-workflow): fix revision with scope variable

* test(plugin-workflow): add failing case

* fix(plugin-workflow): fix revision with scope variable

* chore(plugin-workflow): fix lint errors

* fix(plugin-workflow): fix workflow canvas page style

* fix(plugin-workflow): revert abstracted node config drawer back to each node

* fix(plugin-workflow): fix parallel extra call

* fix(plugin-workflow): fix parallel branch end

* fix(plugin-workflow): fix jobs variable in processor

* fix(plugin-workflow): fix workflow canvas scroll style

* fix(plugin-workflow): fix slowly opening job modal

* fix(plugin-workflow): fix cycling reference
2023-05-15 18:45:45 -07:00

69 lines
1.9 KiB
TypeScript

import { SchemaInitializerItemOptions, useCollectionDataSource } from '@nocobase/client';
import { appends, collection, filter } from '../schemas/collection';
import { NAMESPACE } from '../locale';
import { CollectionBlockInitializer } from '../components/CollectionBlockInitializer';
import { CollectionFieldInitializers } from '../components/CollectionFieldInitializers';
import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
import { useCollectionFieldOptions } from '../variable';
import { FieldsSelect } from '../components/FieldsSelect';
export default {
title: `{{t("Query record", { ns: "${NAMESPACE}" })}}`,
type: 'query',
group: 'collection',
fieldset: {
collection,
multiple: {
type: 'boolean',
title: `{{t("Multiple records", { ns: "${NAMESPACE}" })}}`,
'x-decorator': 'FormItem',
'x-component': 'Checkbox',
},
params: {
type: 'object',
properties: {
filter,
appends,
},
},
failOnEmpty: {
type: 'boolean',
title: `{{t("Fail on no data", { ns: "${NAMESPACE}" })}}`,
'x-decorator': 'FormItem',
'x-component': 'Checkbox',
},
},
view: {},
scope: {
useCollectionDataSource,
},
components: {
FilterDynamicComponent,
FieldsSelect,
},
useVariables({ config }, types) {
return useCollectionFieldOptions({
collection: config.collection,
types,
depth: config.params?.appends?.length ? 1 : 0,
});
},
useInitializers(node): SchemaInitializerItemOptions | null {
if (!node.config.collection) {
return null;
}
return {
type: 'item',
title: node.title ?? `#${node.id}`,
component: CollectionBlockInitializer,
collection: node.config.collection,
dataSource: `{{$jobsMapByNodeId.${node.id}}}`,
};
},
initializers: {
CollectionFieldInitializers,
},
};