diff --git a/assets/components/formsave/mgr/js/formsave.js b/assets/components/formsave/mgr/js/formsave.js index 9fd9994..c6debc8 100644 --- a/assets/components/formsave/mgr/js/formsave.js +++ b/assets/components/formsave/mgr/js/formsave.js @@ -22,8 +22,8 @@ */ var FormSave = function(config) { - config = config || {}; - FormSave.superclass.constructor.call(this,config); + config = config || {}; + FormSave.superclass.constructor.call(this,config); }; Ext.extend(FormSave, Ext.Component, { @@ -42,28 +42,35 @@ Ext.extend(FormSave, Ext.Component, { Ext.onReady(function() { if (Ext.get('formsave-container')) { - this.mainPanel = new Ext.Panel({ - renderTo: 'modx-panel-holder', - border: false, - autoHeight: true, - unstyled: true, - padding: 0, - margin: 0, - baseCls: 'fs-mainpanel', + this.mainPanel = new MODx.Panel({ + renderTo: 'formsave-container', + id: 'formsave-wrapper', + + // This panel will provide the scrolling for the search & export forms, + // and the grid itself. + // @todo Whould hook this into a resize event, so it works after a browser resize. + height: document.body.clientHeight - 60, // 60 is the height of the top toolbar + autoScroll: true, + items: [ - { + { html: '

', border: false, - cls: 'modx-page-header' + cls: 'modx-page-header' }, { - id: 'formsave-content', - border: false, - padding: '0px', - margin: '0px', - baseCls: 'formsave-content', - plain: true, - unstyled: true + xtype: 'modx-tabs' + ,defaults: { border: false, autoHeight: true } + ,border: true + ,items: [{ + // @todo Fix this by replacing it with a _() call + title: 'Stored Forms', + defaults: { autoHeight: true }, + items: [{ + xtype: 'modx-panel', + id: 'formsave-mainpanel' + }] + }], } ] }); @@ -219,17 +226,17 @@ Ext.extend(FormSave, Ext.Component, { }, getUrlVar: function(key) { // Thanks to: http://snipplr.com/users/Roshambo/ - var vars = [], hash; - var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - for(var i = 0; i < hashes.length; i++) - { - hash = hashes[i].split('='); - if (hash[0] == key) { - return hash[1]; - } - } - - return ''; + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++) + { + hash = hashes[i].split('='); + if (hash[0] == key) { + return hash[1]; + } + } + + return ''; }, createAlias: function(string) { string = string.toLowerCase(); @@ -239,20 +246,20 @@ Ext.extend(FormSave, Ext.Component, { if (allowed.indexOf(string[i]) != -1) { output += string[i]; } else { - output += '-'; + output += '-'; } - } + } while(output.indexOf('--') != -1) { - output = output.replace(/--/gi, '-', output); + output = output.replace(/--/gi, '-', output); } if (output.substr(0, 1) == '-') { - output = output.substr(1); + output = output.substr(1); } if (output.substr(-1) == '-') { - output = output.substr(0, (output.length)-1); + output = output.substr(0, (output.length)-1); } return output; @@ -260,29 +267,29 @@ Ext.extend(FormSave, Ext.Component, { }); function getDocHeight() { - var D = document; - return Math.max( - D.body.clientHeight, - window.innerHeight, - document.documentElement.clientHeight - ); + var D = document; + return Math.max( + D.body.clientHeight, + window.innerHeight, + document.documentElement.clientHeight + ); } function getWindowScrollSize() { - var D = document; - var y = Math.max( - Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), - Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), - Math.max(D.body.clientHeight, D.documentElement.clientHeight) - ); - - var x = Math.max( - Math.max(D.body.scrollWidth, D.documentElement.scrollWidth), - Math.max(D.body.offsetWidth, D.documentElement.offsetWidth), - Math.max(D.body.clientWidth, D.documentElement.clientWidth) - ); - - return {x: x, y: y}; + var D = document; + var y = Math.max( + Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), + Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), + Math.max(D.body.clientHeight, D.documentElement.clientHeight) + ); + + var x = Math.max( + Math.max(D.body.scrollWidth, D.documentElement.scrollWidth), + Math.max(D.body.offsetWidth, D.documentElement.offsetWidth), + Math.max(D.body.clientWidth, D.documentElement.clientWidth) + ); + + return {x: x, y: y}; } var fsCore = new FormSave(); \ No newline at end of file diff --git a/assets/components/formsave/mgr/js/page_forms.js b/assets/components/formsave/mgr/js/page_forms.js index de431cc..364e92c 100644 --- a/assets/components/formsave/mgr/js/page_forms.js +++ b/assets/components/formsave/mgr/js/page_forms.js @@ -22,7 +22,7 @@ */ var fsPageStores = Ext.extend(Ext.Panel, { - initComponent: function() { + initComponent: function() { // Rightclick mouse menu for the grid this.rowMenu = new Ext.menu.Menu({ baseParams: { @@ -47,9 +47,9 @@ var fsPageStores = Ext.extend(Ext.Panel, { Ext.getCmp('form-data-view').update(response.responseText); } }); - } - } - } + } + } + } }, { text: _('formsave.delete'), @@ -79,13 +79,55 @@ var fsPageStores = Ext.extend(Ext.Panel, { icon: Ext.MessageBox.QUESTION, scope: this }); - } - } + } + } } } ] }); + + this.combo = new Ext.form.ComboBox({ + name : 'perpage', + width: 40, + store: new Ext.data.ArrayStore({ + fields: ['id'], + data : [ + ['10'], + ['25'], + ['50'], + ['100'], + ['250'], + ['500'], + ['1000'] + ] + }), + mode : 'local', + value: '15', + listWidth : 40, + triggerAction : 'all', + displayField : 'id', + valueField : 'id', + editable : false, + forceSelection: true + }); + + this.bbar = new Ext.PagingToolbar({ + store: fsCore.stores.forms, + displayInfo: true, + pageSize: 250, + perpendButtons: true, + items: [ + '-', + 'Per Page: ', + this.combo + ] + }); + this.combo.on('select', function(combo, record) { + this.bbar.pageSize = parseInt(record.get('id'), 10); + this.bbar.doLoad(this.bbar.cursor); + }, this); + this.formGrid = new Ext.grid.GridPanel({ store: fsCore.stores.forms, autoHeight: true, @@ -102,60 +144,55 @@ var fsPageStores = Ext.extend(Ext.Panel, { singleSelect: true }) }, - bbar: new Ext.PagingToolbar({ - store: fsCore.stores.forms, - displayInfo: true, - pageSize: 25, - perpendButtons: true - }), + bbar: this.bbar, loadMask: true, enableDragDrop: true, - autoExpandColumn: 'form-data', - columns: [ + autoExpandColumn: 'form-data', + columns: [ { - xtype: 'gridcolumn', - dataIndex: 'id', - header: _('formsave.form_id'), + xtype: 'gridcolumn', + dataIndex: 'id', + header: _('formsave.form_id'), width: 100 - }, + }, { - xtype: 'gridcolumn', - dataIndex: 'topic', - header: _('formsave.form_topic') - }, + xtype: 'gridcolumn', + dataIndex: 'topic', + header: _('formsave.form_topic') + }, { - xtype: 'gridcolumn', - dataIndex: 'data_intro', + xtype: 'gridcolumn', + dataIndex: 'data_intro', id: 'form-data', - header: _('formsave.form_data_intro') - }, - { - xtype: 'gridcolumn', - dataIndex: 'time', - width: 50, - header: _('formsave.form_time'), - renderer: function(value) { - var formDate = Date.parseDate(value, 'U'); - return formDate.format('Y/m/d H:i'); - } - } - ], - listeners: { + header: _('formsave.form_data_intro') + }, + { + xtype: 'gridcolumn', + dataIndex: 'time', + width: 50, + header: _('formsave.form_time'), + renderer: function(value) { + var formDate = Date.parseDate(value, 'U'); + return formDate.format('Y/m/d H:i'); + } + } + ], + listeners: { added: { - scope: this, - fn: function() { - this.formGrid.getStore().load(); + scope: this, + fn: function() { + this.formGrid.getStore().load(); fsCore.stores.forms.load(); - } - }, - rowContextMenu: { - scope: this, - fn: function(grid, rowIndex, event) { - // Set the database ID in the menu's base params so we can access it when an action is performed - this.rowMenu.baseParams.rowId = fsCore.stores.forms.getAt(rowIndex).get('id'); - this.rowMenu.showAt(event.xy); - event.stopEvent(); - } + } + }, + rowContextMenu: { + scope: this, + fn: function(grid, rowIndex, event) { + // Set the database ID in the menu's base params so we can access it when an action is performed + this.rowMenu.baseParams.rowId = fsCore.stores.forms.getAt(rowIndex).get('id'); + this.rowMenu.showAt(event.xy); + event.stopEvent(); + } }, render: { scope: this, @@ -180,7 +217,7 @@ var fsPageStores = Ext.extend(Ext.Panel, { id: 'form-data-view', plain: true, border: false, - html: '' + html: '' } ], bbar: [ @@ -203,17 +240,86 @@ var fsPageStores = Ext.extend(Ext.Panel, { // The mainpanel always has to be in the "this.mainPanel" variable this.mainPanel = new Ext.Panel({ - renderTo: 'formsave-content', + renderTo: 'formsave-mainpanel', padding: 15, border: false, items: [ + // Search form + { + xtype: 'form', + border: false, + labelWidth: 175, + style: { + paddingTop: '10px', + paddingLeft: '10px', + paddingBottom: '10px', + marginBottom: '15px' + }, + // @todo Fix this to use _() + title: 'Search', + bbar: [ + { + xtype: 'label', + html: '
 
' + }, + { + xtype: 'button', + // @todo Fix this to use _() + text: 'Go', + scope: this, + handler: function() { + var term = Ext.getCmp('search').getValue().toLowerCase(); + var id = Ext.getCmp('search_id').getValue().toLowerCase(); + + if (term.length > 0) { + fsCore.stores.forms.filterBy(function(obj) { + for (var key in obj.data.data) { + if (typeof obj.data.data[key] == "string" && obj.data.data[key].toLowerCase().indexOf(term) != -1) return true; + } + return false; + }); + } + else if (id.length > 0) { + fsCore.stores.forms.filterBy(function(obj) { + if (obj.id == id) return true; + return false; + }); + } + } + } + ], + items: [ + { + xtype: 'textfield', + displayField: 'search_id', + // @todo Fix this to use _() + fieldLabel: 'Show just this ID', + name: 'search_id', + id: 'search_id' + }, + { + xtype: 'textfield', + displayField: 'search', + // @todo Fix this to use _() + fieldLabel: 'Search all fields', + name: 'search', + id: 'search' + } + ] + }, + // Export form { xtype: 'form', border: false, labelWidth: 175, style: { + paddingTop: '10px', + paddingLeft: '10px', + paddingBottom: '10px', marginBottom: '15px' }, + // @todo Fix this to use _() + title: 'Export', bbar: [ { xtype: 'label', @@ -346,7 +452,7 @@ var fsPageStores = Ext.extend(Ext.Panel, { } ] } - ] + ] }, this.formGrid ] diff --git a/core/components/formsave/elements/chunks/fs.datawrapper.tpl b/core/components/formsave/elements/chunks/fs.datawrapper.tpl index 7576130..ff14573 100644 --- a/core/components/formsave/elements/chunks/fs.datawrapper.tpl +++ b/core/components/formsave/elements/chunks/fs.datawrapper.tpl @@ -6,7 +6,7 @@ &m=`[[+time:date=`%m`]]` &y=`[[+time:date=`%Y`]]` &h=`[[+time:date=`%H`]]` - &m=`[[+time:date=`%M`]]` + &M=`[[+time:date=`%M`]]` &s=`[[+time:date=`%S`]]` ]]
[[%formsave.published]]: [[+published:eq=`1`:then=`[[%formsave.published_yes]]`:else=`[[%formsave.published_no]]`]] diff --git a/core/components/formsave/lexicon/en/default.inc.php b/core/components/formsave/lexicon/en/default.inc.php index 46722e8..6ae7d08 100644 --- a/core/components/formsave/lexicon/en/default.inc.php +++ b/core/components/formsave/lexicon/en/default.inc.php @@ -47,7 +47,7 @@ $_lang['formsave.form'] = 'Form: '; $_lang['formsave.ip'] = 'IP Address: '; $_lang['formsave.date'] = 'Date: '; -$_lang['formsave.dateformat'] = '[[+m]]/[[+d]]/[[+y]] [[+h]]:[[+m]]'; +$_lang['formsave.dateformat'] = '[[+m]]/[[+d]]/[[+y]] [[+h]]:[[+M]]'; $_lang['formsave.published_yes'] = 'Yes'; $_lang['formsave.published_no'] = 'No'; $_lang['formsave.published'] = 'Published'; diff --git a/core/components/formsave/lexicon/it/default.inc.php b/core/components/formsave/lexicon/it/default.inc.php index 4c668e0..2d529e3 100644 --- a/core/components/formsave/lexicon/it/default.inc.php +++ b/core/components/formsave/lexicon/it/default.inc.php @@ -47,7 +47,7 @@ $_lang['formsave.form'] = 'Modulo: '; $_lang['formsave.ip'] = 'Indirizzo IP: '; $_lang['formsave.date'] = 'Data: '; -$_lang['formsave.dateformat'] = '[[+d]]/[[+m]]/[[+y]] [[+h]]:[[+m]]'; +$_lang['formsave.dateformat'] = '[[+d]]/[[+m]]/[[+y]] [[+h]]:[[+M]]'; $_lang['formsave.published_yes'] = 'Si'; $_lang['formsave.published_no'] = 'No'; $_lang['formsave.published'] = 'Pubblicato'; diff --git a/core/components/formsave/lexicon/nl/default.inc.php b/core/components/formsave/lexicon/nl/default.inc.php index 5fd34f9..3766e9c 100644 --- a/core/components/formsave/lexicon/nl/default.inc.php +++ b/core/components/formsave/lexicon/nl/default.inc.php @@ -47,7 +47,7 @@ $_lang['formsave.form'] = 'Formulier: '; $_lang['formsave.ip'] = 'IP Adres: '; $_lang['formsave.date'] = 'Datum: '; -$_lang['formsave.dateformat'] = '[[+d]]-[[+m]]-[[+y]] [[+h]]:[[+m]]'; +$_lang['formsave.dateformat'] = '[[+d]]-[[+m]]-[[+y]] [[+h]]:[[+M]]'; $_lang['formsave.published_yes'] = 'Ja'; $_lang['formsave.published_no'] = 'Nee'; $_lang['formsave.published'] = 'Gepubliceerd';