From 91339447f36a787cb0f7e86bf158c421e3623ef9 Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Fri, 13 Nov 2009 13:58:59 +0000
Subject: [PATCH] Manage Field Library: add column to show the current template
 field

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30562 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...usinessTemplate_getModifiableFieldList.xml | 38 +++++++++++++------
 .../listbox.xml                               | 10 ++++-
 bt5/erp5_forge/bt/revision                    |  2 +-
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getModifiableFieldList.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getModifiableFieldList.xml
index 4cfd4d9666..d73e1b0e9e 100644
--- a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getModifiableFieldList.xml
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_getModifiableFieldList.xml
@@ -140,15 +140,19 @@ for skin_folder_id in context.getTemplateSkinIdList():\n
             # XXX Should check if this field is used as a template\n
             field_path = \'%s/%s/%s\' % (skin_folder_id, form_id, field.getId())\n
             if field.meta_type == \'ProxyField\':\n
+              template_form_id = field.get_value(\'form_id\')\n
+              template_id = \'%s/%s\' % (template_form_id,\n
+                                       field.get_value(\'field_id\'))\n
               if field.getTemplateField() is None:\n
-                modified_object_dict[field_path] = \'0_keep_dead_proxy_field\'\n
+                modified_object_dict[field_path] = (\'0_keep_dead_proxy_field\',\n
+                                                    template_id)\n
               else:\n
-                template_form_id = field.get_value(\'form_id\')\n
                 if template_form_id not in (\n
                   \'Base_viewFieldLibrary\',\n
                   field_library_id\n
                   ):\n
-                  modified_object_dict[field_path] = \'2_unproxify_field\'\n
+                  modified_object_dict[field_path] = (\'2_unproxify_field\',\n
+                                                      template_id)\n
             else:\n
               # Do not force proxification of field library field.\n
               # The nice developper probably have a good reason not to do it.\n
@@ -158,22 +162,25 @@ for skin_folder_id in context.getTemplateSkinIdList():\n
           for field in form.objectValues():\n
             field_path = \'%s/%s/%s\' % (skin_folder_id, form_id, field.getId())\n
             if field.meta_type == \'ProxyField\':\n
+              template_form_id = field.get_value(\'form_id\')\n
+              template_id = \'%s/%s\' % (template_form_id,\n
+                                       field.get_value(\'field_id\'))\n
               if field.getTemplateField() is None:\n
-                modified_object_dict[field_path] = \'0_keep_dead_proxy_field\'\n
+                modified_object_dict[field_path] = (\'0_keep_dead_proxy_field\',\n
+                                                    template_id)\n
               else:\n
-                template_form_id = field.get_value(\'form_id\')\n
-                # XXX Only considere standard bt5 for now\n
+                # XXX Only consider standard bt5 for now\n
                 template_form_path = \'%s/%s\' % (skin_folder_id, template_form_id)\n
                 if template_form_id != field_library_id:\n
-                  modified_object_dict[field_path] = \'2_unproxify_field\'\n
+                  modified_object_dict[field_path] = (\'2_unproxify_field\',\n
+                                                      template_id)\n
                   # XXX Should proxify to a library\'s field\n
                 else:\n
                   # Check that there is no delegated values\n
                   if field.delegated_list:\n
                     # Found some delegated list\n
-                    modified_object_dict[field_path] = \'0_check_delegated_value\'\n
-                  else:\n
-                    pass\n
+                    modified_object_dict[field_path] = (\n
+                      \'0_check_delegated_value\', template_id)\n
             else:\n
               # Do not force proxification of field.\n
               # The nice developper probably have a good reason not to do it.\n
@@ -182,19 +189,23 @@ for skin_folder_id in context.getTemplateSkinIdList():\n
 i = 0\n
 for key, value in modified_object_dict.items():\n
   line = newTempBase(context, \'tmp_install_%s\' %(str(i)))\n
- \n
+  if isinstance(value, tuple):\n
+    value, template_id = value\n
+  else:\n
+    template_id = None\n
   if value.startswith(\'0_\'):\n
     choice = []\n
   else:\n
     choice = [value]\n
   line.edit(\n
     object_id=key,\n
+    template_id=template_id,\n
     choice=choice,\n
     choice_item_list=[[action_title_dict[value], value]],\n
   )\n
   line.setUid(\'new_%s\' % key)\n
   field_list.append(line)\n
-  i += 1                                  \n
+  i += 1\n
 \n
 field_list.sort(key=lambda x:(x.choice_item_list[0][1], x.object_id))\n
 \n
@@ -267,12 +278,15 @@ return field_list\n
                             <string>field</string>
                             <string>field_path</string>
                             <string>template_form_id</string>
+                            <string>template_id</string>
                             <string>template_form_path</string>
                             <string>i</string>
                             <string>key</string>
                             <string>value</string>
                             <string>str</string>
                             <string>line</string>
+                            <string>isinstance</string>
+                            <string>tuple</string>
                             <string>choice</string>
                             <string>_inplacevar_</string>
                           </tuple>
diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_viewFieldLibraryManagementDialog/listbox.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_viewFieldLibraryManagementDialog/listbox.xml
index 67947dd571..0b72094c53 100644
--- a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_viewFieldLibraryManagementDialog/listbox.xml
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BusinessTemplate_viewFieldLibraryManagementDialog/listbox.xml
@@ -352,6 +352,10 @@
                           <string>object_id</string>
                           <string>ID</string>
                         </tuple>
+                        <tuple>
+                          <string>template_id</string>
+                          <string>Template</string>
+                        </tuple>
                         <tuple>
                           <string>choice</string>
                           <string>Update</string>
@@ -420,9 +424,13 @@
                     <key> <string>hidden</string> </key>
                     <value> <int>0</int> </value>
                 </item>
+                <item>
+                    <key> <string>hide_rows_on_no_search_criterion</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
                 <item>
                     <key> <string>lines</string> </key>
-                    <value> <int>1000</int> </value>
+                    <value> <int>0</int> </value>
                 </item>
                 <item>
                     <key> <string>list_action</string> </key>
diff --git a/bt5/erp5_forge/bt/revision b/bt5/erp5_forge/bt/revision
index 3c2af958d8..19afd4ebd9 100644
--- a/bt5/erp5_forge/bt/revision
+++ b/bt5/erp5_forge/bt/revision
@@ -1 +1 @@
-526
\ No newline at end of file
+527
\ No newline at end of file
-- 
2.30.9