LP#1622696 Prompt dialog format and promise repairs
authorBill Erickson <berickxx@gmail.com>
Thu, 21 Sep 2017 15:53:11 +0000 (11:53 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Sep 2017 15:57:57 +0000 (11:57 -0400)
Improve egPromptDialog formatting by wrapping the column div in a row
div.  This helps the text input site nicely in the middle of the dialog
without overlaps.

Allow for the creation of egPromptDialog without a user-defined scope.

Pass the result of an egPromptDialog to the dialog resolver in addition
to the optional user-defined scope.ok function.

The 2 above changes reduce the amount of boilerplate code required to
collect the dialog value.  For example:

egPromptDialog.open(msg, default_val).result
    .then(function(prompt_value) { ... });

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/share/t_prompt_dialog.tt2
Open-ILS/web/js/ui/default/staff/services/ui.js

index 9581bcc..6fa9e5b 100644 (file)
@@ -8,8 +8,11 @@
     <h4 class="modal-title alert alert-info">{{message}}</h4> 
   </div>
   <div class="modal-body">
-    <div class="col-md-12">
-      <input ng-keyup="$event.keyCode == 13 ? ok() : null" type='text' ng-model="args.value" class="form-control" focus-me="focus"/>
+    <div class="row">
+      <div class="col-md-12">
+        <input ng-keyup="$event.keyCode == 13 ? ok() : null" type='text' 
+          ng-model="args.value" class="form-control" focus-me="focus"/>
+      </div>
     </div>
   </div>
   <div class="modal-footer">
index 0c385fa..27c97ca 100644 (file)
@@ -441,6 +441,7 @@ function($uibModal, $interpolate) {
     var service = {};
 
     service.open = function(message, promptValue, msg_scope) {
+        msg_scope = msg_scope || {};
         return $uibModal.open({
             templateUrl: './share/t_prompt_dialog',
             controller: ['$scope', '$uibModalInstance',
@@ -450,7 +451,7 @@ function($uibModal, $interpolate) {
                     $scope.focus = true;
                     $scope.ok = function() {
                         if (msg_scope.ok) msg_scope.ok($scope.args.value);
-                        $uibModalInstance.close()
+                        $uibModalInstance.close($scope.args.value)
                     }
                     $scope.cancel = function() {
                         if (msg_scope.cancel) msg_scope.cancel();