webstaff: teach egConfirmDialog how to set custom labels for buttons
authorGalen Charlton <gmc@esilibrary.com>
Thu, 24 Sep 2015 18:33:58 +0000 (18:33 +0000)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:46 +0000 (14:58 -0500)
egConfirmDialog() now accepts optional fourth and fifth
arguments to set custom labels for the "OK" and "cancel"
buttons.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/share/t_confirm_dialog.tt2
Open-ILS/web/js/ui/default/staff/services/ui.js

index 45e8ca1..a9d6ac1 100644 (file)
@@ -11,8 +11,8 @@
   <div class="modal-footer">
     [% dialog_footer %]
     <input type="submit" class="btn btn-primary" 
-      ng-click="ok()" value="[% l('OK/Continue') %]"/>
+      ng-click="ok()" value="{{ ok_button_label || '[% l('OK/Continue') %]'}}"/>
     <button class="btn btn-warning" 
-      ng-click="cancel()">[% l('Cancel') %]</button>
+      ng-click="cancel()">{{ cancel_button_label || "[% l('Cancel') %]"}}</button>
   </div>
 </div>
index 4960317..5264d68 100644 (file)
@@ -109,7 +109,8 @@ function($modal , $interpolate) {
 
 /**
  * egConfirmDialog.open("some message goes {{here}}", {
- *  here : 'foo', ok : function() {}, cancel : function() {}});
+ *  here : 'foo', ok : function() {}, cancel : function() {}},
+ *  'OK', 'Cancel');
  */
 .factory('egConfirmDialog', 
     
@@ -117,13 +118,15 @@ function($modal , $interpolate) {
 function($modal, $interpolate) {
     var service = {};
 
-    service.open = function(title, message, msg_scope) {
+    service.open = function(title, message, msg_scope, ok_button_label, cancel_button_label) {
         return $modal.open({
             templateUrl: './share/t_confirm_dialog',
             controller: ['$scope', '$modalInstance',
                 function($scope, $modalInstance) {
                     $scope.title = $interpolate(title)(msg_scope);
                     $scope.message = $interpolate(message)(msg_scope);
+                    $scope.ok_button_label = $interpolate(ok_button_label || '')(msg_scope);
+                    $scope.cancel_button_label = $interpolate(cancel_button_label || '')(msg_scope);
                     $scope.ok = function() {
                         if (msg_scope.ok) msg_scope.ok();
                         $modalInstance.close()