Skip to content

Commit

Permalink
fixed: advanced search not converting string dates into sql format be…
Browse files Browse the repository at this point in the history
…fore submitting
  • Loading branch information
pollen8 committed Feb 25, 2014
1 parent f65fb40 commit 6434d29
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 62 deletions.
2 changes: 1 addition & 1 deletion media/com_fabrik/js/advanced-search-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 32 additions & 21 deletions media/com_fabrik/js/advanced-search.js
@@ -1,16 +1,23 @@
/**
* Advanced Search
*
* @copyright: Copyright (C) 2005-2013, fabrikar.com - All rights reserved.
* @license: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/

/*jshint mootools: true */
/*global Fabrik:true, fconsole:true, Joomla:true, CloneObject:true, $H:true,unescape:true */

AdvancedSearch = new Class({

Implements: [Options, Events],

options: {
'ajax': false,
'controller': 'list',
'parentView': ''
},

initialize: function (options) {
this.setOptions(options);
this.form = document.id('advanced-search-win' + this.options.listref).getElement('form');
Expand All @@ -28,7 +35,7 @@ AdvancedSearch = new Class({
tr.inject(this.form.getElement('.advanced-search-list').getElements('tr').getLast(), 'after');
}.bind(this));
}

this.form.addEvent('click:relay(tr)', function (e, target) {
this.form.getElements('tr').removeClass('fabrikRowClick');
target.addClass('fabrikRowClick');
Expand All @@ -37,17 +44,21 @@ AdvancedSearch = new Class({
this.watchApply();
this.watchElementList();
},

watchApply: function () {

this.form.getElement('.advanced-search-apply').addEvent('click', function (e) {
Fabrik.fireEvent('fabrik.advancedSearch.submit', this);
var filterManager = Fabrik['filter_' + this.options.parentView];

// 25/02/2014 - parentView empty if normal list - if so get listref
var fkey = this.options.parentView !== '' ? 'filter_' + this.options.parentView : 'filter_listform_' + this.options.listref;
var filterManager = Fabrik[fkey];

// Format date advanced search fields to db format before posting
if (typeOf(filterManager) !== 'null') {
filterManager.onSubmit();
}

/* Ensure that we clear down other advanced searches from the session.
* Otherwise, filter on one element and submit works, but changing the filter element and value
* will result in 2 filters applied (not one)
Expand All @@ -59,46 +70,46 @@ AdvancedSearch = new Class({
'value': 1,
'type': 'hidden'
}).inject(this.form);

if (!this.options.ajax) {
return;
}
e.stop();

list.submit(this.options.controller + '.filter');
}.bind(this));
},

getList: function () {
var list = Fabrik.blocks['list_' + this.options.listref];
if (typeOf(list) === 'null') {
list = Fabrik.blocks[this.options.parentView];
}
return list;
},

watchDelete: function () {
//should really just delegate these events from the adv search table
this.form.getElements('.advanced-search-remove-row').removeEvents();
this.form.getElements('.advanced-search-remove-row').addEvent('click', function (e) {
this.removeRow(e);
}.bind(this));
},

watchElementList: function () {
this.form.getElements('select.key').removeEvents();
this.form.getElements('select.key').addEvent('change', function (e) {
this.updateValueInput(e);
}.bind(this));
},

/**
* called when you choose an element from the filter dropdown list
* should run ajax query that updates value field to correspond with selected
* element
* @param {Object} e event
*/

updateValueInput: function (e) {
var row = e.target.getParent('tr');
Fabrik.loader.start(row);
Expand All @@ -110,16 +121,16 @@ AdvancedSearch = new Class({
}
var url = Fabrik.liveSite + "index.php?option=com_fabrik&task=list.elementFilter&format=raw";
var eldata = this.options.elementMap[v];
new Request.HTML({'url': url,
'update': update,
new Request.HTML({'url': url,
'update': update,
'data': {'element': v, 'id': this.options.listid, 'elid': eldata.id, 'plugin': eldata.plugin, 'counter': this.options.counter,
'listref': this.options.listref, 'context': this.options.controller,
'listref': this.options.listref, 'context': this.options.controller,
'parentView': this.options.parentView},
'onComplete': function () {
Fabrik.loader.stop(row);
}}).send();
},

addRow: function (e) {
this.options.counter ++;
e.stop();
Expand All @@ -139,7 +150,7 @@ AdvancedSearch = new Class({
this.watchDelete();
this.watchElementList();
},

removeRow: function (e) {
e.stop();
if (this.form.getElements('.advanced-search-remove-row').length > 1) {
Expand All @@ -158,7 +169,7 @@ AdvancedSearch = new Class({
});
}
},

/**
* removes all rows except for the first one, whose values are reset to empty
*/
Expand Down Expand Up @@ -193,5 +204,5 @@ AdvancedSearch = new Class({
table.removeChild(tr);
e.stop();
}

});
2 changes: 1 addition & 1 deletion media/com_fabrik/js/list-min.js

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions media/com_fabrik/js/list.js
Expand Up @@ -603,13 +603,13 @@ var FbList = new Class({
}
}.bind(this));

if (this.options.filterMethod === 'submitform') {
if (submit) {
submit.removeEvents();
submit.addEvent('click', function (e) {
this.doFilter();
}.bind(this));
}
// Watch submit if present regardless of this.options.filterMethod
if (submit) {
submit.removeEvents();
submit.addEvent('click', function (e) {
e.stop();
this.doFilter();
}.bind(this));
}
this.getFilters().addEvent('keydown', function (e) {
if (e.code === 13) {
Expand Down Expand Up @@ -854,7 +854,8 @@ var FbList = new Class({
'task': 'list.view',
'format': 'raw',
'listid': this.id,
'group_by': this.options.groupedBy
'group_by': this.options.groupedBy,
'listref': this.options.listRef
};
var url = '';
data['limit' + this.id] = this.options.limitLength;
Expand Down

0 comments on commit 6434d29

Please sign in to comment.