Commit 81a111fa authored by Sven Franck's avatar Sven Franck

fixed search field preserving initial key-value search criteria

parent f9a545a2
......@@ -4522,7 +4522,8 @@
config.state.type,
null,
config.element.value,
config.state.query.select_list
config.state.query.select_list,
config.state.restore
);
// update gadget
......@@ -4781,7 +4782,7 @@
// TODO: parentNode is not a proper selector, this should be done
// by storing info fields associated with a gadget in state and
// updating from there!
app.updateInfoElement(
app.setInfo(
config.gadget.parentNode,
state.query,
state.total,
......@@ -5090,9 +5091,9 @@
* @param {integer} selected Total Records currently selected
*/
// WARNING: complex_queries dependency, IE8 & QSA
// TODO: refactor, this is quite the crap...
// TODO: refactor
// TODO: don't reset all 4 fields on every action!
app.updateInfoElement = function (element, options, total, selected) {
app.setInfo = function (element, options, total, selected) {
var i, j, l, selection, info_field, min, pointer, no_items,
text_snippet, i18n_snippet, zero_no_show, select_counter, no_limit,
slot, first, last, info, info_field_list, generateInfo, no_total,
......@@ -5110,7 +5111,7 @@
);
};
// we are working without total query
// skip_total
if (no_total) {
use_total = 0;
} else {
......@@ -5261,11 +5262,11 @@
* @param {string} key Parameter to search single column
* @param {string} value Value to search for across one or all columns
* @param {object} field_list Items to search across
* @param {string} initial_query Intial query indicating blocked columns
* @param {array} restore Initial query identifier (key) and value
* @return {object} query object
*/
// WARNING: complex_queries dependency!
app.generateQueryObject = function (query, type, key, value, field_list) {
app.generateQueryObject = function (query, type, key, value, field_list, restore) {
var property, wrap, query_object, query_clean, default_query, obj,
is_value, i;
......@@ -5307,6 +5308,7 @@
obj.query += ' AND (' + key + ':"' + value + '")';
obj.start = 0;
obj.items = 1;
obj.restore = [key, value];
// search "bar"
} else if (is_value) {
......@@ -5325,6 +5327,11 @@
}
}
// restore initial query in case we are searching for empty string
if (restore) {
obj.query += ' AND (' + restore[0] + ':"' + restore[1] + '")';
}
if (default_query.sort_on) {
obj.sort_on = [default_query.sort];
} else {
......@@ -5640,7 +5647,7 @@
if (pass.create === false && pass.purge === null) {
selector = pass.state.gadget;
} else {
// TODO: in case of update? find data-update?
// TODO: in case of update? should use data-update?
// NOTE: in case of forms, we find the form!
// NOTE: in case of fragments, we punt to the firstElementChild...
selector = element.querySelector("form") ||
......@@ -5649,10 +5656,15 @@
pass.state.gadget = selector;
}
// round up and store state on gadget
// preserve constructor for updates
pass.state.constructor = pass.constructor;
pass.state.selected = pass.create === false ?
(pass.state.selected) : undefined;
// preserve initial search other than _id
if (pass.state.query.restore) {
pass.state.restore = pass.state.query.restore;
}
// pass.state.selected = pass.create === false ?
// (pass.state.selected) : undefined;
// if a callback is provided, set it on state
if (pass.config.property_dict.submit_to) {
......@@ -5667,7 +5679,7 @@
if (pass.no_auth || ((pass.auth && pass.active_login) ||
pass.mode === "new")) {
app.updateInfoElement(
app.setInfo(
pass.create ? element : selector,
pass.state.query,
pass.state.total
......@@ -5711,6 +5723,7 @@
pass.field_list = storage.makeSelectList(pass.config.scheme);
}
}
pass.state.query = app.generateQueryObject(
pass.config.initial_query,
pass.type,
......@@ -5746,6 +5759,7 @@
if (pass.skip === undefined) {
// create or update state object
if (pass.create === false) {
// TODO: get element from state if possible!
pass.state = document.getElementById(pass.reference).state;
pass.constructor = pass.state.method;
pass.store_limit = pass.state.query.limit;
......@@ -7075,9 +7089,9 @@
/* ====================================================================== */
app.contentLoaded(window, function () {
// TODO: don't wipe. Sync...!
// Don't wipe if opened in a popup (like in oAuth redirect_uri)
if (window.opener === null) {
// TODO: don't wipe, sync...
window.localStorage.clear();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment