refstack/refstack-ui/app/shared/alerts/confirmModalFactory.js
Paul Van Eck 3c82bc3443 Add vendor UI
This adds the initial UI functionality for the UI in relations
to vendors.

Change-Id: I58a3b00a421d2d65d59014e586bacc974aa8637b
Co-Authored-By: Andrey Pavlov <andrey-mp@yandex.ru>
2016-06-13 15:08:05 -07:00

68 lines
1.8 KiB
JavaScript

(function () {
'use strict';
angular
.module('refstackApp')
.factory('confirmModal', confirmModal);
confirmModal.$inject = ['$uibModal'];
/**
* Opens confirm modal dialog with input textbox
*/
function confirmModal($uibModal) {
return function(text, successHandler) {
$uibModal.open({
templateUrl: '/shared/alerts/confirmModal.html',
controller: 'CustomConfirmModalController as confirmModal',
size: 'md',
resolve: {
data: function () {
return {
text: text,
successHandler: successHandler
};
}
}
});
};
}
angular
.module('refstackApp')
.controller('CustomConfirmModalController',
CustomConfirmModalController);
CustomConfirmModalController.$inject = ['$uibModalInstance', 'data'];
/**
* This is the controller for the alert pop-up.
*/
function CustomConfirmModalController($uibModalInstance, data) {
var ctrl = this;
ctrl.confirm = confirm;
ctrl.cancel = cancel;
ctrl.data = angular.copy(data);
/**
* Initiate confirmation and call the success handler with the
* input text.
*/
function confirm() {
$uibModalInstance.close();
if (angular.isDefined(ctrl.data.successHandler)) {
ctrl.data.successHandler(ctrl.inputText);
}
}
/**
* Close the confirm modal without initiating changes.
*/
function cancel() {
$uibModalInstance.dismiss('cancel');
}
}
})();