reload on operation added
This commit is contained in:
parent
86b7c21ebb
commit
3d90d19358
|
@ -1,14 +1,15 @@
|
|||
import { AlertOptions } from "@ionic/angular";
|
||||
import { title } from "process";
|
||||
import { Observable } from "rxjs";
|
||||
import { StoragehubService } from "../storagehub.service";
|
||||
import { Item } from "./item.model";
|
||||
import { WSItem } from "./ws-item";
|
||||
|
||||
export interface Action {
|
||||
|
||||
getAlertOptions(item: WSItem, storagehub: StoragehubService): AlertOptions;
|
||||
getAlertOptions(item: WSItem, storagehub: StoragehubService, postOp?: Function): AlertOptions;
|
||||
|
||||
actionHandler(data: any, storagehub: StoragehubService): any;
|
||||
actionHandler(data: any, storagehub: StoragehubService): Observable<any>;
|
||||
|
||||
getName(): string;
|
||||
|
||||
|
@ -19,7 +20,7 @@ export interface Action {
|
|||
|
||||
export class DeleteAction implements Action {
|
||||
|
||||
getAlertOptions(item: WSItem, storagehub: StoragehubService): AlertOptions {
|
||||
getAlertOptions(item: WSItem, storagehub: StoragehubService, reload: Function): AlertOptions {
|
||||
var title = item.getTitle();
|
||||
var options: AlertOptions = {
|
||||
header: `Are you sure to delete item ${title} ?`,
|
||||
|
@ -30,15 +31,17 @@ export class DeleteAction implements Action {
|
|||
{
|
||||
text: 'Yes',
|
||||
handler: () => {
|
||||
this.actionHandler(item, storagehub);
|
||||
this.actionHandler(item, storagehub).subscribe(
|
||||
reload()
|
||||
);
|
||||
}
|
||||
}]
|
||||
};
|
||||
return options;
|
||||
|
||||
}
|
||||
actionHandler(data: WSItem, storagehub: StoragehubService) {
|
||||
storagehub.deleteItem(data.item.id).subscribe((res) =>console.log(`item ${data.getTitle()} deleted`) );
|
||||
actionHandler(data: WSItem, storagehub: StoragehubService): Observable<any> {
|
||||
return storagehub.deleteItem(data.item.id);
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
|
|
|
@ -149,11 +149,11 @@ export class ShowFolderComponent implements OnInit {
|
|||
}
|
||||
|
||||
async actionHandler(action: Action, item: WSItem){
|
||||
var options: AlertOptions = action.getAlertOptions(item, this.storagehub);
|
||||
var options: AlertOptions = action.getAlertOptions(item, this.storagehub, () => {this.loadDocuments()});
|
||||
if (options){
|
||||
await this.presentAlertControl(options);
|
||||
}else
|
||||
await action.actionHandler(item, this.storagehub);
|
||||
action.actionHandler(item, this.storagehub);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue