[Rt-commit] rt branch, 4.0/cf-category-filter-render-type-list, created. rt-4.0.5-82-gd412ff2

? sunnavy sunnavy at bestpractical.com
Sat Mar 10 13:32:56 EST 2012


The branch, 4.0/cf-category-filter-render-type-list has been created
        at  d412ff29bcc6538c046cb6a0a5d2813bb0222f18 (commit)

- Log -----------------------------------------------------------------
commit d00433dd1664f6694c3a939b074099fb3b774b37
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Mar 11 02:16:14 2012 +0800

    filter render type "List" for cfs with category

diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index b3fefbd..e2ef814 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -94,17 +94,21 @@ jQuery(  function () {
 
 % if ( $RenderType eq 'List' ) {
 <fieldset class="cfedit">
+<div name="<%$id%>-Values" id="<%$id%>-Values">
 %   if ( $checktype eq 'radio' ) {
-  <input type="<% $checktype %>" name="<% $name %>" id="<% $name %>-none" value="" <% keys %default ? '' : ' checked="checked"' |n%> />
+  <input class="none" type="<% $checktype %>" name="<% $name %>" id="<% $name %>-none" value="" <% keys %default ? '' : ' checked="checked"' |n%> />
   <label for="<% $name %>-none"><&|/l&>(no value)</&></label><br />
 %   }
 %   my $CFVs = $CustomField->Values;
 %   while ( my $value = $CFVs->Next ) {
 %     my $content = $value->Name;
 %     my $labelid = "$name-". $value->id;
+<div name="<% $value->Category %>">
   <input type="<% $checktype %>" name="<% $name %>" id="<% $labelid %>" value="<% $content %>" <% $default{ lc $content }? ' checked="checked"' : '' |n%> />
   <label for="<% $labelid %>"><% $content %></label><br />
+</div>
 %   }
+</div>
 </fieldset>
 % } else {
 <select
diff --git a/share/html/NoAuth/js/cascaded.js b/share/html/NoAuth/js/cascaded.js
index fb20b32..6ce0a3d 100644
--- a/share/html/NoAuth/js/cascaded.js
+++ b/share/html/NoAuth/js/cascaded.js
@@ -46,6 +46,30 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 function filter_cascade (id, val) {
+    var element = document.getElementById(id);
+    if (!element) { return };
+
+    if ( element.tagName == 'SELECT' ) {
+        return filter_cascade_select.apply(this, arguments);
+    }
+    else {
+        // it's checkbox or radio
+        if ( val == '' && arguments.length == 3 ) {
+            // no category, and the category is from a hierchical cf;
+            // leave it empty
+            jQuery(element).find('input').attr('disabled', 'disabled').hide();
+        }
+        else if ( val == '' ) {
+            jQuery(element).find('div').show().find('input:disabled').attr('disabled', '');
+        }
+        else {
+            jQuery(element).find('div').hide().find('input').attr('disabled', 'disabled');
+            jQuery(element).find('div[name^=' + val + ']').show().find('input').attr('disabled', '');
+        }
+    }
+}
+
+function filter_cascade_select (id, val) {
     var select = document.getElementById(id);
     var complete_select = document.getElementById(id + "-Complete" );
 

commit d412ff29bcc6538c046cb6a0a5d2813bb0222f18
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Mar 11 02:20:00 2012 +0800

    hidden select is useless if render type is "List"

diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index e2ef814..1a28742 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -83,14 +83,6 @@ jQuery(  function () {
 });
 --></script>
 % }
-% if (@category) {
-%# this hidden select is to supply a full list of values,
-%# see filter_cascade() in js/cascaded.js
-      <select name="<%$id%>-Values-Complete" id="<%$id%>-Values-Complete" class="hidden" disabled="disabled">
-        <option value=""<% !$selected && qq[ selected="selected"] |n %>><&|/l&>(no value)</&></option>
-%       $m->out($out);
-      </select>
-% }
 
 % if ( $RenderType eq 'List' ) {
 <fieldset class="cfedit">
@@ -111,6 +103,14 @@ jQuery(  function () {
 </div>
 </fieldset>
 % } else {
+% if (@category) {
+%# this hidden select is to supply a full list of values,
+%# see filter_cascade() in js/cascaded.js
+      <select name="<%$id%>-Values-Complete" id="<%$id%>-Values-Complete" class="hidden" disabled="disabled">
+        <option value=""<% !$selected && qq[ selected="selected"] |n %>><&|/l&>(no value)</&></option>
+%       $m->out($out);
+      </select>
+% }
 <select
   name="<%$id%>-Values" id="<%$id%>-Values" class="CF-<%$CustomField->id%>-Edit"
 % if ( $Rows && ( $Multiple || !@category ) ) {

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


More information about the Rt-commit mailing list