export const COLLECTION_MULTI_COPY_FORM_NAME = "collectionMultiCopyFormName";
export const openCollectionCopyDialog = (resource: { name: string; uuid: string; isSingle?: boolean }) => (dispatch: Dispatch) => {
- //here
dispatch<any>(resetPickerProjectTree());
dispatch<any>(initProjectsTreePicker(COLLECTION_COPY_FORM_NAME));
const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, isSingle: resource.isSingle };
};
export const openMultiCollectionCopyDialog = (resource: { name: string; uuid: string; isSingle?: boolean }) => (dispatch: Dispatch) => {
- //here
dispatch<any>(resetPickerProjectTree());
dispatch<any>(initProjectsTreePicker(COLLECTION_MULTI_COPY_FORM_NAME));
const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, isSingle: resource.isSingle };
export const copyCollection =
(resource: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- console.log("IN COPY COLLECTION", resource);
const formName = resource.isSingle ? COLLECTION_COPY_FORM_NAME : COLLECTION_MULTI_COPY_FORM_NAME;
- dispatch(startSubmit(COLLECTION_COPY_FORM_NAME));
+ dispatch(startSubmit(formName));
let collection = getResource<CollectionResource>(resource.uuid)(getState().resources);
try {
if (!collection) {
.filter(resource => resource.kind === ResourceKind.COLLECTION);
for (const collection of collectionsToCopy) {
- await copySingleCollection(collection as CollectionCopyResource);
+ await copySingleCollection({ ...collection, ownerUuid: data.ownerUuid } as CollectionCopyResource);
}
async function copySingleCollection(copyToProject: CollectionCopyResource) {
icon: CopyIcon,
name: "Make a copy",
execute: (dispatch, resources) => {
- console.log(resources[0]);
- //here fix single vs one
if (resources[0].isSingle) dispatch<any>(openCollectionCopyDialog(resources[0]));
else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
},
component: ToggleTrashAction,
name: "ToggleTrashAction",
execute: (dispatch, resources: ContextMenuResource[]) => {
- //here fix multi?
resources.forEach(resource => dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!)));
},
},
type CopyFormDialogProps = WithDialogProps<string> & InjectedFormProps<CopyFormDialogData>;
export const DialogCopy = (props: CopyFormDialogProps & PickerIdProp) => {
- console.log("single dialog copy", props);
-
return (
<FormDialog
dialogTitle="Make a copy"
));
export const DialogMultiCopy = (props: CopyFormDialogProps & PickerIdProp) => {
- console.log("multi dialog copy", props);
-
return (
<FormDialog
dialogTitle="Make a copy"
form: COLLECTION_COPY_FORM_NAME,
touchOnChange: true,
onSubmit: (data, dispatch) => {
- console.log("DATA main", data);
dispatch(copyCollection(data));
},
}),
form: COLLECTION_MULTI_COPY_FORM_NAME,
touchOnChange: true,
onSubmit: (data, dispatch) => {
- console.log("DATA main", data);
dispatch(copyCollection(data));
},
}),