Make deferred SmartAnnotation loading optional [SCI-7534]

This commit is contained in:
Martin Artnik 2022-11-29 13:47:52 +01:00
parent f231c69a02
commit 76de2d1380
3 changed files with 87 additions and 81 deletions

View file

@ -40,7 +40,7 @@ $.fn.dataTable.render.editRepositoryTextValue = function(formId, columnId, cell)
data-type="RepositoryTextValue">
</div>`);
$cell.find('input').val(text);
SmartAnnotation.init($cell.find('input'));
SmartAnnotation.init($cell.find('input'), true);
};
$.fn.dataTable.render.editRepositoryListValue = function(formId, columnId, cell) {

View file

@ -16,7 +16,7 @@ var RepositoryDatatableRowEditor = (function() {
function initSmartAnnotation($row) {
$row.find('[data-object="repository_cell"]').each(function(el) {
if (el.data('atwho')) {
SmartAnnotation.init(el);
SmartAnnotation.init(el, true);
}
});
}

View file

@ -11,7 +11,7 @@ var SmartAnnotation = (function() {
});
}
function SetAtWho(field) {
function SetAtWho(field, deferred) {
var FilterTypeEnum = Object.freeze({
USER: { tag: 'users', dataUrl: $(document.body).attr('data-atwho-users-url') },
TASK: { tag: 'sa-tasks', dataUrl: $(document.body).attr('data-atwho-task-url') },
@ -121,8 +121,7 @@ var SmartAnnotation = (function() {
};
}
function init() {
$(field).on('focus', function() {
function initAtwho() {
if ($(this).data('atwho-initialized')) return;
$(field).on('shown.atwho', function() {
@ -204,7 +203,14 @@ var SmartAnnotation = (function() {
// .atwho(atWhoSettings('sample#', FilterTypeEnum.REPOSITORY));
$(this).data('atwho-initialized', true);
});
}
function init() {
if (deferred) {
$(field).on('focus', initAtwho);
} else {
initAtwho();
}
}
return {
@ -217,8 +223,8 @@ var SmartAnnotation = (function() {
$('.atwho-header-res').find('.fa-times').click();
}
function initialize(field) {
var atWho = new SetAtWho(field);
function initialize(field, deferred) {
var atWho = new SetAtWho(field, deferred);
atWho.init();
}