Modify

Opened 2 years ago

Last modified 8 weeks ago

#10284 new enhancement

Support Trac 1.0's new custom text field formats "reference", "list"

Reported by: ejucovy Owned by: osimons
Priority: normal Component: CustomFieldAdminPlugin
Severity: normal Keywords:
Cc: jun66j5 Trac Release: 1.0

Description

Per http://trac.edgewall.org/ticket/10643 Trac 1.0 will support two new formats for custom text fields: reference (query-able value) and list (list of query-able values, like keywords)

This patch adds support for these new options in customfieldadmin's Admin UI:

Index: customfieldadmin/admin.py
===================================================================
--- customfieldadmin/admin.py	(revision 11937)
+++ customfieldadmin/admin.py	(working copy)
@@ -48,8 +48,8 @@
                                     req.args.get('options','').split("\n")],
                       'cols': req.args.get('cols','').encode('utf-8'),
                       'rows': req.args.get('rows','').encode('utf-8'),
-                      'order': req.args.get('order', '').encode('utf-8'),
-                      'format': req.args.get('format', '').encode('utf-8')}
+                      'order': req.args.get('order', '').encode('utf-8')}
+            cfield['format'] = req.args.get('format-%s' % cfield['type'], '').encode('utf-8')
             return cfield
         
         cf_api = CustomFields(self.env)
Index: customfieldadmin/tests/admin.py
===================================================================
--- customfieldadmin/tests/admin.py	(revision 11937)
+++ customfieldadmin/tests/admin.py	(working copy)
@@ -42,7 +42,7 @@
                          'name': "test",
                          'type': "textarea",
                          'label': "testing",
-                         'format': "wiki",
+                         'format-textarea': "wiki",
                          'row': '9',
                          'columns': '42'})
         try:
Index: customfieldadmin/htdocs/js/customfieldadmin.js
===================================================================
--- customfieldadmin/htdocs/js/customfieldadmin.js	(revision 11937)
+++ customfieldadmin/htdocs/js/customfieldadmin.js	(working copy)
@@ -8,23 +8,23 @@
         function label(property){ return $(property).parents('div.field')}
         switch (type_element.selectedIndex) {
             case 0: // text
-                label('#options, #cols, #rows').hide();
-                label('#format').show();
+                label('#options, #cols, #rows, .format').hide();
+                label('#format-text').show();
                 break;
             case 1: // select
                 label('#options').show();
-                label('#cols, #rows, #format').hide();
+                label('#cols, #rows, .format').hide();
                 break;
             case 2: // checkbox
-                label('#options, #cols, #rows, #format').hide();
+                label('#options, #cols, #rows, .format').hide();
                 break;
             case 3: // radio
                 label('#options').show();
-                label('#cols, #rows, #format').hide();
+                label('#cols, #rows, .format').hide();
                 break;      
             case 4: // textarea
-                label('#options').hide();
-                label('#cols, #rows, #format').show();
+                label('#options, .format').hide();
+                label('#cols, #rows, #format-textarea').show();
                 break;
         }
     }
Index: customfieldadmin/templates/customfieldadmin.html
===================================================================
--- customfieldadmin/templates/customfieldadmin.html	(revision 11937)
+++ customfieldadmin/templates/customfieldadmin.html	(working copy)
@@ -47,8 +47,17 @@
           </label>
         </div>
         <div class="field">
-          <label>Format (Text or Textarea):<br />
-            <select name="format" id="format">
+          <label>Format (Text):<br />
+            <select name="format-text" id="format-text" class="format">
+              <option py:for="format in ['plain', 'wiki', 'reference', 'list']" value="${format}"
+                  selected="${cfield.format==format and 'selected' or None}">
+                ${format.capitalize()}</option>
+            </select>
+          </label>
+        </div>
+        <div class="field">
+          <label>Format (Textarea):<br />
+            <select name="format-textarea" id="format-textarea" class="format">
               <option py:for="format in ['plain', 'wiki']" value="${format}"
                   selected="${cfield.format==format and 'selected' or None}">
                 ${format.capitalize()}</option>
@@ -108,7 +117,15 @@
         </div>
         <div class="field">
           <label>Format:<br />
-            <select name="format" id="format">
+            <select name="format-text" id="format-text" class="format">
+              <option py:for="format in ['plain', 'wiki', 'reference', 'list']"
+                  value="${format}">${format.capitalize()}</option>
+            </select>
+          </label>
+        </div>
+        <div class="field">
+          <label>Format:<br />
+            <select name="format-textarea" id="format-textarea" class="format">
               <option py:for="format in ['plain', 'wiki']"
                   value="${format}">${format.capitalize()}</option>
             </select>

Attachments (1)

support-custom-text-format-for-r13638.patch (4.8 KB) - added by t2y 6 months ago.
remake to be able to patch for r13638

Download all attachments as: .zip

Change History (7)

comment:1 Changed 6 months ago by t2y

I tried to patch this, but it rejected to r13638.

$ patch -p0 < support-custom-text-format1.patch 
patching file customfieldadmin/admin.py
Hunk #1 FAILED at 48.
1 out of 1 hunk FAILED -- saving rejects to file customfieldadmin/admin.py.rej
patching file customfieldadmin/tests/admin.py
patching file customfieldadmin/htdocs/js/customfieldadmin.js
patching file customfieldadmin/templates/customfieldadmin.html
Hunk #1 FAILED at 47.
Hunk #2 FAILED at 108.
2 out of 2 hunks FAILED -- saving rejects to file customfieldadmin/templates/customfieldadmin.html.rej

comment:2 Changed 6 months ago by t2y

OK, I will fix to this issue for trunk revision.

comment:3 Changed 6 months ago by t2y

All tests passed.

$ python setup.py test
running test
running egg_info
writing requirements to TracCustomFieldAdmin.egg-info/requires.txt
writing TracCustomFieldAdmin.egg-info/PKG-INFO
writing top-level names to TracCustomFieldAdmin.egg-info/top_level.txt
writing dependency_links to TracCustomFieldAdmin.egg-info/dependency_links.txt
writing entry points to TracCustomFieldAdmin.egg-info/entry_points.txt
writing manifest file 'TracCustomFieldAdmin.egg-info/SOURCES.txt'
running build_ext
test_create (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_delete (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_delete_unknown_options (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_not_delete_unknown_options_for_modify (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_systeminfo (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_update (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_update_non_existing (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_update_non_existing_no_name (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_update_textarea (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok
test_translation_function (customfieldadmin.tests.api.CustomFieldL10NTestCase) ... ok
test_translation_function_tag (customfieldadmin.tests.api.CustomFieldL10NTestCase) ... ok
test_add_optional_select (customfieldadmin.tests.admin.CustomFieldAdminPageTestCase) ... ok
test_apply_optional_select (customfieldadmin.tests.admin.CustomFieldAdminPageTestCase) ... ok
test_create (customfieldadmin.tests.admin.CustomFieldAdminPageTestCase) ... ok

----------------------------------------------------------------------
Ran 14 tests in 0.155s

OK

Changed 6 months ago by t2y

remake to be able to patch for r13638

comment:4 Changed 6 months ago by t2y

I confirmed the list and reference custom format work after I made these fields with attached patch.
Could you review and merge it?

comment:5 Changed 6 months ago by jun66j5

  • Cc jun66j5 added

comment:6 Changed 8 weeks ago by rjollos

We'll at least address the issue in trac:#11469.

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.