Upgraded domain picker to access a GeneralIdRef as well as the array
This commit is contained in:
parent
71e19ebc74
commit
d95ba45867
@ -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);
|
||||
}
|
||||
|
||||
@ -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>,
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user