mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-30 00:45:28 +08:00
Merge pull request #8076 from andrej-scinote/aj_SCI_11222
Add job title to reports [SCI-11222]
This commit is contained in:
commit
3b6b1a9bc9
8 changed files with 48 additions and 5 deletions
|
@ -1424,6 +1424,18 @@ function reportHandsonTableConverter() {
|
|||
});
|
||||
}
|
||||
|
||||
function setJobTitles(selectedClass) {
|
||||
if (!selectedClass) return;
|
||||
|
||||
const targetElement = $(`[data-job-title-element-target="${selectedClass}"]`);
|
||||
const jobTitles = dropdownSelector.getData(targetElement)
|
||||
.map((item) => item.params.job_title)
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
|
||||
$(`#${selectedClass}`).val(jobTitles);
|
||||
}
|
||||
|
||||
function loadDocxTemplate() {
|
||||
const template = dropdownSelector.getValues('#docxTemplateSelector');
|
||||
let params = {
|
||||
|
@ -1448,7 +1460,14 @@ function reportHandsonTableConverter() {
|
|||
|
||||
$('.report-template-value-dropdown').each(function() {
|
||||
dropdownSelector.init($(this), {
|
||||
noEmptyOption: true
|
||||
noEmptyOption: true,
|
||||
optionClass: $(this).data('job-title-element-target'),
|
||||
onSelect: function() {
|
||||
setJobTitles(this.optionClass);
|
||||
},
|
||||
onUnSelect: function() {
|
||||
setJobTitles(this.optionClass);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
<% if @editing %>
|
||||
<div class="sci-select-container">
|
||||
<%= label_tag @name, @label %>
|
||||
<%= select_tag @name, options_from_collection_for_select(@project_members, :id, :name, @value), placeholder: @placeholder, class: 'sci-input-field report-template-value-dropdown', data: { type: 'ProjectMembersInputComponent' }, multiple: true %>
|
||||
<%= select_tag @name,
|
||||
options_for_select(@project_members.map do |member|
|
||||
[member.name, member.id, { data: { params: { job_title: member.job_title } } }]
|
||||
end,
|
||||
@value),
|
||||
placeholder: @placeholder,
|
||||
class: 'sci-input-field report-template-value-dropdown',
|
||||
data: { type: 'ProjectMembersInputComponent', job_title_element_target: @job_title_element_target }, multiple: true %>
|
||||
</div>
|
||||
<% else %>
|
||||
<% @project_members.where(id: @value).each do |member| %>
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
module Reports
|
||||
class ProjectMembersInputComponent < TemplateValueComponent
|
||||
def initialize(report:, name:, label:, placeholder: nil, editing: true, displayed_field: :full_name)
|
||||
def initialize(report:, name:, label:, placeholder: nil, editing: true, displayed_field: :full_name, job_title_element_target: nil)
|
||||
super(report: report, name: name, label: label, placeholder: placeholder, editing: editing)
|
||||
@project_members = report.project&.users
|
||||
@displayed_field = displayed_field
|
||||
@job_title_element_target = job_title_element_target
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -262,7 +262,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
:current_password,
|
||||
:change_password,
|
||||
:change_avatar,
|
||||
:external_id
|
||||
:external_id,
|
||||
:job_title
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -29,8 +29,9 @@ class User < ApplicationRecord
|
|||
validate :time_zone_check
|
||||
|
||||
validates :external_id, length: { maximum: Constants::EMAIL_MAX_LENGTH }
|
||||
validates :job_title, length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
|
||||
store_accessor :settings, :time_zone, :notifications_settings, :external_id
|
||||
store_accessor :settings, :time_zone, :notifications_settings, :external_id, :job_title
|
||||
|
||||
DEFAULT_SETTINGS = {
|
||||
time_zone: 'UTC',
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<%= render partial: 'users/registrations/edit_partials/full_name' %>
|
||||
<%= render partial: 'users/registrations/edit_partials/initials' %>
|
||||
<%= render partial: 'users/registrations/edit_partials/external_id' %>
|
||||
<%= render partial: 'users/registrations/edit_partials/job_title' %>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<%= render partial: 'users/registrations/edit_partials/email' %>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<span class="settings-job-title user-settings-block">
|
||||
<h3><%= t("users.registrations.edit.job_title_label") %></h3>
|
||||
<%= render partial: "shared/inline_editing",
|
||||
locals: {
|
||||
initial_value: @user.job_title,
|
||||
config: {
|
||||
params_group: 'user',
|
||||
field_to_udpate: 'job_title',
|
||||
path_to_update: registration_path(resource_name, format: :json)
|
||||
}
|
||||
} %>
|
||||
</span>
|
|
@ -3080,6 +3080,7 @@ en:
|
|||
new_email_label: "New email"
|
||||
external_id_label: 'External ID'
|
||||
external_id_title: 'External Id'
|
||||
job_title_label: 'Job title'
|
||||
current_password_label: "Current password"
|
||||
password_explanation: "(we need your current password to confirm your changes)"
|
||||
waiting_for_confirm: "Currently waiting confirmation for: %{email}"
|
||||
|
|
Loading…
Add table
Reference in a new issue