12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /**
- * Created by robin on 11/2/15.
- */
-
-
- angular.module('luticateUtils')
- .directive('dialogOkCancel', ['luticateDialogErrorHelper',
- function (luticateDialogErrorHelper) {
- return {
- restrict: 'EA',
- transclude: true,
- templateUrl: '/luticateUtils/dialogokcancel.html',
- link: function link($scope, element, attrs) {
- $scope.title = attrs.title;
- $scope.model = {};
- $scope.pending = false;
- $scope.submitted = false;
-
- $scope.__submit = function()
- {
- $scope.submitted = true;
- if ($scope.form.$valid) {
- $scope.pending = true;
- $scope.promise = $scope.submitForm();
- if ($scope.promise)
- {
- $scope.promise.then(function(data) {
- if ($scope.onDone) {
- $scope.onDone(data);
- }
- $scope.$close(data);
- $scope.pending = false;
- })
- .catch(function(error)
- {
- if ($scope.onError) {
- $scope.onError(error);
- }
- luticateDialogErrorHelper.errorDialog(error)
- .result.then(function(data)
- {
- }, function(error2)
- {
- $scope.$dismiss(error);
- });
- $scope.pending = false;
- });
- }
- else {
- $scope.$close();
- $scope.pending = false;
- }
- }
- };
-
- $scope.__cancel = function()
- {
- if ($scope.onCanceled) {
- $scope.onCanceled();
- }
- $scope.$dismiss();
- $scope.pending = false;
- };
- }
- };
- }]);
-
- angular.module("luticateUtils").run(["$templateCache", function($templateCache)
- {
- $templateCache.put("/luticateUtils/dialogokcancel.html", '<div class="popin modal-content" xmlns="http://www.w3.org/1999/html">' +
- '<form name="form" class="form-horizontal" ng-submit="__submit()">' +
- '<div class="modal-header">{{ title }}</div>' +
- '<div class="modal-body" lu-busy="modal">' +
- ' <div class="form-group">' +
- ' <ng-transclude></ng-transclude>' +
- ' </div>' +
- ' <div class="clearfix"></div>' +
- /*' <span class="error" ng-show="submitted">' +
- ' <p class="error">{{ errorString }}</p>' +
- '</span>' +*/
- '</div>' +
- '<div class="modal-footer">' +
- ' <button type="button" class="btn btn-inverse" ng-click="__cancel()">Cancel</button>' +
- ' <button type="submit" class="btn btn-primary" ng-enabled="!pending">OK</button>' +
- ' </div>' +
- ' </form>' +
- ' </div>')
- }]);
|