mapping.controller.js
7 years ago
mapping.directive.js
7 years ago
mapping.scss
7 years ago
mapping.tpl.html
7 years ago
mapping.controller.js
34 lines
| 1 | GoogleMerchants.controller('mappingController', ['$scope', function($scope){ |
| 2 | |
| 3 | $scope.show = false; |
| 4 | |
| 5 | $scope.mappingsBackup = null; |
| 6 | |
| 7 | $scope.removeMapping = function(mapping) { |
| 8 | |
| 9 | if($scope.mappings.length > 1) { |
| 10 | $scope.mappings.splice($scope.mappings.indexOf(mapping), 1); |
| 11 | } |
| 12 | }; |
| 13 | |
| 14 | $scope.$watch('show', function(newValue){ |
| 15 | // If we show it, backup the current mappings in case cancel is pressed |
| 16 | if(newValue) { |
| 17 | $scope.mappingsBackup = $scope.mappings; |
| 18 | } |
| 19 | }); |
| 20 | $scope.addMapping = function() { |
| 21 | $scope.mappings.push({}); |
| 22 | }; |
| 23 | |
| 24 | $scope.close = function() { |
| 25 | // Restore mappings |
| 26 | $scope.mappings = $scope.mappingsBackup; |
| 27 | $scope.show = false; |
| 28 | }; |
| 29 | |
| 30 | $scope.saveMappings = function() { |
| 31 | $scope.show = false; |
| 32 | }; |
| 33 | |
| 34 | }]); |