allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [5/7] allura git commit: [#7884] ticket:805 Improve SortableRepeatedField widget and features UI
Date Mon, 29 Jun 2015 18:07:58 GMT
[#7884] ticket:805 Improve SortableRepeatedField widget and features UI

- change styles to fit with the rest of the page
- cursor: move for the "move" icon
- hide "add" button and help messages
- add new field, when user focuses last one


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/651047d9
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/651047d9
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/651047d9

Branch: refs/heads/master
Commit: 651047d9ea42e195d4d6c9c0c2f052846628eb48
Parents: eabccab
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Jun 17 15:40:48 2015 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Jun 29 18:04:52 2015 +0000

----------------------------------------------------------------------
 .../ext/admin/templates/admin_widgets/features_field.html |  2 +-
 .../ext/admin/templates/admin_widgets/metadata_admin.html |  7 ++++---
 Allura/allura/ext/admin/widgets.py                        | 10 +++-------
 Allura/allura/lib/widgets/form_fields.py                  |  5 +++++
 .../lib/widgets/resources/js/sortable_repeated_field.js   | 10 ++++++++++
 .../allura/templates/widgets/sortable_repeated_field.html | 10 +++++++---
 6 files changed, 30 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/651047d9/Allura/allura/ext/admin/templates/admin_widgets/features_field.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/features_field.html b/Allura/allura/ext/admin/templates/admin_widgets/features_field.html
index 5d70528..413158a 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/features_field.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/features_field.html
@@ -21,7 +21,7 @@
   {% set f = widget.fields[0] %}
   {% set ctx = widget.context_for(f) %}
   <div data-name="{{f.name}}">
-    <span class="ui-icon ui-icon-arrowthick-2-n-s" style="display:inline-block;"></span>
+    <span class="ui-icon ui-icon-arrowthick-2-n-s" style="display:inline-block;cursor:move;"></span>
     {{f.display(**ctx)}}
   </div>
 </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/651047d9/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index bebef0c..b313dfc 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -49,10 +49,11 @@
 
     <div style="clear:both">&nbsp;</div>
 
-    <fieldset class="preferences" id="features">
-      <legend>{{ widget.display_label(widget.fields.features) }}</legend>
+    <div id="features">
+      {{ widget.display_label(widget.fields.features) }}
       {{ widget.display_field(widget.fields.features) }}
-    </fieldset>
+    </div>
+    <br>
 
     {% if tg.config.get('support_tool_choices') %}
     Preferred Support Page (for users of your project):<br>

http://git-wip-us.apache.org/repos/asf/allura/blob/651047d9/Allura/allura/ext/admin/widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/widgets.py b/Allura/allura/ext/admin/widgets.py
index 9e6e39d..0d5cae9 100644
--- a/Allura/allura/ext/admin/widgets.py
+++ b/Allura/allura/ext/admin/widgets.py
@@ -193,14 +193,10 @@ class MetadataAdmin(ff.AdminForm):
         # is not just ew.TextField
         features = ffw.SortableRepeatedField(
             label='Features',
-            empty_msg='No features yet',
-            nonempty_msg='Drag and drop features to reorder. '
-                         'Leave empty to delete a feature.',
+            show_msg=False,
+            show_button=False,
             append_to='bottom',
-            button=ew.InputField(
-                css_class='add',
-                field_type='button',
-                value='Add feature'),
+            extra_field_on_focus_name='feature',
             field=FeaturesField())
         icon = ew.FileField(label='Icon')
         external_homepage = ew.InputField(field_type="text", label='Homepage',

http://git-wip-us.apache.org/repos/asf/allura/blob/651047d9/Allura/allura/lib/widgets/form_fields.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py
index be3fd1a..77665f9 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -413,6 +413,7 @@ class SortableRepeatedMixin(JQueryMixin):
         'stub_cls',
         'msg_cls',
         'append_to',
+        'extra_field_on_focus_name',
     ]
     defaults = dict(
         container_cls='sortable-repeated-field',
@@ -423,7 +424,11 @@ class SortableRepeatedMixin(JQueryMixin):
         append_to='top',
         empty_msg='No fields have been defined',
         nonempty_msg='Drag and drop the fields to reorder',
+        show_msg=True,
+        show_button=True,
+        extra_field_on_focus_name=None,
         repetitions=0)
+
     button = ew.InputField(
         css_class='add', field_type='button', value='New Field')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/651047d9/Allura/allura/lib/widgets/resources/js/sortable_repeated_field.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/sortable_repeated_field.js b/Allura/allura/lib/widgets/resources/js/sortable_repeated_field.js
index ca78493..5371299 100644
--- a/Allura/allura/lib/widgets/resources/js/sortable_repeated_field.js
+++ b/Allura/allura/lib/widgets/resources/js/sortable_repeated_field.js
@@ -26,6 +26,7 @@
         stub_cls:'sortable-field-stub',
         msg_cls:'sortable-field-message',
         append_to:'top',  // append new field to top by default. Also supports 'bottom'
+        extra_field_on_focus_name:null,
     };
 
     $.fn.SortableRepeatedField = function(options) {
@@ -85,6 +86,11 @@
                 self.data.$delete_buttons.one('click', _deleteField);
                 self.data.$flist.sortable({stop:_renumberFields});
                 self.data.$stub.hide();
+                if (self.opts.extra_field_on_focus_name) {
+                  self.data.$flist.find('.' + self.opts.field_cls)
+                      .find('input[name$=' + self.opts.extra_field_on_focus_name + ']')
+                      .off('focus').last().on('focus', _addExtraField);
+                }
                 _manageMessages();
             },
             fld_name: function() {
@@ -159,5 +165,9 @@
                     });
             });
         }
+        function _addExtraField() {
+          $(this).off('focus');
+          _addField();
+        }
     };
 }(jQuery));

http://git-wip-us.apache.org/repos/asf/allura/blob/651047d9/Allura/allura/templates/widgets/sortable_repeated_field.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/sortable_repeated_field.html b/Allura/allura/templates/widgets/sortable_repeated_field.html
index dc41694..538d14f 100644
--- a/Allura/allura/templates/widgets/sortable_repeated_field.html
+++ b/Allura/allura/templates/widgets/sortable_repeated_field.html
@@ -20,18 +20,22 @@
      xmlns:py="http://genshi.edgewall.org/"
      class="$container_cls"
      py:attrs="{'data-name':name}">
-  <div><p
+   <div><py:if test="show_msg"><p
           class="$msg_cls"
           data-empty-message="$empty_msg"
           data-nonempty-message="$nonempty_msg"
-          /></div>
-  ${widget.button.display()}
+          /></py:if></div>
+  <py:if test="show_button">${widget.button.display()}</py:if>
   <br style="clear:both"/>
   <div class="$flist_cls">
     <py:for each="i in xrange(repetitions)"
             py:with="ctx=widget.context_for(i)">
       ${widget.field.display(css_class=field_cls, **ctx)}
     </py:for>
+    <py:if test="extra_field_on_focus_name"
+           py:with="ctx=widget.context_for(repetitions)">
+      ${widget.field.display(css_class=field_cls, **ctx)}
+    </py:if>
     ${widget.field.display(name=name+'#', css_class=stub_cls)}
   </div>
 </div>


Mime
View raw message