import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
-import { initProjectsTreePicker } from '../tree-picker/tree-picker-actions';
+import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
export const COLLECTION_MOVE_FORM_NAME = 'collectionMoveFormName';
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
export const COLLECTION_PARTIAL_COPY_FORM_NAME = 'COLLECTION_PARTIAL_COPY_DIALOG';
};
dispatch(initialize(COLLECTION_PARTIAL_COPY_FORM_NAME, initialData));
dispatch<any>(resetPickerProjectTree());
+ dispatch<any>(initProjectsTreePicker(COLLECTION_PARTIAL_COPY_FORM_NAME));
dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME, data: {} }));
}
};
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
-import { initProjectsTreePicker } from '../tree-picker/tree-picker-actions';
+import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
export const PROJECT_MOVE_FORM_NAME = 'projectMoveFormName';
import * as React from 'react';
+export interface PickerIdProp {
+ pickerId: string;
+}
+
export const pickerId =
(id: string) =>
- <P extends { pickerId: string }>(Component: React.ComponentType<P>) =>
+ <P extends PickerIdProp>(Component: React.ComponentType<P>) =>
(props: P) =>
<Component {...props} pickerId={id} />;
\ No newline at end of file
// SPDX-License-Identifier: AGPL-3.0
import * as React from "react";
+import { memoize } from "lodash/fp";
import { FormDialog } from '~/components/form-dialog/form-dialog';
import { CollectionNameField, CollectionDescriptionField, CollectionProjectPickerField } from '~/views-components/form-fields/collection-form-fields';
import { WithDialogProps } from '~/store/dialog/with-dialog';
import { InjectedFormProps } from 'redux-form';
import { CollectionPartialCopyFormData } from '~/store/collections/collection-partial-copy-actions';
+import { PickerIdProp } from "~/store/tree-picker/picker-id";
type DialogCollectionPartialCopyProps = WithDialogProps<string> & InjectedFormProps<CollectionPartialCopyFormData>;
-export const DialogCollectionPartialCopy = (props: DialogCollectionPartialCopyProps) =>
+export const DialogCollectionPartialCopy = (props: DialogCollectionPartialCopyProps & PickerIdProp) =>
<FormDialog
dialogTitle='Create a collection'
- formFields={CollectionPartialCopyFields}
+ formFields={CollectionPartialCopyFields(props.pickerId)}
submitLabel='Create a collection'
{...props}
/>;
-export const CollectionPartialCopyFields = () => <div>
- <CollectionNameField />
- <CollectionDescriptionField />
- <CollectionProjectPickerField />
-</div>;
+export const CollectionPartialCopyFields = memoize(
+ (pickerId: string) =>
+ () =>
+ <div>
+ <CollectionNameField />
+ <CollectionDescriptionField />
+ <CollectionProjectPickerField {...{ pickerId }} />
+ </div>);
import { COPY_NAME_VALIDATION, COPY_FILE_VALIDATION } from '~/validators/validators';
import { TextField } from "~/components/text-field/text-field";
import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
+import { PickerIdProp } from '~/store/tree-picker/picker-id';
type CopyFormDialogProps = WithDialogProps<string> & InjectedFormProps<CopyFormDialogData>;
-export const DialogCopy = (props: CopyFormDialogProps & { pickerId: string }) =>
+export const DialogCopy = (props: CopyFormDialogProps & PickerIdProp) =>
<FormDialog
dialogTitle='Make a copy'
formFields={CopyDialogFields(props.pickerId)}
import { withDialog, } from '~/store/dialog/with-dialog';
import { CollectionPartialCopyFormData, copyCollectionPartial, COLLECTION_PARTIAL_COPY_FORM_NAME } from '~/store/collections/collection-partial-copy-actions';
import { DialogCollectionPartialCopy } from "~/views-components/dialog-copy/dialog-collection-partial-copy";
+import { pickerId } from "~/store/tree-picker/picker-id";
export const PartialCopyCollectionDialog = compose(
onSubmit: (data, dispatch) => {
dispatch(copyCollectionPartial(data));
}
- }))(DialogCollectionPartialCopy);
\ No newline at end of file
+ }),
+ pickerId(COLLECTION_PARTIAL_COPY_FORM_NAME),
+)(DialogCollectionPartialCopy);
\ No newline at end of file
import { ProjectTreePickerField } from '~/views-components/project-tree-picker/project-tree-picker';
import { MOVE_TO_VALIDATION } from '~/validators/validators';
import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
+import { PickerIdProp } from "~/store/tree-picker/picker-id";
-export const DialogMoveTo = (props: WithDialogProps<string> & InjectedFormProps<MoveToFormDialogData> & { pickerId: string }) =>
+export const DialogMoveTo = (props: WithDialogProps<string> & InjectedFormProps<MoveToFormDialogData> & PickerIdProp) =>
<FormDialog
dialogTitle='Move to'
formFields={MoveToDialogFields(props.pickerId)}
import { Field, WrappedFieldProps } from "redux-form";
import { TextField } from "~/components/text-field/text-field";
import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION } from "~/validators/validators";
-import { ProjectTreePicker } from "~/views-components/project-tree-picker/project-tree-picker";
+import { ProjectTreePicker, ProjectTreePickerField } from "~/views-components/project-tree-picker/project-tree-picker";
+import { PickerIdProp } from '../../store/tree-picker/picker-id';
export const CollectionNameField = () =>
<Field
validate={COLLECTION_DESCRIPTION_VALIDATION}
label="Description - optional" />;
-export const CollectionProjectPickerField = () =>
+export const CollectionProjectPickerField = (props: PickerIdProp) =>
<Field
name="projectUuid"
- component={ProjectPicker}
+ pickerId={props.pickerId}
+ component={ProjectTreePickerField}
validate={COLLECTION_PROJECT_VALIDATION} />;
-
-const ProjectPicker = (props: WrappedFieldProps) =>
- <div style={{ height: '144px', display: 'flex', flexDirection: 'column' }}>
- <ProjectTreePicker onChange={projectUuid => props.input.onChange(projectUuid)} />
- </div>;
import { TreePickerId } from '~/models/tree';
import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker';
import { ProjectsTreePickerItem } from '~/views-components/projects-tree-picker/generic-projects-tree-picker';
+import { PickerIdProp } from '~/store/tree-picker/picker-id';
type ProjectTreePickerProps = Pick<TreePickerProps<ProjectResource>, 'onContextMenu' | 'toggleItemActive' | 'toggleItemOpen' | 'toggleItemSelection'>;
isActive={item.active}
hasMargin={true} />;
-export const ProjectTreePickerField = (props: WrappedFieldProps & { pickerId: string }) =>
+export const ProjectTreePickerField = (props: WrappedFieldProps & PickerIdProp) =>
<div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
<ProjectsTreePicker
pickerId={props.pickerId}
const handleChange = (props: WrappedFieldProps) =>
(_: any, { id }: TreeItem<ProjectsTreePickerItem>) =>
- props.input.value === id
- ? props.input.onChange('')
- : props.input.onChange(id);
+ props.input.onChange(id);