mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 10:08:11 +08:00
[CAPA] Unable to view assigned persons within a task [SCI-9811]
This commit is contained in:
parent
b1b8059e41
commit
33527d14c8
3 changed files with 84 additions and 0 deletions
81
app/assets/javascripts/my_modules/assigned_users.js
Normal file
81
app/assets/javascripts/my_modules/assigned_users.js
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* global I18n dropdownSelector HelperModule animateSpinner */
|
||||
/* eslint-disable no-use-before-define */
|
||||
(function() {
|
||||
function initAssignedUsersSelector() {
|
||||
var myModuleUserSelector = '#module-assigned-users-selector';
|
||||
|
||||
dropdownSelector.init(myModuleUserSelector, {
|
||||
closeOnSelect: true,
|
||||
labelHTML: true,
|
||||
tagClass: 'my-module-user-tags',
|
||||
tagLabel: (data) => {
|
||||
return `<img class="img-responsive block-inline" src="${data.params.avatar_url}" alt="${data.label}"/>
|
||||
<span class="user-full-name block-inline">${data.label}</span>`;
|
||||
},
|
||||
customDropdownIcon: () => {
|
||||
return '';
|
||||
},
|
||||
optionLabel: (data) => {
|
||||
if (data.params.avatar_url) {
|
||||
return `<span class="global-avatar-container" style="margin-top: 10px">
|
||||
<img src="${data.params.avatar_url}" alt="${data.label}"/></span>
|
||||
<span style="margin-left: 10px">${data.label}</span>`;
|
||||
}
|
||||
|
||||
return data.label;
|
||||
},
|
||||
onSelect: function() {
|
||||
var selectElement = $(myModuleUserSelector);
|
||||
var lastUser = selectElement.next().find('.ds-tags').last();
|
||||
var lastUserId = lastUser.find('.tag-label').data('ds-tag-id');
|
||||
var newUser;
|
||||
|
||||
if (lastUserId > 0) {
|
||||
newUser = {
|
||||
user_my_module: {
|
||||
user_id: lastUserId
|
||||
}
|
||||
};
|
||||
} else {
|
||||
newUser = {
|
||||
user_my_module: {
|
||||
user_id: selectElement.val()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$.post(selectElement.data('users-create-url'), newUser, function(result) {
|
||||
dropdownSelector.removeValue(myModuleUserSelector, 0, '', true);
|
||||
dropdownSelector.addValue(myModuleUserSelector, {
|
||||
value: result.user.id,
|
||||
label: result.user.full_name,
|
||||
params: {
|
||||
avatar_url: result.user.avatar_url,
|
||||
user_module_id: result.user.user_module_id
|
||||
}
|
||||
}, true);
|
||||
}).fail(function() {
|
||||
dropdownSelector.removeValue(myModuleUserSelector, lastUserId, '', true);
|
||||
});
|
||||
},
|
||||
onUnSelect: (id) => {
|
||||
var umID = $(myModuleUserSelector).find(`option[value="${id}"]`).data('params').user_module_id;
|
||||
|
||||
$.ajax({
|
||||
url: `${$(myModuleUserSelector).data('update-module-users-url')}/${umID}`,
|
||||
type: 'DELETE',
|
||||
success: () => {
|
||||
dropdownSelector.closeDropdown(myModuleUserSelector);
|
||||
},
|
||||
error: (r) => {
|
||||
if (r.status === 403) {
|
||||
HelperModule.flashAlertMsg(I18n.t('general.no_permissions'), 'danger');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).getContainer(myModuleUserSelector).addClass('my-module-users-container');
|
||||
}
|
||||
|
||||
initAssignedUsersSelector();
|
||||
}());
|
|
@ -19,3 +19,5 @@
|
|||
'data-view-mode': !can_manage_my_module_designated_users?(my_module)
|
||||
} %>
|
||||
</div>
|
||||
|
||||
<%= javascript_include_tag 'my_modules/assigned_users' %>
|
||||
|
|
|
@ -31,6 +31,7 @@ Rails.application.config.assets.precompile += %w(my_modules/status_flow.js)
|
|||
Rails.application.config.assets.precompile += %w(my_modules/protocols/protocol_status_bar.js)
|
||||
Rails.application.config.assets.precompile += %w(my_modules/results.js)
|
||||
Rails.application.config.assets.precompile += %w(my_modules/stock.js)
|
||||
Rails.application.config.assets.precompile += %w(my_modules/assigned_users.js)
|
||||
Rails.application.config.assets.precompile += %w(my_modules/tags.js)
|
||||
Rails.application.config.assets.precompile += %w(my_modules/archived.js)
|
||||
Rails.application.config.assets.precompile += %w(my_modules/pwa_mobile_app.js)
|
||||
|
|
Loading…
Reference in a new issue