[Bps-public-commit] rt-extension-formtools branch dynamic-forms-from-config updated. 0.53-115-g43f69ba

BPS Git Server git at git.bestpractical.com
Tue Nov 28 19:53:07 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-formtools".

The branch, dynamic-forms-from-config has been updated
       via  43f69ba86d5150f8c19bf50068fdd6213425b1e5 (commit)
       via  8546fd74e6ce6a0af6724c4e743f938feb3e06e5 (commit)
       via  8ab7f8e988712a150cb00df9499a6bb9db4ef54a (commit)
       via  dfb49c358a8ac07ad8c241a7b85ceda1158abfa9 (commit)
       via  3228d6ee3f0c1c6a46cecf8d652dae2325919c22 (commit)
       via  985715c0f42a515bc23bf5f55b4719bb62b22202 (commit)
      from  629e58baa0ca1da9d77284a731746f63ede70b3d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 43f69ba86d5150f8c19bf50068fdd6213425b1e5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Nov 28 11:49:36 2023 -0500

    Support mandatory validation for Content

diff --git a/html/FormTools/Field b/html/FormTools/Field
index f591719..eea7abc 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -114,6 +114,11 @@ $default = '' unless defined $default;
 
 % if ($field_type eq 'core' && $name eq 'Content' && $render_as ne 'hidden') {
 
+<div
+% if ( $ARGS{validation} ) {
+    data-validation="<% $ARGS{validation} %>"
+% }
+>
 <& /Elements/MessageBox,
     Name => $name,
     ($rows ? (Height => $rows) : ()),
@@ -122,6 +127,12 @@ $default = '' unless defined $default;
     Default => $default,
     FullWidth => 1,
 &>
+% if ( $ARGS{validation} ) {
+  <span class="cfhints my-1 d-inline-block required">
+    <% loc('Required') %>
+  </span>
+% }
+</div>
 
 % } else {
 
diff --git a/html/Forms/dhandler b/html/Forms/dhandler
index 3706eeb..b88ee50 100644
--- a/html/Forms/dhandler
+++ b/html/Forms/dhandler
@@ -52,6 +52,22 @@ jQuery(function () {
                 }
             }).change();
         }
+        else if ( elem.find('textarea.richtext').length ) {
+            const textarea = elem.find('textarea.richtext');
+            const form = elem.closest('form');
+            form.on('submit', function(e) {
+                const editor = CKEDITOR.instances[textarea.attr('id')];
+                if ( editor.getData() ) {
+                    return;
+                }
+                else {
+                    editor.focus();
+                    elem.get(0).scrollIntoView();
+                    e.preventDefault();
+                    form.removeClass('rt-form-submitted');
+                }
+            });
+        }
         else {
             elem.find(':input:visible').attr('required', true);
 

commit 8546fd74e6ce6a0af6724c4e743f938feb3e06e5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Nov 28 10:15:16 2023 -0500

    Reset z-index for checkbox rows so select options can be fully clickable
    
    This is initially for selects in dependent validation, where the
    following "Hide" checkbox row partially conceals the dropdown items of
    "dependent_name" and "dependent_value" inputs.

diff --git a/static/css/rt-extension-formtools.css b/static/css/rt-extension-formtools.css
index 33f4132..086dffc 100644
--- a/static/css/rt-extension-formtools.css
+++ b/static/css/rt-extension-formtools.css
@@ -85,3 +85,8 @@ div .formtools-admin-description {
 #formtools-edit .custom-control-label.has-text-input::after {
   top: 0.5rem;
 }
+
+/* Make select options fully clickable */
+#formtools-edit .custom-checkbox {
+    z-index: auto;
+}

commit 8ab7f8e988712a150cb00df9499a6bb9db4ef54a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Nov 27 17:10:12 2023 -0500

    Show "Required" hint for fields marked required in the form

diff --git a/html/FormTools/Field b/html/FormTools/Field
index bc55db7..f591719 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -301,4 +301,13 @@ $input_name         => undef
 %}
 
 % }
+
+
+% if (  ( !$cf || !$cf->FriendlyPattern ) && ( $ARGS{validation}
+%    || ( $ARGS{dependent_validation} && $ARGS{dependent_validation}{enabled} && $ARGS{dependent_validation}{name} ) )
+% ) {
+    <span class="cfhints my-1 d-inline-block required">
+      <% loc('Required') %>
+    </span>
+% }
 </%METHOD>
