2023-02-26 13:10:00 +01:00
|
|
|
import { ModalOptions } from "@ionic/angular";
|
2023-02-25 23:49:59 +01:00
|
|
|
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 {
|
2023-02-25 23:49:59 +01:00
|
|
|
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) => {
|
|
|
|
this.actionHandler({ item: item, destinationItem: destinationItem }, storagehub).subscribe(
|
|
|
|
() => {
|
|
|
|
reload();
|
|
|
|
notify(`${item.getTitle()} copied`);
|
|
|
|
}
|
2023-02-26 13:10:00 +01:00
|
|
|
)
|
|
|
|
}
|
2023-02-25 23:49:59 +01:00
|
|
|
}
|
2023-02-26 16:34:34 +01:00
|
|
|
};
|
2023-02-25 23:49:59 +01:00
|
|
|
}
|
|
|
|
|
2023-02-26 16:34:34 +01:00
|
|
|
|
|
|
|
actionHandler(data: { item: WSItem, destinationItem: WSItem }, storagehub: StoragehubService): Observable<any> {
|
2023-02-26 13:10:00 +01:00
|
|
|
return storagehub.copyItem(data.destinationItem.item.id, data.item.item.id, data.item.item.name);
|
2023-02-25 23:49:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getName(): string {
|
|
|
|
return "Copy";
|
|
|
|
}
|
|
|
|
getActionType(): string | undefined {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|