# HG changeset patch # User Milka Kuzminski # Date 2020-11-09 21:54:55 # Node ID c3119a6d1397f971e748a852e71729d1b7223faa # Parent 5a275c9fd549a27e079815dfce5edcefe693f9be datagrids: save permanently the state if sorting for pull-request grids. diff --git a/rhodecode/apps/my_account/views/my_account.py b/rhodecode/apps/my_account/views/my_account.py --- a/rhodecode/apps/my_account/views/my_account.py +++ b/rhodecode/apps/my_account/views/my_account.py @@ -702,7 +702,9 @@ class MyAccountView(BaseAppView, DataGri **valid_data) if old_email != valid_data['email']: old = UserEmailMap.query() \ - .filter(UserEmailMap.user == c.user).filter(UserEmailMap.email == valid_data['email']).first() + .filter(UserEmailMap.user == c.user)\ + .filter(UserEmailMap.email == valid_data['email'])\ + .first() old.email = old_email h.flash(_('Your account was updated successfully'), category='success') Session().commit() @@ -718,6 +720,7 @@ class MyAccountView(BaseAppView, DataGri def _get_pull_requests_list(self, statuses): draw, start, limit = self._extract_chunk(self.request) search_q, order_by, order_dir = self._extract_ordering(self.request) + _render = self.request.get_partial_renderer( 'rhodecode:templates/data_table/_dt_elements.mako') diff --git a/rhodecode/public/js/src/rhodecode.js b/rhodecode/public/js/src/rhodecode.js --- a/rhodecode/public/js/src/rhodecode.js +++ b/rhodecode/public/js/src/rhodecode.js @@ -704,3 +704,13 @@ var storeUserSessionAttr = function (key ajaxPOST(pyroutes.url('store_user_session_value'), postData, success); return false; }; + + +var getUserSessionAttr = function(key) { + var storeKey = templateContext.session_attrs; + var val = storeKey[key] + if (val !== undefined) { + return JSON.parse(val) + } + return null +} diff --git a/rhodecode/templates/admin/my_account/my_account_pullrequests.mako b/rhodecode/templates/admin/my_account/my_account_pullrequests.mako --- a/rhodecode/templates/admin/my_account/my_account_pullrequests.mako +++ b/rhodecode/templates/admin/my_account/my_account_pullrequests.mako @@ -46,6 +46,8 @@ $pullRequestListTable.DataTable({ processing: true, serverSide: true, + stateSave: true, + stateDuration: -1, ajax: { "url": "${h.route_path('my_account_pullrequests_data')}", "data": function (d) { @@ -119,6 +121,10 @@ if (data['owned']) { $(row).addClass('owned'); } + }, + "stateSaveParams": function (settings, data) { + data.search.search = ""; // Don't save search + data.start = 0; // don't save pagination } }); $pullRequestListTable.on('xhr.dt', function (e, settings, json, xhr) { @@ -129,6 +135,7 @@ $pullRequestListTable.css('opacity', 0.3); }); + // filter $('#q_filter').on('keyup', $.debounce(250, function () { diff --git a/rhodecode/templates/pullrequests/pullrequests.mako b/rhodecode/templates/pullrequests/pullrequests.mako --- a/rhodecode/templates/pullrequests/pullrequests.mako +++ b/rhodecode/templates/pullrequests/pullrequests.mako @@ -74,6 +74,8 @@ $pullRequestListTable.DataTable({ processing: true, serverSide: true, + stateSave: true, + stateDuration: -1, ajax: { "url": "${h.route_path('pullrequest_show_all_data', repo_name=c.repo_name)}", "data": function (d) { @@ -114,6 +116,10 @@ if (data['closed']) { $(row).addClass('closed'); } + }, + "stateSaveParams": function (settings, data) { + data.search.search = ""; // Don't save search + data.start = 0; // don't save pagination } });