Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtul Pratap Singh <atulpratapsingh05@gmail.com>2016-02-21 16:11:38 +0300
committerAtul Pratap Singh <atulpratapsingh05@gmail.com>2016-02-21 16:11:38 +0300
commit2c073621eb54cff0b0238b53540bae939bcb913c (patch)
treea2b8e8caf7e5aa8d32c804c55b5c435f3ca66e71 /js/navigation.js
parentb3a2b74aa47b0b957d87b20fc76f75f4c9b3a5b4 (diff)
Resolve #11643 : Maintain filter states for db/table navigation filters
Signed-off-by: Atul Pratap Singh <atulpratapsingh05@gmail.com>
Diffstat (limited to 'js/navigation.js')
-rw-r--r--js/navigation.js94
1 files changed, 93 insertions, 1 deletions
diff --git a/js/navigation.js b/js/navigation.js
index c134f34702..86f60141b1 100644
--- a/js/navigation.js
+++ b/js/navigation.js
@@ -30,6 +30,89 @@ function navTreeStateUpdate() {
}
}
+
+/**
+ * updates the filter state in sessionStorage
+ *
+ * @returns void
+ */
+function navFilterStateUpdate(filterName, filterValue) {
+ if (isStorageSupported('sessionStorage')) {
+ var storage = window.sessionStorage;
+ try {
+ var currentFilter = $.extend({}, JSON.parse(storage.getItem('navTreeSearchFilters')));
+ var filter = {};
+ filter[filterName] = filterValue;
+ currentFilter = $.extend(currentFilter, filter);
+ storage.setItem('navTreeSearchFilters', JSON.stringify(currentFilter));
+ } catch (error) {
+ storage.removeItem('navTreeSearchFilters');
+ }
+ }
+}
+
+
+/**
+ * restores the filter state on navigation reload
+ *
+ * @returns void
+ */
+function navFilterStateRestore() {
+ if (isStorageSupported('sessionStorage')
+ && typeof window.sessionStorage.navTreeSearchFilters !== 'undefined'
+ ) {
+ var searchClauses = JSON.parse(window.sessionStorage.navTreeSearchFilters);
+ if (Object.keys(searchClauses).length < 1) {
+ return;
+ }
+ // restore database filter if present and not empty
+ if (searchClauses.hasOwnProperty("dbFilter")
+ && searchClauses.dbFilter.length
+ ) {
+ $obj = $('#pma_navigation_tree');
+ if (! $obj.data('fastFilter')) {
+ $obj.data(
+ 'fastFilter',
+ new PMA_fastFilter.filter($obj, "")
+ );
+ }
+ $obj.find('li.fast_filter.db_fast_filter input.searchClause')
+ .val(searchClauses.dbFilter)
+ .trigger('keyup');
+ }
+ // find all table filters present in the tree
+ $tableFilters = $('#pma_navigation_tree li.database')
+ .children('div.list_container')
+ .find('li.fast_filter input.searchClause');
+ // restore table filters
+ $tableFilters.each(function () {
+ $obj = $(this).closest('div.list_container');
+ // aPath associated with this filter
+ var filterName = $(this).siblings('input[name=aPath]').val();
+ // if this table's filter has a state stored in storage
+ if (searchClauses.hasOwnProperty(filterName)
+ && searchClauses[filterName].length
+ ) {
+ // clear state if item is not visible,
+ // happens when table filter becomes invisible
+ // as db filter has already been applied
+ if (! $obj.is(":visible")) {
+ navFilterStateUpdate(filterName, "");
+ return true;
+ }
+ if (! $obj.data('fastFilter')) {
+ $obj.data(
+ 'fastFilter',
+ new PMA_fastFilter.filter($obj, "")
+ );
+ }
+ $(this).val(searchClauses[filterName])
+ .trigger('keyup');
+ }
+ });
+ }
+}
+
/**
* Loads child items of a node and executes a given callback
*
@@ -557,7 +640,7 @@ $(function () {
PMA_commonParams.get('token') === storage.token
) {
// Reload the tree to the state before page refresh
- PMA_reloadNavigation(null, JSON.parse(storage.navTreePaths));
+ PMA_reloadNavigation(navFilterStateRestore, JSON.parse(storage.navTreePaths));
}
}
});
@@ -625,6 +708,7 @@ function expandTreeNode($expandElem, callback) {
*
*/
function scrollToView($element, $forceToTop) {
+ navFilterStateRestore();
var $container = $('#pma_navigation_tree_content');
var elemTop = $element.offset().top - $container.offset().top;
var textHeight = 20;
@@ -1386,6 +1470,14 @@ var PMA_fastFilter = {
} else if ($obj.data('fastFilter')) {
$obj.data('fastFilter').restore(true);
}
+ // update filter state
+ var filterName;
+ if ($(this).attr('name') == 'searchClause2') {
+ filterName = $(this).siblings('input[name=aPath]').val();
+ } else {
+ filterName = 'dbFilter';
+ }
+ navFilterStateUpdate(filterName, $(this).val());
},
clear: function (event) {
event.stopPropagation();