From 6838045d27391ba8727a92125b94a8e6197299b8 Mon Sep 17 00:00:00 2001 From: Alejandro de Tovar Date: Wed, 21 Aug 2019 12:15:48 +0200 Subject: [PATCH] updated base package --- src/app/app.component.ts | 63 +++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f36172b..0140740 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -56,6 +56,8 @@ export class AppComponent implements OnInit { default = true; action: ActionModel | null = null; + reset = false; + private pagerSchema: PagerModelSchema = { total: 'total', currentPage: 'current_page', @@ -152,6 +154,13 @@ export class AppComponent implements OnInit { ); } + resetDam() { + this.reset = true; + setTimeout(() => { + this.reset = false; + }, 250); + } + deleteItem(item: Item) { this.mainService .delete(item) @@ -170,31 +179,39 @@ export class AppComponent implements OnInit { const action = new ActionModel(data); let actionType = null; - if (action.method === 'show') { - actionType = this.mainService.getResource(action); + if (action.method === 'select') { + action.status = 'success'; + setTimeout(() => { + alert(`Selectd item ${action.item.title}`); + this.action = action; + }, 2500); } else { - actionType = this.mainService.saveForm(action); - } + if (action.method === 'show') { + actionType = this.mainService.getResource(action); + } else { + actionType = this.mainService.saveForm(action); + } - actionType - .subscribe( - ({ result }) => { - const { data } = result as any; - action.data = data; - action.status = 'success'; - }, - ({ error, message, statusText }) => { - action.status = 'fail'; - if (hasIn('errors', error)) { - action.errors = error.errors; + actionType + .subscribe( + ({ result }) => { + const { data } = result as any; + action.data = data; + action.status = 'success'; + }, + ({ error, message, statusText }) => { + action.status = 'fail'; + if (hasIn('errors', error)) { + action.errors = error.errors; + } } - } - ) - .add(() => { - if (action.method !== 'show') { - this.getItems(); - } - this.action = action; - }); + ) + .add(() => { + if (action.method !== 'show') { + this.getItems(); + } + this.action = action; + }); + } } }