Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
updated base package
Browse files Browse the repository at this point in the history
  • Loading branch information
venespana committed Aug 21, 2019
1 parent 57d43ec commit 6838045
Showing 1 changed file with 40 additions and 23 deletions.
63 changes: 40 additions & 23 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand All @@ -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;
});
}
}
}

0 comments on commit 6838045

Please sign in to comment.