From baaec67399f72b9c975927bb600190bd6eb8fef2 Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 10 Jul 2017 16:22:32 +0200 Subject: [PATCH] fixes issue with smart annotations in repositories [fixes SCI-1452] --- .../javascripts/repositories/repository_datatable.js | 4 +++- app/assets/javascripts/sitewide/atwho_res.js.erb | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/repositories/repository_datatable.js b/app/assets/javascripts/repositories/repository_datatable.js index 3ceeab6ff..165006d31 100644 --- a/app/assets/javascripts/repositories/repository_datatable.js +++ b/app/assets/javascripts/repositories/repository_datatable.js @@ -573,7 +573,6 @@ function onClickEdit() { }); // initialize smart annotation - SmartAnnotation.init($('[data-object="repository_cell"]')); _.each($('[data-object="repository_cell"]'), function(el) { if (_.isUndefined($(el).data('atwho'))) { SmartAnnotation.init(el); @@ -642,9 +641,11 @@ function onClickSave() { data: data, success: function(data) { HelperModule.flashAlertMsg(data.flash, 'success'); + SmartAnnotation.closePopup(); onClickCancel(); }, error: function(e) { + SmartAnnotation.closePopup(); var data = e.responseJSON; clearAllErrors(); @@ -794,6 +795,7 @@ function onClickCancel() { }, false); changeToViewMode(); updateButtons(); + SmartAnnotation.closePopup(); animateSpinner(null, false); } diff --git a/app/assets/javascripts/sitewide/atwho_res.js.erb b/app/assets/javascripts/sitewide/atwho_res.js.erb index 377918eb3..24889894f 100644 --- a/app/assets/javascripts/sitewide/atwho_res.js.erb +++ b/app/assets/javascripts/sitewide/atwho_res.js.erb @@ -424,6 +424,11 @@ var SmartAnnotation = (function() { init: init }; } + // Closes the atwho popup * needed in repositories to close the popup + // if nothing is selected and the user leaves the form * + function closePopup() { + $('.atwho-header-res').find('.glyphicon-remove').click(); + } function initialize(field) { var atWho = new setAtWho(field); @@ -432,7 +437,8 @@ var SmartAnnotation = (function() { var publicApi = Object.freeze({ init: initialize, - preventPropagation: atwhoStopPropagation + preventPropagation: atwhoStopPropagation, + closePopup: closePopup }); return publicApi;