refactor(plugin-workflow): use assigned fields for create/update node values (#4546)

* refactor(plugin-workflow): use assigned fields for create/update node values

* fix(plugin-workflow): fix schema and values when change collection

* fix(plugin-workflow): fix node form initial values

* test: fix e2e

* fix(plugin-workflow): fix add node error

* refactor(plugin-workflow): change to self host schema in node

* feat(plugin-workflow): make collection uneditable after first saved

---------

Co-authored-by: hongboji <j414562100@qq.com>
This commit is contained in:
Junyi 2024-06-12 15:12:31 +08:00 committed by GitHub
parent 577f9a34e8
commit 2aa46171b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 613 additions and 229 deletions

View File

@ -346,10 +346,10 @@ export function Input(props: VariableInputProps) {
<Tag contentEditable={false} color="blue">
{variableText.map((item, index) => {
return (
<>
<React.Fragment key={item}>
{index ? ' / ' : ''}
{item}
</>
</React.Fragment>
);
})}
</Tag>

View File

@ -364,7 +364,7 @@ export class CreateRecordNode {
this.collectionDropDown = page
.getByLabel('block-item-DataSourceCollectionCascader-workflows-Collection')
.locator('.ant-select-selection-search-input');
this.addFieldsButton = page.getByRole('button', { name: 'plus Add field' });
this.addFieldsButton = page.getByLabel('schema-initializer-Grid-assignFieldValuesForm:configureFields');
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
this.cancelButton = page.getByLabel('action-Action-Cancel-workflows');
this.addNodeButton = page.getByLabel(`add-button-create-${nodeName}`, { exact: true });
@ -394,12 +394,12 @@ export class UpdateRecordNode {
.getByLabel('block-item-DataSourceCollectionCascader-workflows-Collection')
.locator('.ant-select-selection-search-input');
this.batchUpdateModeRadio = page
.getByLabel('block-item-IndividualHooksRadioWithTooltip-workflows-Update mode')
.getByLabel('block-item-RadioWithTooltip-workflows-Update mode')
.getByLabel('Update in a batch');
this.articleByArticleUpdateModeRadio = page
.getByLabel('block-item-IndividualHooksRadioWithTooltip-workflows-Update mode')
.getByLabel('block-item-RadioWithTooltip-workflows-Update mode')
.getByLabel('Update one by one');
this.addFieldsButton = page.getByRole('button', { name: 'plus Add field' });
this.addFieldsButton = page.getByLabel('schema-initializer-Grid-assignFieldValuesForm:configureFields');
this.submitButton = page.getByLabel('action-Action-Submit-workflows');
this.cancelButton = page.getByLabel('action-Action-Cancel-workflows');
this.addNodeButton = page.getByLabel(`add-button-update-${nodeName}`, { exact: true });

View File

@ -74,9 +74,9 @@ export function AddButton(props: AddButtonProps) {
const onCreate = useCallback(
async ({ keyPath }) => {
const type = keyPath.pop();
const config = {};
const [optionKey] = keyPath;
const instruction = engine.instructions.get(type);
const config = instruction.createDefaultConfig();
if (optionKey) {
const { value } = instruction.options?.find((item) => item.key === optionKey) ?? {};
Object.assign(config, typeof value === 'function' ? value() : value);

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, single row text fields for common table
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -85,11 +85,14 @@ test('Collection event add data trigger, single row text fields for common table
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.mouse.move(300, 0, { steps: 100 });
const createRecordNodefieldData = createNodeFieldDisplayName + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
await page
.getByLabel('block-item-CollectionFieldset-workflows-Fields values')
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByRole('textbox')
.fill(createRecordNodefieldData);
await createRecordNode.submitButton.click();
@ -129,8 +132,8 @@ test('Collection event add data trigger, normal table single line text field, se
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -185,14 +188,24 @@ test('Collection event add data trigger, normal table single line text field, se
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-button')
.click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await createRecordNode.submitButton.click();
@ -231,8 +244,8 @@ test('Collection event add data trigger, normal table integer field, set constan
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -287,11 +300,14 @@ test('Collection event add data trigger, normal table integer field, set constan
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.mouse.move(300, 0, { steps: 100 });
const createRecordNodefieldData = faker.number.int();
await page
.getByLabel('block-item-CollectionFieldset-workflows-Fields values')
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByRole('spinbutton')
.fill(createRecordNodefieldData.toString());
await createRecordNode.submitButton.click();
@ -331,8 +347,8 @@ test('Collection event add data trigger, normal table integer field, set trigger
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -387,14 +403,24 @@ test('Collection event add data trigger, normal table integer field, set trigger
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-button')
.click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await createRecordNode.submitButton.click();
@ -433,8 +459,8 @@ test('Collection event add data trigger, normal table numeric field, set constan
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -489,11 +515,14 @@ test('Collection event add data trigger, normal table numeric field, set constan
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.mouse.move(300, 0, { steps: 100 });
const createRecordNodefieldData = faker.number.float({ min: 0, max: 999999999, precision: 0.0001 });
await page
.getByLabel('block-item-CollectionFieldset-workflows-Fields values')
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByRole('spinbutton')
.fill(createRecordNodefieldData.toString());
await createRecordNode.submitButton.click();
@ -533,8 +562,8 @@ test('Collection event add data trigger, normal table numeric field, set trigger
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -589,14 +618,24 @@ test('Collection event add data trigger, normal table numeric field, set trigger
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-button')
.click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await createRecordNode.submitButton.click();
@ -635,8 +674,8 @@ test('Collection event add data trigger, normal table dropdown radio field, set
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -691,9 +730,15 @@ test('Collection event add data trigger, normal table dropdown radio field, set
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByTestId('select-single').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByTestId('select-single')
.click();
await page.getByRole('option', { name: '存续' }).click();
await createRecordNode.submitButton.click();
@ -732,8 +777,8 @@ test('Collection event add data trigger, normal table dropdown radio field, set
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -788,14 +833,24 @@ test('Collection event add data trigger, normal table dropdown radio field, set
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-button')
.click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await createRecordNode.submitButton.click();
@ -834,8 +889,8 @@ test('Collection event add data trigger, normal table dropdown radio fields, set
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -890,8 +945,9 @@ test('Collection event add data trigger, normal table dropdown radio fields, set
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.mouse.move(300, 0, { steps: 100 });
await page.getByTestId('select-multiple').click();
await page.getByRole('option', { name: '软件销售', exact: true }).click();
await page.getByRole('option', { name: '软件开发', exact: true }).click();
@ -932,8 +988,8 @@ test('Collection event add data trigger, normal table dropdown radio fields, set
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -988,14 +1044,24 @@ test('Collection event add data trigger, normal table dropdown radio fields, set
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-button')
.click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await createRecordNode.submitButton.click();
@ -1034,8 +1100,8 @@ test('Collection event add data trigger, normal table date field, set constant d
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -1090,12 +1156,20 @@ test('Collection event add data trigger, normal table date field, set constant d
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('block-item-CollectionFieldset').getByPlaceholder('Select date').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByPlaceholder('Select date')
.click();
const createRecordNodefieldData = dayjs().format('YYYY-MM-DD');
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByPlaceholder('Select date')
.fill(createRecordNodefieldData);
await page.getByTitle(createRecordNodefieldData.toString()).locator('div').click();
@ -1136,8 +1210,8 @@ test('Collection event add data trigger, normal table date field, set trigger no
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const createNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const createNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -1192,14 +1266,24 @@ test('Collection event add data trigger, normal table date field, set trigger no
await page.getByRole('menuitemcheckbox', { name: 'Main right' }).click();
await page.getByRole('menuitemcheckbox', { name: createNodeCollectionDisplayName }).click();
// 设置字段
await createRecordNode.addFieldsButton.click();
await createRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: createNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.mouse.move(300, 0, { steps: 100 });
await page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-button')
.click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${createNodeCollectionName}-${createNodeCollectionName}.${createNodeFieldName}-${createNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await createRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter dropdown radio fields not null,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -103,7 +103,7 @@ test('Collection event add data trigger, filter dropdown radio fields not null,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByTestId('select-multiple').click();
await page.getByRole('option', { name: '数据处理服务', exact: true }).click();
@ -183,8 +183,8 @@ test('Collection event add data trigger, filter dropdown radio fields not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -257,14 +257,18 @@ test('Collection event add data trigger, filter dropdown radio fields not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -341,8 +345,8 @@ test('Collection event add data trigger, filter date field not null, common tabl
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -417,12 +421,19 @@ test('Collection event add data trigger, filter date field not null, common tabl
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = dayjs().format('YYYY-MM-DD');
await page.getByLabel('block-item-CollectionFieldset').getByPlaceholder('Select date').click();
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByPlaceholder('Select date')
.click();
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByPlaceholder('Select date')
.fill(updateRecordNodefieldData);
await page.getByTitle(updateRecordNodefieldData.toString()).locator('div').click();
@ -499,8 +510,8 @@ test('Collection event add data trigger, filter date field not empty, common tab
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -573,14 +584,18 @@ test('Collection event add data trigger, filter date field not empty, common tab
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter single line text field not empty
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -108,10 +108,15 @@ test('Collection event add data trigger, filter single line text field not empty
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = updateNodeFieldDisplayName + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
await page.getByLabel('block-item-CollectionFieldset').getByRole('textbox').fill(updateRecordNodefieldData);
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('textbox')
.fill(updateRecordNodefieldData);
await updateRecordNode.submitButton.click();
// 查看更新前数据
@ -183,8 +188,8 @@ test('Collection event add data trigger, filter single line text field not empty
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -262,14 +267,18 @@ test('Collection event add data trigger, filter single line text field not empty
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -343,8 +352,8 @@ test('Collection event add data trigger, filter multi-line text field not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -423,10 +432,15 @@ test('Collection event add data trigger, filter multi-line text field not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = updateNodeFieldDisplayName + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
await page.getByLabel('block-item-CollectionFieldset').getByRole('textbox').fill(updateRecordNodefieldData);
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('textbox')
.fill(updateRecordNodefieldData);
await updateRecordNode.submitButton.click();
// 查看更新前数据
@ -498,8 +512,8 @@ test('Collection event add data trigger, filter multiline text field not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -577,14 +591,18 @@ test('Collection event add data trigger, filter multiline text field not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -658,8 +676,8 @@ test('Collection event add data trigger, filter integer field not null, common t
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -732,11 +750,13 @@ test('Collection event add data trigger, filter integer field not null, common t
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = faker.number.int();
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('spinbutton')
.fill(updateRecordNodefieldData.toString());
await updateRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter integer field not empty, common
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -103,14 +103,18 @@ test('Collection event add data trigger, filter integer field not empty, common
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
const updateRecordNodefieldData = faker.number.int();
@ -181,8 +185,8 @@ test('Collection event add data trigger, filter numeric field not null, common t
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -257,11 +261,13 @@ test('Collection event add data trigger, filter numeric field not null, common t
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = faker.number.float({ min: 0, max: 999999999, precision: 0.0001 });
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('spinbutton')
.fill(updateRecordNodefieldData.toString());
await updateRecordNode.submitButton.click();
@ -332,8 +338,8 @@ test('Collection event add data trigger, filter numeric field not empty, common
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -406,14 +412,18 @@ test('Collection event add data trigger, filter numeric field not empty, common
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -485,8 +495,8 @@ test('Collection event add data trigger, filter dropdown radio field not null, c
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -558,10 +568,15 @@ test('Collection event add data trigger, filter dropdown radio field not null, c
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = '4';
await page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByTestId('select-single').click();
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByTestId('select-single')
.click();
await page.getByRole('option', { name: '注销' }).click();
await updateRecordNode.submitButton.click();
@ -633,8 +648,8 @@ test('Collection event add data trigger, filter dropdown radio field not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -707,14 +722,18 @@ test('Collection event add data trigger, filter dropdown radio field not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter dropdown radio fields not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -104,14 +104,18 @@ test('Collection event add data trigger, filter dropdown radio fields not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -188,8 +192,8 @@ test('Collection event add data trigger, filter date field not null, common tabl
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -265,12 +269,19 @@ test('Collection event add data trigger, filter date field not null, common tabl
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = dayjs().format('YYYY-MM-DD');
await page.getByLabel('block-item-CollectionFieldset').getByPlaceholder('Select date').click();
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByPlaceholder('Select date')
.click();
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByPlaceholder('Select date')
.fill(updateRecordNodefieldData);
await page.getByTitle(updateRecordNodefieldData.toString()).locator('div').click();
@ -347,8 +358,8 @@ test('Collection event add data trigger, filter date field not empty, common tab
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -422,14 +433,18 @@ test('Collection event add data trigger, filter date field not empty, common tab
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter single line text field not empty
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -109,10 +109,15 @@ test('Collection event add data trigger, filter single line text field not empty
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = updateNodeFieldDisplayName + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
await page.getByLabel('block-item-CollectionFieldset').getByRole('textbox').fill(updateRecordNodefieldData);
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('textbox')
.fill(updateRecordNodefieldData);
await updateRecordNode.submitButton.click();
// 查看更新前数据
@ -184,8 +189,8 @@ test('Collection event add data trigger, filter single line text field not empty
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -264,14 +269,18 @@ test('Collection event add data trigger, filter single line text field not empty
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -345,8 +354,8 @@ test('Collection event add data trigger, filter multi-line text field not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -426,10 +435,15 @@ test('Collection event add data trigger, filter multi-line text field not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = updateNodeFieldDisplayName + dayjs().format('YYYYMMDDHHmmss.SSS').toString();
await page.getByLabel('block-item-CollectionFieldset').getByRole('textbox').fill(updateRecordNodefieldData);
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('textbox')
.fill(updateRecordNodefieldData);
await updateRecordNode.submitButton.click();
// 查看更新前数据
@ -501,8 +515,8 @@ test('Collection event add data trigger, filter multiline text field not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -581,14 +595,18 @@ test('Collection event add data trigger, filter multiline text field not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter integer field not null, common t
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -104,11 +104,13 @@ test('Collection event add data trigger, filter integer field not null, common t
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = faker.number.int();
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('spinbutton')
.fill(updateRecordNodefieldData.toString());
await updateRecordNode.submitButton.click();
@ -180,8 +182,8 @@ test('Collection event add data trigger, filter integer field not empty, common
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -255,14 +257,18 @@ test('Collection event add data trigger, filter integer field not empty, common
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
const updateRecordNodefieldData = faker.number.int();
@ -333,8 +339,8 @@ test('Collection event add data trigger, filter numeric field not null, common t
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -410,11 +416,13 @@ test('Collection event add data trigger, filter numeric field not null, common t
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = faker.number.float({ min: 0, max: 999999999, precision: 0.0001 });
await page
.getByLabel('block-item-CollectionFieldset')
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByRole('spinbutton')
.fill(updateRecordNodefieldData.toString());
await updateRecordNode.submitButton.click();
@ -485,8 +493,8 @@ test('Collection event add data trigger, filter numeric field not empty, common
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -560,14 +568,18 @@ test('Collection event add data trigger, filter numeric field not empty, common
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();

View File

@ -29,8 +29,8 @@ test('Collection event add data trigger, filter dropdown radio field not null, c
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -103,10 +103,15 @@ test('Collection event add data trigger, filter dropdown radio field not null, c
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
const updateRecordNodefieldData = '4';
await page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByTestId('select-single').click();
await page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByTestId('select-single')
.click();
await page.getByRole('option', { name: '注销' }).click();
await updateRecordNode.submitButton.click();
@ -178,8 +183,8 @@ test('Collection event add data trigger, filter dropdown radio field not empty,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -253,14 +258,18 @@ test('Collection event add data trigger, filter dropdown radio field not empty,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByLabel('variable-button').click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger variables' }).click();
await page.getByRole('menuitemcheckbox', { name: 'Trigger data' }).click();
await page.getByRole('menuitemcheckbox', { name: triggerNodeFieldDisplayName }).click();
await expect(
page.getByLabel('block-item-CollectionFieldset-workflows-Fields values').getByLabel('variable-tag'),
page
.getByLabel(
`block-item-AssignedField-${updateNodeCollectionName}-${updateNodeCollectionName}.${updateNodeFieldName}-${updateNodeFieldDisplayName}`,
)
.getByLabel('variable-tag'),
).toHaveText(`Trigger variables / Trigger data / ${triggerNodeFieldDisplayName}`);
await updateRecordNode.submitButton.click();
@ -334,8 +343,8 @@ test('Collection event add data trigger, filter dropdown radio fields not null,
mockRecords,
}) => {
//数据表后缀标识
const triggerNodeAppendText = 'a' + faker.string.alphanumeric(4);
const updateNodeAppendText = 'b' + faker.string.alphanumeric(4);
const triggerNodeAppendText = 'a' + Math.random().toString(36).substring(2, 12);
const updateNodeAppendText = 'b' + Math.random().toString(36).substring(2, 12);
//创建触发器节点数据表
const triggerNodeCollectionDisplayName = `自动>组织[普通表]${triggerNodeAppendText}`;
const triggerNodeCollectionName = `tt_amt_org${triggerNodeAppendText}`;
@ -409,7 +418,7 @@ test('Collection event add data trigger, filter dropdown radio fields not null,
await page.getByRole('option', { name: 'is not empty' }).click();
// 设置字段
await updateRecordNode.addFieldsButton.click();
await updateRecordNode.addFieldsButton.hover();
await page.getByRole('menuitem', { name: updateNodeFieldDisplayName }).click();
await page.getByTestId('select-multiple').click();
await page.getByRole('option', { name: '数据处理服务', exact: true }).click();

View File

@ -0,0 +1,136 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import React, { useCallback, useMemo, useState } from 'react';
import { createForm, onFieldValueChange, onFormValuesChange } from '@formily/core';
import { FormLayout } from '@formily/antd-v5';
import { toJS } from '@formily/reactive';
import { Schema, useForm, useFormEffects } from '@formily/react';
import { uid } from '@formily/shared';
import {
CollectionField,
CollectionManagerProvider,
CollectionProvider,
FormProvider,
SchemaComponent,
SchemaComponentOptions,
SchemaComponentProvider,
Variable,
VariableScopeProvider,
parseCollectionName,
useAPIClient,
useActionContext,
useSchemaOptionsContext,
} from '@nocobase/client';
import { useFlowContext } from '../FlowContext';
import { useWorkflowVariableOptions } from '../variable';
function reduceSchema(s, fn) {
fn(s);
if (s?.properties) {
Object.values(s.properties).forEach((value) => {
reduceSchema(value, fn);
});
}
}
function createNewSchema() {
return {
name: uid(),
type: 'void',
'x-component': 'Grid',
'x-initializer': 'assignFieldValuesForm:configureFields',
};
}
export function AssignedFieldsFormSchemaConfig(props) {
const { workflow } = useFlowContext();
const { setFormValueChanged } = useActionContext();
const api = useAPIClient();
const scope = useWorkflowVariableOptions();
const nodeForm = useForm();
const { values, setValuesIn } = nodeForm;
const params = toJS(values.params);
const [dataSourceName, collectionName] = parseCollectionName(values.collection);
const schemaOptions = useSchemaOptionsContext();
const [schema, setSchema] = useState(
props.value && Object.keys(props.value).length ? props.value : createNewSchema(),
);
const form = useMemo(
() =>
createForm({
initialValues: params.values,
disabled: workflow.executed,
effects() {
onFormValuesChange((f) => {
setValuesIn('params.values', toJS(f.values));
setFormValueChanged(true);
});
},
}),
[workflow.executed],
);
useFormEffects(() => {
onFieldValueChange('collection', async (field) => {
form.clearFormGraph('*');
const newSchema = createNewSchema();
setValuesIn('params.values', {});
setSchema(newSchema);
});
});
const onChange = useCallback(
(s) => {
const [nextSchema] = Object.values(s.toJSON().properties);
props.onChange(nextSchema);
const keys = new Set<string>();
reduceSchema(nextSchema, (item) => {
if (item['x-component'] === 'AssignedField') {
if (item['x-collection-field']?.startsWith(`${collectionName}.`)) {
const [, field] = item['x-collection-field'].split('.');
keys.add(field);
}
}
});
const nextValues = {};
Array.from(keys).forEach((key) => {
if (key in form.values) {
nextValues[key] = form.values[key];
}
});
setValuesIn('params.values', nextValues);
},
[collectionName, props.onChange],
);
return (
<CollectionManagerProvider dataSource={dataSourceName}>
<CollectionProvider name={collectionName}>
<FormProvider form={form}>
<FormLayout layout={'vertical'}>
<VariableScopeProvider scope={scope}>
<SchemaComponentProvider form={form} designable>
<SchemaComponentOptions {...schemaOptions}>
<SchemaComponent schema={schema} onChange={onChange} />
</SchemaComponentOptions>
</SchemaComponentProvider>
</VariableScopeProvider>
</FormLayout>
</FormProvider>
</CollectionProvider>
</CollectionManagerProvider>
);
}

View File

@ -53,7 +53,9 @@ function AssociationInput(props) {
return <Input {...props} value={value} onChange={onChange} />;
}
// NOTE: observer for watching useProps
/**
* @deprecated
*/
const CollectionFieldSet = observer(
({ value, disabled, onChange, filter }: any) => {
const { token } = useToken();

View File

@ -11,10 +11,11 @@ import { SchemaInitializerItemType, parseCollectionName, useCollectionDataSource
import { CollectionBlockInitializer } from '../components/CollectionBlockInitializer';
import CollectionFieldset from '../components/CollectionFieldset';
import { AssignedFieldsFormSchemaConfig } from '../components/AssignedFieldsFormSchemaConfig';
import { NAMESPACE } from '../locale';
import { appends, collection, values } from '../schemas/collection';
import { getCollectionFieldOptions, useGetCollectionFields } from '../variable';
import { Instruction } from '.';
import { Instruction, useNodeSavedConfig } from '.';
function useVariables({ key: name, title, config }, options) {
const [dataSourceName, collection] = parseCollectionName(config.collection);
@ -54,6 +55,7 @@ export default class extends Instruction {
fieldset = {
collection: {
...collection,
'x-disabled': '{{ useNodeSavedConfig(["collection"]) }}',
'x-reactions': [
...collection['x-reactions'],
{
@ -61,36 +63,60 @@ export default class extends Instruction {
effects: ['onFieldValueChange'],
fulfill: {
state: {
visible: '{{!!$self.value}}',
value: '{{Object.create({})}}',
},
},
},
],
},
// multiple: {
// type: 'boolean',
// title: '多条数据',
// name: 'multiple',
// 'x-decorator': 'FormItem',
// 'x-component': 'Checkbox',
// 'x-component-props': {
// disabled: true
// }
// },
assignFormSchema: {
type: 'object',
title: '{{t("Fields values")}}',
'x-decorator': 'FormItem',
'x-component': 'AssignedFieldsFormSchemaConfig',
'x-reactions': [
{
dependencies: ['collection'],
fulfill: {
state: {
display: '{{($deps[0] && $self.value) ? "visible" : "hidden"}}',
},
},
},
],
},
params: {
type: 'object',
properties: {
values,
values: {
...values,
'x-reactions': [
{
dependencies: ['collection', 'assignFormSchema'],
fulfill: {
state: {
display: '{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}',
},
},
},
],
},
appends,
},
},
};
createDefaultConfig() {
return {
assignFormSchema: {},
};
}
scope = {
useCollectionDataSource,
useNodeSavedConfig,
};
components = {
CollectionFieldset,
AssignedFieldsFormSchemaConfig,
};
useVariables = useVariables;
useInitializers(node): SchemaInitializerItemType | null {

View File

@ -12,7 +12,7 @@ import { isValidFilter } from '@nocobase/utils/client';
import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
import { collection, filter } from '../schemas/collection';
import { Instruction } from '.';
import { Instruction, useNodeSavedConfig } from '.';
import { NAMESPACE, lang } from '../locale';
export default class extends Instruction {
@ -23,6 +23,7 @@ export default class extends Instruction {
fieldset = {
collection: {
...collection,
'x-disabled': '{{ useNodeSavedConfig(["collection"]) }}',
'x-reactions': [
...collection['x-reactions'],
{
@ -57,6 +58,7 @@ export default class extends Instruction {
},
};
scope = {
useNodeSavedConfig,
useCollectionDataSource,
};
components = {

View File

@ -9,9 +9,10 @@
import { CloseOutlined, DeleteOutlined } from '@ant-design/icons';
import { createForm } from '@formily/core';
import { toJS } from '@formily/reactive';
import { ISchema, useForm } from '@formily/react';
import { App, Button, Dropdown, Input, Tag, Tooltip, message } from 'antd';
import { cloneDeep } from 'lodash';
import { cloneDeep, get } from 'lodash';
import React, { useCallback, useContext, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@ -53,15 +54,30 @@ export abstract class Instruction {
type: string;
group: string;
description?: string;
/**
* @experimental
*/
options?: { label: string; value: any; key: string }[];
fieldset: { [key: string]: ISchema };
/**
* @experimental
*/
view?: ISchema;
scope?: { [key: string]: any };
components?: { [key: string]: any };
Component?(props): JSX.Element;
/**
* @experimental
*/
createDefaultConfig?(): Record<string, any> {
return {};
}
useVariables?(node, options?: UseVariableOptions): VariableOption;
useScopeVariables?(node, options?): VariableOption[];
useInitializers?(node): SchemaInitializerItemType | null;
/**
* @experimental
*/
isAvailable?(ctx: NodeAvailableContext): boolean;
end?: boolean | ((node) => boolean);
}
@ -86,6 +102,7 @@ function useUpdateAction() {
config: form.values,
},
});
form.setInitialValues(toJS(form.values));
ctx.setFormValueChanged(false);
ctx.setVisible(false);
refresh();
@ -99,6 +116,11 @@ export function useNodeContext() {
return useContext(NodeContext);
}
export function useNodeSavedConfig(keys = []) {
const node = useNodeContext();
return keys.some((key) => get(node.config, key) != null);
}
/**
* @experimental
*/
@ -378,6 +400,7 @@ export function NodeDefaultView(props) {
scope={{
...instruction.scope,
useFormProviderProps,
useUpdateAction,
}}
components={instruction.components}
schema={{
@ -477,7 +500,7 @@ export function NodeDefaultView(props) {
'x-component': 'Action',
'x-component-props': {
type: 'primary',
useAction: useUpdateAction,
useAction: '{{ useUpdateAction }}',
},
},
},

View File

@ -24,7 +24,7 @@ import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
import { NAMESPACE } from '../locale';
import { appends, collection, filter, pagination, sort } from '../schemas/collection';
import { WorkflowVariableInput, getCollectionFieldOptions, useGetCollectionFields } from '../variable';
import { Instruction } from '.';
import { Instruction, useNodeSavedConfig } from '.';
import { RadioWithTooltip } from '../components';
function useVariables({ key: name, title, config }, options) {
@ -65,6 +65,7 @@ export default class extends Instruction {
fieldset = {
collection: {
...collection,
'x-disabled': '{{ useNodeSavedConfig(["collection"]) }}',
'x-reactions': [
...collection['x-reactions'],
{
@ -129,6 +130,7 @@ export default class extends Instruction {
},
};
scope = {
useNodeSavedConfig,
useCollectionDataSource,
useSortableFields() {
const compile = useCompile();

View File

@ -7,47 +7,19 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { useField, useForm } from '@formily/react';
import React from 'react';
import { uid } from '@formily/shared';
import { useCollectionDataSource, useCollectionManager_deprecated } from '@nocobase/client';
import { useCollectionDataSource } from '@nocobase/client';
import { isValidFilter } from '@nocobase/utils/client';
import CollectionFieldset from '../components/CollectionFieldset';
import { AssignedFieldsFormSchemaConfig } from '../components/AssignedFieldsFormSchemaConfig';
import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
import { RadioWithTooltip } from '../components/RadioWithTooltip';
import { NAMESPACE, lang } from '../locale';
import { collection, filter, values } from '../schemas/collection';
import { Instruction } from '.';
function IndividualHooksRadioWithTooltip({ onChange, ...props }) {
const { getCollectionFields } = useCollectionManager_deprecated();
const form = useForm();
const { collection } = form.values;
const fields = getCollectionFields(collection);
const field = useField<any>();
function onValueChange({ target }) {
const valuesField = field.query('.values').take();
if (!valuesField) {
return;
}
const filteredValues = fields.reduce((result, item) => {
if (
item.name in valuesField.value &&
(target.value || !['hasOne', 'hasMany', 'belongsToMany'].includes(item.type))
) {
result[item.name] = valuesField.value[item.name];
}
return result;
}, {});
form.setValuesIn('params.values', filteredValues);
onChange(target.value);
}
return <RadioWithTooltip {...props} onChange={onValueChange} />;
}
import { Instruction, useNodeSavedConfig } from '.';
export default class extends Instruction {
title = `{{t("Update record", { ns: "${NAMESPACE}" })}}`;
@ -57,6 +29,7 @@ export default class extends Instruction {
fieldset = {
collection: {
...collection,
'x-disabled': '{{ useNodeSavedConfig(["collection"]) }}',
'x-reactions': [
...collection['x-reactions'],
{
@ -94,7 +67,7 @@ export default class extends Instruction {
type: 'boolean',
title: `{{t("Update mode", { ns: "${NAMESPACE}" })}}`,
'x-decorator': 'FormItem',
'x-component': 'IndividualHooksRadioWithTooltip',
'x-component': 'RadioWithTooltip',
'x-component-props': {
options: [
{
@ -120,21 +93,49 @@ export default class extends Instruction {
},
values: {
...values,
'x-component-props': {
filter(this, field) {
return this.params?.individualHooks || !['hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
'x-reactions': [
{
dependencies: ['collection', 'assignFormSchema'],
fulfill: {
state: {
display: '{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}',
},
},
},
},
],
},
},
},
assignFormSchema: {
type: 'object',
title: '{{t("Fields values")}}',
'x-decorator': 'FormItem',
'x-component': 'AssignedFieldsFormSchemaConfig',
'x-reactions': [
{
dependencies: ['collection'],
fulfill: {
state: {
display: '{{($deps[0] && $self.value) ? "visible" : "hidden"}}',
},
},
},
],
},
};
createDefaultConfig() {
return {
assignForm: uid(),
};
}
scope = {
useCollectionDataSource,
useNodeSavedConfig,
};
components = {
FilterDynamicComponent,
CollectionFieldset,
IndividualHooksRadioWithTooltip,
AssignedFieldsFormSchemaConfig,
RadioWithTooltip,
};
}