123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /**
- * Created by robin on 11/2/15.
- */
-
- (function () {
- 'use strict';
-
- angular.module('luticateUtils')
- .directive('dialogOkCancel', ['luticateDialogErrorHelper',
- function (luticateDialogErrorHelper) {
- return {
- restrict: 'EA',
- transclude: true,
- templateUrl: '/luticateUtils/dialogokcancel-directive.html',
- link: function link($scope, element, attrs) {
- $scope.title = attrs.title;
- $scope.model = {};
- $scope.pending = false;
- $scope.submitted = false;
-
- $scope.novalidate = attrs.novalidate != undefined ? "" : undefined;
-
- $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-directive.html", '<div class="popin modal-content" xmlns="http://www.w3.org/1999/html">' +
- '<form name="form" ng-submit="__submit()" ng-attr-novalidate="{{novalidate}}">' +
- '<div class="modal-header">{{ title }}</div>' +
- '<div class="modal-body" lu-busy="modal">' +
- ' <div class="form-group form-horizontal">' +
- ' <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>');
- }]);
- })();
|