mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 06:35:56 +08:00
Merge branch 'develop' into features/asset-sync
This commit is contained in:
commit
7a4d17f63e
|
@ -442,7 +442,7 @@ GEM
|
|||
net-smtp (0.3.3)
|
||||
net-protocol
|
||||
newrelic_rpm (9.2.2)
|
||||
nio4r (2.5.9)
|
||||
nio4r (2.7.0)
|
||||
nokogiri (1.14.5)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
|
@ -505,7 +505,7 @@ GEM
|
|||
pry (>= 0.10.4)
|
||||
psych (3.3.4)
|
||||
public_suffix (5.0.1)
|
||||
puma (6.3.1)
|
||||
puma (6.4.2)
|
||||
nio4r (~> 2.0)
|
||||
raabro (1.4.0)
|
||||
racc (1.7.1)
|
||||
|
@ -686,7 +686,7 @@ GEM
|
|||
unicode-display_width (2.4.2)
|
||||
uniform_notifier (1.16.0)
|
||||
version_gem (1.1.3)
|
||||
view_component (3.2.0)
|
||||
view_component (3.9.0)
|
||||
activesupport (>= 5.2.0, < 8.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
method_source (~> 1.0)
|
||||
|
|
|
@ -100,8 +100,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
function initActionButtons() {
|
||||
initUpdatePDFReport();
|
||||
initGenerateDocxReport();
|
||||
initUpdateDocxReport();
|
||||
initEditReport();
|
||||
initSaveReportPDFToInventory();
|
||||
initDeleteReports();
|
||||
}
|
||||
|
||||
function updateButtons() {
|
||||
if (window.actionToolbarComponent) {
|
||||
window.actionToolbarComponent.setActionsLoadedCallback(initActionButtons);
|
||||
window.actionToolbarComponent.fetchActions({ report_ids: CHECKBOX_SELECTOR.selectedRows });
|
||||
$('.dataTables_scrollBody').css('padding-bottom', `${CHECKBOX_SELECTOR.selectedRows.length > 0 ? 68 : 0}px`);
|
||||
}
|
||||
|
@ -263,7 +273,7 @@
|
|||
}
|
||||
|
||||
function initUpdatePDFReport() {
|
||||
$(document).on('click', '#updatePdf', function(ev) {
|
||||
$('#updatePdf').on('click', function(ev) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
|
||||
|
@ -283,7 +293,7 @@
|
|||
}
|
||||
|
||||
function initGenerateDocxReport() {
|
||||
$(document).on('click', '#requestDocx', function(ev) {
|
||||
$('#requestDocx').on('click', function(ev) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
$(this).closest('.dropdown-menu').dropdown('toggle');
|
||||
|
@ -292,7 +302,7 @@
|
|||
}
|
||||
|
||||
function initUpdateDocxReport() {
|
||||
$(document).on('click', '#updateDocx', function(ev) {
|
||||
$('#updateDocx').on('click', function(ev) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
|
||||
|
@ -325,7 +335,7 @@
|
|||
}
|
||||
|
||||
function initSaveReportPDFToInventory() {
|
||||
$(document).on('click', '#savePdfToInventoryButton', function(ev) {
|
||||
$('#savePdfToInventoryButton').on('click', function(ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
|
@ -347,7 +357,7 @@
|
|||
}
|
||||
|
||||
function initDeleteReports() {
|
||||
$(document).on('click', '#delete-reports-btn', function() {
|
||||
$('#delete-reports-btn').on('click', function() {
|
||||
if (CHECKBOX_SELECTOR.selectedRows.length > 0) {
|
||||
$('#report-ids').attr('value', '[' + CHECKBOX_SELECTOR.selectedRows + ']');
|
||||
$('#delete-reports-modal').modal('show');
|
||||
|
@ -376,10 +386,4 @@
|
|||
$('#show_report_preview').click();
|
||||
|
||||
initDatatable();
|
||||
initUpdatePDFReport();
|
||||
initGenerateDocxReport();
|
||||
initUpdateDocxReport();
|
||||
initEditReport();
|
||||
initSaveReportPDFToInventory();
|
||||
initDeleteReports();
|
||||
}());
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
if ($(table).parent().hasClass('table-wrapper')) return;
|
||||
|
||||
$(table).wrap(`
|
||||
<div class="table-wrapper" style="overflow: auto; width: ${$($(rtf)[0]).parent().width()}px"></div>
|
||||
<div class="table-wrapper w-full" style="overflow: auto;"></div>
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,9 +148,6 @@ let inlineEditing = (function() {
|
|||
$(editBlocks).click();
|
||||
}
|
||||
})
|
||||
.on('blur', `${editBlocks} textarea, ${editBlocks} input`, function(e) {
|
||||
saveAllEditFields();
|
||||
})
|
||||
.on('click', editBlocks, function(e) {
|
||||
// 'A' mean that, if we click on <a></a> element we will not go in edit mode
|
||||
var container = $(this);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
});
|
||||
|
||||
$(document).on('click', '.print-label-button', function(e) {
|
||||
$.removeData($(this)[0], 'rows');
|
||||
|
||||
var selectedRows = $(this).data('rows');
|
||||
|
||||
e.preventDefault();
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
class ResultAssetsController < BaseController
|
||||
before_action :load_team, :load_project, :load_experiment, :load_task, :load_result
|
||||
before_action :check_manage_permission, only: %i(create destroy)
|
||||
before_action :load_asset, only: %i(show destroy)
|
||||
before_action :check_upload_type, only: :create
|
||||
|
||||
def index
|
||||
result_assets =
|
||||
timestamps_filter(@result.result_assets).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: result_assets, each_serializer: ResultAssetSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @asset.result_asset, serializer: ResultAssetSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
asset = if @form_multipart_upload
|
||||
@result.assets.new(asset_params.merge({ team_id: @team.id }))
|
||||
else
|
||||
blob = ActiveStorage::Blob.create_and_upload!(
|
||||
io: StringIO.new(Base64.decode64(asset_params[:file_data])),
|
||||
filename: asset_params[:file_name],
|
||||
content_type: asset_params[:file_type]
|
||||
)
|
||||
@result.assets.new(file: blob, team: @team)
|
||||
end
|
||||
|
||||
asset.save!(context: :on_api_upload)
|
||||
asset.post_process_file
|
||||
|
||||
render jsonapi: asset.result_asset,
|
||||
serializer: ResultAssetSerializer,
|
||||
status: :created
|
||||
end
|
||||
|
||||
def destroy
|
||||
@asset.destroy!
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def asset_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'attachments'
|
||||
|
||||
return params.require(:data).require(:attributes).permit(:file) if @form_multipart_upload
|
||||
|
||||
attr_list = %i(file_data file_type file_name)
|
||||
params.require(:data).require(:attributes).require(attr_list)
|
||||
params.require(:data).require(:attributes).permit(attr_list)
|
||||
end
|
||||
|
||||
def load_asset
|
||||
@asset = @result.assets.find(params.require(:id))
|
||||
raise PermissionError.new(Result, :read) unless can_read_result?(@result)
|
||||
end
|
||||
|
||||
def check_upload_type
|
||||
@form_multipart_upload = true if params.dig(:data, :attributes, :file)
|
||||
end
|
||||
|
||||
def check_manage_permission
|
||||
raise PermissionError.new(Result, :manage) unless can_manage_result?(@result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
76
app/controllers/api/v2/result_elements/assets_controller.rb
Normal file
76
app/controllers/api/v2/result_elements/assets_controller.rb
Normal file
|
@ -0,0 +1,76 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
module ResultElements
|
||||
class AssetsController < ::Api::V2::BaseController
|
||||
before_action :load_team, :load_project, :load_experiment, :load_task, :load_result
|
||||
before_action :check_manage_permission, only: %i(create destroy)
|
||||
before_action :load_asset, only: %i(show destroy)
|
||||
before_action :check_upload_type, only: :create
|
||||
|
||||
def index
|
||||
result_assets =
|
||||
timestamps_filter(@result.assets).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: result_assets, each_serializer: Api::V2::AssetSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @asset, serializer: Api::V2::AssetSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
asset = if @form_multipart_upload
|
||||
@result.assets.new(asset_params.merge({ team_id: @team.id }))
|
||||
else
|
||||
blob = ActiveStorage::Blob.create_and_upload!(
|
||||
io: StringIO.new(Base64.decode64(asset_params[:file_data])),
|
||||
filename: asset_params[:file_name],
|
||||
content_type: asset_params[:file_type]
|
||||
)
|
||||
@result.assets.new(file: blob, team: @team)
|
||||
end
|
||||
|
||||
asset.save!(context: :on_api_upload)
|
||||
asset.post_process_file
|
||||
|
||||
render jsonapi: asset,
|
||||
serializer: Api::V2::AssetSerializer,
|
||||
status: :created
|
||||
end
|
||||
|
||||
def destroy
|
||||
@asset.destroy!
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def asset_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'attachments'
|
||||
|
||||
return params.require(:data).require(:attributes).permit(:file) if @form_multipart_upload
|
||||
|
||||
attr_list = %i(file_data file_type file_name)
|
||||
params.require(:data).require(:attributes).require(attr_list)
|
||||
params.require(:data).require(:attributes).permit(attr_list)
|
||||
end
|
||||
|
||||
def load_asset
|
||||
@asset = @result.assets.find(params.require(:id))
|
||||
raise PermissionError.new(Result, :read) unless can_read_result?(@result)
|
||||
end
|
||||
|
||||
def check_upload_type
|
||||
@form_multipart_upload = true if params.dig(:data, :attributes, :file)
|
||||
end
|
||||
|
||||
def check_manage_permission
|
||||
raise PermissionError.new(Result, :manage) unless can_manage_result?(@result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
104
app/controllers/api/v2/result_elements/tables_controller.rb
Normal file
104
app/controllers/api/v2/result_elements/tables_controller.rb
Normal file
|
@ -0,0 +1,104 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
module ResultElements
|
||||
class TablesController < BaseController
|
||||
before_action :load_team, :load_project, :load_experiment, :load_task, :load_result
|
||||
before_action only: %i(show update destroy) do
|
||||
load_result_table(:id)
|
||||
end
|
||||
before_action :check_manage_permission, only: %i(create update destroy)
|
||||
|
||||
def index
|
||||
result_tables = timestamps_filter(@result.result_tables).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: result_tables, each_serializer: ResultTableSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @table.result_table, serializer: ResultTableSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
table = @result.tables.new(table_params.merge!(team: @team, created_by: current_user))
|
||||
|
||||
@result.with_lock do
|
||||
@result.result_orderable_elements.create!(
|
||||
position: @result.result_orderable_elements.size,
|
||||
orderable: table.result_table
|
||||
)
|
||||
|
||||
table.save!
|
||||
end
|
||||
|
||||
render jsonapi: table.result_table, serializer: ResultTableSerializer, status: :created
|
||||
end
|
||||
|
||||
def update
|
||||
@table.assign_attributes(table_params)
|
||||
|
||||
if @table.changed? && @table.save!
|
||||
render jsonapi: @table.result_table, serializer: ResultTableSerializer
|
||||
else
|
||||
render body: nil, status: :no_content
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@table.destroy!
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_manage_permission
|
||||
raise PermissionError.new(Result, :manage) unless can_manage_result?(@result)
|
||||
end
|
||||
|
||||
def convert_plate_template(metadata_params)
|
||||
if metadata_params.present? && metadata_params['plateTemplate']
|
||||
metadata_params['plateTemplate'] = ActiveRecord::Type::Boolean.new.cast(metadata_params['plateTemplate'])
|
||||
end
|
||||
end
|
||||
|
||||
def table_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'tables'
|
||||
|
||||
attributes_params = params.require(:data).require(:attributes).permit(
|
||||
:name,
|
||||
:contents,
|
||||
metadata: [
|
||||
:plateTemplate,
|
||||
{ cells: %i(col row className) }
|
||||
]
|
||||
)
|
||||
|
||||
convert_plate_template(attributes_params[:metadata])
|
||||
validate_metadata_params(attributes_params)
|
||||
attributes_params
|
||||
end
|
||||
|
||||
def validate_metadata_params(attributes_params)
|
||||
metadata = attributes_params[:metadata]
|
||||
contents = JSON.parse(attributes_params[:contents] || '{}')
|
||||
|
||||
if metadata.present? && metadata[:cells].present? && contents.present?
|
||||
metadata_cells = metadata[:cells]
|
||||
data = contents['data']
|
||||
|
||||
if data.present? && data[0].present?
|
||||
data_size = (data[0].is_a?(Array) ? data.size * data[0].size : data.size)
|
||||
|
||||
if data_size < metadata_cells.size
|
||||
error_message = I18n.t('api.core.errors.table.metadata.detail_too_many_cells')
|
||||
raise ActionController::BadRequest, error_message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
68
app/controllers/api/v2/result_elements/texts_controller.rb
Normal file
68
app/controllers/api/v2/result_elements/texts_controller.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
module ResultElements
|
||||
class TextsController < BaseController
|
||||
before_action :load_team, :load_project, :load_experiment, :load_task, :load_result
|
||||
before_action only: %i(show update destroy) do
|
||||
load_result_text(:id)
|
||||
end
|
||||
before_action :check_manage_permission, only: %i(create update destroy)
|
||||
|
||||
def index
|
||||
result_texts = timestamps_filter(@result.result_texts).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: result_texts, each_serializer: ResultTextSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @result_text, serializer: ResultTextSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
result_text = @result.result_texts.new(result_text_params)
|
||||
|
||||
@result.with_lock do
|
||||
@result.result_orderable_elements.create!(
|
||||
position: @result.result_orderable_elements.size,
|
||||
orderable: result_text
|
||||
)
|
||||
|
||||
result_text.save!
|
||||
end
|
||||
|
||||
render jsonapi: result_text, serializer: ResultTextSerializer, status: :created
|
||||
end
|
||||
|
||||
def update
|
||||
@result_text.assign_attributes(result_text_params)
|
||||
|
||||
if @result_text.changed? && @result_text.save!
|
||||
render jsonapi: @result_text, serializer: ResultTextSerializer, status: :ok
|
||||
else
|
||||
render body: nil, status: :no_content
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@result_text.destroy!
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_manage_permission
|
||||
raise PermissionError.new(Result, :manage) unless can_manage_result?(@result)
|
||||
end
|
||||
|
||||
def result_text_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'result_texts'
|
||||
|
||||
params.require(:data).require(:attributes).permit(:text, :name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,102 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
class ResultTablesController < BaseController
|
||||
before_action :load_team, :load_project, :load_experiment, :load_task, :load_result
|
||||
before_action only: %i(show update destroy) do
|
||||
load_result_table(:id)
|
||||
end
|
||||
before_action :check_manage_permission, only: %i(create update destroy)
|
||||
|
||||
def index
|
||||
result_tables = timestamps_filter(@result.result_tables).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: result_tables, each_serializer: ResultTableSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @table.result_table, serializer: ResultTableSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
table = @result.tables.new(table_params.merge!(team: @team, created_by: current_user))
|
||||
|
||||
@result.with_lock do
|
||||
@result.result_orderable_elements.create!(
|
||||
position: @result.result_orderable_elements.size,
|
||||
orderable: table.result_table
|
||||
)
|
||||
|
||||
table.save!
|
||||
end
|
||||
|
||||
render jsonapi: table.result_table, serializer: ResultTableSerializer, status: :created
|
||||
end
|
||||
|
||||
def update
|
||||
@table.assign_attributes(table_params)
|
||||
|
||||
if @table.changed? && @table.save!
|
||||
render jsonapi: @table.result_table, serializer: ResultTableSerializer
|
||||
else
|
||||
render body: nil, status: :no_content
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@table.destroy!
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_manage_permission
|
||||
raise PermissionError.new(Result, :manage) unless can_manage_result?(@result)
|
||||
end
|
||||
|
||||
def convert_plate_template(metadata_params)
|
||||
if metadata_params.present? && metadata_params['plateTemplate']
|
||||
metadata_params['plateTemplate'] = ActiveRecord::Type::Boolean.new.cast(metadata_params['plateTemplate'])
|
||||
end
|
||||
end
|
||||
|
||||
def table_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'tables'
|
||||
|
||||
attributes_params = params.require(:data).require(:attributes).permit(
|
||||
:name,
|
||||
:contents,
|
||||
metadata: [
|
||||
:plateTemplate,
|
||||
{ cells: %i(col row className) }
|
||||
]
|
||||
)
|
||||
|
||||
convert_plate_template(attributes_params[:metadata])
|
||||
validate_metadata_params(attributes_params)
|
||||
attributes_params
|
||||
end
|
||||
|
||||
def validate_metadata_params(attributes_params)
|
||||
metadata = attributes_params[:metadata]
|
||||
contents = JSON.parse(attributes_params[:contents] || '{}')
|
||||
|
||||
if metadata.present? && metadata[:cells].present? && contents.present?
|
||||
metadata_cells = metadata[:cells]
|
||||
data = contents['data']
|
||||
|
||||
if data.present? && data[0].present?
|
||||
data_size = (data[0].is_a?(Array) ? data.size * data[0].size : data.size)
|
||||
|
||||
if data_size < metadata_cells.size
|
||||
error_message = I18n.t('api.core.errors.table.metadata.detail_too_many_cells')
|
||||
raise ActionController::BadRequest, error_message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,66 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
class ResultTextsController < BaseController
|
||||
before_action :load_team, :load_project, :load_experiment, :load_task, :load_result
|
||||
before_action only: %i(show update destroy) do
|
||||
load_result_text(:id)
|
||||
end
|
||||
before_action :check_manage_permission, only: %i(create update destroy)
|
||||
|
||||
def index
|
||||
result_texts = timestamps_filter(@result.result_texts).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: result_texts, each_serializer: ResultTextSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @result_text, serializer: ResultTextSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
result_text = @result.result_texts.new(result_text_params)
|
||||
|
||||
@result.with_lock do
|
||||
@result.result_orderable_elements.create!(
|
||||
position: @result.result_orderable_elements.size,
|
||||
orderable: result_text
|
||||
)
|
||||
|
||||
result_text.save!
|
||||
end
|
||||
|
||||
render jsonapi: result_text, serializer: ResultTextSerializer, status: :created
|
||||
end
|
||||
|
||||
def update
|
||||
@result_text.assign_attributes(result_text_params)
|
||||
|
||||
if @result_text.changed? && @result_text.save!
|
||||
render jsonapi: @result_text, serializer: ResultTextSerializer, status: :ok
|
||||
else
|
||||
render body: nil, status: :no_content
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@result_text.destroy!
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_manage_permission
|
||||
raise PermissionError.new(Result, :manage) unless can_manage_result?(@result)
|
||||
end
|
||||
|
||||
def result_text_params
|
||||
raise TypeError unless params.require(:data).require(:type) == 'result_texts'
|
||||
|
||||
params.require(:data).require(:attributes).permit(:text, :name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,7 +3,41 @@
|
|||
module Api
|
||||
module V2
|
||||
module StepElements
|
||||
class AssetsController < ::Api::V1::AssetsController; end
|
||||
class AssetsController < ::Api::V1::AssetsController
|
||||
def index
|
||||
attachments =
|
||||
timestamps_filter(@step.assets).page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
|
||||
render jsonapi: attachments, each_serializer: Api::V2::AssetSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render jsonapi: @asset, serializer: Api::V2::AssetSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
raise PermissionError.new(Asset, :create) unless can_manage_protocol_in_module?(@protocol)
|
||||
|
||||
if @form_multipart_upload
|
||||
asset = @step.assets.new(asset_params.merge({ team_id: @team.id }))
|
||||
else
|
||||
blob = ActiveStorage::Blob.create_and_upload!(
|
||||
io: StringIO.new(Base64.decode64(asset_params[:file_data])),
|
||||
filename: asset_params[:file_name],
|
||||
content_type: asset_params[:file_type]
|
||||
)
|
||||
asset = @step.assets.new(file: blob, team: @team)
|
||||
end
|
||||
|
||||
asset.save!(context: :on_api_upload)
|
||||
asset.post_process_file
|
||||
|
||||
render jsonapi: asset,
|
||||
serializer: Api::V2::AssetSerializer,
|
||||
status: :created
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module NotificationsHelper
|
||||
def send_email_notification(user, notification)
|
||||
AppMailer.delay.notification(user.id, notification)
|
||||
|
@ -17,14 +19,17 @@ module NotificationsHelper
|
|||
team: team.name,
|
||||
assigned_by_user: user.name)
|
||||
end
|
||||
message = "#{I18n.t('search.index.team')} #{team.name}"
|
||||
end
|
||||
|
||||
GeneralNotification.send_notifications({
|
||||
type: role ? :invite_user_to_team : :remove_user_from_team,
|
||||
title: sanitize_input(title),
|
||||
message: sanitize_input(message),
|
||||
user: target_user
|
||||
})
|
||||
GeneralNotification.send_notifications(
|
||||
{
|
||||
type: role ? :invite_user_to_team : :remove_user_from_team,
|
||||
title: sanitize_input(title),
|
||||
subject_id: team.id,
|
||||
subject_class: team.class.name,
|
||||
subject_name: team.respond_to?(:name) && team.name,
|
||||
user: target_user
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
multiple: false,
|
||||
params: {},
|
||||
reloadCallback: null,
|
||||
actionsLoadedCallback: null,
|
||||
loaded: false,
|
||||
loading: false,
|
||||
width: 0,
|
||||
|
@ -107,6 +108,7 @@
|
|||
this.actions = data.actions;
|
||||
this.loading = false;
|
||||
this.setButtonOverflow();
|
||||
if (this.actionsLoadedCallback) this.$nextTick(this.actionsLoadedCallback);
|
||||
});
|
||||
}, 10);
|
||||
},
|
||||
|
@ -161,6 +163,9 @@
|
|||
setReloadCallback(func) {
|
||||
this.reloadCallback = func;
|
||||
},
|
||||
setActionsLoadedCallback(func) {
|
||||
this.actionsLoadedCallback = func;
|
||||
},
|
||||
doAction(action, event) {
|
||||
switch(action.type) {
|
||||
case 'legacy':
|
||||
|
|
|
@ -308,7 +308,14 @@ export default {
|
|||
handleOutsideClick(event) {
|
||||
if (!this.isShowing) return;
|
||||
|
||||
const allowedSelectors = ['a', '.modal', '.label-printing-progress-modal', '.atwho-view'];
|
||||
const allowedSelectors = [
|
||||
'a',
|
||||
'.modal',
|
||||
'.dp__instance_calendar',
|
||||
'.label-printing-progress-modal',
|
||||
'.atwho-view'
|
||||
];
|
||||
|
||||
const excludeSelectors = ['#myModuleRepositoryFullViewModal'];
|
||||
|
||||
const isOutsideSidebar = !$(event.target).parents('#repository-item-sidebar-wrapper').length;
|
||||
|
@ -348,7 +355,7 @@ export default {
|
|||
this.loadRepositoryRow(repositoryRowUrl);
|
||||
this.currentItemUrl = repositoryRowUrl;
|
||||
},
|
||||
loadRepositoryRow(repositoryRowUrl) {
|
||||
loadRepositoryRow(repositoryRowUrl, scrollTop = 0) {
|
||||
this.dataLoading = true
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
|
@ -368,13 +375,17 @@ export default {
|
|||
this.dataLoading = false;
|
||||
this.$nextTick(() => {
|
||||
this.generateBarCode(this.defaultColumns.code);
|
||||
|
||||
// if scrollTop was provided, scroll to it
|
||||
this.$nextTick(() => { this.$refs.bodyWrapper.scrollTop = scrollTop; });
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
reload() {
|
||||
if (this.isShowing) {
|
||||
this.loadRepositoryRow(this.currentItemUrl);
|
||||
// perserve scrollTop on reload
|
||||
this.loadRepositoryRow(this.currentItemUrl, this.$refs.bodyWrapper.scrollTop);
|
||||
}
|
||||
},
|
||||
showRepositoryAssignModal() {
|
||||
|
|
|
@ -90,6 +90,10 @@
|
|||
},
|
||||
computed: {
|
||||
attachmentsOrdered() {
|
||||
if (this.attachments.some((attachment) => attachment.attributes.uploading)) {
|
||||
return this.attachments;
|
||||
}
|
||||
|
||||
return this.attachments.sort((a, b) => {
|
||||
if (a.attributes.asset_order == b.attributes.asset_order) {
|
||||
switch(this.parent.attributes.assets_order) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<span class="sci-checkbox-label" >
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="h-1 w-1 bg-sn-black rounded-full mt-auto mb-auto"></div>
|
||||
<div v-else class="h-1 w-1 bg-sn-black rounded-full mt-3"></div>
|
||||
<div class="pr-24 relative flex items-start max-w-[90ch]"
|
||||
:class="{
|
||||
'pointer-events-none': !checklistItem.attributes.isNew && !updateUrl,
|
||||
|
|
|
@ -97,10 +97,7 @@ export default {
|
|||
upload.create((error, blob) => {
|
||||
if (error) {
|
||||
fileObject.error = I18n.t('attachments.new.general_error');
|
||||
this.attachments.splice(filePosition, 1);
|
||||
setTimeout(() => {
|
||||
this.attachments.push(fileObject);
|
||||
}, 0);
|
||||
this.attachments = this.attachments.with(filePosition, fileObject);
|
||||
reject(error);
|
||||
} else {
|
||||
const signedId = blob.signed_id;
|
||||
|
@ -109,16 +106,10 @@ export default {
|
|||
}, (result) => {
|
||||
fileObject.id = result.data.id;
|
||||
fileObject.attributes = result.data.attributes;
|
||||
this.attachments.splice(filePosition, 1);
|
||||
setTimeout(() => {
|
||||
this.attachments.push(fileObject);
|
||||
}, 0);
|
||||
this.attachments = this.attachments.with(filePosition, fileObject);
|
||||
}).fail(() => {
|
||||
fileObject.error = I18n.t('attachments.new.general_error');
|
||||
this.attachments.splice(filePosition, 1);
|
||||
setTimeout(() => {
|
||||
this.attachments.push(fileObject);
|
||||
}, 0);
|
||||
this.attachments = this.attachments.with(filePosition, fileObject);
|
||||
});
|
||||
filesUploadedCntr += 1;
|
||||
if (filesUploadedCntr === filesToUploadCntr) {
|
||||
|
|
|
@ -12,9 +12,12 @@ class RepositoryItemDateReminderJob < ApplicationJob
|
|||
|
||||
def process_repository_values(model, comparison_value)
|
||||
model
|
||||
.joins(repository_cell: { repository_column: :repository })
|
||||
.where(notification_sent: false, repositories: { type: 'Repository' })
|
||||
.where('repository_date_time_values.updated_at >= ?', 2.days.ago)
|
||||
.joins(repository_cell: [:repository_row, { repository_column: :repository }])
|
||||
.where(
|
||||
notification_sent: false,
|
||||
repositories: { type: 'Repository', archived: false },
|
||||
repository_rows: { archived: false }
|
||||
).where('repository_date_time_values.updated_at >= ?', 2.days.ago)
|
||||
.where( # date(time) values that are within the reminder range
|
||||
"data <= " \
|
||||
"(?::timestamp + CAST(((repository_columns.metadata->>'reminder_unit')::int * " \
|
||||
|
|
|
@ -141,8 +141,14 @@ class MyModule < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.approaching_due_dates
|
||||
where(due_date_notification_sent: false)
|
||||
.where('due_date > ? AND due_date <= ?', DateTime.current, DateTime.current + 1.day)
|
||||
joins(experiment: :project)
|
||||
.active
|
||||
.where(
|
||||
due_date_notification_sent: false,
|
||||
projects: { archived: false },
|
||||
experiments: { archived: false }
|
||||
)
|
||||
.where('my_modules.due_date > ? AND my_modules.due_date <= ?', DateTime.current, DateTime.current + 1.day)
|
||||
end
|
||||
|
||||
def parent
|
||||
|
|
23
app/serializers/api/v2/asset_serializer.rb
Normal file
23
app/serializers/api/v2/asset_serializer.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
class AssetSerializer < ActiveModel::Serializer
|
||||
type :attachments
|
||||
|
||||
attributes :id, :file_name, :file_size, :file_type, :file_url
|
||||
|
||||
include TimestampableModel
|
||||
|
||||
def file_type
|
||||
object.content_type
|
||||
end
|
||||
|
||||
def file_url
|
||||
if object.file&.attached?
|
||||
Rails.application.routes.url_helpers.rails_blob_path(object.file, disposition: 'attachment')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V2
|
||||
class ResultAssetSerializer < ActiveModel::Serializer
|
||||
type :assets
|
||||
attributes :file_id, :file_name, :file_size, :file_type, :file_url
|
||||
|
||||
def file_id
|
||||
object.asset&.id
|
||||
end
|
||||
|
||||
def file_name
|
||||
object.asset&.file_name
|
||||
end
|
||||
|
||||
def file_size
|
||||
object.asset&.file_size
|
||||
end
|
||||
|
||||
def file_type
|
||||
object.asset&.content_type
|
||||
end
|
||||
|
||||
def file_url
|
||||
if object.asset&.file&.attached?
|
||||
Rails.application.routes.url_helpers.rails_blob_path(object.asset.file, disposition: 'attachment')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@ module Api
|
|||
has_many :result_comments, key: :comments, serializer: Api::V1::CommentSerializer
|
||||
has_many :result_texts, key: :result_texts, serializer: ResultTextSerializer
|
||||
has_many :result_tables, key: :tables, serializer: ResultTableSerializer
|
||||
has_many :result_assets, key: :assets, serializer: ResultAssetSerializer
|
||||
has_many :assets, serializer: AssetSerializer
|
||||
has_many :result_orderable_elements, key: :result_elements, serializer: ResultOrderableElementSerializer
|
||||
|
||||
include TimestampableModel
|
||||
|
|
|
@ -12,7 +12,7 @@ module Api
|
|||
attribute :completed_on, if: -> { object.completed? }
|
||||
belongs_to :user, serializer: Api::V1::UserSerializer
|
||||
belongs_to :protocol, serializer: Api::V1::ProtocolSerializer
|
||||
has_many :assets, serializer: Api::V1::AssetSerializer
|
||||
has_many :assets, serializer: AssetSerializer
|
||||
has_many :checklists, serializer: Api::V1::ChecklistSerializer
|
||||
has_many :tables, serializer: Api::V1::TableSerializer
|
||||
has_many :step_texts, serializer: Api::V1::StepTextSerializer
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
</head>
|
||||
<body id="sci-shareable-links" data-datetime-picker-format="YYYY-MM-DD">
|
||||
<div class="flex shareable-links">
|
||||
<div class="sticky top-0 w-80 h-screen px-6 py-6 flex flex-col
|
||||
border-0 border-r border-solid border-sn-sleepy-grey">
|
||||
<div class="sticky top-0 h-screen px-6 py-6 flex flex-col
|
||||
border-0 border-r border-solid border-sn-sleepy-grey w-[15vw]">
|
||||
<%= render "shareable_links/my_modules/left_navigation" %>
|
||||
</div>
|
||||
<div class="flex flex-col flex-1 min-h-screen p-4 bg-sn-super-light-grey">
|
||||
<div class="flex flex-col flex-1 min-h-screen p-4 bg-sn-super-light-grey w-[85vw]">
|
||||
<%= yield %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<div class="task-notes">
|
||||
<div class="task-notes-content">
|
||||
<% if @my_module.description.present? %>
|
||||
<div class="rtf-view w-full">
|
||||
<div class="rtf-view overflow-auto w-full">
|
||||
<%= smart_annotation_text(@my_module.shareable_tinymce_render(:description)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<div>
|
||||
<div id="protocol-description-container" >
|
||||
<% if protocol.description.present? %>
|
||||
<div class="rtf-view w-full">
|
||||
<div class="rtf-view overflow-auto w-full">
|
||||
<%= smart_annotation_text(protocol.shareable_tinymce_render(:description)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<% if element.text.present? %>
|
||||
<div class="rtf-view w-full rounded min-h-[2.25rem] mb-4 relative group/text_container content__text-body">
|
||||
<div class="rtf-view rounded min-h-[2.25rem] mb-4 relative group/text_container content__text-body overflow-auto w-full">
|
||||
<%= smart_annotation_text(element.shareable_tinymce_render(:text)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
|
|
@ -95,15 +95,17 @@ namespace :v2 do
|
|||
resources :experiments do
|
||||
resources :tasks do
|
||||
resources :results, only: %i(index create show update destroy) do
|
||||
resources :result_assets, only: %i(index show create update destroy), path: 'assets'
|
||||
resources :result_tables, only: %i(index show create update destroy), path: 'tables'
|
||||
resources :result_texts, only: %i(index show create update destroy)
|
||||
scope module: 'result_elements' do
|
||||
resources :assets, except: %i(new edit), path: 'attachments'
|
||||
resources :tables, except: %i(new edit), path: 'tables'
|
||||
resources :texts, except: %i(new edit)
|
||||
end
|
||||
end
|
||||
|
||||
resources :protocols, only: :show do
|
||||
resources :steps, except: %i(new edit) do
|
||||
scope module: 'step_elements' do
|
||||
resources :assets, except: %i(new edit)
|
||||
resources :assets, except: %i(new edit), path: 'attachments'
|
||||
resources :checklists, except: %i(new edit) do
|
||||
resources :checklist_items, except: %i(new edit), as: :items
|
||||
end
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FixTeamIdForClonedRepositoryAssets < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
execute(
|
||||
'UPDATE "assets" ' \
|
||||
'SET "team_id" = "repositories"."team_id" ' \
|
||||
'FROM "repositories" ' \
|
||||
'INNER JOIN "repository_columns" ON "repository_columns"."repository_id" = "repositories"."id" ' \
|
||||
'INNER JOIN "repository_cells" ON "repository_cells"."repository_column_id" = "repository_columns"."id" ' \
|
||||
'INNER JOIN "repository_asset_values" ON "repository_asset_values"."id" = "repository_cells"."value_id" ' \
|
||||
'AND "repository_cells"."value_type" = \'RepositoryAssetValue\' ' \
|
||||
'WHERE "repository_asset_values"."asset_id" = "assets"."id" AND "assets"."team_id" != "repositories"."team_id"'
|
||||
)
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
||||
RSpec.describe 'Api::V2::ResultElements::AssetsController', type: :request do
|
||||
let(:user) { create(:user) }
|
||||
let(:team) { create(:team, created_by: user) }
|
||||
let(:project) { create(:project, team: team, created_by: user) }
|
||||
|
@ -15,7 +15,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
let(:valid_headers) { { Authorization: "Bearer #{generate_token(user.id)}", 'Content-Type': 'application/json' } }
|
||||
|
||||
let(:api_path) do
|
||||
api_v2_team_project_experiment_task_result_result_assets_path(
|
||||
api_v2_team_project_experiment_task_result_assets_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -24,7 +24,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
)
|
||||
end
|
||||
|
||||
describe 'GET result_assets, #index' do
|
||||
describe 'GET result assets, #index' do
|
||||
let(:result_asset) { create(:result_asset, result: result) }
|
||||
|
||||
context 'when has valid params' do
|
||||
|
@ -37,7 +37,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
expect(hash_body[:data]).to match_array(
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource
|
||||
.new(result.result_assets, each_serializer: Api::V2::ResultAssetSerializer)
|
||||
.new(result.result_assets, each_serializer: Api::V2::AssetSerializer)
|
||||
.to_json
|
||||
)['data']
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
|
||||
context 'when result is not found' do
|
||||
it 'renders 404' do
|
||||
get api_v2_team_project_experiment_task_result_result_assets_path(
|
||||
get api_v2_team_project_experiment_task_result_assets_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -65,7 +65,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
context 'when has valid params' do
|
||||
it 'renders 200' do
|
||||
hash_body = nil
|
||||
get api_v2_team_project_experiment_task_result_result_asset_path(
|
||||
get api_v2_team_project_experiment_task_result_asset_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -79,7 +79,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
expect(hash_body[:data]).to match(
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource
|
||||
.new(result_asset, serializer: Api::V2::ResultAssetSerializer)
|
||||
.new(result_asset.asset, serializer: Api::V2::AssetSerializer)
|
||||
.to_json
|
||||
)['data']
|
||||
)
|
||||
|
@ -125,7 +125,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
expect(hash_body[:data]).to match(
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource
|
||||
.new(ResultAsset.last, serializer: Api::V2::ResultAssetSerializer)
|
||||
.new(ResultAsset.last.asset, serializer: Api::V2::AssetSerializer)
|
||||
.to_json
|
||||
)['data']
|
||||
)
|
||||
|
@ -155,7 +155,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
let(:result_asset_archived) { create(:result_asset, result: result_archived) }
|
||||
|
||||
let(:action) do
|
||||
delete(api_v2_team_project_experiment_task_result_result_asset_path(
|
||||
delete(api_v2_team_project_experiment_task_result_asset_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -166,7 +166,7 @@ RSpec.describe 'Api::V2::ResultAssetsController', type: :request do
|
|||
end
|
||||
|
||||
let(:action_archived) do
|
||||
delete(api_v2_team_project_experiment_task_result_result_asset_path(
|
||||
delete(api_v2_team_project_experiment_task_result_asset_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
||||
RSpec.describe 'Api::V2::ResultElements::TablesController', type: :request do
|
||||
let(:user) { create(:user) }
|
||||
let(:team) { create(:team, created_by: user) }
|
||||
let(:project) { create(:project, team: team, created_by: user) }
|
||||
|
@ -15,7 +15,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
let(:valid_headers) { { Authorization: "Bearer #{generate_token(user.id)}", 'Content-Type': 'application/json' } }
|
||||
|
||||
let(:api_path) do
|
||||
api_v2_team_project_experiment_task_result_result_tables_path(
|
||||
api_v2_team_project_experiment_task_result_tables_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -46,7 +46,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
|
||||
context 'when result is not found' do
|
||||
it 'renders 404' do
|
||||
get api_v2_team_project_experiment_task_result_result_tables_path(
|
||||
get api_v2_team_project_experiment_task_result_tables_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -65,7 +65,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
context 'when has valid params' do
|
||||
it 'renders 200' do
|
||||
hash_body = nil
|
||||
get api_v2_team_project_experiment_task_result_result_table_path(
|
||||
get api_v2_team_project_experiment_task_result_table_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -134,7 +134,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
let(:request_body) do
|
||||
{
|
||||
data: {
|
||||
type: 'result_tables',
|
||||
type: 'tables',
|
||||
attributes: {}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
let(:result_table) { create(:result_table, result: result) }
|
||||
let(:result_table_archived) { create(:result_table, result: result_archived) }
|
||||
let(:action) do
|
||||
patch(api_v2_team_project_experiment_task_result_result_table_path(
|
||||
patch(api_v2_team_project_experiment_task_result_table_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -163,7 +163,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
end
|
||||
|
||||
let(:action_archived) do
|
||||
patch(api_v2_team_project_experiment_task_result_result_table_path(
|
||||
patch(api_v2_team_project_experiment_task_result_table_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -211,7 +211,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
let(:request_body) do
|
||||
{
|
||||
data: {
|
||||
type: 'result_tables',
|
||||
type: 'tables',
|
||||
attributes: {}
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
let(:request_body) do
|
||||
{
|
||||
data: {
|
||||
type: 'result_tables',
|
||||
type: 'tables',
|
||||
attributes: {
|
||||
name: 'Result table',
|
||||
contents: '{"data": [["group/time", "1 dpi", "6 dpi", "", ""], ["PVYNTN", "1", "1", "", ""]]}'
|
||||
|
@ -249,7 +249,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
let(:result_table) { create(:result_table, result: result) }
|
||||
let(:result_table_archived) { create(:result_table, result: result_archived) }
|
||||
let(:delete_action) do
|
||||
delete(api_v2_team_project_experiment_task_result_result_table_path(
|
||||
delete(api_v2_team_project_experiment_task_result_table_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -260,7 +260,7 @@ RSpec.describe 'Api::V2::ResultTablesController', type: :request do
|
|||
end
|
||||
|
||||
let(:delete_action_archived) do
|
||||
delete(api_v2_team_project_experiment_task_result_result_table_path(
|
||||
delete(api_v2_team_project_experiment_task_result_table_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
||||
RSpec.describe 'Api::V2::ResultElements::TextsController', type: :request do
|
||||
let(:user) { create(:user) }
|
||||
let(:team) { create(:team, created_by: user) }
|
||||
let(:project) { create(:project, team: team, created_by: user) }
|
||||
|
@ -14,7 +14,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
let(:valid_headers) { { Authorization: "Bearer #{generate_token(user.id)}", 'Content-Type': 'application/json' } }
|
||||
|
||||
let(:api_path) do
|
||||
api_v2_team_project_experiment_task_result_result_texts_path(
|
||||
api_v2_team_project_experiment_task_result_texts_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -45,7 +45,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
|
||||
context 'when result is not found' do
|
||||
it 'renders 404' do
|
||||
get api_v2_team_project_experiment_task_result_result_texts_path(
|
||||
get api_v2_team_project_experiment_task_result_texts_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -64,7 +64,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
context 'when has valid params' do
|
||||
it 'renders 200' do
|
||||
hash_body = nil
|
||||
get api_v2_team_project_experiment_task_result_result_text_path(
|
||||
get api_v2_team_project_experiment_task_result_text_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -195,7 +195,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
let(:result_text) { create(:result_text, result: result) }
|
||||
let(:result_text_archived) { create(:result_text, result: result_archived) }
|
||||
let(:action) do
|
||||
patch(api_v2_team_project_experiment_task_result_result_text_path(
|
||||
patch(api_v2_team_project_experiment_task_result_text_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -205,7 +205,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
), params: request_body.to_json, headers: valid_headers)
|
||||
end
|
||||
let(:action_archived) do
|
||||
patch(api_v2_team_project_experiment_task_result_result_text_path(
|
||||
patch(api_v2_team_project_experiment_task_result_text_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -335,7 +335,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
let(:result_text) { create(:result_text, result: result) }
|
||||
let(:result_text_archived) { create(:result_text, result: result_archived) }
|
||||
let(:action) do
|
||||
delete(api_v2_team_project_experiment_task_result_result_text_path(
|
||||
delete(api_v2_team_project_experiment_task_result_text_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
||||
|
@ -346,7 +346,7 @@ RSpec.describe 'Api::V2::ResultTextsController', type: :request do
|
|||
end
|
||||
|
||||
let(:action_archived) do
|
||||
delete(api_v2_team_project_experiment_task_result_result_text_path(
|
||||
delete(api_v2_team_project_experiment_task_result_text_path(
|
||||
team_id: team.id,
|
||||
project_id: project.id,
|
||||
experiment_id: experiment.id,
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::AssetsController', type: :request do
|
||||
RSpec.describe 'Api::V2::StepElements::AssetsController', type: :request do
|
||||
before :all do
|
||||
@user = create(:user)
|
||||
@team = create(:team, created_by: @user)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::ChecklistsController', type: :request do
|
||||
RSpec.describe 'Api::V2::StepElements::ChecklistItemsController', type: :request do
|
||||
before :all do
|
||||
@user = create(:user)
|
||||
@team = create(:team, created_by: @user)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::ChecklistsController', type: :request do
|
||||
RSpec.describe 'Api::V2::StepElements::ChecklistsController', type: :request do
|
||||
before :all do
|
||||
@user = create(:user)
|
||||
@team = create(:team, created_by: @user)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::StepElements::TablesController', type: :request do
|
||||
RSpec.describe 'Api::V2::StepElements::StepElements::TablesController', type: :request do
|
||||
before :all do
|
||||
@user = create(:user)
|
||||
@team = create(:team, created_by: @user)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V2::StepElements::TextsController', type: :request do
|
||||
RSpec.describe 'Api::V2::StepElements::StepElements::TextsController', type: :request do
|
||||
before :all do
|
||||
@user = create(:user)
|
||||
@team = create(:team, created_by: @user)
|
||||
|
|
|
@ -117,9 +117,8 @@
|
|||
fnReset: function() {
|
||||
let self = this;
|
||||
this._fnGetAllColumns().forEach(function(column) {
|
||||
if (column.sWidth == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof column.sWidth !== 'string' || column.sWidth === null) return;
|
||||
|
||||
let widthResult = column.sWidth.match(/(\d+)/i),
|
||||
oldWidth = widthResult != null ? parseInt(widthResult[0]) : 0,
|
||||
|
@ -149,9 +148,8 @@
|
|||
self.s.state.originalTableWidth = this._fnGetTable().width();
|
||||
|
||||
cols.forEach(function (column) {
|
||||
if (column.sWidth == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof column.sWidth !== 'string' || column.sWidth === null) return;
|
||||
|
||||
let widthResult = column.sWidth.match(/(\d+)/i),
|
||||
oldWidth = widthResult != null ? parseInt(widthResult[0]) : 0,
|
||||
|
|
Loading…
Reference in a new issue