Merge branch 'develop' into features/bmt-search

This commit is contained in:
Martin Artnik 2021-09-24 11:01:27 +02:00
commit 49b9ee37cc
35 changed files with 144 additions and 79 deletions

View file

@ -487,7 +487,7 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.3.0)
rdoc (6.3.2)
recaptcha (5.6.0)
json
regexp_parser (2.0.3)

View file

@ -6,10 +6,10 @@ define PRODUCTION_CONFIG_BODY
SECRET_KEY_BASE=$(shell openssl rand -hex 64)
PAPERCLIP_HASH_SECRET=$(shell openssl rand -base64 128 | tr -d '\n')
DATABASE_URL=postgresql://postgres:mysecretpassword@db/scinote_production
PAPERCLIP_STORAGE=filesystem
ACTIVESTORAGE_SERVICE=local
ENABLE_RECAPTCHA=false
ENABLE_USER_CONFIRMATION=false
ENABLE_USER_REGISTRATION=true
ENABLE_USER_REGISTRATION=false
DEFACE_ENABLED=false
endef
export PRODUCTION_CONFIG_BODY

View file

@ -1 +1 @@
1.22.4
1.22.4.1

View file

@ -179,7 +179,8 @@ var RepositoryColumns = (function() {
closeOnSelect: true,
optionClass: 'custom-option',
selectAppearance: 'simple',
disableSearch: true
disableSearch: true,
labelHTML: true
});
dropdownSelector.init('.list-column-type .delimiter', delimiterDropdownConfig);

View file

@ -1,32 +1,33 @@
function updateProgressModal() {
var status;
var modal = $(document).find('.label-printing-progress-modal');
(function() {
function updateProgressModal() {
var modal = $('.label-printing-progress-modal');
if (modal.length === 0) {
return;
}
if (modal.length === 0) return;
$.getJSON(
`/label_printers/${modal.data('labelPrinterId')}/update_progress_modal`
+ `?starting_item_count=${modal.data('startingItemCount')}`,
function(data) {
modal.replaceWith(data.html);
status = modal.data('label-printer-status');
if (status !== 'done' && status !== 'error') {
setTimeout(updateProgressModal, 3000);
$.getJSON(
modal.data('progress-url'), function(data) {
modal.replaceWith(data.html);
let status = modal.data('label-printer-status');
if (!['done', 'error'].includes(status)) {
setTimeout(updateProgressModal, 3000);
}
}
}
);
}
$(document).on('click', '.label-printing-progress-modal .close', function() {
$(this).closest('.label-printing-progress-modal').remove();
});
$(document).on('turbolinks:load', function() {
var modal = $(document).find('.label-printing-progress-modal');
if (modal.length > 0) {
updateProgressModal();
);
}
});
$(document).on('click', '.label-printing-progress-modal .close', function() {
$(this).closest('.label-printing-progress-modal').remove();
});
$(document).on('ajax:success', '.print-label-form', function(e, data) {
var modal = $('.label-printing-progress-modal');
if (modal.length) {
modal.replaceWith(data.html);
} else {
$('body').append($(data.html));
}
updateProgressModal();
$('#modal-print-repository-row-label').modal('hide');
});
}());

View file

@ -210,7 +210,7 @@
padding: 5px 0 5px 40px;
&:hover {
background-color: $brand-focus-light;
background-color: $color-concrete;
border-radius: 5px;
}
@ -363,7 +363,7 @@
width: calc(50% - 25px);
&.selected {
background: $brand-light-blue;
background: $color-alto;
opacity: 1;
}

View file

@ -481,6 +481,10 @@ li.module-hover {
}
}
.projects-title {
flex-grow: 1;
}
.delete-folders-form,
.delete-folders-btn {
display: inline-block;

View file

@ -212,4 +212,10 @@ div.print-report {
}
}
}
.export-all-link {
em {
color: $brand-primary !important;
}
}
}

View file

