diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-05-08 15:49:21 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-05-08 15:49:21 +0200 |
| commit | 19d62a8cbf2a70491b722c67c5f7e479c613569b (patch) | |
| tree | a3863ff1b48c21dbf6088d33a5f19170270730fe | |
| parent | c5e909da1b83048d0323e9aa5da826c7f1a63fb0 (diff) | |
Add image name edition
| -rw-r--r-- | client/js/controllers/image/edit.js | 28 | ||||
| -rw-r--r-- | client/js/services/Image.js | 6 | ||||
| -rw-r--r-- | client/partials/image/edit.html | 4 |
3 files changed, 25 insertions, 13 deletions
diff --git a/client/js/controllers/image/edit.js b/client/js/controllers/image/edit.js index 60675be..fd52982 100644 --- a/client/js/controllers/image/edit.js +++ b/client/js/controllers/image/edit.js @@ -3,25 +3,33 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload) +mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', '$rootScope', function ($scope, Image, Loading, Identity, upload, $rootScope) { $scope.$on('editImageEvent', function (eventName, image, axioms) { $scope.image = image; + $scope.data = {}; + $scope.data.id = image.id; + + $scope.data.name = image.name; + $scope.data.visibility = image.visibility; + $scope.data.protected = image.protected; + $scope.axioms = axioms; $('#editImageModal').modal('show'); }); $scope.data = {}; - $scope.data.visibility = "public"; - $scope.data.protected = false; - - $scope.applyEdition = function (image) { - image.visibility = $scope.data.visibility; - image.protected = $scope.data.protected; - Image.updateImage(image, function(){}); + + + $scope.applyEdition = function (id) { + Image.updateImage($scope.data, function () { + $rootScope.$broadcast("updateImageEvent"); + $('#editImageModal').modal('hide'); + + }); }; - - $scope.getToken=function(){ + + $scope.getToken = function () { return Identity.getToken(); } }]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index f72de41..6b69f4a 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -63,11 +63,15 @@ mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) { * @returns {undefined} */ var updateImage = function (image, callback) { + console.log(image) + + var result = $http.post('../server/index.php', - $.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': image})); + $.param({"token": Identity.getToken(), "task": "image", 'action': 'updateImage', 'id': image.id, 'opt': {'name': image.name}})); // Wait and handle the response result.then(function (response) { + console.log(response.data.Images) callback(); }, function (response) { alert(response); diff --git a/client/partials/image/edit.html b/client/partials/image/edit.html index c3a7c0c..ce2c7fd 100644 --- a/client/partials/image/edit.html +++ b/client/partials/image/edit.html @@ -16,7 +16,7 @@ <div class="form-group"> <label class="control-label col-sm-2">Name</label> <div class="col-sm-20"> - <input type="text" value="{{ image.name}}" /> + <input type="text" ng-model="data.name" value="{{ image.name}}"/> </div> </div> @@ -50,7 +50,7 @@ <div class="modal-footer"> <!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>--> - <a class="btn btn-lg btn-primary btn-block" ng-click="applyEdition(image)" >Apply</a> + <a class="btn btn-lg btn-primary btn-block" ng-click="applyEdition(image.id)" >Apply</a> </div> </div> |
