// we use the metadata loaded into the stash to create window tabs // each tab is one table // all tabs are in the same "form" wrt ajax submission // most of the messing about is to get the right form field types // also readonly, validation var tabs = [ [% FOREACH tname IN lf.tab_order.nsort %] [% SET info = lf.table_info.$tname %] [% ',' IF lf.tab_order.keys.size > 1 AND NOT loop.first %]{ [% IF lf.tab_order.item(tname) == 1 %] title: '[% lf.main.title %]' [% ELSE %] title: 'New [% info.title %]' ,xtype: 'fieldset' ,checkboxToggle: true ,checkboxName: 'checkbox.[% info.path %]' ,collapsed: true [% END %] ,items: [ [% SET count = 1 %] [% FOREACH field IN info.col_order %] [% NEXT IF info.cols.$field.is_rr %] [% ',' IF count > 1 %]{ [% SET count = count + 1 %] [% IF lf.tab_order.item(tname) == 1 %] name: '[% field %]' ,id: '[% field %]' [% ELSE %] name: '[% info.path %].[% field %]' ,id: '[% info.path %].[% field %]' [% END %] ,fieldLabel: '[% info.cols.$field.heading %]' ,anchor: '-20' ,autoHeight: true [% IF info.cols.$field.default_value %] ,value: '[% info.cols.$field.default_value | replace('\'', '\\\'') %]' [% END %] [% UNLESS info.cols.$field.editable %] ,readOnly: true ,cls: 'x-item-disabled' //,disabled: true // argh, prevents submit :-( so use cls [% ELSIF info.cols.$field.required %] ,allowBlank: false [% END %] [% IF info.cols.$field.is_fk AND info.cols.$field.editable %] ,xtype: 'combo' ,displayField: 'stringified' ,valueField: 'dbid' ,hiddenName: 'combobox.[% field %]' ,loadingText: 'Searching...' ,forceSelection: true ,selectOnFocus: true ,typeAhead: false ,pageSize: 5 ,triggerAction: 'all' ,store: new Ext.data.JsonStore({ url: '[% c.uri_for( c.controller('LFB::Root').action_for('db_picker'), db, info.path, "list_stringified" ) %]' ,root: 'rows' ,totalProperty: 'total' ,fields: [ 'dbid', 'stringified' ] ,listeners: { beforeload: function(store, options) { var start = options.params.start; var limit = options.params.limit; options.params.page = Math.floor(start / limit) + 1; options.params.fkname = '[% field %]'; return true; } } }) [% ELSE %] ,xtype: '[% info.cols.$field.extjs_xtype OR "textfield" %]' [% SWITCH info.cols.$field.extjs_xtype %] [% CASE 'timefield' %] ,format: 'H:i:s' [% CASE 'datefield' %] ,format: 'Y-m-d' [% CASE 'xdatetime' %] ,otherToNow: false ,dateFormat: 'Y-m-d' ,timeFormat: 'H:i:s' [% END %] [% END %] } [% END %] ] } [% END %] ];