workspace-ionic-app/src/app/model/actions/copy-item.ts

43 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-02-26 13:10:00 +01:00
import { ModalOptions } from "@ionic/angular";
import { Observable } from "rxjs";
import { StoragehubService } from "src/app/storagehub.service";
import { WsViewerComponent } from "src/app/ws-viewer/ws-viewer.component";
import { WSItem } from "../ws-item";
import { Action } from "./action";
export class CopyAction extends Action {
2023-02-26 16:34:34 +01:00
override getModalOptions(item: WSItem, storagehub: StoragehubService, reload: Function, notify: Function): ModalOptions | undefined {
return {
component: WsViewerComponent,
componentProps: {
finishLabel: "Copy here",
2023-02-26 16:34:34 +01:00
title: "Select destination folder for " + item.getTitle(),
2023-02-26 13:10:00 +01:00
notClickableIds: [item.item.id],
notSelectableIds: [item.item.parentId],
2023-02-26 16:34:34 +01:00
onSelected: (destinationItem: WSItem) => {
2023-03-08 17:13:03 +01:00
this.actionHandler({ item: item, destinationItem: destinationItem }, storagehub).then( (obs) => obs.subscribe(
2023-02-26 16:34:34 +01:00
() => {
2023-03-13 17:39:14 +01:00
reload(destinationItem.item.id)
2023-02-26 16:34:34 +01:00
notify(`${item.getTitle()} copied`);
}
2023-03-08 17:13:03 +01:00
))
2023-02-26 13:10:00 +01:00
}
}
2023-02-26 16:34:34 +01:00
};
}
2023-02-26 16:34:34 +01:00
2023-03-08 17:13:03 +01:00
actionHandler(data: { item: WSItem, destinationItem: WSItem }, storagehub: StoragehubService){
2023-02-26 13:10:00 +01:00
return storagehub.copyItem(data.destinationItem.item.id, data.item.item.id, data.item.item.name);
}
getName(): string {
return "Copy";
}
getActionType(): string | undefined {
return undefined;
}
}