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

BPS Git Server git at git.bestpractical.com
Wed Nov 1 23:44:41 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  a1c76fb948f9dd554746a2daccb74b7160705e63 (commit)
       via  6c458acb1ece4259c82fcde3a5507b26a3415da5 (commit)
       via  601c875b961d3b6ae44e896c45ba490d6ffa6993 (commit)
       via  cde5de999199b776c522a84ec060906b06d4a670 (commit)
       via  8c7d1e0b3a3907a4cf64f2cf38d4e950d9bc6172 (commit)
       via  3e1459cc954fd86a1cf68f43eac4870030ce33ba (commit)
       via  1b8d6c7dfb5e1e8d470ac7e689aaf2f0d4238c37 (commit)
       via  598e9389810907c75c951a3602aec0f48315e39c (commit)
      from  9e1a3d1b50b9c557d619e7910c89cdc0e60d9e89 (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 a1c76fb948f9dd554746a2daccb74b7160705e63
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 19:31:37 2023 -0400

    Show label for Content like other fields

diff --git a/html/FormTools/Field b/html/FormTools/Field
index 42fe477..9e7be68 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -115,6 +115,23 @@ $default = '' unless defined $default;
 
 % if ($field_type eq 'core' && $name eq 'Content') {
 
+<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) : ()),

commit 6c458acb1ece4259c82fcde3a5507b26a3415da5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 18:10:48 2023 -0400

    Fix hr/html elements
    
    Previously HR was wrongly saved as "<hr>test</hr>" and HTML content
    textarea was missing.

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 471acd8..e7eab12 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -15,7 +15,7 @@
       </div>
       <div class="d-block text-center">
 % foreach my $item ( @html_components ) {
-        <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>"}) %>">
+        <div id="formtools-element-<% $item %>" class="formtools-element" draggable="true" ondragstart="formTools.dragstart(event);" ondragend="formTools.dragend(event);" data-value="<% JSON({ type => 'raw_html', $item eq 'hr' ? ( wrapper => 'hr' ) : () }) %>">
           <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Place here') %></p>
           <p class="m-1 p-2 border rounded">
             <span class="badge badge-primary"><% $item eq 'html' ? 'HTML' : uc($item) %></span>
@@ -309,7 +309,7 @@
                   <% $item->{comp_name} %>
 %               }
                 </span>