@ -32,6 +32,8 @@
width: calc(100% + 4em);
h1 {
align-items: center;
display: flex;
flex-grow: 1;
margin: 0;
}

View file

@ -41,8 +41,7 @@
.dropdown-menu {
.form-dropdown-break hr {
margin-bottom: 8px;
margin-top: 0;
margin: 0;
}
.form-dropdown-item {
@ -62,6 +61,13 @@
.form-dropdown-item-info {
color: $color-silver-chalice !important;
border-top: 1px solid $color-concrete;
padding-top: .3em;
}
&:only-child .form-dropdown-item-info {
border-top: 0;
padding-top: 0;
}
.project-archive-restore-form {

View file

@ -63,11 +63,12 @@ module Api
p.require(%i(id attributes))
p.require(:attributes).require(:value)
end
@inventory_item.transaction do
@inventory_item.with_lock do
inventory_cells_params.each do |cell_params|
cell = @inventory_item.repository_cells.find(cell_params[:id])
cell_value = cell_params.dig(:attributes, :value)
next unless cell.value.data_changed?(cell_value)
cell.value.update_data!(cell_value, current_user)
item_changed = true
end

View file

@ -109,7 +109,13 @@ class RepositoryRowsController < ApplicationController
label_printer.update!(current_print_job_ids: job_ids * params[:copies].to_i)
redirect_to repository_path(@repository)
render json: {
html: render_to_string(
partial: 'label_printers/print_progress_modal.html.erb',
locals: { starting_item_count: label_printer.current_print_job_ids.length,
label_printer: label_printer }
)
}
end
def update

View file

@ -1,7 +1,7 @@
class ResultAssetsController < ApplicationController
include ResultsHelper
before_action :load_vars, only: [:edit, :update, :download]
before_action :load_vars, only: [:edit, :update]
before_action :load_vars_nested, only: [:new, :create]
before_action :check_manage_permissions, only: %i(new create edit update)

View file

@ -7,6 +7,7 @@ class ResultTablesController < ApplicationController
before_action :check_manage_permissions, only: %i(new create edit update)
before_action :check_archive_permissions, only: [:update]
before_action :check_view_permissions, only: [:download]
def new
@table = Table.new
@ -155,6 +156,10 @@ class ResultTablesController < ApplicationController
end
end
def check_view_permissions
render_403 unless can_read_result?(@result)
end
def result_params
params.require(:result).permit(
:name, :archived,

View file

@ -10,6 +10,7 @@ class ResultTextsController < ApplicationController
before_action :check_manage_permissions, only: %i(new create edit update)
before_action :check_archive_permissions, only: [:update]
before_action :check_view_permissions, only: [:download]
def new
@result = Result.new(
@ -159,6 +160,10 @@ class ResultTextsController < ApplicationController
end
end
def check_view_permissions
render_403 unless can_read_result?(@result)
end
def result_params
params.require(:result).permit(
:name, :archived,

View file

@ -29,6 +29,9 @@ module ReportsHelper
image_tag(preview.processed.service_url(expires_in: Constants::URL_LONG_EXPIRE_TIME))
rescue ActiveStorage::FileNotFoundError
image_tag('icon_small/missing.png')
rescue StandardError => e
Rails.logger.error e.message
tag.i(I18n.t('projects.reports.index.generation.file_preview_generation_error'))
end
def assigned_repository_or_snapshot(my_module, repository)

View file

@ -7,7 +7,6 @@ module User::ProjectRoles
# Check if user is member of project
around %i(
is_member_of_project?
is_owner_of_project?
is_user_of_project?
is_user_or_higher_of_project?
is_technician_of_project?
@ -15,7 +14,7 @@ module User::ProjectRoles
is_viewer_of_project?
) do |proxy, *args, &block|
if args[0]
@user_project = user_projects.where(project: args[0]).take
@user_project = user_projects.find_by(project: args[0])
@user_project ? proxy.call(*args, &block) : false
else
false
@ -33,7 +32,13 @@ module User::ProjectRoles
end
def is_owner_of_project?(project)
@user_project.owner?
# if project has no assigned users, creator can manage it
if project.user_projects.none? && project.created_by_id == id
true
else
user_project = user_projects.find_by(project: project)
user_project.present? ? user_project.owner? : false
end
end
def is_user_of_project?(project)

View file

@ -19,7 +19,14 @@ module Reports::Docx::DrawResultAsset
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list?
begin
Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list?
rescue StandardError => e
Rails.logger.error e.message
@docx.p do
text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true
end
end
draw_result_comments(result) if @settings.dig('task', 'result_comments')
end

View file

@ -17,6 +17,13 @@ module Reports::Docx::DrawStepAsset
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list?
begin
Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list?
rescue StandardError => e
Rails.logger.error e.message
@docx.p do
text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true
end
end
end
end

View file

@ -152,14 +152,8 @@ module Reports
y = y * 300 / x
x = 300
end
blob_data = if asset_preview.class == ActiveStorage::Preview
asset_preview.image.download
else
asset_preview.blob.download
end
docx.img asset_preview.service_url.split('&')[0] do
data blob_data
width x
height y
end

View file

@ -17,7 +17,7 @@ module RepositoryRows
def call
return self unless valid?
ActiveRecord::Base.transaction do
@repository_row.with_lock do
# Update invetory row's cells
params[:repository_cells]&.each do |column_id, value|
column = @repository_row.repository.repository_columns.find_by(id: column_id)

View file

@ -6,7 +6,7 @@
<h4 class="modal-title" id="modal-move-module-label"><%=t "experiments.canvas.edit.modal_move_module.title" %></h4>
</div>
<div class="modal-body">
<% experiments = @experiment.project.experiments.active %>
<% experiments = @experiment.project.experiments.order(name: :asc).active %>
<% if experiments.count > 1 %>
<%= bootstrap_form_tag do |f| %>
<%= f.select :experiment_id, experiments

View file

@ -1,4 +1,7 @@
<div class="label-printing-progress-modal" data-label-printer-status="<%= label_printer.printing_status %>" data-label-printer-id="<%= label_printer.id %>" data-starting-item-count="<%= starting_item_count %>">
<div class="label-printing-progress-modal"
data-label-printer-status="<%= label_printer.printing_status %>" data-label-printer-id="<%= label_printer.id %>"
data-starting-item-count="<%= starting_item_count %>"
data-progress-url="<%= update_progress_modal_label_printer_path(label_printer, starting_item_count: starting_item_count) %>">
<div class="modal-header">
<div class="title">
<%= label_printer.name %>

View file

@ -63,9 +63,6 @@
<% end %>
</li>
<% end %>
<li class="form-dropdown-break">
<hr>
</li>
<li class="form-dropdown-item">
<div class="form-dropdown-item-info">
<small><%= t('experiments.experiment_id') %>: <strong><%= experiment.code %></strong></small>

View file

@ -20,7 +20,7 @@
<% else %>
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
<% end %>
<a href="<%= file_link %>">
<a href="<%= file_link %>" class="export-all-link" >
<em><%= t("projects.reports.elements.result_asset.file_name", file: file_link&.split('/')&.last) %></em>
</a>
<% else %>

View file

@ -13,7 +13,7 @@
<% else %>
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
<% end %>
<a href="<%= file_link %>">
<a href="<%= file_link %>" class="export-all-link">
<em><%= t('projects.reports.elements.step_asset.file_name', file: file_link&.split('/')&.last) %></em>
</a>
<% else %>

View file

@ -2,7 +2,7 @@
<div class="modal-dialog" role="document">
<div class="modal-content">
<% if @printers.size > 0 %>
<%= form_tag print_repository_repository_rows_path do %>
<%= form_tag print_repository_repository_rows_path, { class: 'print-label-form', data: { remote: true } } do %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">

View file

@ -161,11 +161,6 @@
<%= render partial: 'repositories/import_repository_records_modal',
locals: { repository: @repository } %>
<% if @busy_printer %>
<%= render(
partial: 'label_printers/print_progress_modal',
locals: { starting_item_count: @busy_printer.current_print_job_ids.length, label_printer: @busy_printer }) %>
<% end %>
<%= render partial: "repositories/delete_record_modal" %>
<%= render partial: 'repositories/export_repository_modal',

View file

@ -329,7 +329,7 @@ class Extends
task_protocol: [15, 22, 16, 18, 19, 20, 21, 17, 38, 39, 100, 111, 45, 46, 47, 121, 124, 115, 118, 127, 130, 137,
168, 171, 177],
task_inventory: [55, 56, 146, 147],
experiment: [*27..31, 57],
experiment: [*27..31, 57, 141],
reports: [48, 50, 49, 163, 164],
inventories: [70, 71, 105, 144, 145, 72, 73, 74, 102, 142, 143, 75, 76, 77, 78, 96, 107, 113, 114, *133..136],
protocol_repository: [80, 103, 89, 87, 79, 90, 91, 88, 85, 86, 84, 81, 82,

View file

@ -532,6 +532,7 @@ en:
error_pdf_notification_title: "Your report .PDF generation failed. Please try again."
error_notification_message: "Report: %{report_link} | Team: %{team_name}"
content_generation_error: "Failed to generate report content"
file_preview_generation_error: "We were unable to generate preview for this file."
modal_delete:
head_title: "Delete report/s"
message: "Are you sure to delete selected report/s?"

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
class AddUniqueConstraintToRepositoryCell < ActiveRecord::Migration[6.1]
def change
add_index :repository_cells,
%i(repository_row_id repository_column_id),
name: 'index_repository_cells_on_repository_row_and_repository_column',
unique: true
end
end

View file

@ -5266,6 +5266,13 @@ CREATE INDEX index_repository_asset_values_on_last_modified_by_id ON public.repo
CREATE INDEX index_repository_cells_on_repository_column_id ON public.repository_cells USING btree (repository_column_id);
--
-- Name: index_repository_cells_on_repository_row_and_repository_column; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_repository_cells_on_repository_row_and_repository_column ON public.repository_cells USING btree (repository_row_id, repository_column_id);
--
-- Name: index_repository_cells_on_repository_row_id; Type: INDEX; Schema: public; Owner: -
--
@ -7569,6 +7576,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20210720112050'),
('20210811103123'),
('20210812095254'),
('20210825112050');
('20210825112050'),
('20210906132120');

View file

@ -5,8 +5,6 @@ services:
image: postgres:11
volumes:
- scinote_production_postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- "POSTGRES_USER=postgres"
- "POSTGRES_PASSWORD=mysecretpassword"

View file

@ -54,7 +54,7 @@
"@joeattardi/emoji-button": "^2.5.4",
"@rails/webpacker": "^4.0.7",
"autoprefixer": "^7.2.6",
"axios": "0.21.1",
"axios": "0.21.2",
"babel-loader": "^8.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"bootstrap-sass": "^3.3.7",

View file

@ -1463,12 +1463,12 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
axios@0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
axios@0.21.2:
version "0.21.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017"
integrity sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==
dependencies:
follow-redirects "^1.10.0"
follow-redirects "^1.14.0"
axobject-query@^0.1.0:
version "0.1.0"
@ -4060,10 +4060,10 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"
follow-redirects@^1.0.0, follow-redirects@^1.10.0:
version "1.13.1"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7"
integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==
follow-redirects@^1.0.0, follow-redirects@^1.14.0:
version "1.14.3"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.3.tgz#6ada78118d8d24caee595595accdc0ac6abd022e"
integrity sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==
for-in@^0.1.3:
version "0.1.8"