Matteo Scandolo | 388795a | 2016-02-22 09:57:55 -0800 | [diff] [blame] | 1 | (function () { |
| 2 | 'use strict'; |
Matteo Scandolo | 0456495 | 2016-02-24 11:22:48 -0800 | [diff] [blame] | 3 | angular.module('xos.diagnostic') |
Matteo Scandolo | 574c73f | 2016-03-01 17:08:45 -0800 | [diff] [blame] | 4 | .directive('selectSubscriberModal', function(){ |
Matteo Scandolo | 388795a | 2016-02-22 09:57:55 -0800 | [diff] [blame] | 5 | return { |
| 6 | scope: { |
| 7 | subscribers: '=', |
| 8 | open: '=' |
| 9 | }, |
| 10 | bindToController: true, |
| 11 | restrict: 'E', |
Matteo Scandolo | 574c73f | 2016-03-01 17:08:45 -0800 | [diff] [blame] | 12 | templateUrl: 'templates/select-subscriber-modal.tpl.html', |
Matteo Scandolo | 388795a | 2016-02-22 09:57:55 -0800 | [diff] [blame] | 13 | controllerAs: 'vm', |
| 14 | controller: function($rootScope){ |
| 15 | |
| 16 | this.close = () => { |
| 17 | this.open = false; |
| 18 | }; |
| 19 | |
| 20 | this.select = (subscriber) => { |
| 21 | $rootScope.$emit('subscriber.selected', subscriber); |
| 22 | this.close(); |
| 23 | }; |
| 24 | } |
| 25 | }; |
Matteo Scandolo | 574c73f | 2016-03-01 17:08:45 -0800 | [diff] [blame] | 26 | }) |
| 27 | .directive('subscriberStatusModal', function(){ |
| 28 | return { |
| 29 | scope: { |
| 30 | open: '=', |
| 31 | subscriber: '=' |
| 32 | }, |
| 33 | bindToController: true, |
| 34 | restrict: 'E', |
| 35 | templateUrl: 'templates/subscriber-status-modal.tpl.html', |
| 36 | controllerAs: 'vm', |
| 37 | controller: function($log, $scope){ |
| 38 | |
| 39 | // mock until api |
| 40 | $scope.$watch(() => this.subscriber, (subscriber) => { |
| 41 | if(subscriber){ |
| 42 | subscriber.status = 'enabled'; |
| 43 | } |
| 44 | }); |
| 45 | |
| 46 | this.close = () => { |
| 47 | this.open = false; |
| 48 | }; |
| 49 | |
| 50 | this.setStatus = (status) => { |
| 51 | this.subscriber.status = status; |
| 52 | $log.info(`Set subscriber status to: ${status}`); |
| 53 | }; |
| 54 | } |
| 55 | }; |
Matteo Scandolo | 388795a | 2016-02-22 09:57:55 -0800 | [diff] [blame] | 56 | }); |
| 57 | })(); |