partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 3ecd3b2d24863229911156d1807c821988b6bc63
parent 199249ebc2a898734e442b2e3db199413957e479
Author: Felicitus <felicitus@felicitus.org>
Date:   Tue,  8 Sep 2015 15:49:32 +0200

Renamed Ext.ux.SearchField to PartKeepr.form.field.SearchField, refactored directory structure to match class path

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/EditorGrid.js | 2+-
Dsrc/PartKeepr/FrontendBundle/Resources/public/js/Ext.ux/SearchField.js | 114-------------------------------------------------------------------------------
Asrc/PartKeepr/FrontendBundle/Resources/public/js/form/field/SearchField.js | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Resources/views/index.html.twig | 2+-
4 files changed, 116 insertions(+), 116 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/EditorGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Editor/EditorGrid.js @@ -124,7 +124,7 @@ Ext.define('PartKeepr.EditorGrid', { }, this) }); - this.searchField = Ext.create("Ext.ux.form.SearchField", { + this.searchField = Ext.create("PartKeepr.form.field.SearchField", { store: this.store, targetField: 'name' }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Ext.ux/SearchField.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Ext.ux/SearchField.js @@ -1,113 +0,0 @@ -/** - * Defines a search field, which automatically hooks into the passed store. - * - * The "clear" trigger is shown only when text is entered. - */ -Ext.define('Ext.ux.form.SearchField', { - extend: 'Ext.form.field.Text', - alias: 'widget.searchfield', - - triggers: { - clear: { - cls: Ext.baseCSSPrefix + 'form-clear-trigger', - hidden: true, - handler: 'resetSearch', - scope: 'this', - }, - search: { - cls: Ext.baseCSSPrefix + 'form-search-trigger', - handler: 'startSearch', - scope: 'this' - } - }, - - hasSearch : false, - - /** - * Defines the parameter name which is being passed to the store's proxy. - */ - targetField : 'query', - - filter: null, - - listeners: { - 'specialkey': { - fn: 'keyHandler', - scope: 'this' - } - }, - - /** - * Initializes the component. Binds the enter key to startSearch. - */ - initComponent: function(){ - this.callParent(arguments); - - this.filter = Ext.create("Ext.util.Filter", { - property: this.targetField, - value: '', - operator: 'like' - }); - }, - /** - * Handles special keys used in this field. - * - * Enter: Starts the search - * Escape: Removes the search and clears the field contents - */ - keyHandler: function (field, e) { - switch (e.getKey()) { - case e.ENTER: - this.startSearch(); - break; - case e.ESC: - this.resetSearch(); - break; - } - }, - /** - * Resets the search field to empty and re-triggers the store to load the matching records. - */ - resetSearch: function () { - var me = this, - store = me.store, - val; - - me.setValue(''); - - if (me.hasSearch) { - - store.removeFilter(this.filter); - - store.currentPage = 1; - store.load({ start: 0 }); - me.hasSearch = false; - - this.getTrigger("clear").hide(); - } - }, - /** - * Starts the search with the entered value. - */ - startSearch: function () { - var me = this, - store = me.store, - value = me.getValue(); - - if (value.length < 1) { - me.resetSearch(); - return; - } - - this.filter.setValue("%"+value+"%"); - store.addFilter(this.filter); - store.currentPage = 1; - store.load({ start: 0 }); - - me.hasSearch = true; - this.getTrigger("clear").show(); - }, - setStore: function (store) { - this.store = store; - } -});- \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/form/field/SearchField.js b/src/PartKeepr/FrontendBundle/Resources/public/js/form/field/SearchField.js @@ -0,0 +1,113 @@ +/** + * Defines a search field, which automatically hooks into the passed store. + * + * The "clear" trigger is shown only when text is entered. + */ +Ext.define('PartKeepr.form.field.SearchField', { + extend: 'Ext.form.field.Text', + alias: 'widget.partkeepr-searchfield', + + triggers: { + clear: { + cls: Ext.baseCSSPrefix + 'form-clear-trigger', + hidden: true, + handler: 'resetSearch', + scope: 'this', + }, + search: { + cls: Ext.baseCSSPrefix + 'form-search-trigger', + handler: 'startSearch', + scope: 'this' + } + }, + + hasSearch : false, + + /** + * Defines the parameter name which is being passed to the store's proxy. + */ + targetField : 'query', + + filter: null, + + listeners: { + 'specialkey': { + fn: 'keyHandler', + scope: 'this' + } + }, + + /** + * Initializes the component. Binds the enter key to startSearch. + */ + initComponent: function(){ + this.callParent(arguments); + + this.filter = Ext.create("Ext.util.Filter", { + property: this.targetField, + value: '', + operator: 'like' + }); + }, + /** + * Handles special keys used in this field. + * + * Enter: Starts the search + * Escape: Removes the search and clears the field contents + */ + keyHandler: function (field, e) { + switch (e.getKey()) { + case e.ENTER: + this.startSearch(); + break; + case e.ESC: + this.resetSearch(); + break; + } + }, + /** + * Resets the search field to empty and re-triggers the store to load the matching records. + */ + resetSearch: function () { + var me = this, + store = me.store, + val; + + me.setValue(''); + + if (me.hasSearch) { + + store.removeFilter(this.filter); + + store.currentPage = 1; + store.load({ start: 0 }); + me.hasSearch = false; + + this.getTrigger("clear").hide(); + } + }, + /** + * Starts the search with the entered value. + */ + startSearch: function () { + var me = this, + store = me.store, + value = me.getValue(); + + if (value.length < 1) { + me.resetSearch(); + return; + } + + this.filter.setValue("%"+value+"%"); + store.addFilter(this.filter); + store.currentPage = 1; + store.load({ start: 0 }); + + me.hasSearch = true; + this.getTrigger("clear").show(); + }, + setStore: function (store) { + this.store = store; + } +});+ \ No newline at end of file diff --git a/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig b/src/PartKeepr/FrontendBundle/Resources/views/index.html.twig @@ -66,7 +66,7 @@ '@PartKeeprFrontendBundle/Resources/public/js/compat.js' '@PartKeeprFrontendBundle/Resources/public/js/Ext.ux/NumericField.js' '@PartKeeprFrontendBundle/Resources/public/js/Components/Widgets/CurrencyNumberField.js' - '@PartKeeprFrontendBundle/Resources/public/js/Ext.ux/SearchField.js' + '@PartKeeprFrontendBundle/Resources/public/js/form/field/SearchField.js' '@PartKeeprFrontendBundle/Resources/public/js/Ext.ux/Iframe.js' '@PartKeeprFrontendBundle/Resources/public/js/Ext.ux/ClearableComboBox.js' '@PartKeeprFrontendBundle/Resources/public/js/Util/ServiceCall.js'