[hg] galaxy 2792: Sample Form definitions:
details: http://www.bx.psu.edu/hg/galaxy/rev/874817d9147a changeset: 2792:874817d9147a user: rc date: Mon Sep 28 13:37:14 2009 -0400 description: Sample Form definitions: - layout details added to csv file importer - form preview 3 file(s) affected in this change: lib/galaxy/web/controllers/forms.py lib/galaxy/web/controllers/requests_admin.py templates/admin/forms/show_form_read_only.mako diffs (236 lines): diff -r 40c3c7798b64 -r 874817d9147a lib/galaxy/web/controllers/forms.py --- a/lib/galaxy/web/controllers/forms.py Mon Sep 28 12:39:53 2009 -0400 +++ b/lib/galaxy/web/controllers/forms.py Mon Sep 28 13:37:14 2009 -0400 @@ -307,7 +307,7 @@ fields.append(self.__get_field(i, **kwd)) fields = fields else: - fields = self.__import_fields(trans, csv_file, form_type) + fields, layout = self.__import_fields(trans, csv_file, form_type) return name, desc, form_type, layout, fields def __update_current_form(self, trans, **kwd): name, desc, form_type, layout, fields = self.__get_form(trans, **kwd) @@ -325,6 +325,7 @@ ''' import csv fields = [] + layouts = set() try: reader = csv.reader(csv_file.file) if form_type == trans.app.model.FormDefinition.types.SAMPLE: @@ -337,6 +338,7 @@ 'type': row[4], 'selectlist': options, 'layout':row[6]}) + layouts.add(row[6]) else: for row in reader: options = row[5].split(',') @@ -353,7 +355,7 @@ message='Error in importing <b>%s</b> file' % csv_file, **kwd)) self.__imported_from_file = True - return fields + return fields, list(layouts) def __save_form(self, trans, fdc_id=None, **kwd): ''' diff -r 40c3c7798b64 -r 874817d9147a lib/galaxy/web/controllers/requests_admin.py --- a/lib/galaxy/web/controllers/requests_admin.py Mon Sep 28 12:39:53 2009 -0400 +++ b/lib/galaxy/web/controllers/requests_admin.py Mon Sep 28 13:37:14 2009 -0400 @@ -710,7 +710,11 @@ select_user.add_option('Select one', 'none', selected=True) else: select_user.add_option('Select one', 'none') - for user in trans.app.model.User.query().all(): + def __get_email(user): + return user.email + user_list = trans.app.model.User.query().all() + user_list.sort(key=__get_email) + for user in user_list: if not user.deleted: if userid == str(user.id): select_user.add_option(user.email, user.id, selected=True) diff -r 40c3c7798b64 -r 874817d9147a templates/admin/forms/show_form_read_only.mako --- a/templates/admin/forms/show_form_read_only.mako Mon Sep 28 12:39:53 2009 -0400 +++ b/templates/admin/forms/show_form_read_only.mako Mon Sep 28 13:37:14 2009 -0400 @@ -6,62 +6,126 @@ ${render_msg( msg, messagetype )} %endif +<%def name="render_grid( grid_index, grid_name, fields_dict )"> + %if grid_name: + <div class="toolFormTitle">${grid_name}</div> + %endif + <div style="clear: both"></div> + <table class="grid"> + <thead> + <tr> + %for index, field in fields_dict.items(): + <th> + ${field['label']} + <div class="toolParamHelp" style="clear: both;"> + <i>${field['helptext']}</i> + </div> + </th> + %endfor + <th></th> + </tr> + <thead> + <tbody> + <tr> + %for index, field in fields_dict.items(): + <td> + <div>${field['required']}</div> +## <div>${field['type']}</div> + </td> + %endfor + <th></th> + </tr> + %for index, field in fields_dict.items(): + <td> +## <div>${field['required']}</div> + <div><i>Type:</i></div> + <div>${field['type']}</div> + </td> + %endfor + <th></th> + </tr> + <tr> + %for index, field in fields_dict.items(): + <td> + %if field['type'] == 'SelectField': + <div><i>Options:</i></div> + %for option in field['selectlist']: + <div>${option}</div> + %endfor + %endif + </td> + %endfor + <th></th> + </tr> + <tbody> + </table> +</%def> + <div class="toolForm"> <div class="toolFormTitle">${form.name} - <i>${form.desc}</i></div> <form name="library" action="${h.url_for( controller='forms', action='manage' )}" method="post" > - <table class = "grid"> - <tbody> - %for index, field in enumerate(form.fields): - <tr> - <td> - <div class="form-row"> - <label>${1+index}. Label</label> - <a>${field['label']}</a> - %if field['type'] == 'SelectField': - <a id="${field['label']}-popup" class="popup-arrow" style="display: none;">▼</a> - %for option in field['selectlist']: - <div popupmenu="${field['label']}-type-popup"> - <a class="action-button" href="" >${option}</a> - </div> - %endfor - %endif - </div> - </td> - <td> - <div class="form-row"> - <label>Help text </label> - %if not field['helptext']: - <a><i>No helptext</i></a> - %else: - <a>${field['helptext']}</a> - %endif - </div> - </td> - <td> - <div class="form-row"> - <label>Type:</label> - <a>${field['type']}</a> - %if field['type'] == 'SelectField': - <a id="fieldtype-popup" class="popup-arrow" style="display: none;">▼</a> - %for option in field['selectlist']: - <div popupmenu="type-popup"> - <a class="action-button" href="" >${option}</a> - </div> - %endfor - %endif - </div> - </td> - <td> - <div class="form-row"> - <label>Required?</label> - <a>${field['required']}</a> - </div> - </td> - </tr> + %if form.type == trans.app.model.FormDefinition.types.SAMPLE: + %if not len(form.layout): + ${render_grid( 0, '', form.fields_of_grid( None ) )} + %else: + %for grid_index, grid_name in enumerate(form.layout): + ${render_grid( grid_index, grid_name, form.fields_of_grid( grid_name ) )} %endfor - </tbody> - </table> - ##<input type="submit" name="save_changes_button" value="Back"/> + %endif + %else: + <table class = "grid"> + <tbody> + %for index, field in enumerate(form.fields): + <tr> + <td> + <div class="form-row"> + <label>${1+index}. Label</label> + <a>${field['label']}</a> + %if field['type'] == 'SelectField': + <a id="${field['label']}-popup" class="popup-arrow" style="display: none;">▼</a> + %for option in field['selectlist']: + <div popupmenu="${field['label']}-type-popup"> + <a class="action-button" href="" >${option}</a> + </div> + %endfor + %endif + </div> + </td> + <td> + <div class="form-row"> + <label>Help text </label> + %if not field['helptext']: + <a><i>No helptext</i></a> + %else: + <a>${field['helptext']}</a> + %endif + </div> + </td> + <td> + <div class="form-row"> + <label>Type:</label> + <a>${field['type']}</a> + %if field['type'] == 'SelectField': + <a id="fieldtype-popup" class="popup-arrow" style="display: none;">▼</a> + %for option in field['selectlist']: + <div popupmenu="type-popup"> + <a class="action-button" href="" >${option}</a> + </div> + %endfor + %endif + </div> + </td> + <td> + <div class="form-row"> + <label>Required?</label> + <a>${field['required']}</a> + </div> + </td> + </tr> + %endfor + </tbody> + </table> + %endif </form> </div> </div> \ No newline at end of file
participants (1)
-
Nate Coraor