diff --git a/models/widgets_fields.py b/models/widgets_fields.py index 7c6682ffc331e8de9a57620ef41eff86eea0fa54..a60b71a81374e9407d8790918b99ce95e45b25da 100644 --- a/models/widgets_fields.py +++ b/models/widgets_fields.py @@ -6,7 +6,6 @@ # # harvest selector (merge) # -#------------------------------------------------------------------------------- fieldsModifier = dbui.FieldsModifier('harvester_selector') fieldsModifier.configure_field('year_start', flex=1) fieldsModifier.configure_field('year_end', flex=1) @@ -16,7 +15,6 @@ fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Year')) # # new_fields # -#------------------------------------------------------------------------------- fieldsModifier = dbui.FieldsModifier('new_fields') fieldsModifier.configure_field('dictionary', headers=['foo', 'faa'], modifyKeys=True, @@ -25,14 +23,13 @@ fieldsModifier.configure_field('dictionary', headers=['foo', 'faa'], "integer": 0, "float": 0.01, "date": "not implemented"}) - -fieldsModifier.configure_field('python_code', xtype='xaceeditorfield',) + +fieldsModifier.configure_field('python_code', xtype='xaceeditorfield') #------------------------------------------------------------------------------- # # publications # -#------------------------------------------------------------------------------- fieldsModifier = dbui.FieldsModifier('publications') fieldsModifier.configure_field('conference_start', format='Y-m-d') fieldsModifier.configure_field('conference_end', format='Y-m-d') diff --git a/models/widgets_forms.py b/models/widgets_forms.py index 9ef413461132ec98f6964935501608cd24772390..8084cec472c26a9407a28041bfb296031340cfde 100644 --- a/models/widgets_forms.py +++ b/models/widgets_forms.py @@ -2,11 +2,13 @@ """ widgets forms """ +#------------------------------------------------------------------------------- # # add plugin to all forms # dbui.configure_forms(db, plugins=['pFormToolTip']) +#------------------------------------------------------------------------------- # # link comboboxes in foo1 selector # @@ -19,6 +21,7 @@ dbui.configure_forms(db, plugins=['pFormToolTip']) # displayFieldSlaves='granularity_local', # valueFieldSlaves='granularity') +#------------------------------------------------------------------------------- # # link several comboboxes in harvester selector # @@ -32,14 +35,14 @@ formModifier.link_comboboxes(master=virtdb.harvester_selector.id_projects, slave=virtdb.harvester_selector.id_teams, masterHasSlaveData='harvesters') -# -# new fields +#------------------------------------------------------------------------------- +# +# new_fields # formModifier = dbui.FormModifier('new_fields') -formModifier.configure(width=400, - defaults={'width': 270}) - +formModifier.configure(width=400) +#------------------------------------------------------------------------------- # # Create fieldSet for the publication form # diff --git a/models/widgets_viewport.py b/models/widgets_viewport.py index ae668ba4fbb7d222978d3b1ab23bca216bb1004c..fbd0374a4155e2ab2283a4431d5d3241dfa517a1 100644 --- a/models/widgets_viewport.py +++ b/models/widgets_viewport.py @@ -17,9 +17,7 @@ for tablename in ('categories', 'harvesters', 'publications', 'new_fields'): items=[dbui.to_formPanel(db[tablename])], layout='fit', title="Add %s ..." % tablename, - modal=True, - autoHeight=True, - widht=500) + modal=True) formNode.add_child(T(tablename), leaf) diff --git a/static/plugin_dbui/src/fielddict.js b/static/plugin_dbui/src/fielddict.js index 497f83172465e8f059ed24f36252118b0aaa54df..080388a7b3a536763c66d9f2baa65841d15db8cf 100644 --- a/static/plugin_dbui/src/fielddict.js +++ b/static/plugin_dbui/src/fielddict.js @@ -58,10 +58,6 @@ Ext.define('App.form.DictField', { */ headers: null, - /** - * @cfg {Number} height - * The height of the widget. - */ /** * @cfg {Boolean} * The columns header is hidden when true. @@ -98,7 +94,6 @@ Ext.define('App.form.DictField', { // property grid this.grid = Ext.create('Ext.grid.property.Grid', { - height: this.height, hideHeaders: this.hideHeaders, source: Ext.apply({}, this.dictCfg), }); @@ -152,6 +147,7 @@ Ext.define('App.form.DictField', { beforeDestroy: function () { this.grid.un('cellcontextmenu', this.onCellContextMenu, this); + this.grid.un('containercontextmenu', this.onContainerContextMenu, this); this.grid.un('headercontextmenu', this.onHeaderContextMenu, this); Ext.destroyMembers(this, 'grid'); @@ -295,6 +291,19 @@ Ext.define('App.form.DictField', { this.bodyEl.setVisibilityMode(Ext.dom.Element.DISPLAY).hide(); }, + /** + * Resize the component + * + * @param {Number} w + * @param {Number} h + * + */ + onResize: function (w, h) { + + this.grid.setSize(w - this.getLabelWidth(), h); + this.callParent(arguments); + }, + /** * Update a key. */ diff --git a/static/plugin_dbui/src/fieldeditor.js b/static/plugin_dbui/src/fieldeditor.js index e1ec9fca814cebc8cd304e16c8de953f673d82f0..deddad36ee6a4af67f684a271861c87ce75644ce 100644 --- a/static/plugin_dbui/src/fieldeditor.js +++ b/static/plugin_dbui/src/fieldeditor.js @@ -25,7 +25,7 @@ Ext.define('App.form.AceEditorField', { language: 'python', /** - * @cfg {Number} + * @cfg {Number} [required] * The height of the editor widget */ editorHeight: 150, @@ -38,6 +38,16 @@ Ext.define('App.form.AceEditorField', { // private property editor: null, + // private method requests by the component model of ExtJS + initComponent: function (config) { + + // Hack to get the size of the editor render properly + // The width is to small when it is not specified. + this.minWidth = this.minWidth || 258; + + this.callParent(arguments); + }, + // private method requests by the component model of ExtJS beforeDestroy: function () { @@ -77,7 +87,6 @@ Ext.define('App.form.AceEditorField', { // wrap an element around the input field this.resizeEl = this.positionEl = this.wrap = this.bodyEl.wrap(); - // the editor require that the width an height are defined this.wrap.setWidth(this.wrap.getWidth()); this.wrap.setHeight(this.editorHeight); @@ -95,6 +104,23 @@ Ext.define('App.form.AceEditorField', { this.bodyEl.setVisibilityMode(Ext.dom.Element.DISPLAY).hide(); }, + /** + * Resize the component + * + * @param {Number} w + * @param {Number} h + * + */ + onResize: function (w, h) { + + this.wrap.setSize(w - this.getLabelWidth(), h); + if (this.editor) { + this.editor.resize(); + } + + this.callParent(arguments); + }, + /** * Set the value for this field. * diff --git a/static/plugin_dbui/src/fieldlist.js b/static/plugin_dbui/src/fieldlist.js index 44dd27abc277a9d0cd3b83d650b32f510454f4be..095f3b04d2cfaffdc9c408165d630fb6496fcae3 100644 --- a/static/plugin_dbui/src/fieldlist.js +++ b/static/plugin_dbui/src/fieldlist.js @@ -4,6 +4,10 @@ * * **Note** :The list can only contains string. * + * **Note** : The onRender handle can be removed using the approach + * describe in the url (see rixo): + * http://stackoverflow.com/questions/6153362/how-to-create-custom-extjs-form-field-component + * * @experimental * @since 0.4.15.0 * @@ -19,10 +23,6 @@ Ext.define('App.form.ListField', { */ header: 'Element', - /** - * @cfg {number} height - * The height of the widget. - */ /** * @cfg {boolean} * Hide the column header when true. @@ -64,6 +64,10 @@ Ext.define('App.form.ListField', { var cellEditing; + // Hack to get the size of the grid render properly. + // The width is to small when it is not specified. + this.minWidth = this.minWidth || 258; + // instantiate the local store this.store = Ext.create('Ext.data.ArrayStore', { fields: [{name: 'element'}] @@ -90,11 +94,6 @@ Ext.define('App.form.ListField', { store: this.store, }); - // Set the height of the grid with a bottom margin of 10 - if (this.height) { - this.grid.setHeight(this.height); - } - // instantiate the context menu this.menu = Ext.create('Ext.menu.Menu', { items: [{ @@ -322,6 +321,19 @@ Ext.define('App.form.ListField', { this.bodyEl.setVisibilityMode(Ext.dom.Element.DISPLAY).hide(); }, + /** + * Resize the component + * + * @param {Number} w + * @param {Number} h + * + */ + onResize: function (w, h) { + + this.grid.setSize(w - this.getLabelWidth(), h); + this.callParent(arguments); + }, + /** * Set the value for this field. *