diff --git a/app/assets/javascripts/sitewide/atwho_res.js b/app/assets/javascripts/sitewide/atwho_res.js index e14f75dcb..06b72a724 100644 --- a/app/assets/javascripts/sitewide/atwho_res.js +++ b/app/assets/javascripts/sitewide/atwho_res.js @@ -54,7 +54,7 @@ var SmartAnnotation = (function() { at: at, callbacks: { remoteFilter: function(query, callback) { - var $currentAtWho = $('.atwho-view[style]'); + var $currentAtWho = $(`.atwho-view[data-at-who-id=${$(field).attr('data-smart-annotation')}]`); var filterType; var params = { query: query }; filterType = FilterTypeEnum[$currentAtWho.find('.tab-pane.active').data('object-type')]; @@ -62,7 +62,6 @@ var SmartAnnotation = (function() { callback([{ name: '' }]); return false; } - if (filterType.tag === 'sa-repositories') { let repositoryTab = $currentAtWho.find('[data-object-type="REPOSITORY"]'); let activeRepository = repositoryTab.find('.btn-primary'); @@ -71,6 +70,11 @@ var SmartAnnotation = (function() { } } $.getJSON(filterType.dataUrl, params, function(data) { + localStorage.setItem('smart_annotation_states/teams/' + data.team, JSON.stringify({ + tag: filterType.tag, + repository: data.repository + })); + callback(data.res); if (data.repository) { @@ -118,7 +122,11 @@ var SmartAnnotation = (function() { function init() { $(field) .on('shown.atwho', function() { - var $currentAtWho = $('.atwho-view[style]'); + var $currentAtWho = $('.atwho-view[style]:not(.old)'); + var atWhoId = $currentAtWho.find('.atwho-header-res').data('at-who-key') + $currentAtWho.addClass('old').attr('data-at-who-id', atWhoId); + $(field).attr('data-smart-annotation', atWhoId); + $currentAtWho.find('.tab-button').off().on('shown.bs.tab', function() { $(field).click().focus(); $(this).closest('.nav-tabs').find('.tab-button').removeClass('active'); @@ -132,8 +140,18 @@ var SmartAnnotation = (function() { }); if ($currentAtWho.find('.tab-pane.active').length === 0) { - let filterType = DEFAULT_SEARCH_FILTER; - $currentAtWho.find(`.${filterType.tag}`).click(); + let filterType = DEFAULT_SEARCH_FILTER.tag; + let teamId = $currentAtWho.find('.atwho-header-res').data('team-id'); + let remeberedState = localStorage.getItem('smart_annotation_states/teams/' + teamId); + if (remeberedState) { + try { + remeberedState = JSON.parse(remeberedState); + filterType = remeberedState.tag; + $currentAtWho.find(`.repository-object[data-object-id=${remeberedState.repository}]`) + .addClass('btn-primary'); + } catch {}; + } + $currentAtWho.find(`.${filterType}`).click(); } }) .on('reposition.atwho', function(event, flag, query) { diff --git a/app/assets/stylesheets/shared/smart_annotation.scss b/app/assets/stylesheets/shared/smart_annotation.scss index 823c042ae..b22c312cb 100644 --- a/app/assets/stylesheets/shared/smart_annotation.scss +++ b/app/assets/stylesheets/shared/smart_annotation.scss @@ -17,7 +17,7 @@ margin-bottom: 0; } - .rep-tab.active { + .rep-tab.active:not(:empty) { border-bottom: $border-default; display: flex; padding: .25em; diff --git a/app/controllers/at_who_controller.rb b/app/controllers/at_who_controller.rb index a4cc40aec..7c71816d9 100644 --- a/app/controllers/at_who_controller.rb +++ b/app/controllers/at_who_controller.rb @@ -48,6 +48,7 @@ class AtWhoController < ApplicationController repository_rows: items })], repository: repository.id, + team: current_team.id, status: :ok } end @@ -68,6 +69,7 @@ class AtWhoController < ApplicationController res: [render_to_string(partial: 'shared/smart_annotation/project_items.html.erb', locals: { projects: res.projects })], + team: current_team.id, status: :ok } end @@ -82,6 +84,7 @@ class AtWhoController < ApplicationController res: [render_to_string(partial: 'shared/smart_annotation/experiment_items.html.erb', locals: { experiments: res.experiments })], + team: current_team.id, status: :ok } end @@ -96,6 +99,7 @@ class AtWhoController < ApplicationController res: [render_to_string(partial: 'shared/smart_annotation/my_module_items.html.erb', locals: { my_modules: res.my_modules })], + team: current_team.id, status: :ok } end diff --git a/app/views/shared/smart_annotation/_footer.html.erb b/app/views/shared/smart_annotation/_footer.html.erb index 6cff1b510..011cf5085 100644 --- a/app/views/shared/smart_annotation/_footer.html.erb +++ b/app/views/shared/smart_annotation/_footer.html.erb @@ -1 +1,2 @@
+ diff --git a/app/views/shared/smart_annotation/_menu.html.erb b/app/views/shared/smart_annotation/_menu.html.erb index ca05b2b8f..3139bddd6 100644 --- a/app/views/shared/smart_annotation/_menu.html.erb +++ b/app/views/shared/smart_annotation/_menu.html.erb @@ -1,5 +1,5 @@ <% at_who_key = SecureRandom.hex %> -