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