diff --git a/html/Forms/dhandler b/html/Forms/dhandler
index d757486..3706eeb 100644
--- a/html/Forms/dhandler
+++ b/html/Forms/dhandler
@@ -124,6 +124,7 @@ jQuery(function () {
                     target.find('input[type=radio][value=""]').prop('checked', false).attr('disabled', true);
                 }
                 target.find(':input:visible').attr('required', true);
+                target.find('.cfhints.required').removeClass('hidden');
             }
             else {
                 if ( target.find('select.selectpicker').length ) {
@@ -134,6 +135,7 @@ jQuery(function () {
                     target.find('input[type=radio][value=""]').attr('disabled', false);
                 }
                 target.find(':input:visible').attr('required', false);
+                target.find('.cfhints.required').addClass('hidden');
             }
         };
         jQuery(':input[type!=hidden][name="' + dependent_name +'"]').change(syncValidation).change();

commit dfb49c358a8ac07ad8c241a7b85ceda1158abfa9
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Nov 27 16:35:16 2023 -0500

    Drop Label support for the special "Content" field
    
    This is more consistent with RT core. If users do need some
    descriptions, they can add some HTML beforehand.

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index e982797..9089a35 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -97,15 +97,19 @@
                   </a>
                 </div>
                 <div class="modal-body">
+%               if ( $item ne 'Content' ) {
                   <&| /Elements/LabeledValue, Label => loc('Label') &>
                     <input name="label" type="text" class="form-control" placeholder="<% $item %>" value="" />
                   </&>
+%               }
                   <&| /Elements/LabeledValue, Label => loc('Default Value') &>
                     <input name="default" type="text" class="form-control" placeholder="<% $default_values{$item} %>" value="" />
                   </&>
+%               if ( $item ne 'Content' ) {
                   <&| /Elements/LabeledValue, Label => loc('Tooltip') &>
                     <input name="tooltip" type="text" class="form-control" value="" />
                   </&>
+%               }
                   <&| /Elements/LabeledValue, Label => '' &>
                     <div class="custom-control custom-checkbox">
                       <input class="custom-control-input" id="<% CSSClass($item) %>-validation" type="checkbox" name="validation" value="1" />
@@ -415,16 +419,19 @@
                       </&>
 %                     }
 %                   } elsif ( $item->{type} eq 'component' && $item->{comp_name} eq 'Field' ) {
+%                     if ( $item->{arguments}{name} ne 'Content' ) {
                       <&| /Elements/LabeledValue, Label => loc('Label') &>
                         <input name="label" type="text" class="form-control" placeholder="<% $item->{arguments}{name} %>" value="<% $item->{arguments}{label} // ''  %>" />
                       </&>
+%                     }
                       <&| /Elements/LabeledValue, Label => loc('Default Value') &>
                         <input name="default" type="text" class="form-control" placeholder="<% $default_values{$item->{arguments}{name}} %>" value="<% $item->{arguments}{default} // '' %>" />
                       </&>
-
+%                     if ( $item->{arguments}{name} ne 'Content' ) {
                       <&| /Elements/LabeledValue, Label => loc('Tooltip') &>
                         <input name="tooltip" type="text" class="form-control" placeholder="<% $tooltips{$item->{arguments}{name}} // '' %>" value="<% $item->{arguments}{tooltip} // '' %>" />
                       </&>
+%                     }
                       <&| /Elements/LabeledValue, Label => '' &>
                         <div class="custom-control custom-checkbox">
                           <input class="custom-control-input" id="formtools-element-<% $form_page_id{$page_name} %>-<% $i %>-validation" type="checkbox" name="validation" value="1" <% $item->{arguments}{validation} ? q{checked="checked"} : '' |n %> />
diff --git a/html/FormTools/Field b/html/FormTools/Field
index abdb48d..bc55db7 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -114,29 +114,13 @@ $default = '' unless defined $default;
 
 % if ($field_type eq 'core' && $name eq 'Content' && $render_as ne 'hidden') {
 
-<div class="form-row">
-  <div class="col-3 label">
-% if ($tooltip) {
-    <span class="prev-icon-helper">
-% }
-      <% $field_label %>
-% if ($tooltip) {
-    </span>
-% }
-
-% if ($tooltip) {
-    <span class="far fa-question-circle icon-helper" data-toggle="tooltip" data-placement="top" data-original-title="<% $tooltip %>"></span>
-% }
-    <% $after_label |n %>
-  </div>
-</div>
-
 <& /Elements/MessageBox,
     Name => $name,
     ($rows ? (Height => $rows) : ()),
     ($cols ? (Width => $cols) : ()),
     IncludeSignature => 0,
     Default => $default,
+    FullWidth => 1,
 &>
 
 % } else {
diff --git a/static/js/rt-extension-formtools.js b/static/js/rt-extension-formtools.js
index 63ba4cf..93411dc 100644
--- a/static/js/rt-extension-formtools.js
+++ b/static/js/rt-extension-formtools.js
@@ -111,7 +111,7 @@ formTools = {
         }
         else if ( value.type === 'component' && value.comp_name === 'Field' ) {
             const label = form.find(':input[name=label]').val();
-            if ( label.length ) {
+            if ( label && label.length ) {
                 value.arguments.label = label;
                 element.find('span.label').text('(' + label + ')');
             }
@@ -131,7 +131,7 @@ formTools = {
 
             const tooltip = form.find(':input[name=tooltip]').val();
 
-            if ( tooltip.length ) {
+            if ( tooltip && tooltip.length ) {
                 value.arguments.tooltip = tooltip;
             }
             else {

commit 3228d6ee3f0c1c6a46cecf8d652dae2325919c22
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Nov 27 16:23:07 2023 -0500

    Abort in advance if current user lacks rights to create tickets

diff --git a/html/Forms/dhandler b/html/Forms/dhandler
index 561cf1d..d757486 100644
--- a/html/Forms/dhandler
+++ b/html/Forms/dhandler
@@ -211,7 +211,7 @@ else {
     $page = $form_config->{'formtools-start-page'};
 }
 
-my $queue_obj = RT::Queue->new( RT->SystemUser );
+my $queue_obj = RT::Queue->new( $session{CurrentUser} );
 my ($ok, $msg) = $queue_obj->Load( $form_config->{'queue'} );
 
 unless ( $ok ) {
@@ -219,6 +219,8 @@ unless ( $ok ) {
     Abort('Unable to load form, invalid queue');
 }
 
+Abort('Permission Denied') unless $queue_obj->CurrentUserHasRight('CreateTicket');
+
 $m->notes( queue => $queue_obj );
 $m->notes( page_title => $form_config->{'formtools-pages'}{$page}{'name'} );
 

commit 985715c0f42a515bc23bf5f55b4719bb62b22202
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Nov 27 16:13:45 2023 -0500

    Do not add HR after the last item

diff --git a/html/Elements/Forms/ListForms b/html/Elements/Forms/ListForms
index 6f7b919..c73386e 100644
--- a/html/Elements/Forms/ListForms
+++ b/html/Elements/Forms/ListForms
@@ -4,6 +4,10 @@
 %    next unless $form_attribute->CurrentUserCanSee;
 %    my $form = $form_attribute->Content;
 %    next if $form->{disabled};
+
+% if ( $item_number != 1 ) {
+<hr />
+% }
 <div class="row mt-3 mb-3">
   <div class="col-4">
     <a href="<% RT->Config->Get('WebPath') %><% $SelfServicePath %>/Forms/<% $form_attribute->Description %>">
@@ -14,7 +18,6 @@
     <% $form->{'form-description'} |n %>
   </div>
 </div>
-<hr />
 % $item_number++;
 % }
 </&>

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

Summary of changes:
 html/Admin/FormTools/Modify.html      |  9 ++++++++-
 html/Elements/Forms/ListForms         |  5 ++++-
 html/FormTools/Field                  | 36 +++++++++++++++++++----------------
 html/Forms/dhandler                   | 22 ++++++++++++++++++++-
 static/css/rt-extension-formtools.css |  5 +++++
 static/js/rt-extension-formtools.js   |  4 ++--
 6 files changed, 60 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
rt-extension-formtools


More information about the Bps-public-commit mailing list