[Rt-commit] rt branch, 4.2/scrip-custom-code-textareas-visible-only-when-needed, repushed

Dustin Collins strega at bestpractical.com
Wed Aug 31 17:47:09 EDT 2016


The branch 4.2/scrip-custom-code-textareas-visible-only-when-needed was deleted and repushed:
       was ab55e15efcb873e70c59e3c7a86f2d5f5ba9c0fc
       now f00328ba497506a6c05a53129bfdcf24458e2913

1:  ab55e15 ! 1:  f00328b Hide scrip custom code fields when appropriate
    @@ -1,17 +1,44 @@
     Author: Dustin Collins <strega at bestpractical.com>
     
    -    Scrip custom code textures are now visible only for 'User Defined' condition and action.
    -    
    -    Fixes I#32260
    +    Hide scrip custom code fields when appropriate
    +    
    +    The textareas for condition, action prepare, and action commit code
    +    only make sense for scrips that use "User Defined" condition or
    +    action. This commit shows or hides each textarea (using JavaScript)
    +    based on whether the scrip's current configuration will use its
    +    contents. This is meant to reduce user confusion about when these
    +    textareas take effect, and significantly reduce the length of the page
    +    in the common case of no "User Defined" code.
    +    
    +    To reinforce to users the relationship between the dropdown and its
    +    custom code textarea(s), we've moved each textarea up into the form,
    +    right below to its dropdown. If the fields were to remain in two
    +    separate sections, then users wouldn't notice the show/hide action at
    +    a distance and would wonder why the textareas appear only some of the
    +    time. This also reduces the perceived complexity of the scrip
    +    create/modify page down to one consistent form, rather than two
    +    confusingly-related sections, each with its own Save Changes button.
    +    
    +    Now that we've moved the textareas to be inline with the rest of the
    +    form, there arises a new problem where specifying lots of code would
    +    cause the rest of the page (e.g. Template selection) to scroll
    +    offscreen. So adapting the size of the textbox to how many lines are
    +    in the provided code (+3 lines for buffer) has been replaced with a
    +    constant of 6 rows. Users will still be able to use their browser's
    +    textarea resize tool to make the code entry fields longer.
    +    
    +    There is no animation for the show/hide actions because jQuery's
    +    slideUp and slideDown animations cannot handle table tags.
    +    
    +    Fixes: I#32260
     
     diff --git a/share/html/Admin/Scrips/Create.html b/share/html/Admin/Scrips/Create.html
     --- a/share/html/Admin/Scrips/Create.html
     +++ b/share/html/Admin/Scrips/Create.html
     @@
    -     Label => loc('Create'),
          Name => 'Create',
      &>
    --
    + 
     -% if ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode')) {
     -<& Elements/EditCustomCode, %ARGS, Scrip => $scrip &>
     -<& /Elements/Submit,
    @@ -20,7 +47,6 @@
     -&>
     -% }
     -
    -+        
      </form>
      <%ARGS>
      $Queue => 0
    @@ -29,24 +55,14 @@
     --- a/share/html/Admin/Scrips/Elements/EditBasics
     +++ b/share/html/Admin/Scrips/Elements/EditBasics
     @@
    - %# those contributions and any derivatives thereof.
    - %#
    - %# END BPS TAGGED BLOCK }}}
    -+
    -+% my $canExecuteCode = ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode'));
    -+
    - <tr><td class="label"><&|/l&>Description</&>:</td><td class="value">\
    - <input name="Description" \
    -     size="60" \
    -@@
          Default => $ARGS{"ScripCondition"} || $Scrip->ConditionObj->Id,
      &></td></tr>
      
     +% if ($canExecuteCode) {
    -+<tr class="CustomIsApplicableCode <% $Scrip->ScripCondition == $userDefinedCondition->id ? '' : 'hidden' %>">
    -+<td class="label"><&|/l&>Custom code</&>:</td><td class="value">\
    ++<tr class="CustomIsApplicableCode <% ($Scrip->ScripCondition||0) == $userDefinedCondition->id ? '' : 'hidden' %>">
    ++<td class="label"><&|/l&>Condition code</&>:</td><td class="value">\
     +% my $conditionCode = $ARGS{ CustomIsApplicableCode } || $Scrip->CustomIsApplicableCode() || '';
    -+<textarea cols="80" rows="<% 6 %>" name="CustomIsApplicableCode"><% $conditionCode %></textarea>
    ++<textarea cols="80" rows="6" name="CustomIsApplicableCode"><% $conditionCode %></textarea>
     +</td></tr>
     +% }
     +
    @@ -56,16 +72,16 @@
      &></td></tr>
      
     +% if ($canExecuteCode) {
    -+<tr class="CustomPrepareAndCommitCode <% $Scrip->ScripAction == $userDefinedAction->id ? '' : 'hidden' %>">
    ++<tr class="CustomPrepareCode <% ($Scrip->ScripAction||0) == $userDefinedAction->id ? '' : 'hidden' %>">
     +<td class="label"><&|/l&>Prepare code</&>:</td><td class="value">\
     +% my $prepareCode = $ARGS{ CustomPrepareCode } || $Scrip->CustomPrepareCode() || '';
    -+<textarea cols="80" rows="<% 6 %>" name="CustomPrepareCode"><% $prepareCode %></textarea>
    ++<textarea cols="80" rows="6" name="CustomPrepareCode"><% $prepareCode %></textarea>
     +</td></tr>
     +
    -+<tr class="CustomPrepareAndCommitCode <% $Scrip->ScripAction == $userDefinedAction->id ? '' : 'hidden' %>">
    ++<tr class="CustomCommitCode <% ($Scrip->ScripAction||0) == $userDefinedAction->id ? '' : 'hidden' %>">
     +<td class="label"><&|/l&>Commit code</&>:</td><td class="value">\
     +% my $commitCode = $ARGS{ CustomCommitCode } || $Scrip->CustomCommitCode() || '';
    -+<textarea cols="80" rows="<% 6 %>" name="CustomCommitCode"><% $commitCode %></textarea>
    ++<textarea cols="80" rows="6" name="CustomCommitCode"><% $commitCode %></textarea>
     +</td></tr>
     +% }
     +
    @@ -88,9 +104,9 @@
     +    jQuery("select[name=ScripAction]").change(function (e) {
     +        var scripActionId = jQuery(this).val();
     +        if (scripActionId == <% $userDefinedAction->id %>) {
    -+            jQuery(".CustomPrepareAndCommitCode").removeClass('hidden');
    ++            jQuery(".CustomPrepareCode, .CustomCommitCode").removeClass('hidden');
     +        }else{
    -+            jQuery(".CustomPrepareAndCommitCode").addClass('hidden');
    ++            jQuery(".CustomPrepareCode, .CustomCommitCode").addClass('hidden');
     +        }
     +    });
     +});
    @@ -101,6 +117,8 @@
      $Queue => undef
      </%ARGS>
      <%INIT>
    ++my $canExecuteCode = ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode'));
    ++
     +my $userDefinedCondition = RT::ScripCondition->new($session{CurrentUser});
     +$userDefinedCondition->LoadByCols(ExecModule => 'UserDefined');
     +



More information about the rt-commit mailing list