From d182202fc6001983541504ed323d68479086317e Mon Sep 17 00:00:00 2001 From: WuKong Date: Sat, 22 Apr 2017 13:25:07 +0200 Subject: add moonv4 Change-Id: I247af788d0b0fb961fbc85416486b241eb1d807c Signed-off-by: WuKong --- .../static/app/pdp/action/pdp.controller.delete.js | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 moonv4/moon_gui/static/app/pdp/action/pdp.controller.delete.js (limited to 'moonv4/moon_gui/static/app/pdp/action/pdp.controller.delete.js') diff --git a/moonv4/moon_gui/static/app/pdp/action/pdp.controller.delete.js b/moonv4/moon_gui/static/app/pdp/action/pdp.controller.delete.js new file mode 100644 index 00000000..62557864 --- /dev/null +++ b/moonv4/moon_gui/static/app/pdp/action/pdp.controller.delete.js @@ -0,0 +1,66 @@ +/** + * @author arnaud marhin + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('PDPDeleteController', PDPDeleteController); + + PDPDeleteController.$inject = ['$scope', '$translate', 'alertService', 'pdpService']; + + function PDPDeleteController($scope, $translate, alertService, pdpService) { + + var del = this; + + /* + * + */ + + del.pdp = $scope.pdp; + del.loading = false; + del.remove = deletePDP; + + /* + * + */ + + function deletePDP() { + del.loading = true; + + pdpService.data.pdp.remove({pdp_id: del.pdp.id}, deleteSuccess, deleteError); + + function deleteSuccess(data) { + + $translate('moon.pdp.remove.success', { pdpName: del.pdp.name }) + .then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:pdpDeletedSuccess', del.pdp); + + } + + function deleteError(reason) { + + $translate('moon.pdp.remove.error', { pdpName: del.pdp.name }) + .then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:pdpDeletedError', del.pdp); + + } + + } + + } + +})(); -- cgit 1.2.3-korg