Upgraded domain picker to access a GeneralIdRef as well as the array

This commit is contained in:
Colin Dawson 2026-02-15 23:52:07 +00:00
parent 71e19ebc74
commit d95ba45867
3 changed files with 18 additions and 12 deletions

View File

@ -11,7 +11,7 @@ interface DomainPickerProps {
name: string;
label: string;
error?: string;
values: CustomFieldValue[];
values: CustomFieldValue[] | GeneralIdRef;
minEntries?: number;
maxEntries?: number;
includeBlankFirstEntry?: boolean;
@ -47,10 +47,17 @@ export default function DomainPicker({
const selected: Option[] = [];
if (values) {
for (const option of values) {
if (Array.isArray(values)) {
for (const option of values as CustomFieldValue[]) {
const foundOption = opts.filter(
(x) =>
Number(x._id) === Number((option.value as GeneralIdRef).id),
)[0];
if (foundOption) selected.push(foundOption);
}
} else {
const foundOption = opts.filter(
(x) =>
Number(x._id) === Number((option.value as GeneralIdRef).id),
(x) => Number(x._id) === Number((values as GeneralIdRef).id),
)[0];
if (foundOption) selected.push(foundOption);
}

View File

@ -18,8 +18,7 @@ import {
} from "../../../components/common/formHelpers";
import ErrorBlock from "../../../components/common/ErrorBlock";
import authentication from "../../frame/services/authenticationService";
import { MakeGeneralIdRef } from "../../../utils/GeneralIdRef";
import { CustomFieldValue } from "../glossary/services/glossaryService";
import { GeneralIdRef, MakeGeneralIdRef } from "../../../utils/GeneralIdRef";
import TasksTab from "./components/TasksTab";
import { useFormWithGuard } from "../../../components/common/useFormRouter";
@ -39,7 +38,7 @@ const WorkflowTemplateDetails: React.FC<{ editMode: boolean }> = ({
loaded: false,
data: {
name: "",
domainId: [] as CustomFieldValue[],
domainId: {} as GeneralIdRef,
activityNameTemplate: "",
description: "",
tasks: [] as TaskDefinition[],
@ -87,9 +86,7 @@ const WorkflowTemplateDetails: React.FC<{ editMode: boolean }> = ({
}
} else {
const user = authentication.getCurrentUser();
newData.domainId = [
{ value: MakeGeneralIdRef(user?.domainid) } as CustomFieldValue,
];
newData.domainId = MakeGeneralIdRef(user?.domainid);
}
form.setState({ ...form.state, loaded: true, data: newData });
@ -182,7 +179,9 @@ const WorkflowTemplateDetails: React.FC<{ editMode: boolean }> = ({
errors={errors}
isEditMode={editMode}
onFieldChange={form.handleChange}
handleDomainPickerChange={form.handleDomainPickerChange}
handleDomainPickerChange={(name, values) =>
form.handlePickerChange(name, values[0].value)
}
/>
</Tab>,

View File

@ -35,7 +35,7 @@ export interface TaskDefinition<TConfig = Record<string, unknown>> {
export interface CreateWorkflowTemplateVersion extends FormData {
name: string;
domainId: CustomFieldValue[];
domainId: GeneralIdRef;
activityNameTemplate: string;
description: string;