diff --git a/app/assets/javascripts/shareable_links/my_module_protocol_show.js b/app/assets/javascripts/shareable_links/my_module_protocol_show.js
index 3b9a309ba..d7d939279 100644
--- a/app/assets/javascripts/shareable_links/my_module_protocol_show.js
+++ b/app/assets/javascripts/shareable_links/my_module_protocol_show.js
@@ -1,4 +1,4 @@
-/* global tableColRowName*/
+/* global tableColRowName notTurbolinksPreview */
(function() {
'use strict';
@@ -8,9 +8,12 @@
}
function initStepsExpandCollapse() {
- $(document).on('click', '.protocol-step-actions', function(event) {
- let action = $(event.target).hasClass('steps-expand') ? 'show' : 'hide';
- $('.step-container .collapse').collapse(action);
+ $(document).on('click', '#steps-collapse-btn', function() {
+ $('.step-container .collapse').collapse('hide');
+ });
+
+ $(document).on('click', '#steps-expand-btn', function() {
+ $('.step-container .collapse').collapse('show');
});
}
@@ -68,5 +71,7 @@
});
}
- initMyModuleProtocolShow();
+ if (notTurbolinksPreview()) {
+ initMyModuleProtocolShow();
+ }
}());
diff --git a/app/assets/javascripts/shareable_links/my_module_results_show.js b/app/assets/javascripts/shareable_links/my_module_results_show.js
new file mode 100644
index 000000000..a17af4da5
--- /dev/null
+++ b/app/assets/javascripts/shareable_links/my_module_results_show.js
@@ -0,0 +1,56 @@
+/* global notTurbolinksPreview */
+
+(function() {
+ 'use strict';
+
+ function initializeHandsonTable(el) {
+ var input = el.siblings('input.hot-table-contents');
+ var inputObj = JSON.parse(input.attr('value'));
+ var metadataJson = el.siblings('input.hot-table-metadata');
+ var data = inputObj.data;
+ var metadata;
+
+ metadata = JSON.parse(metadataJson.val() || '{}');
+ el.handsontable({
+ disableVisualSelection: true,
+ rowHeaders: true,
+ colHeaders: true,
+ editor: false,
+ copyPaste: false,
+ formulas: true,
+ data: data,
+ cell: metadata.cells || []
+ });
+ }
+
+ function initAttachments() {
+ $(document).on('click', '.shareable-file-preview-link, .shareable-gallery-switcher', function(e) {
+ e.preventDefault();
+ $('.modal-file-preview.in').modal('hide');
+ $($(`.modal-file-preview[data-object-id=${$(this).data('id')}]`)).modal('show');
+ });
+ }
+
+ function initResultsExpandCollapse() {
+ $(document).on('click', '#results-collapse-btn', function() {
+ $('.result .panel-collapse').collapse('hide');
+ });
+
+ $(document).on('click', '#results-expand-btn', function() {
+ $('.result .panel-collapse').collapse('show');
+ });
+ }
+
+ function initMyModuleResultsShow() {
+ initAttachments();
+ initResultsExpandCollapse();
+
+ $('.hot-table-container').each(function() {
+ initializeHandsonTable($(this));
+ });
+ }
+
+ if (notTurbolinksPreview()) {
+ initMyModuleResultsShow();
+ }
+}());
diff --git a/app/controllers/my_module_shareable_links_controller.rb b/app/controllers/my_module_shareable_links_controller.rb
index 57aad4f8e..391dbff53 100644
--- a/app/controllers/my_module_shareable_links_controller.rb
+++ b/app/controllers/my_module_shareable_links_controller.rb
@@ -4,23 +4,30 @@ class MyModuleShareableLinksController < ApplicationController
before_action :load_my_module, except: %i(protocol_show
repository_index_dt
repository_snapshot_index_dt
- download_asset)
+ download_step_asset
+ download_result_asset
+ results_show)
before_action :check_view_permissions, only: :show
before_action :check_manage_permissions, except: %i(protocol_show
repository_index_dt
repository_snapshot_index_dt
- download_asset)
+ download_step_asset
+ download_result_asset
+ results_show)
before_action :shareable_link_load_my_module, only: %i(protocol_show
repository_index_dt
repository_snapshot_index_dt
- download_asset)
+ download_step_asset
+ download_result_asset
+ results_show)
before_action :load_repository, only: :repository_index_dt
before_action :load_repository_snapshot, only: :repository_snapshot_index_dt
- before_action :load_asset, only: :download_asset
skip_before_action :authenticate_user!, only: %i(protocol_show
repository_index_dt
repository_snapshot_index_dt
- download_asset)
+ download_step_asset
+ download_result_asset
+ results_show)
skip_before_action :verify_authenticity_token, only: %i(protocol_show
repository_index_dt
repository_snapshot_index_dt)
@@ -34,6 +41,26 @@ class MyModuleShareableLinksController < ApplicationController
render 'shareable_links/my_module_protocol_show', layout: 'shareable_links'
end
+ def results_show
+ @results_order = params[:order] || 'new'
+
+ @results = @my_module.results.active
+ @results = @results.page(params[:page]).per(Constants::RESULTS_PER_PAGE_LIMIT)
+
+ @results = case @results_order
+ when 'old' then @results.order(created_at: :asc)
+ when 'old_updated' then @results.order(updated_at: :asc)
+ when 'new_updated' then @results.order(updated_at: :desc)
+ when 'atoz' then @results.order(name: :asc)
+ when 'ztoa' then @results.order(name: :desc)
+ else @results.order(created_at: :desc)
+ end
+
+ @gallery = @results.left_joins(:asset).pluck('assets.id').compact
+
+ render 'shareable_links/my_module_results_show', layout: 'shareable_links'
+ end
+
def repository_index_dt
@draw = params[:draw].to_i
per_page = params[:length].to_i < 1 ? Constants::REPOSITORY_DEFAULT_PAGE_SIZE : params[:length].to_i
@@ -71,7 +98,20 @@ class MyModuleShareableLinksController < ApplicationController
render 'repository_rows/simple_view_index'
end
- def download_asset
+ def download_step_asset
+ @asset = @my_module.assets_in_steps.find_by(id: params[:id])
+
+ return render_404 if @asset.blank?
+
+ redirect_to @asset.file.url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes, disposition: 'attachment'),
+ allow_other_host: true
+ end
+
+ def download_result_asset
+ @asset = @my_module.assets_in_results.find_by(id: params[:id])
+
+ return render_404 if @asset.blank?
+
redirect_to @asset.file.url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes, disposition: 'attachment'),
allow_other_host: true
end
@@ -123,12 +163,6 @@ class MyModuleShareableLinksController < ApplicationController
@my_module = @shareable_link.shareable
end
- def load_asset
- @asset = @my_module.assets_in_steps.find_by(id: params[:id])
-
- return render_404 if @asset.blank?
- end
-
def load_repository
@repository = @my_module.assigned_repositories.find_by(id: params[:id])
render_404 unless @repository
diff --git a/app/helpers/secondary_navigation_helper.rb b/app/helpers/secondary_navigation_helper.rb
index db7e5df09..c0dea6fbf 100644
--- a/app/helpers/secondary_navigation_helper.rb
+++ b/app/helpers/secondary_navigation_helper.rb
@@ -37,7 +37,7 @@ module SecondaryNavigationHelper
end
def is_module_protocols?
- %w(protocols my_module_protocol_show).include?(action_name)
+ %w(protocols protocol_show).include?(action_name)
end
def is_module_results?
diff --git a/app/views/shareable_links/my_module_results_show.html.erb b/app/views/shareable_links/my_module_results_show.html.erb
new file mode 100644
index 000000000..544f743d1
--- /dev/null
+++ b/app/views/shareable_links/my_module_results_show.html.erb
@@ -0,0 +1,50 @@
+
<%= @my_module.name %>
+
+
+
+ <%= render partial: 'shareable_links/my_modules/header_actions' %>
+
+
+
+ <% @results.each do |result| %>
+ <%= render partial: "shareable_links/my_modules/results/result", locals: { result: result, gallery: @gallery } %>
+ <% end %>
+
+
+
+
+
+
+<%= javascript_include_tag "handsontable.full" %>
+<%= render 'shared/formulas_libraries' %>
+<%= javascript_include_tag 'shareable_links/my_module_results_show' %>
+
+<%= javascript_include_tag 'shared/file_preview' %>
+<%= javascript_include_tag 'pdf_js' %>
+<%= stylesheet_link_tag 'pdf_js_styles' %>
diff --git a/app/views/shareable_links/my_modules/_attachments.html.erb b/app/views/shareable_links/my_modules/_attachments.html.erb
index 16f0d896b..1c92812d0 100644
--- a/app/views/shareable_links/my_modules/_attachments.html.erb
+++ b/app/views/shareable_links/my_modules/_attachments.html.erb
@@ -7,8 +7,8 @@
<% attachments.each do |attachment| %>
<% if attachment.file.attached? %>
- <%= render partial: "shareable_links/my_modules/step_attachments/#{ attachment.view_mode }", locals: { asset: attachment, step: step } %>
- <%= render partial: "shareable_links/my_modules/step_attachments/file_preview", locals: { asset: attachment, gallery: attachments.pluck(:id) } %>
+ <%= render partial: "shareable_links/my_modules/step_attachments/#{ attachment.view_mode }", locals: { asset: attachment, show_context: true } %>
+ <%= render partial: "shareable_links/my_modules/step_attachments/file_preview", locals: { asset: attachment, gallery: attachments.pluck(:id) } %>
<% else %>
<%= attachment.view_mode %>
<%= render partial: "shareable_links/my_modules/step_attachments/empty", locals: { asset: attachment } %>
diff --git a/app/views/shareable_links/my_modules/_header_actions.html.erb b/app/views/shareable_links/my_modules/_header_actions.html.erb
index c74f367a0..5d867008e 100644
--- a/app/views/shareable_links/my_modules/_header_actions.html.erb
+++ b/app/views/shareable_links/my_modules/_header_actions.html.erb
@@ -6,7 +6,7 @@
<%= t("nav2.modules.steps") %>
"
- href="#"
+ href="<%= shared_protocol_results_path(@shareable_link.uuid) %>"
title="<%= t("nav2.modules.results") %>"
>
<%= t("nav2.modules.results") %>
diff --git a/app/views/shareable_links/my_modules/_protocol.html.erb b/app/views/shareable_links/my_modules/_protocol.html.erb
index 24cd00e8a..8274a6fac 100644
--- a/app/views/shareable_links/my_modules/_protocol.html.erb
+++ b/app/views/shareable_links/my_modules/_protocol.html.erb
@@ -47,11 +47,11 @@
<% if protocol.steps.length > 0 %>
-
- <%= render partial: "shareable_links/my_modules/step_attachments/context_menu", locals: { asset: asset } %>
+ <% if defined?(show_context) && show_context %>
+ <%= render partial: "shareable_links/my_modules/step_attachments/context_menu", locals: { asset: asset } %>
+ <% end %>
<% if wopi_enabled? && wopi_file?(asset) %>
diff --git a/app/views/shareable_links/my_modules/step_attachments/_list.html.erb b/app/views/shareable_links/my_modules/step_attachments/_list.html.erb
index 83ea532e4..cc43c7f93 100644
--- a/app/views/shareable_links/my_modules/step_attachments/_list.html.erb
+++ b/app/views/shareable_links/my_modules/step_attachments/_list.html.erb
@@ -17,5 +17,7 @@
<%= t('assets.placeholder.modified_label') %> <%= asset.updated_at.iso8601 if asset.updated_at %>
<%= t('assets.placeholder.size_label', size: number_to_human_size(asset.file_size)) %>
- <%= render partial: "shareable_links/my_modules/step_attachments/context_menu", locals: { asset: asset } %>
+ <% if defined?(show_context) && show_context %>
+ <%= render partial: "shareable_links/my_modules/step_attachments/context_menu", locals: { asset: asset } %>
+ <% end %>
diff --git a/app/views/shareable_links/my_modules/step_attachments/_thumbnail.html.erb b/app/views/shareable_links/my_modules/step_attachments/_thumbnail.html.erb
index c4ba547d8..dc617b176 100644
--- a/app/views/shareable_links/my_modules/step_attachments/_thumbnail.html.erb
+++ b/app/views/shareable_links/my_modules/step_attachments/_thumbnail.html.erb
@@ -26,5 +26,7 @@
<%= number_to_human_size(asset.file_size) %>
<% end %>
- <%= render partial: "shareable_links/my_modules/step_attachments/context_menu", locals: { asset: asset } %>
+ <% if defined?(show_context) && show_context %>
+ <%= render partial: "shareable_links/my_modules/step_attachments/context_menu", locals: { asset: asset } %>
+ <% end %>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 6f2c38c0d..8110f8993 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -125,6 +125,7 @@ Rails.application.config.assets.precompile += %w(my_modules/shared/layout_overri
Rails.application.config.assets.precompile += %w(shareable_links/my_module_protocol_show.js)
Rails.application.config.assets.precompile += %w(shareable_links/repositories.js)
Rails.application.config.assets.precompile += %w(shareable_links/date_formatting.js)
+Rails.application.config.assets.precompile += %w(shareable_links/my_module_results_show.js)
# Libraries needed for Handsontable formulas
Rails.application.config.assets.precompile += %w(jquery.js)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b629365b0..216cb0e2d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1209,6 +1209,7 @@ en:
new_table_result: "Table"
new_asset_result: "File"
published_on_html: "Added on %{timestamp} by %{user}"
+ published_on_iso_html: "Added on %{timestamp} by %{user}"
published_table: "entered a table on %{timestamp}."
published_text: "entered a text on %{timestamp}."
published_asset: "uploaded a file on %{timestamp}."
diff --git a/config/routes.rb b/config/routes.rb
index e727dde11..bdc68cf1a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -966,8 +966,14 @@ Rails.application.routes.draw do
to: 'my_module_shareable_links#protocol_show',
as: :shared_protocol
get '/shared/:uuid/protocol/asset/:id/download',
- to: 'my_module_shareable_links#download_asset',
+ to: 'my_module_shareable_links#download_step_asset',
as: :shared_protocol_asset_download
+ get '/shared/:uuid/protocol/asset/:id/download_result',
+ to: 'my_module_shareable_links#download_result_asset',
+ as: :shared_protocol_result_asset_download
+ get '/shared/:uuid/protocol/results',
+ to: 'my_module_shareable_links#results_show',
+ as: :shared_protocol_results
post '/shared/:uuid/repositories/:id/items',
to: 'my_module_shareable_links#repository_index_dt',
as: :shared_protocol_items,