Modify

Opened 12 years ago

Closed 4 years ago

#10284 closed enhancement (fixed)

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

Reported by: ejucovy Owned by: Ryan J Ollos
Priority: normal Component: CustomFieldAdminPlugin
Severity: normal Keywords:
Cc: Jun Omae Trac Release: 1.0

Description (last modified by Ryan J Ollos)

Per #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 Tetsuya Morimoto 10 years ago.
remake to be able to patch for r13638

Download all attachments as: .zip

Change History (14)

comment:1 Changed 10 years ago by Tetsuya Morimoto

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 10 years ago by Tetsuya Morimoto

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

comment:3 Changed 10 years ago by Tetsuya Morimoto

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 10 years ago by Tetsuya Morimoto

remake to be able to patch for r13638

comment:4 Changed 10 years ago by Tetsuya Morimoto

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 10 years ago by Jun Omae

Cc: Jun Omae added; anonymous removed

comment:6 Changed 10 years ago by Ryan J Ollos

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

comment:7 Changed 7 years ago by Jun Omae

I think patched plugin on Trac 0.12.x should show only supported types (reference and list types shouldn't be shown on Trac 0.12.x). If it is difficult to implement with single source, we should create new branch for Trac 1.0.

comment:8 Changed 6 years ago by Christiaan

Will you also then look at the MultiSelectFieldPlugin as it has a .options = for a text field which this removes. I didn't think I need to create a new ticket for that.

Last edited 4 years ago by Ryan J Ollos (previous) (diff)

comment:9 Changed 4 years ago by Ryan J Ollos

Description: modified (diff)

comment:10 in reply to:  8 Changed 4 years ago by Ryan J Ollos

Replying to Christiaan:

Will you also then look at the MultiSelectFieldPlugin as it has a .options = for a text field which this removes. I didn't think I need to create a new ticket for that.

This will be addressed in trac:#13206.

comment:11 Changed 4 years ago by Ryan J Ollos

Owner: changed from osimons to Ryan J Ollos
Status: newaccepted

comment:12 Changed 4 years ago by Ryan J Ollos

In 17761:

TracCustomFieldAdmin 0.3.0dev: Rename branch and support 1.2+

Add support for text type reference and list formats.

Refs #10284.

comment:13 Changed 4 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.