Commit 4278b32c authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[xsd2uicfg] Generate autoform field kwargs rule for string attributes

so they use a simple TextInput rather than a TextArea.
parent 256b381dc1f4
......@@ -18,7 +18,6 @@
import json
from cubicweb.predicates import match_form_params, is_instance
from cubicweb.web import formwidgets as fw
from cubicweb.web.views import uicfg, tabs
from cubes.relationwidget import views as rwdg
......@@ -30,14 +29,11 @@ _ = unicode
affk = uicfg.autoform_field_kwargs
pvdc = uicfg.primaryview_display_ctrl
rec = uicfg.reledit_ctrl
for etype in ('SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
affk.set_fields_order(etype, ('id', 'user_cardinality', 'user_annotation'))
pvdc.set_fields_order(etype, ('id', 'user_cardinality', 'user_annotation'))
affk.set_field_kwargs('*', 'id', widget=fw.TextInput({'size': 80}))
def _container_eid(entity):
"""Attempt to return the container eid from the entity, handling case where entity is being
......@@ -120,7 +116,6 @@ class BinaryDataObjectTabbedPrimaryView(tabs.TabbedPrimaryView):
]
affk.set_field_kwargs('*', 'format_litteral', widget=fw.TextInput({'size': 80}))
affk.set_fields_order('SEDAFormatLitteral', ('user_cardinality', 'format_litteral'))
......
......@@ -14,6 +14,8 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""THIS FILE IS GENERATED FROM SEDA 2.0 XSD FILES, DO NOT EDIT"""
from cubicweb.web import formwidgets as fw
from cubicweb.web.views import uicfg
ives = uicfg.indexview_etype_section
......@@ -590,6 +592,51 @@ afs.tag_subject_of(('*', 'seda_relationship_code_list_version_to', '*'), 'main',
affk = uicfg.autoform_field_kwargs
affk.tag_subject_of(('*', 'comment', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'related_transfer_reference', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'transfer_request_reply_identifier', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'id', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'service_level', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'href', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'restriction_rule_id_ref', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'restriction_value', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'title', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'file_plan_position', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'system_id', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'originating_system_id', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'archival_agency_archive_unit_identifier', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'originating_agency_archive_unit_identifier', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'transferring_agency_archive_unit_identifier', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'description', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'type', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'document_type', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'status', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'version', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'tag', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'source', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_version_id', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_altitude_ref', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_latitude', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_latitude_ref', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_longitude', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_longitude_ref', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'gps_date_stamp', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'masterdata', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'event_identifier', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'event_detail', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'repository_archive_unit_pid', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'repository_object_pid', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'spatial', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'temporal', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'juridictional', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'keyword_content', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'custodial_history_item', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'shape', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'creating_application_name', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'creating_application_version', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'creating_os', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'creating_os_version', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'format_litteral', '*'), {'widget': fw.TextInput({'size': 80})})
affk.tag_subject_of(('*', 'seda_mime_type_code_list_version_to', '*'), {'label': 'value'})
affk.tag_subject_of(('*', 'seda_encoding_code_list_version_to', '*'), {'label': 'value'})
affk.tag_subject_of(('*', 'seda_compression_algorithm_code_list_version_to', '*'), {'label': 'value'})
......
......@@ -64,7 +64,9 @@ class UICFGGenerator(object):
}
def generate(self, mapping, stream):
self._processed = set()
stream.write(PY_HEADER)
stream.write('\nfrom cubicweb.web import formwidgets as fw\n')
stream.write('from cubicweb.web.views import uicfg\n\n')
# indexview_etype_section configuration
stream.write('ives = uicfg.indexview_etype_section\n')
......@@ -110,6 +112,12 @@ class UICFGGenerator(object):
role = 'subject'
yield mapping.rtype, role, section
def autoform_field_kwargs_for_e_type_mapping(self, mapping):
for rtype, target_etype in sorted(mapping.attributes.items()):
if target_etype == 'String' and rtype not in self._processed:
self._processed.add(rtype)
yield rtype, 'subject', {'widget': Code("fw.TextInput({'size': 80})")}
def autoform_field_kwargs_for_rdef_mapping(self, mapping):
if mapping.rtype.endswith('code_list_version_to'):
yield mapping.rtype, 'subject', {'label': 'value'}
......@@ -124,6 +132,14 @@ class UICFGGenerator(object):
yield mapping.rtype, role, section
class Code(unicode):
"""Special unicode subclass whose repr() doesn't add quotes, for insertion of python code in a data
structure
"""
def __repr__(self):
return str(self)
if __name__ == '__main__':
import sys
UICFGGenerator().generate(xsy_mapping(), sys.stdout)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment