Max Chu | 3c8b65f | 2017-07-19 17:47:59 -0700 | [diff] [blame] | 1 | let self; |
| 2 | |
| 3 | class ElineSide { |
| 4 | |
| 5 | static $inject = ['XosSidePanel', 'XosModelStore', '$http', '$log', 'toastr']; |
| 6 | |
| 7 | constructor( |
| 8 | private XosSidePanel: any, |
| 9 | private XosModelStore: any, |
| 10 | private $http: any, |
| 11 | private $log: any, |
| 12 | private toastr: any, |
| 13 | ) { |
| 14 | self = this; |
| 15 | } |
| 16 | |
| 17 | public saveEline(item: any) { |
| 18 | let path = item.path; |
| 19 | delete item.path; |
| 20 | item.$save().then((res) => { |
| 21 | item.path = path; |
| 22 | this.toastr.success(`${item.name} successfully saved!`); |
| 23 | }) |
| 24 | .catch((error) => { |
| 25 | this.toastr.error(`Error while saving ${item.name}: ${error.specific_error}`); |
| 26 | }); |
| 27 | } |
| 28 | |
Max Chu | dafc0ba | 2017-08-15 11:03:09 -0700 | [diff] [blame] | 29 | public deleteEline(item: any) { |
| 30 | let name = item.name; |
| 31 | item.$delete().then((res) => { |
| 32 | this.toastr.success(`${name} successfully deleted!`); |
| 33 | }) |
| 34 | .catch((error) => { |
| 35 | this.toastr.error(`Error while deleting ${name}: ${error.specific_error}`); |
| 36 | }); |
| 37 | } |
Max Chu | 3c8b65f | 2017-07-19 17:47:59 -0700 | [diff] [blame] | 38 | |
| 39 | } |
| 40 | |
| 41 | export const elineSide: angular.IComponentOptions = { |
| 42 | template: require('./eline-side.component.html'), |
| 43 | controllerAs: 'vm', |
| 44 | controller: ElineSide, |
| 45 | bindings: { |
| 46 | mng: '=' |
| 47 | } |
| 48 | }; |