Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

dialogokcancel.js 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Created by robin on 11/2/15.
  3. */
  4. angular.module('luticateUtils')
  5. .directive('dialogOkCancel', [
  6. function () {
  7. return {
  8. restrict: 'EA',
  9. transclude: true,
  10. templateUrl: '/luticateUtils/dialogokcancel.html',
  11. link: function link($scope, element, attrs) {
  12. $scope.title = attrs.title;
  13. $scope.model = {};
  14. $scope.pending = false;
  15. $scope.submitted = false;
  16. $scope.errorString = "";
  17. $scope.__submit = function()
  18. {
  19. $scope.submitted = true;
  20. $scope.errorString = "";
  21. if ($scope.form.$valid) {
  22. $scope.pending = true;
  23. $scope.promise = $scope.submitForm();
  24. if ($scope.promise)
  25. {
  26. $scope.promise.then(function(data) {
  27. if ($scope.onDone) {
  28. $scope.onDone(data);
  29. }
  30. $scope.$close(data);
  31. $scope.pending = false;
  32. })
  33. .catch(function(error)
  34. {
  35. if ($scope.onError) {
  36. $scope.onError(error);
  37. }
  38. if (error.Data) {
  39. $scope.errorString = error.Data;
  40. }
  41. else {
  42. $scope.errorString = error;
  43. }
  44. $scope.pending = false;
  45. });
  46. }
  47. else {
  48. $scope.$close();
  49. $scope.pending = false;
  50. }
  51. }
  52. };
  53. $scope.__cancel = function()
  54. {
  55. if ($scope.onCanceled) {
  56. $scope.onCanceled();
  57. }
  58. $scope.$dismiss();
  59. $scope.pending = false;
  60. };
  61. }
  62. };
  63. }]);
  64. angular.module("luticateUtils").run(["$templateCache", function($templateCache)
  65. {
  66. $templateCache.put("/luticateUtils/dialogokcancel.html", '<div class="popin modal-content" xmlns="http://www.w3.org/1999/html">' +
  67. '<form name="form" class="form-horizontal" ng-submit="__submit()">' +
  68. '<div class="modal-header">{{ title }}</div>' +
  69. '<div class="modal-body" lu-busy="modal">' +
  70. ' <div class="form-group">' +
  71. ' <ng-transclude></ng-transclude>' +
  72. ' </div>' +
  73. ' <div class="clearfix"></div>' +
  74. ' <span class="error" ng-show="submitted">' +
  75. ' <p class="error">{{ errorString }}</p>' +
  76. '</span>' +
  77. '</div>' +
  78. '<div class="modal-footer">' +
  79. ' <button type="button" class="btn btn-default" ng-click="__cancel()">Cancel</button>' +
  80. ' <button type="submit" class="btn btn-default" ng-enabled="!pending">OK</button>' +
  81. ' </div>' +
  82. ' </form>' +
  83. ' </div>')
  84. }]);