-%             if ( $item->{type} eq 'raw_html' || ( $item->{type} eq 'component' && $item->{comp_name} eq 'Field' ) || $item->{type} eq 'hidden' ) {
+%             if ( ( $item->{type} eq 'raw_html' && ( $item->{wrapper} // '' ) ne 'hr' ) || ( $item->{type} eq 'component' && $item->{comp_name} eq 'Field' ) || $item->{type} eq 'hidden' ) {
                 <a href="#" class="edit" data-toggle="modal" data-target="#formtools-element-<% $form_page_id{$page_name} %>-<% $i %>-modal">
                   <span class="fas fa-pencil-alt" alt="<% loc('Edit') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Edit') %>"></span>
                 </a>
@@ -344,7 +344,7 @@
                         <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' ) {
+%                     } else {
                         <textarea name="content" class="form-control"><% $item->{html} %></textarea>
 %                     }
                       </&>

commit 601c875b961d3b6ae44e896c45ba490d6ffa6993
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 17:23:27 2023 -0400

    Fix typo: core fields are supposed to be labelled as "Core Field"

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 652f776..471acd8 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -66,7 +66,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('Place here') %></p>
           <p class="m-1 p-2 border rounded">
-            <span class="badge badge-primary"><% loc('Custom Field') %></span>
+            <span class="badge badge-primary"><% loc('Core Field') %></span>
             <span class="content"><% $item %> <span class="label"></span></span>
             <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>
@@ -287,6 +287,8 @@
                     <% loc('Component') %>
 %                 } elsif ( $item->{type} eq 'hidden' ) {
                     <% loc('Hidden') %>
+%                 } elsif ( RT::Extension::FormTools::is_core_field($item->{arguments}{name}) ) {
+                    <% loc('Core Field') %>
 %                 } else {
                     <% loc('Custom Field') %>
 %                 }

commit cde5de999199b776c522a84ec060906b06d4a670
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 17:17:37 2023 -0400

    Alert before leaving the page if there are pending changes

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 1a1e5a5..652f776 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -415,6 +415,17 @@ jQuery(function() {
     jQuery('.formtools-page-form').on('submit', formTools.pageSubmit);
     jQuery('.formtools-delete-page').on('click', formTools.deletePage);
     jQuery('.formtools-component-menu input[name=search]').on('propertychange change keyup paste input', formTools.refreshSource);
+
+    // Alert before leaving the page if there are pending changes
+    window.addEventListener('beforeunload', (event) => {
+        if ( !document.querySelector('#formtools-form-modify.submitting')
+          && !document.querySelector('.pending-changes.hidden') ) {
+            event.preventDefault();
+
+            // Included for legacy support, e.g. Chrome/Edge < 119
+            event.returnValue = true;
+        }
+    });
 });
 </script>
 <%INIT>
diff --git a/static/js/rt-extension-formtools.js b/static/js/rt-extension-formtools.js
index ba2db0a..0b1692f 100644
--- a/static/js/rt-extension-formtools.js
+++ b/static/js/rt-extension-formtools.js
@@ -190,6 +190,13 @@ formTools = {
             jQuery('.formtools-form-pages .pending-changes').removeClass('hidden');
         }
         form.find('input[name=Content]').val(JSON.stringify(content));
+
+        if (e) { // It's a real form submitting
+            form.addClass('submitting');
+        }
+        else {
+            form.removeClass('submitting');
+        }
     },
 
     deleteElement: function(event) {

commit 8c7d1e0b3a3907a4cf64f2cf38d4e950d9bc6172
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 16:46:17 2023 -0400

    Make sure the drop div always has some space left to add new items

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index c095c0b..1a1e5a5 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -320,6 +320,7 @@
 %           $i++;
 %         }
             <p class="formtools-element-placeholder m-1 p-2 border rounded"><% loc('Place here') %></p>
+            <div class="formtools-element-empty-room"></div>
           </div>
           <div class="modal-wrapper">
 %         $i = 0;
diff --git a/static/css/rt-extension-formtools.css b/static/css/rt-extension-formtools.css
index 6c42b76..c77b448 100644
--- a/static/css/rt-extension-formtools.css
+++ b/static/css/rt-extension-formtools.css
@@ -80,3 +80,7 @@ div .formtools-admin-description {
 .formtools-form-pages input::placeholder {
     opacity: 0.5;
 }
+
+.formtools-element-empty-room {
+    height: 200px;
+}
diff --git a/static/js/rt-extension-formtools.js b/static/js/rt-extension-formtools.js
index 1c4982c..ba2db0a 100644
--- a/static/js/rt-extension-formtools.js
+++ b/static/js/rt-extension-formtools.js
@@ -59,7 +59,7 @@ formTools = {
                 area.insertBefore(source_copy, sibling);
             }
             else {
-                area.insertBefore(source_copy, area.children[area.children.length-1]);
+                area.insertBefore(source_copy, area.children[area.children.length-2]);
             }
 
             const modal_copy = jQuery('#' + old_id + '-modal').clone(true);

commit 3e1459cc954fd86a1cf68f43eac4870030ce33ba
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 16:14:25 2023 -0400

    Update deletePage action to correctly show the first page after the deletion
    
    Besides the form class name fix, this commit also removes deleted tab a
    bit later, which is somehow necessary to successfully show the content
    of the first page.

diff --git a/static/js/rt-extension-formtools.js b/static/js/rt-extension-formtools.js
index fe8a5f1..1c4982c 100644
--- a/static/js/rt-extension-formtools.js
+++ b/static/js/rt-extension-formtools.js
@@ -205,14 +205,14 @@ formTools = {
     },
 
     deletePage: function() {
-        jQuery('.formtools-element-modal.show').modal('hide');
+        jQuery('.formtools-page-modal.show').modal('hide');
         const tab = jQuery(this).closest('.tab-pane');
-        tab.fadeOut(function() {
-            jQuery('#formtools-pages').find('a.nav-link[href="#' + tab.attr('id') + '"]').closest('li').remove();
-            jQuery('#formtools-pages').find('li:first a.nav-link').tab('show');
+        jQuery('#formtools-pages').find('li:first a.nav-link').tab('show');
+        jQuery('#formtools-pages').find('a.nav-link[href="#' + tab.attr('id') + '"]').closest('li').remove();
+        setTimeout( function() {
             tab.remove();
-        });
-        formTools.submit();
+            formTools.submit();
+        }, 500 );
         return false;
     },
 

commit 1b8d6c7dfb5e1e8d470ac7e689aaf2f0d4238c37
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 15:52:42 2023 -0400

    Show a pending changes message on changes to indicate people to save

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 8a6d8f6..c095c0b 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -208,6 +208,9 @@
   </div>
   <div class="formtools-form-pages boxcontainer col-md-9" id="formtools-pages-wrapper">
   <&| /Widgets/TitleBox, title => loc('FormTools Pages') &>
+    <div class="mb-3 mx-3 mt-0 alert alert-warning pending-changes hidden">
+      <&|/l&>New changes pending. Click "Save Changes" to update the form.</&>
+    </div>
 
     <ul class="nav nav-<% $nav_type %>s" id="formtools-pages">
 %   my $current_context = {};
@@ -405,6 +408,8 @@
 <script type="text/javascript">
 jQuery(function() {
     jQuery('#formtools-form-modify').on('submit', formTools.submit);
+    formTools.submit(); // Keep track of current values
+
     jQuery('.formtools-element-form').on('submit', formTools.elementSubmit);
     jQuery('.formtools-page-form').on('submit', formTools.pageSubmit);
     jQuery('.formtools-delete-page').on('click', formTools.deletePage);
diff --git a/static/js/rt-extension-formtools.js b/static/js/rt-extension-formtools.js
index 9ab0605..fe8a5f1 100644
--- a/static/js/rt-extension-formtools.js
+++ b/static/js/rt-extension-formtools.js
@@ -69,6 +69,7 @@ formTools = {
             modal_copy.modal('show');
             modal_copy.attr('ondragenter', 'formTools.dragenter(event);');
         }
+        formTools.submit();
     },
 
     dragend: function (ev) {
@@ -144,6 +145,7 @@ formTools = {
         }
         element.data('value', value);
         form.closest('.formtools-element-modal').modal('hide');
+        formTools.submit();
     },
 
     pageSubmit: function(e) {
@@ -151,10 +153,11 @@ formTools = {
         const form = jQuery(this);
         jQuery('#formtools-pages a.nav-link.active').text(form.find('input[name=name]').val());
         form.closest('.formtools-page-modal').modal('hide');
+        formTools.submit();
     },
 
     submit: function(e) {
-        const form = jQuery(this);
+        const form = jQuery(e ? e.target : '#formtools-form-modify');
         const content = {};
         jQuery('div.formtools-content').each(function() {
             let page = jQuery(this).data('page');
@@ -175,6 +178,17 @@ formTools = {
             });
         });
         form.find('input[name=ActiveTab]').val(jQuery('.formtools-content:visible').data('page-id'));
+
+        const serialized_content = JSON.stringify(content);
+        if ( !form.data('old-value') ) {
+            form.data('old-value', serialized_content);
+        }
+        else if ( serialized_content === form.data('old-value') ) {
+            jQuery('.formtools-form-pages .pending-changes').addClass('hidden');
+        }
+        else {
+            jQuery('.formtools-form-pages .pending-changes').removeClass('hidden');
+        }
         form.find('input[name=Content]').val(JSON.stringify(content));
     },
 
@@ -186,6 +200,7 @@ formTools = {
             modal.remove();
         }
         element.remove();
+        formTools.submit();
         return false;
     },
 
@@ -197,6 +212,7 @@ formTools = {
             jQuery('#formtools-pages').find('li:first a.nav-link').tab('show');
             tab.remove();
         });
+        formTools.submit();
         return false;
     },
 

