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

View File

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

View File

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