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

BPS Git Server git at git.bestpractical.com
Thu Oct 5 21:41:01 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  fb9708c226cf0c435d3cc61165acf8af2da676d5 (commit)
       via  ad058adc128aa77957503d7af08636d82407940c (commit)
       via  d5b67dfec6666e4f0038756995c8a13e02e322c7 (commit)
      from  8b09c335da5af3d0360a727be64bf2cd129c6dbe (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 fb9708c226cf0c435d3cc61165acf8af2da676d5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 5 17:39:00 2023 -0400

    Tweak badge words to be a bit more clear

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index d1f0f0a..62e1311 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -59,7 +59,7 @@
         <div id="formtools-element-<% $item %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" data-value="<% JSON({ type => 'component', comp_name => 'Field', arguments => { name => $item } }) %>">
           <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Put it here') %></p>
           <p class="m-1 p-2 border rounded">
-            <span class="badge badge-primary">component</span>
+            <span class="badge badge-primary"><% loc('Field') %></span>
             <% $item %>
             <a href="#" class="edit" data-toggle="modal" data-target="#formtools-element-modal">
               <span class="fas fa-pencil-alt" alt="<% loc('Edit') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Edit') %>"></span>
@@ -106,7 +106,7 @@
         <div id="formtools-element-<% $item %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" data-value="<% JSON({ type => 'component', comp_name => 'Field', arguments => { name => $item } }) %>">
           <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Put it here') %></p>
           <p class="m-1 p-2 border rounded">
-            <span class="badge badge-primary">component</span>
+            <span class="badge badge-primary"><% loc('Field') %></span>
             <% $item %>
             <a href="#" class="edit" data-toggle="modal" data-target="#formtools-element-modal">
               <span class="fas fa-pencil-alt" alt="<% loc('Edit') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Edit') %>"></span>
@@ -154,7 +154,7 @@
         <div id="formtools-element-<% $item %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" data-value="<% JSON($other_components{$item}) %>">
           <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Put it here') %></p>
           <p class="m-1 p-2 border rounded">
-            <span class="badge badge-primary"><% $other_components{$item}{type} %></span>
+            <span class="badge badge-primary"><% $other_components{$item}{type} eq 'hidden' ? loc('Hidden') : loc('Component') %></span>
             <span class="content"><% $item %></span>
 %         if ( $item eq 'Hidden' ) {
             <a href="#" class="edit" data-toggle="modal" data-target="#formtools-element-modal">
@@ -270,7 +270,17 @@
             <div id="formtools-element-<% $form_page_id{$page_name} %>-<% $i %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" ondragenter="formTools.dragenter(event)" ondragleave="formTools.dragleave(event)" data-value="<% JSON($item) %>">
               <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Put it here') %></p>
               <p class="m-1 p-2 border rounded">
-                <span class="badge badge-primary"><% $item->{type} eq 'raw_html' ? uc($item->{wrapper} || 'HTML') : $item->{type} %></span>
+                <span class="badge badge-primary">
+%                 if ( $item->{type} eq 'raw_html' ) {
+                    <% uc($item->{wrapper} || 'HTML') %>
+%                 } elsif ( ( $item->{comp_name} // '' ) eq 'ShowChoices' ) {
+                    <% loc('Component') %>
+%                 } elsif ( $item->{type} eq 'hidden' ) {
+                    <% loc('Hidden') %>
+%                 } else {
+                    <% loc('Field') %>
+%                 }
+                </span>
                 <span class="content">
 %               if ( $item->{type} eq 'raw_html' ) {
 %                 if ( $item->{wrapper} ) {

commit ad058adc128aa77957503d7af08636d82407940c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 5 16:44:58 2023 -0400

    Make html elements be easier to review and modify
    
    For h1, h2, h3, and p, users can just input real content, and we can add
    the html wrapper automatically. Elements h4, h5, and h6 are dropped
    because they are not used so often.
    
    Here we also add a new no-wrapper HTML element, where user can input
    anything they want.

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 83217ea..d1f0f0a 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -11,7 +11,7 @@
         <div id="formtools-element-<% $item %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" data-value="<% JSON({ type => 'raw_html', html => "<$item>test</$item>"}) %>">
           <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Put it here') %></p>
           <p class="m-1 p-2 border rounded">
-            <span class="badge badge-primary">raw_html</span>
+            <span class="badge badge-primary"><% $item eq 'html' ? 'HTML' : uc($item) %></span>
             <span class="content"><% loc('[_1] Element', uc($item)) %></span>
 %           if ( $item ne 'hr' ) {
             <a href="#" class="edit" data-toggle="modal" data-target="#formtools-element-modal">
@@ -34,7 +34,15 @@
                     </a>
                   </div>
                   <div class="modal-body">
-                    <textarea name="html" class="form-control"><% "<$item>Text</$item>" %></textarea>
+                    <&| /Elements/LabeledValue, Label => loc("Content") &>
+%                   if ( $item =~ /^h\d/ ) {
+                      <input name="content" class="form-control" data-wrapper="<% $item %>" />
+%                   } elsif ( $item eq 'p' ) {
+                      <textarea name="content" class="form-control" data-wrapper="<% $item %>"></textarea>
+%                   } elsif ( $item eq 'html' ) {
+                      <textarea name="content" class="form-control"></textarea>
+%                   }
+                    </&>
                   </div>
                   <div class="modal-footer">
                     <button type="submit" class="btn btn-primary button form-control"><% loc('Save') %></button>
@@ -262,10 +270,14 @@
             <div id="formtools-element-<% $form_page_id{$page_name} %>-<% $i %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" ondragenter="formTools.dragenter(event)" ondragleave="formTools.dragleave(event)" data-value="<% JSON($item) %>">
               <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Put it here') %></p>
               <p class="m-1 p-2 border rounded">
-                <span class="badge badge-primary"><% $item->{type} %></span>
+                <span class="badge badge-primary"><% $item->{type} eq 'raw_html' ? uc($item->{wrapper} || 'HTML') : $item->{type} %></span>
                 <span class="content">
 %               if ( $item->{type} eq 'raw_html' ) {
-                  <% length $item->{html} > 40 ? substr($item->{html}, 0, 40) . '...' : $item->{html} %>
+%                 if ( $item->{wrapper} ) {
+                    <% length $item->{content} > 40 ? substr($item->{content}, 0, 40) . '...' : $item->{content} %>
+%                 } else {
+                    <% length $item->{html} > 40 ? substr($item->{html}, 0, 40) . '...' : $item->{html} %>
+%                 }
 %               } elsif ( $item->{type} eq 'hidden' ) {
                   <% $item->{'input-name'} %>: <% $item->{'input-value'} %>
 %               } else {
@@ -293,7 +305,15 @@
                       </div>
                       <div class="modal-body">
 %                     if ( $item->{type} eq 'raw_html' ) {
-                        <textarea name="html" class="form-control"><% $item->{html} %></textarea>
+                        <&| /Elements/LabeledValue, Label => loc("Content") &>
+%                       if ( ($item->{wrapper} // '') =~ /^h\d/i ) {
+                          <input name="content" class="form-control" data-wrapper="<% $item->{wrapper} %>" value="<% $item->{content} %>"/>
+%                       } elsif ( lc ($item->{wrapper} // '') eq 'p' ) {
+                          <textarea name="content" class="form-control" data-wrapper="<% $item->{wrapper} %>"><% $item->{content} %></textarea>
+%                       } elsif ( $item eq 'html' ) {
+                          <textarea name="content" class="form-control"><% $item->{html} %></textarea>
+%                       }
+                        </&>
 %                     } elsif ( $item->{type} eq 'component' && $item->{comp_name} eq 'Field' ) {
                         <div class="form-row">
                           <div class="col-3 label"><&|/l&>Label</&>:</div>
@@ -462,7 +482,7 @@ my $title = loc("Modify form [_1]", $form_attribute->Description);
 
 my $nav_type = 'pill'; # 'tab' or 'pill'
 
-my @html_components = qw( h1 h2 h3 h4 h5 h6 hr p );
+my @html_components = qw( h1 h2 h3 hr p html );
 my @core_components = qw( Requestors Owner Subject Content );
 
 my $queue = RT::Queue->new($session{'CurrentUser'});
diff --git a/static/js/rt-extension-formtools.js b/static/js/rt-extension-formtools.js
index 905714b..edd3929 100644
--- a/static/js/rt-extension-formtools.js
+++ b/static/js/rt-extension-formtools.js
@@ -80,8 +80,18 @@ formTools = {
         const value = element.data('value');
 
         if ( value.type === 'raw_html' ) {
-            value.html = form.find(':input[name=html]').val();
-            element.find('span.content').text(value.html.length > 40 ? value.html.substr(0, 40) + '...' : value.html);
+            const input = form.find(':input[name=content]');
+            const content = input.val();
+            const wrapper = input.data('wrapper');
+            if ( wrapper ) {
+                value.content = content;
+                value.wrapper = wrapper;
+                value.html = '<' + wrapper + '>' + content + '</' + wrapper + '>';
+            }
+            else {
+                value.html = content;
+            }
+            element.find('span.content').text(content.length > 40 ? content.substr(0, 40) + '...' : content);
         }
         else if ( value.type === 'component' && value.comp_name === 'Field' ) {
             const label = form.find(':input[name=label]').val();

commit d5b67dfec6666e4f0038756995c8a13e02e322c7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 5 15:50:12 2023 -0400

    Fix initial pages to generate uuid as keys
    
    Not adding "()" made "create_uuid_as_string" a plain string :/

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 338b55a..83217ea 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -488,8 +488,8 @@ my %other_components = (
 
 
 $form->{'formtools-pages'} ||= {
-    create_uuid_as_string => { sort_order => 1, name => 'Page 1' },
-    create_uuid_as_string => {
+    create_uuid_as_string() => { sort_order => 1, name => 'Page 1' },
+    create_uuid_as_string() => {
         sort_order => 999,
         name       => 'Result',
         content    => [

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

Summary of changes:
 html/Admin/FormTools/Modify.html    | 52 +++++++++++++++++++++++++++++--------
 static/js/rt-extension-formtools.js | 14 ++++++++--
 2 files changed, 53 insertions(+), 13 deletions(-)


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


More information about the Bps-public-commit mailing list