commit 598e9389810907c75c951a3602aec0f48315e39c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 1 19:36:21 2023 -0400

    Consistently use formTools.deleteElement to remove elements

diff --git a/html/Admin/FormTools/Modify.html b/html/Admin/FormTools/Modify.html
index 3593552..8a6d8f6 100644
--- a/html/Admin/FormTools/Modify.html
+++ b/html/Admin/FormTools/Modify.html
@@ -71,7 +71,7 @@
             <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>
             </a>
-            <a href="#" class="remove" onclick="jQuery(this).find('[data-toggle=tooltip]').tooltip('hide'); this.closest('.formtools-element').remove(); return false;">
+            <a href="#" class="remove" onclick="return formTools.deleteElement(event);">
               <span class="far fa-times-circle" alt="<% loc('Remove') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Remove') %>"></span>
             </a>
           </p>
@@ -115,7 +115,7 @@
             <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>
             </a>
-            <a href="#" class="remove" onclick="jQuery(this).find('[data-toggle=tooltip]').tooltip('hide'); this.closest('.formtools-element').remove(); return false;">
+            <a href="#" class="remove" onclick="return formTools.deleteElement(event);">
               <span class="far fa-times-circle" alt="<% loc('Remove') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Remove') %>"></span>
             </a>
           </p>
@@ -170,7 +170,7 @@
               <span class="fas fa-pencil-alt" alt="<% loc('Edit') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Edit') %>"></span>
             </a>
 %         }
-            <a href="#" class="remove" onclick="jQuery(this).find('[data-toggle=tooltip]').tooltip('hide'); this.closest('.formtools-element').remove(); return false;">
+            <a href="#" class="remove" onclick="return formTools.deleteElement(event);">
               <span class="far fa-times-circle" alt="<% loc('Remove') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Remove') %>"></span>
             </a>
           </p>
@@ -309,7 +309,7 @@
                   <span class="fas fa-pencil-alt" alt="<% loc('Edit') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Edit') %>"></span>
                 </a>
 %             }
-                <a href="#" class="remove" onclick="jQuery(this).find('[data-toggle=tooltip]').tooltip('hide'); this.closest('.formtools-element').remove(); return false;">
+                <a href="#" class="remove" onclick="return formTools.deleteElement(event);">
                   <span class="far fa-times-circle" alt="<% loc('Remove') %>" data-toggle="tooltip" data-placement="top" data-original-title="<% loc('Remove') %>"></span>
                 </a>
               </p>

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

Summary of changes:
 html/Admin/FormTools/Modify.html      | 35 +++++++++++++++++++++++++--------
 html/FormTools/Field                  | 17 ++++++++++++++++
 static/css/rt-extension-formtools.css |  4 ++++
 static/js/rt-extension-formtools.js   | 37 ++++++++++++++++++++++++++++-------
 4 files changed, 78 insertions(+), 15 deletions(-)


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


More information about the Bps-public-commit mailing list