From c2338d677d116e8a8eb45dad639115627f7d873b Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 27 Oct 2022 12:13:25 +0200 Subject: [PATCH 1/8] Fix label preview height in print modal [SCI-7410] --- .../stylesheets/repository/repository_print_label_modal.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/repository/repository_print_label_modal.scss b/app/assets/stylesheets/repository/repository_print_label_modal.scss index 80a3e17b6..0d264f4b9 100644 --- a/app/assets/stylesheets/repository/repository_print_label_modal.scss +++ b/app/assets/stylesheets/repository/repository_print_label_modal.scss @@ -68,7 +68,9 @@ background-color: $color-concrete; display: flex; justify-content: center; + max-height: 300px; min-height: 200px; + overflow-y: auto; padding: .5em 0; img { From 22fad95efd1b905fe0547ea77e6c24faefab6bea Mon Sep 17 00:00:00 2001 From: ajugo Date: Fri, 28 Oct 2022 11:47:54 +0200 Subject: [PATCH 2/8] Rename protocol repository to templates [SCI-7418] (#4587) --- config/locales/en.yml | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 809658737..4a50d4ef8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -957,7 +957,7 @@ en: no_tags: "+ Add tags" manage_tags: "Manage tags" create_new_tag: "create new" - recent_protocols_from_repository: "Recent protocols from the Repository" + recent_protocols_from_repository: "Recent protocols from the Templates" notes: title: "Notes" no_description: "No task description" @@ -969,10 +969,10 @@ en: title: "Protocol" options_dropdown: title: "Protocol options" - load_from_repo: "Load from repository" + load_from_repo: "Load from templates" import: "Import protocol" export: "Export protocol" - save_to_repo: "Save to repository" + save_to_repo: "Save to templates" delete_steps: "Delete all steps" description: title: "Edit task %{module} description" @@ -1018,48 +1018,48 @@ en: template_updated: "Protocol template updated on:" protocol_updated: "Protocol updated on:" messages: - template_updated_html: "There is a new version of this protocol available in the protocol repository.
Would you like to update it?" + template_updated_html: "There is a new version of this protocol available in the protocol templates.
Would you like to update it?" protocol_updated: "The version of this protocol in the task is modified, do you wish to save it as a new protocol template?" - unlinked: "This protocol is not linked to the repository." + unlinked: "This protocol is not linked to the templates." btns: unlink: "Unlink protocol template" - unlink_title: "Unlink this protocol from the parent in the repository" + unlink_title: "Unlink this protocol from the parent in the templates" revert: "Revert protocol" - revert_title: "Revert the protocol to the repository version. This will discard any local changes." - save_to_repository: "Save to repository" - save_a_copy_to_repository: "Save a copy to repository" - save_to_repository_title: "Copy this protocol to repository" - update_self: "Update from repository" - update_self_title: "Update this protocol with the version stored in the repository" + revert_title: "Revert the protocol to the templates version. This will discard any local changes." + save_to_repository: "Save to templates" + save_a_copy_to_repository: "Save a copy to templates" + save_to_repository_title: "Copy this protocol to templates" + update_self: "Update from templates" + update_self_title: "Update this protocol with the version stored in the templates" confirm_link_update_modal: unlink_title: "Unlink protocol template" - unlink_message: "Are you sure you want to unlink the task protocol from the repository version? This will stop any tracking of changes." + unlink_message: "Are you sure you want to unlink the task protocol from the templates version? This will stop any tracking of changes." unlink_btn_text: "Unlink" revert_title: "Revert protocol" - revert_message: "Are you sure you want to revert the task protocol to the repository version? This will override any local changes you made." + revert_message: "Are you sure you want to revert the task protocol to the templates version? This will override any local changes you made." revert_btn_text: "Revert" - update_parent_title: "Update repository version" - update_parent_message: "Are you sure you want to update the repository protocol with this version? This will override any other changes made in the repository version." - update_self_title: "Update from repository" - update_self_message: "Are you sure you want to update this protocol with the version from the repository? This will override any local changes you made." + update_parent_title: "Update templates version" + update_parent_message: "Are you sure you want to update the templates protocol with this version? This will override any other changes made in the templates version." + update_self_title: "Update from templates" + update_self_message: "Are you sure you want to update this protocol with the version from the templates? This will override any local changes you made." unlink_flash: "Protocol was successfully unlinked." unlink_error: "Failed to unlink protocol." revert_flash: "Protocol was successfully reverted to protocol version." revert_error: "Failed to revert protocol." revert_error_locked: "Failed to revert protocol. One or more files in the protocol are currently being edited." - update_parent_flash: "Protocol in repository was successfully updated with the version from the task." - update_parent_error: "Failed to update repository version of the protocol." - update_parent_error_locked: "Failed to update repository version of the protocol. One or more files in the protocol are currently being edited." - update_from_parent_flash: "Version in the repository was successfully updated." - update_from_parent_error: "Failed to update the protocol with the version in the repository." - update_from_parent_error_locked: "Failed to update the protocol with the version in the repository. One or more files in the protocol are currently being edited." - load_from_repository_flash: "Successfully loaded the protocol from the repository." - load_from_repository_error: "Failed to load the protocol from the repository." - load_from_repository_error_locked: "Failed to load the protocol from the repository. One or more files in the protocol are currently being edited." + update_parent_flash: "Protocol in templates was successfully updated with the version from the task." + update_parent_error: "Failed to update templates version of the protocol." + update_parent_error_locked: "Failed to update templates version of the protocol. One or more files in the protocol are currently being edited." + update_from_parent_flash: "Version in the templates was successfully updated." + update_from_parent_error: "Failed to update the protocol with the version in the templates." + update_from_parent_error_locked: "Failed to update the protocol with the version in the templates. One or more files in the protocol are currently being edited." + load_from_repository_flash: "Successfully loaded the protocol from the templates." + load_from_repository_error: "Failed to load the protocol from the templates." + load_from_repository_error_locked: "Failed to load the protocol from the templates. One or more files in the protocol are currently being edited." load_from_repository_modal: - title: "Load protocol from repository" + title: "Load protocol from templates" text: "Choose the protocol to be loaded to the task." - text2: "This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository." + text2: "This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates." tab_public: "Team protocols" tab_private: "My protocols" tab_recent: "Recent protocols" @@ -1072,20 +1072,20 @@ en: thead_published_on: "Published at" thead_created_at: "Created at" thead_updated_at: "Last modified at" - confirm_message: "Are you sure you wish to load protocol from repository? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository." - import_to_linked_task_rep: "Are you sure you wish to load protocol from repository? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository." + confirm_message: "Are you sure you wish to load protocol from templates? This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates." + import_to_linked_task_rep: "Are you sure you wish to load protocol from templates? This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates." load: "Load" copy_to_repository_modal: - title: "Save to protocol repository" - name_label: "Repository protocol name" + title: "Save to protocol templates" + name_label: "Templates protocol name" name_placeholder: "My protocol" type_label: "Save to" type_public: "Team protocols" type_private: "My protocols" type_text: "You can make a copy of a protocol and save it to Team protocols or My protocols. Team protocols are visible to all team members, My protocols are for personal usage only." - link_label: "Link task to this protocol in repository" + link_label: "Link task to this protocol in templates" link_text: "Warning! This will unlink the currently linked protocol." - error_400: "Due to unknown error, protocol could not be copied to repository." + error_400: "Due to unknown error, protocol could not be copied to templates." confirm: "Save" load_from_file_flash: "Successfully loaded the protocol from the file." load_from_file_error: "Failed to load the protocol from file." @@ -2488,7 +2488,7 @@ en: title_import_into_protocol_protocols_io: "Load protocol from protocols.io file" import_into_protocol_message: "This will overwrite the current protocol!" import_into_protocol_confirm: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol." - import_to_linked_task_file: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository." + import_to_linked_task_file: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol in the task and unlink it from templates. The current protocol will remain unchanged in templates." name_label: "Protocol name" authors_label: "Authors" description_label: "Description" From 5b08ee1cc84b2ef8c9a14d3bf2f47acb3b685930 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 3 Nov 2022 15:48:32 +0100 Subject: [PATCH 3/8] Hide active reminders, if stock management disabled [SCI-7428] --- .../repositories/_toolbar_buttons.html.erb | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/views/repositories/_toolbar_buttons.html.erb b/app/views/repositories/_toolbar_buttons.html.erb index f2fb0c140..d8f2637eb 100644 --- a/app/views/repositories/_toolbar_buttons.html.erb +++ b/app/views/repositories/_toolbar_buttons.html.erb @@ -48,20 +48,22 @@
-
-
- - + <% if RepositoryBase.stock_management_enabled? %> +
+
+ + +
+ + <%= t('repositories.index.active_reminders.label') %> + <%= t('repositories.index.active_reminders.short_label') %> +
- - <%= t('repositories.index.active_reminders.label') %> - <%= t('repositories.index.active_reminders.short_label') %> - -
+ <% end %>
<% if @repository.is_a?(BmtRepository) %>
From 34ffcbd8e8469c0155df3a41f274b3e6cb4e4e74 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 4 Nov 2022 11:07:59 +0100 Subject: [PATCH 4/8] Fix duplicate activities wording [SCI-7426] --- config/locales/global_activities/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/global_activities/en.yml b/config/locales/global_activities/en.yml index 39ca6dfb9..b7d75e804 100644 --- a/config/locales/global_activities/en.yml +++ b/config/locales/global_activities/en.yml @@ -247,9 +247,9 @@ en: task_step_text_duplicated_html: "%{user} duplicated text %{text_name} in protocol’s step %{step_position} %{step} on task %{my_module}." task_step_table_duplicated_html: "%{user} duplicated table %{table_name} in protocol’s step %{step_position} %{step} on task %{my_module}." task_step_checklist_duplicated_html: "%{user} duplicated checklist %{checklist_name} in protocol’s step %{step_position} %{step} on task %{my_module}." - protocol_step_text_duplicated_html: "%{user} duplicated text %{text_name} in protocol’s step %{step_position} %{step} in protocol %{protocol} in Protocol repository." - protocol_step_table_duplicated_html: "%{user} duplicated table %{table_name} in protocol’s step %{step_position} %{step} in protocol %{protocol} in Protocol repository." - protocol_step_checklist_duplicated_html: "%{user} duplicated checklist %{checklist_name} in protocol’s step %{step_position} %{step} in protocol %{protocol} in Protocol repository." + protocol_step_text_duplicated_html: "%{user} duplicated text %{text_name} in protocol’s step %{step_position} %{step} in Protocol repository." + protocol_step_table_duplicated_html: "%{user} duplicated table %{table_name} in protocol’s step %{step_position} %{step} in Protocol repository." + protocol_step_checklist_duplicated_html: "%{user} duplicated checklist %{checklist_name} in protocol’s step %{step_position} %{step} in Protocol repository." label_template_created_html: "%{user} created %{type} label template %{label_template} in Label templates." label_template_edited_html: "%{user} edited %{type} label template %{label_template} in Label templates." label_template_deleted_html: "%{user} deleted %{type} label template %{label_template} in Label templates." From c361dec0b6a6c7928e76f82fcbfe7f249db1293e Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 7 Nov 2022 11:55:01 +0100 Subject: [PATCH 5/8] Fix Fluics templates sync scheduler [SCI-7435] --- config/initializers/scheduler.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/initializers/scheduler.rb b/config/initializers/scheduler.rb index edc33070b..d9d650bd6 100644 --- a/config/initializers/scheduler.rb +++ b/config/initializers/scheduler.rb @@ -4,7 +4,7 @@ require 'rufus-scheduler' scheduler = Rufus::Scheduler.singleton -if ENV['ENABLE_TEMPLATES_SYNC'] +if ENV['ENABLE_TEMPLATES_SYNC'] == 'true' # Templates sync periodic task scheduler.every '12h' do Rails.logger.info('Templates, syncing all template projects') @@ -33,8 +33,8 @@ if Rails.application.secrets.system_notifications_uri.present? && end end -if ENV['ENABLE_FLUICS_SYNC'] && LabelPrinter.fluics.any? +if ENV['ENABLE_FLUICS_SYNC'] == 'true' scheduler.every '24h' do - LabelPrinters::Fluics::SyncService.new.sync_templates! + LabelPrinters::Fluics::SyncService.new.sync_templates! if LabelPrinter.fluics.any? end end From 82d4b03cf68271d6168c4b3b39432e6ab186dedb Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 7 Nov 2022 21:56:38 +0100 Subject: [PATCH 6/8] Fix global activities user selection dropdown [SCI-7402] --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8bc5c1446..6e82b609f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -403,7 +403,7 @@ class User < ApplicationRecord result = result.where.not(confirmed_at: nil) if active_only if team_to_ignore.present? - ignored_ids = UserTeam.select(:user_id).where(team_id: team_to_ignore.id) + ignored_ids = UserAssignment.select(:user_id).where(assignable: team_to_ignore) result = result.where.not(users: { id: ignored_ids }) end @@ -629,7 +629,7 @@ class User < ApplicationRecord query_teams = teams.pluck(:id) query_teams &= filters[:teams].map(&:to_i) if filters[:teams] query_teams &= User.team_by_subject(filters[:subjects]) if filters[:subjects] - User.where(id: UserTeam.where(team_id: query_teams).select(:user_id)) + User.where(id: UserAssignment.where(assignable_id: query_teams, assignable_type: 'Team').select(:user_id)) .search(false, search_query) .select(:full_name, :id) .map { |i| { label: escape_input(i[:full_name]), value: i[:id] } } From be7ef8fdc031d03c75c98cf8f57496583ad5e7a8 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 8 Nov 2022 14:41:11 +0100 Subject: [PATCH 7/8] Fix team export/import [SCI-7434] --- app/services/model_exporters/team_exporter.rb | 24 +++++++++++--- app/services/team_importer.rb | 33 ++++++++++++------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/app/services/model_exporters/team_exporter.rb b/app/services/model_exporters/team_exporter.rb index 1c429aed1..31a75fd48 100644 --- a/app/services/model_exporters/team_exporter.rb +++ b/app/services/model_exporters/team_exporter.rb @@ -4,7 +4,7 @@ module ModelExporters class TeamExporter < ModelExporter def initialize(team_id) super() - @team = Team.includes(:user_teams).find(team_id) + @team = Team.find(team_id) end def export_to_dir @@ -42,9 +42,11 @@ module ModelExporters @tiny_mce_assets_to_copy.push(team.tiny_mce_assets) if team.tiny_mce_assets.present? { team: team, - default_admin_id: team.user_teams.where(role: 2).first.user.id, + default_admin_id: team.user_assignments.where(user_role: UserRole.find_predefined_owner_role).first.user.id, users: team.users.map { |u| user(u) }, - user_teams: team.user_teams, + user_assignments: team.user_assignments.map do |ua| + user_assignment(ua) + end, notifications: Notification .includes(:user_notifications) .where('user_notifications.user_id': team.users) @@ -52,7 +54,11 @@ module ModelExporters repositories: team.repositories.map { |r| repository(r) }, tiny_mce_assets: team.tiny_mce_assets.map { |tma| tiny_mce_asset_data(tma) }, protocols: team.protocols.where(my_module: nil).map do |pr| - protocol(pr) + protocol(pr).merge( + user_assignments: pr.user_assignments.map do |ua| + user_assignment(ua) + end + ) end, protocol_keywords: team.protocol_keywords, project_folders: team.project_folders, @@ -124,13 +130,17 @@ module ModelExporters user_id: user_assignment.user_id, assigned_by_id: user_assignment.assigned_by_id, role_name: user_assignment.user_role.name, - assigned: user_assignment.assigned + assigned: user_assignment.assigned, + team_id: user_assignment.team_id } end def report(report) { report: report, + user_assignments: report.user_assignments.map do |ua| + user_assignment(ua) + end, report_elements: report.report_elements } end @@ -146,6 +156,10 @@ module ModelExporters end } unless repository.is_a?(RepositorySnapshot) + result[:user_assignments] = + repository.user_assignments.where(team: repository.team, user: repository.team.users).map do |ua| + user_assignment(ua) + end result[:repository_snapshots] = repository.repository_snapshots.map { |r| repository(r) } end result diff --git a/app/services/team_importer.rb b/app/services/team_importer.rb index bc1b3df2c..af8ef5429 100644 --- a/app/services/team_importer.rb +++ b/app/services/team_importer.rb @@ -27,6 +27,8 @@ class TeamImporter @checklist_mappings = {} @table_mappings = {} @report_mappings = {} + @label_template_mappings = {} + @step_text_mappings = {} @project_counter = 0 @repository_counter = 0 @@ -59,25 +61,18 @@ class TeamImporter team_last_modified_by = team.last_modified_by_id team.last_modified_by_id = nil team.without_templates = true + team.skip_user_assignments = true team.save! + @team_id = team.id create_users(team_json['users'], team) + puts 'Assigning users to the team...' + create_user_assignments(team_json['user_assignments'], team) # Find new id of the first admin in the team @admin_id = @user_mappings[team_json['default_admin_id']] create_notifications(team_json['notifications']) - - puts 'Assigning users to the team...' - team_json['user_teams'].each do |user_team_json| - user_team = UserTeam.new(user_team_json) - user_team.id = nil - user_team.user_id = find_user(user_team.user_id) - user_team.team_id = team.id - user_team.assigned_by_id = find_user(user_team.assigned_by_id) - user_team.save! - end - create_protocol_keywords(team_json['protocol_keywords'], team) create_protocols(team_json['protocols'], nil, team) create_project_folders(team_json['project_folders'], team) @@ -316,6 +311,7 @@ class TeamImporter team.label_templates.where.not(type: 'FluicsLabelTemplate').destroy_all label_templates_json.each do |template_json| template = LabelTemplate.new(template_json) + orig_template_id = template.id template.id = nil template.team_id = team.id template.created_by_id = find_user(template.created_by_id) if template.created_by_id @@ -323,6 +319,7 @@ class TeamImporter template.save! @label_template_counter += 1 + @label_template_mappings[orig_template_id] = template.id end end @@ -457,7 +454,11 @@ class TeamImporter repository.archived_by_id = find_user(repository.archived_by_id) repository.restored_by_id = find_user(repository.restored_by_id) repository.discarded_by_id = find_user(repository.discarded_by_id) + repository.skip_user_assignments = true repository.save! + + create_user_assignments(repository_json['user_assignments'], repository) + @repository_mappings[orig_repository_id] = repository.id @repository_counter += 1 repository_json['repository_columns'].each do |repository_column_json| @@ -790,6 +791,9 @@ class TeamImporter protocol.skip_user_assignments = true protocol.parent_id = @protocol_mappings[protocol.parent_id] unless protocol.parent_id.nil? protocol.save! + + create_user_assignments(protocol_json['user_assignments'], protocol) if protocol.in_repository? + @protocol_counter += 1 @protocol_mappings[orig_protocol_id] = protocol.id @@ -832,9 +836,11 @@ class TeamImporter step_json['step_orderable_elements'].each do |element_json| if element_json['step_text'] orderable = StepText.new(element_json['step_text']) + orig_step_text_id = orderable.id orderable.step_id = step.id orderable.id = nil orderable.save! + @step_text_mappings[orig_step_text_id] = orderable.id elsif element_json['table'] table = Table.new(element_json['table']) orig_table_id = table.id @@ -983,7 +989,11 @@ class TeamImporter report.user_id = find_user(report.user_id) report.last_modified_by_id = find_user(report.last_modified_by_id) report.team_id = team.id + report.skip_user_assignments = true report.save! + + create_user_assignments(report_json['user_assignments'], report) + @report_mappings[orig_report_id] = report.id @report_counter += 1 report_json['report_elements'].each do |report_element_json| @@ -1057,6 +1067,7 @@ class TeamImporter user_assignment.user_id = find_user(user_assignment_json['user_id']) user_assignment.assigned = user_assignment_json['assigned'] user_assignment.assigned_by_id = find_user(user_assignment_json['assigned_by_id']) + user_assignment.team_id = @team_id user_assignment.save! end end From 9d41ff4f929734a3389eed99c9236ce394595471 Mon Sep 17 00:00:00 2001 From: artoscinote <85488244+artoscinote@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:48:18 +0100 Subject: [PATCH 8/8] Bump version to 1.26.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index dd43a143f..c7c3f3333 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.26.1 +1.26.2