[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-241-g8dff551

Thomas Sibley trs at bestpractical.com
Tue Nov 6 01:47:58 EST 2012


The branch, 4.0/apply-scrips-to-multiple-queues has been updated
       via  8dff551c9f2ac000d0f25d8715713e55328e47a7 (commit)
       via  d7260f97129b4db07ce8e90e08dfe4fdd6ae70a2 (commit)
       via  d1192a4dbd53843c6cb470be09b29479a10e6324 (commit)
       via  fd4f8ea8a34b5e59d1eca1dbf1a4e242321532fc (commit)
      from  b47d45907946d689e81411b9f80c22182c82d104 (commit)

Summary of changes:
 etc/RT_Config.pm.in                           |  1 +
 share/html/Admin/Scrips/Objects.html          |  4 ++++
 share/html/Elements/ColumnMap                 |  2 +-
 share/html/Elements/RT__CustomField/ColumnMap |  2 +-
 share/html/Elements/RT__Scrip/ColumnMap       |  2 +-
 share/html/Elements/Submit                    |  4 ++--
 share/html/NoAuth/js/event-registration.js    | 15 +++++++++++++++
 share/html/NoAuth/js/util.js                  |  8 ++++++--
 8 files changed, 31 insertions(+), 7 deletions(-)
 create mode 100644 share/html/NoAuth/js/event-registration.js

- Log -----------------------------------------------------------------
commit fd4f8ea8a34b5e59d1eca1dbf1a4e242321532fc
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Nov 5 17:01:44 2012 -0800

    Disable selection of individual objects when "apply globally" is checked
    
    Unapplied scrips and CFs show both an "apply globally" checkbox as well
    as collection lists of available individual objects.  If "apply
    globally" is checked, prevent checking individual objects as well
    before the page is submitted.  The API already prevents both changes
    from going through, so this is simply a bit of icing on the admin
    interface.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 395c724..5b8571f 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -880,6 +880,7 @@ Set(@JSFiles, qw/
     supersubs.js
     jquery.supposition.js
     history-folding.js
+    event-registration.js
     late.js
 /);
 
diff --git a/share/html/NoAuth/js/event-registration.js b/share/html/NoAuth/js/event-registration.js
new file mode 100644
index 0000000..5601459
--- /dev/null
+++ b/share/html/NoAuth/js/event-registration.js
@@ -0,0 +1,15 @@
+jQuery(function() {
+    var global_checkboxes = [
+        "form[name=AddRemoveScrip] input[type=checkbox][name^=AddScrip-][value=0]",
+        "form input[type=checkbox][name^=AddCustomField-][value=0]"
+    ];
+    jQuery(global_checkboxes.join(", "))
+        .change(function(){
+            var self    = jQuery(this);
+            var checked = self.attr("checked");
+
+            self.closest("form")
+                .find("table.collection input[type=checkbox]")
+                .attr("disabled", checked ? "disabled" : "");
+        });
+});

commit d1192a4dbd53843c6cb470be09b29479a10e6324
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Nov 5 22:14:35 2012 -0800

    Turn the apply globally checkbox labels into real clickable <label>s

diff --git a/share/html/Admin/Scrips/Objects.html b/share/html/Admin/Scrips/Objects.html
index 12e6cc4..2f8c333 100644
--- a/share/html/Admin/Scrips/Objects.html
+++ b/share/html/Admin/Scrips/Objects.html
@@ -54,16 +54,20 @@
 
 % if ( $is_global ) {
 <h2><&|/l&>Applies to all objects</&></h2>
+<label>
 <input type="checkbox" name="RemoveScrip-<% $id %>" value="0" />
 <&|/l&>check this box to remove this scrip from all objects and be able to choose specific objects.</&>
+</label>
 % } else {
 <h2><% loc('Stage') %></h2>
 <& /Admin/Elements/SelectStage, Default => $Stage &>
 
 <h2><&|/l&>Apply globally</&></h2>
 
+<label>
 <input type="checkbox" name="AddScrip-<% $id %>" value="0" />
 <&|/l&>check this box to apply this scrip to all objects.</&>
+</label>
 
 <h2><&|/l&>Selected objects</&></h2>
 <& /Elements/CollectionList,

commit d7260f97129b4db07ce8e90e08dfe4fdd6ae70a2
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Nov 5 22:21:25 2012 -0800

    Grab the parent form and checkbox state from the current element in setCheckbox()
    
    This provides more flexibility for setCheckbox() than passing in the
    form and state as arguments themselves.
    
    Desired state may still be passed as the third argument, if necessary,
    as with a button using this function.

diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap
index c649fe6..3cade8c 100644
--- a/share/html/Elements/ColumnMap
+++ b/share/html/Elements/ColumnMap
@@ -119,7 +119,7 @@ my $COLUMN_MAP = {
             my $checked = $m->request_args->{ $name .'All' }? 'checked="checked"': '';
 
             return \qq{<input type="checkbox" name="${name}All" value="1" $checked
-                              onclick="setCheckbox(this.form, '$name', this.checked)" />};
+                              onclick="setCheckbox(this, '$name')" />};
         },
         value => sub {
             my $id = $_[0]->id;
diff --git a/share/html/Elements/RT__CustomField/ColumnMap b/share/html/Elements/RT__CustomField/ColumnMap
index b08353e..426f47d 100644
--- a/share/html/Elements/RT__CustomField/ColumnMap
+++ b/share/html/Elements/RT__CustomField/ColumnMap
@@ -121,7 +121,7 @@ my $COLUMN_MAP = {
             my $checked = $m->request_args->{ $name .'All' }? 'checked="checked"': '';
 
             return \qq{<input type="checkbox" name="${name}All" value="1" $checked
-                              onclick="setCheckbox(this.form, '$name', this.checked)" />};
+                              onclick="setCheckbox(this, '$name')" />};
         },
         value => sub {
             my $id = $_[0]->id;
diff --git a/share/html/Elements/RT__Scrip/ColumnMap b/share/html/Elements/RT__Scrip/ColumnMap
index 25348d2..1975602 100644
--- a/share/html/Elements/RT__Scrip/ColumnMap
+++ b/share/html/Elements/RT__Scrip/ColumnMap
@@ -108,7 +108,7 @@ my $COLUMN_MAP = {
             my $checked = $m->request_args->{ $name .'All' }? 'checked="checked"': '';
 
             return \qq{<input type="checkbox" name="${name}All" value="1" $checked
-                              onclick="setCheckbox(this.form, '$name', this.checked)" />};
+                              onclick="setCheckbox(this, '$name')" />};
         },
         value => sub {
             my $id = $_[0]->id;
diff --git a/share/html/Elements/Submit b/share/html/Elements/Submit
index 6a45714..0baa951 100755
--- a/share/html/Elements/Submit
+++ b/share/html/Elements/Submit
@@ -52,10 +52,10 @@ id="<%$id%>"
 >
   <div class="extra-buttons">
 % if ($CheckAll) {
-  <input type="button" value="<%$CheckAllLabel%>" onclick="setCheckbox(this.form, <% length $CheckboxName ? qq{'$CheckboxName'} : length $CheckboxNameRegex ? $CheckboxNameRegex : q{''} %>, true);return false;" class="button" />
+  <input type="button" value="<%$CheckAllLabel%>" onclick="setCheckbox(this, <% length $CheckboxName ? qq{'$CheckboxName'} : length $CheckboxNameRegex ? $CheckboxNameRegex : q{''} %>, true);return false;" class="button" />
 % }
 % if ($ClearAll) {
-  <input type="button" value="<%$ClearAllLabel%>" onclick="setCheckbox(this.form, <% length $CheckboxName ? qq{'$CheckboxName'} : length $CheckboxNameRegex ? $CheckboxNameRegex : q{''} %>, false);return false;" class="button" />
+  <input type="button" value="<%$ClearAllLabel%>" onclick="setCheckbox(this, <% length $CheckboxName ? qq{'$CheckboxName'} : length $CheckboxNameRegex ? $CheckboxNameRegex : q{''} %>, false);return false;" class="button" />
 % }
 % if ($Reset) {
   <input type="reset" value="<%$ResetLabel%>" class="button" />
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index b1a4a0b..38de298 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -127,7 +127,10 @@ function focusElementById(id) {
     if (e) e.focus();
 }
 
-function setCheckbox(form, name, val) {
+function setCheckbox(input, name, val) {
+    if (val == null) val = input.checked;
+
+    var form    = input.form;
     var myfield = form.getElementsByTagName('input');
     for ( var i = 0; i < myfield.length; i++ ) {
         if ( myfield[i].type != 'checkbox' ) continue;

commit 8dff551c9f2ac000d0f25d8715713e55328e47a7
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Nov 5 22:45:08 2012 -0800

    setCheckbox()es within the closest form _or_ collection list
    
    If input is inside a collection list, we don't want to affect other
    collection lists.
    
    This prevents the checkboxes to apply scrips and CFs from checking the
    "apply globally" checkbox inside the form but outside the collection
    list.

diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 38de298..91be625 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -130,8 +130,9 @@ function focusElementById(id) {
 function setCheckbox(input, name, val) {
     if (val == null) val = input.checked;
 
-    var form    = input.form;
-    var myfield = form.getElementsByTagName('input');
+    // Find inputs within the current form or collection list, whichever is closest.
+    var container = jQuery(input).closest("form, table.collection-as-table").get(0);
+    var myfield   = container.getElementsByTagName('input');
     for ( var i = 0; i < myfield.length; i++ ) {
         if ( myfield[i].type != 'checkbox' ) continue;
         if ( name ) {

-----------------------------------------------------------------------


More information about the Rt-commit mailing list