mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-04 12:14:37 +08:00
Allow saving & editing of reports with repository elements
Closes SCI-1279.
This commit is contained in:
parent
b5f6d1da94
commit
02dd6636ba
24 changed files with 82 additions and 78 deletions
|
@ -217,9 +217,7 @@ function initializeNewElement(newEl) {
|
|||
url: url,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {
|
||||
id: parentElementId
|
||||
},
|
||||
data: parentElementId,
|
||||
success: function(data, status, jqxhr) {
|
||||
// Open modal, set its title, and display module contents
|
||||
addContentsModal.find(".modal-title").text(modalTitle);
|
||||
|
@ -500,11 +498,11 @@ function initializeUnsavedWorkDialog() {
|
|||
*/
|
||||
function getSidebarEl(reportEl) {
|
||||
var type = reportEl.data("type");
|
||||
var id = reportEl.data("id");
|
||||
var scrollId = reportEl.data("scroll-id");
|
||||
return $(SIDEBAR_PARENT_TREE).find(
|
||||
"li" +
|
||||
"[data-type='" + type + "']" +
|
||||
"[data-id='" + id + "']"
|
||||
"[data-scroll-id='" + scrollId + "']"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -516,11 +514,11 @@ function getSidebarEl(reportEl) {
|
|||
*/
|
||||
function getReportEl(sidebarEl) {
|
||||
var type = sidebarEl.data("type");
|
||||
var id = sidebarEl.data("id");
|
||||
var scrollId = sidebarEl.data("scroll-id");
|
||||
return $(REPORT_CONTENT).find(
|
||||
"div.report-element" +
|
||||
"[data-type='" + type + "']" +
|
||||
"[data-id='" + id + "']"
|
||||
"[data-scroll-id='" + scrollId + "']"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -565,14 +563,14 @@ function initSidebarElement(reportEl) {
|
|||
var elChildrenContainer = reportEl.children(".report-element-children");
|
||||
var type = reportEl.data("type");
|
||||
var name = reportEl.data("name");
|
||||
var id = reportEl.data("id");
|
||||
var scrollId = reportEl.data("scroll-id");
|
||||
var iconClass = "glyphicon " + reportEl.data("icon-class");
|
||||
|
||||
// Generate list element
|
||||
var newLi = $(document.createElement("li"));
|
||||
newLi
|
||||
.attr("data-type", type)
|
||||
.attr("data-id", id);
|
||||
.attr("data-scroll-id", scrollId);
|
||||
|
||||
var newSpan = $(document.createElement("span"));
|
||||
newSpan.appendTo(newLi);
|
||||
|
@ -1025,7 +1023,7 @@ function addElement(jsonEl, prevEl) {
|
|||
.find(
|
||||
".report-element" +
|
||||
"[data-type='" + el.attr("data-type") + "']" +
|
||||
"[data-id='" + el.attr("data-id") + "']"
|
||||
"[data-scroll-id='" + el.attr("data-scroll-id") + "']"
|
||||
);
|
||||
if (existing.length && existing.length > 0) {
|
||||
// TODO Remove event listeners on existing element
|
||||
|
|
|
@ -233,7 +233,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
# Experiment for adding contents into experiment element
|
||||
def experiment_contents_modal
|
||||
experiment = Experiment.find_by_id(params[:id])
|
||||
experiment = Experiment.find_by_id(params[:experiment_id])
|
||||
|
||||
respond_to do |format|
|
||||
if experiment.blank?
|
||||
|
@ -255,7 +255,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
# Modal for adding contents into module element
|
||||
def module_contents_modal
|
||||
my_module = MyModule.find_by_id(params[:id])
|
||||
my_module = MyModule.find_by_id(params[:my_module_id])
|
||||
|
||||
respond_to do |format|
|
||||
if my_module.blank?
|
||||
|
@ -277,7 +277,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
# Modal for adding contents into step element
|
||||
def step_contents_modal
|
||||
step = Step.find_by_id(params[:id])
|
||||
step = Step.find_by_id(params[:step_id])
|
||||
|
||||
respond_to do |format|
|
||||
if step.blank?
|
||||
|
@ -299,7 +299,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
# Modal for adding contents into result element
|
||||
def result_contents_modal
|
||||
result = Result.find_by_id(params[:id])
|
||||
result = Result.find_by_id(params[:result_id])
|
||||
|
||||
respond_to do |format|
|
||||
if result.blank?
|
||||
|
|
|
@ -45,13 +45,9 @@ module ReportsHelper
|
|||
|
||||
ReportElement.type_ofs.keys.each do |type|
|
||||
next unless element.public_send("#{type}?")
|
||||
local_sym = type.split('_').last.to_sym
|
||||
local_sym = type
|
||||
.split('_')
|
||||
.first
|
||||
.to_sym if type.in? ReportExtends::FIRST_PART_ELEMENTS
|
||||
local_sym = :my_module if type.in? ReportExtends::MY_MODULE_ELEMENTS
|
||||
locals[local_sym] = element.element_reference
|
||||
element.element_references.each do |el_ref|
|
||||
locals[el_ref.class.name.underscore.to_sym] = el_ref
|
||||
end
|
||||
locals[:order] = element
|
||||
.sort_order if type.in? ReportExtends::SORTED_ELEMENTS
|
||||
end
|
||||
|
|
|
@ -95,7 +95,7 @@ class Report < ActiveRecord::Base
|
|||
el.parent = parent
|
||||
el.type_of = json_element['type_of']
|
||||
el.sort_order = json_element['sort_order']
|
||||
el.set_element_reference(json_element['id'])
|
||||
el.set_element_references(json_element['id'])
|
||||
el.save!
|
||||
|
||||
if json_element['children'].present?
|
||||
|
|
|
@ -31,6 +31,7 @@ class ReportElement < ActiveRecord::Base
|
|||
belongs_to :checklist, inverse_of: :report_elements
|
||||
belongs_to :asset, inverse_of: :report_elements
|
||||
belongs_to :table, inverse_of: :report_elements
|
||||
belongs_to :repository, inverse_of: :report_elements
|
||||
|
||||
def has_children?
|
||||
children.length > 0
|
||||
|
@ -44,19 +45,21 @@ class ReportElement < ActiveRecord::Base
|
|||
step_comments? or result_comments?
|
||||
end
|
||||
|
||||
# Get the referenced element (previously, element's type_of must be set)
|
||||
def element_reference
|
||||
# Get the referenced elements (previously, element's type_of must be set)
|
||||
def element_references
|
||||
ReportExtends::ELEMENT_REFERENCES.each do |el_ref|
|
||||
return eval(el_ref.element.gsub('_id', '')) if el_ref.check(self)
|
||||
return el_ref.elements.map { |el| eval(el.gsub('_id', '')) } if el_ref.check(self)
|
||||
end
|
||||
end
|
||||
|
||||
# Set the element reference (previously, element's type_of must be set)
|
||||
def set_element_reference(ref_id)
|
||||
# Set the element references (previously, element's type_of must be set)
|
||||
def set_element_references(ref_ids)
|
||||
ReportExtends::SET_ELEMENT_REFERENCES_LIST.each do |el_ref|
|
||||
check = el_ref.check(self)
|
||||
next unless check
|
||||
public_send("#{el_ref.element}=", ref_id)
|
||||
el_ref.elements.each do |element|
|
||||
public_send("#{element}=", ref_ids[element])
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -64,7 +67,7 @@ class ReportElement < ActiveRecord::Base
|
|||
# removes element that are archived or deleted
|
||||
def clean_removed_or_archived_elements
|
||||
parent_model = ''
|
||||
%w(project experiment my_module step result checklist asset table)
|
||||
%w(project experiment my_module step result checklist asset table repository)
|
||||
.each do |el|
|
||||
parent_model = el if send el
|
||||
end
|
||||
|
@ -81,17 +84,12 @@ class ReportElement < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def has_one_of_referenced_elements
|
||||
num_of_refs = [project,
|
||||
experiment,
|
||||
my_module,
|
||||
step,
|
||||
result,
|
||||
checklist,
|
||||
asset,
|
||||
table].count { |r| r.present? }
|
||||
if num_of_refs != 1
|
||||
errors.add(:base,
|
||||
'Report element must have exactly one element reference.')
|
||||
element_references.each do |el|
|
||||
if el.nil?
|
||||
errors.add(:base,
|
||||
'Report element doesn\'t have correct element references.')
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ class Repository < ActiveRecord::Base
|
|||
has_many :repository_rows
|
||||
has_many :repository_table_states,
|
||||
inverse_of: :repository, dependent: :destroy
|
||||
has_many :report_elements, inverse_of: :repository, dependent: :destroy
|
||||
|
||||
auto_strip_attributes :name, nullify: false
|
||||
validates :name,
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
<div class="report-element report-experiment-element"
|
||||
data-ts="<%= timestamp.to_i %>"
|
||||
data-type="experiment"
|
||||
data-id="<%= experiment.id %>"
|
||||
data-id='{ "experiment_id": <%= experiment.id %> }'
|
||||
data-scroll-id="<%= experiment.id %>"
|
||||
data-modal-title="<%=t "projects.reports.elements.modals.experiment_contents.head_title",
|
||||
experiment: experiment.name %>" data-name="<%= name %>" data-icon-class="fa fa-flask">
|
||||
<div class="report-element-header">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if order.blank? and @order.present? then order = @order end %>
|
||||
<% timestamp = Time.current + 1.year - 2.days %>
|
||||
<% activities = my_module.activities.order(created_at: order) %>
|
||||
<div class="report-element report-module-activity-element" data-ts="<%= timestamp.to_i %>" data-type="my_module_activity" data-id="<%= my_module.id %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%=t "projects.reports.elements.module_activity.sidebar_name" %>" data-icon-class="glyphicon glyphicon-equalizer">
|
||||
<div class="report-element report-module-activity-element" data-ts="<%= timestamp.to_i %>" data-type="my_module_activity" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= my_module.id %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%=t "projects.reports.elements.module_activity.sidebar_name" %>" data-icon-class="glyphicon glyphicon-equalizer">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left activity-icon">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if my_module.blank? and @my_module.present? then my_module = @my_module end %>
|
||||
<% timestamp = my_module.created_at %>
|
||||
<% name = my_module.name %>
|
||||
<div class="report-element report-module-element" data-ts="<%= timestamp.to_i %>" data-type="my_module" data-id="<%= my_module.id %>" data-modal-title="<%=t "projects.reports.elements.modals.module_contents.head_title", module: my_module.name %>" data-name="<%= name %>" data-icon-class="glyphicon-credit-card">
|
||||
<div class="report-element report-module-element" data-ts="<%= timestamp.to_i %>" data-type="my_module" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= my_module.id %>" data-modal-title="<%=t "projects.reports.elements.modals.module_contents.head_title", module: my_module.name %>" data-name="<%= name %>" data-icon-class="glyphicon-credit-card">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left user-time">
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<% repository = Repository.find(element_id) %>
|
||||
<% repository ||= Repository.find(element_id) %>
|
||||
<% if my_module.blank? and @my_module.present? then my_module = @my_module end %>
|
||||
<% rows = my_module.repository_rows.where(repository: repository) %>
|
||||
<% if order.blank? and @order.present? then order = @order end %>
|
||||
<% timestamp = Time.current + 1.year - 1.days %>
|
||||
<% rows_json = my_module.repository_json_hot(element_id, order) %>
|
||||
<div class="report-element report-module-repository-element" data-sort-hot="1" data-ts="<%= timestamp.to_i %>" data-type="my_module_repository" data-id="<%= "#{my_module.id}_#{repository.id}" %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%= repository.name %>" data-icon-class="glyphicon-oil">
|
||||
<% rows_json = my_module.repository_json_hot(repository.id, order) %>
|
||||
<div class="report-element report-module-repository-element" data-sort-hot="1" data-ts="<%= timestamp.to_i %>" data-type="my_module_repository" data-id='{ "my_module_id": <%= my_module.id %>, "repository_id": <%= repository.id %> }' data-scroll-id="<%= "#{my_module.id}_#{repository.id}" %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%= repository.name %>" data-icon-class="glyphicon-oil">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left repository-icon">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<% timestamp = asset.created_at %>
|
||||
<% name = result.name %>
|
||||
<% icon_class = is_image ? "glyphicon-picture" : "glyphicon-file" %>
|
||||
<div class="report-element report-result-element report-result-asset-element" data-ts="<%= timestamp.to_i %>" data-type="result_asset" data-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="<%= icon_class %>">
|
||||
<div class="report-element report-result-element report-result-asset-element" data-ts="<%= timestamp.to_i %>" data-type="result_asset" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="<%= icon_class %>">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left result-icon">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% comments = result.result_comments %>
|
||||
<% timestamp = table.created_at %>
|
||||
<% name = result.name %>
|
||||
<div class="report-element report-result-element report-result-table-element" data-ts="<%= timestamp.to_i %>" data-type="result_table" data-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="glyphicon-th">
|
||||
<div class="report-element report-result-element report-result-table-element" data-ts="<%= timestamp.to_i %>" data-type="result_table" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="glyphicon-th">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left result-name-container">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% comments = result.result_comments %>
|
||||
<% timestamp = result.created_at %>
|
||||
<% name = result.name %>
|
||||
<div class="report-element report-result-element report-result-text-element" data-ts="<%= timestamp.to_i %>" data-type="result_text" data-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="glyphicon-asterisk">
|
||||
<div class="report-element report-result-element report-result-text-element" data-ts="<%= timestamp.to_i %>" data-type="result_text" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="glyphicon-asterisk">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left result-icon">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if order.blank? and @order.present? then order = @order end %>
|
||||
<% timestamp = Time.current + 1.year - 1.days %>
|
||||
<% samples_json = my_module.samples_json_hot(order) %>
|
||||
<div class="report-element report-module-samples-element" data-sort-hot="3" data-ts="<%= timestamp.to_i %>" data-type="my_module_samples" data-id="<%= my_module.id %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%=t "projects.reports.elements.module_samples.sidebar_name" %>" data-icon-class="glyphicon-tint">
|
||||
<div class="report-element report-module-samples-element" data-sort-hot="3" data-ts="<%= timestamp.to_i %>" data-type="my_module_samples" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= my_module.id %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%=t "projects.reports.elements.module_samples.sidebar_name" %>" data-icon-class="glyphicon-tint">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left samples-icon">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<% assets = step.assets %>
|
||||
<% checklists = step.checklists %>
|
||||
<% comments = step.step_comments %>
|
||||
<div class="report-element report-step-element" data-ts="<%= timestamp.to_i %>" data-type="step" data-id="<%= step.id %>" data-modal-title="<%=t "projects.reports.elements.modals.step_contents.head_title", step: step.name %>" data-name="<%=t "projects.reports.elements.step.sidebar_name", pos: (step.position + 1), name: step.name %>" data-icon-class="glyphicon-circle-arrow-right">
|
||||
<div class="report-element report-step-element" data-ts="<%= timestamp.to_i %>" data-type="step" data-id='{ "step_id": <%= step.id %> }' data-scroll-id="<%= step.id %>" data-modal-title="<%=t "projects.reports.elements.modals.step_contents.head_title", step: step.name %>" data-name="<%=t "projects.reports.elements.step.sidebar_name", pos: (step.position + 1), name: step.name %>" data-icon-class="glyphicon-circle-arrow-right">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left user-time">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% if project.blank? and @project.present? then project = @project end %>
|
||||
<% name = t("projects.reports.elements.project_header.title", project: project.name) %>
|
||||
<div class="report-element report-project-header-element" data-ts="ignore" data-type="project_header" data-id="<%= project.id %>" data-name="<%= name %>" data-icon-class="glyphicon-header">
|
||||
<div class="report-element report-project-header-element" data-ts="ignore" data-type="project_header" data-id='{ "project_id": <%= project.id %> }' data-scroll-id="<%= project.id %>" data-name="<%= name %>" data-icon-class="glyphicon-header">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left user-time">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if order.blank? and @order.present? then order = @order end %>
|
||||
<% comments = result.result_comments.order(created_at: order) %>
|
||||
<% timestamp = Time.current + 1.year %>
|
||||
<div class="report-element report-comments-element report-result-comments-element" data-ts="<%= timestamp.to_i %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-type="result_comments" data-id="<%= result.id %>" data-name="<%=t "projects.reports.elements.result_comments.sidebar_name" %>" data-icon-class="glyphicon-comment">
|
||||
<div class="report-element report-comments-element report-result-comments-element" data-ts="<%= timestamp.to_i %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-type="result_comments" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-name="<%=t "projects.reports.elements.result_comments.sidebar_name" %>" data-icon-class="glyphicon-comment">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left comments-icon">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% is_image = asset.is_image? %>
|
||||
<% timestamp = asset.created_at %>
|
||||
<% icon_class = is_image ? 'glyphicon-picture' : 'glyphicon-file' %>
|
||||
<div class="report-element report-step-attachment-element report-step-asset-element" data-ts="<%= timestamp.to_i %>" data-type="step_asset" data-id="<%= asset.id %>" data-name="<%=t "projects.reports.elements.step_asset.sidebar_name", file: asset.file_file_name %>" data-icon-class="<%= icon_class %>">
|
||||
<div class="report-element report-step-attachment-element report-step-asset-element" data-ts="<%= timestamp.to_i %>" data-type="step_asset" data-id='{ "asset_id": <%= asset.id %> }' data-scroll-id="<%= asset.id %>" data-name="<%=t "projects.reports.elements.step_asset.sidebar_name", file: asset.file_file_name %>" data-icon-class="<%= icon_class %>">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left attachment-icon">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if checklist.blank? and @checklist.present? then checklist = @checklist end %>
|
||||
<% items = checklist.checklist_items %>
|
||||
<% timestamp = checklist.created_at %>
|
||||
<div class="report-element report-step-attachment-element report-step-checklist-element" data-ts="<%= timestamp.to_i %>" data-type="step_checklist" data-id="<%= checklist.id %>" data-name="<%= checklist.name %>" data-icon-class="glyphicon-list">
|
||||
<div class="report-element report-step-attachment-element report-step-checklist-element" data-ts="<%= timestamp.to_i %>" data-type="step_checklist" data-id='{ "checklist_id": <%= checklist.id %> }' data-scroll-id="<%= checklist.id %>" data-name="<%= checklist.name %>" data-icon-class="glyphicon-list">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left attachment-icon">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if order.blank? and @order.present? then order = @order end %>
|
||||
<% comments = step.step_comments.order(created_at: order) %>
|
||||
<% timestamp = Time.current + 1.year %>
|
||||
<div class="report-element report-comments-element report-step-comments-element" data-ts="<%= timestamp.to_i %>" data-order="asc" data-type="step_comments" data-id="<%= step.id %>" data-name="<%=t "projects.reports.elements.step_comments.sidebar_name" %>" data-icon-class="glyphicon-comment">
|
||||
<div class="report-element report-comments-element report-step-comments-element" data-ts="<%= timestamp.to_i %>" data-order="asc" data-type="step_comments" data-id='{ "step_id": <%= step.id %> }' data-scroll-id="<%= step.id %>" data-name="<%=t "projects.reports.elements.step_comments.sidebar_name" %>" data-icon-class="glyphicon-comment">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left comments-icon">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% if table.blank? and @table.present? then table = @table end %>
|
||||
<% timestamp = table.created_at %>
|
||||
<div class="report-element report-step-attachment-element report-step-table-element" data-ts="<%= timestamp.to_i %>" data-type="step_table" data-id="<%= table.id %>" data-name="<%= table.name %>" data-icon-class="glyphicon-th">
|
||||
<div class="report-element report-step-attachment-element report-step-table-element" data-ts="<%= timestamp.to_i %>" data-type="step_table" data-id='{ "table_id": <%= table.id %> }' data-scroll-id="<%= table.id %>" data-name="<%= table.name %>" data-icon-class="glyphicon-th">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left attachment-icon">
|
||||
|
|
|
@ -35,7 +35,8 @@ class Extends
|
|||
result_comments: 12,
|
||||
project_activity: 13, # TODO
|
||||
project_samples: 14, # TODO
|
||||
experiment: 15 }
|
||||
experiment: 15,
|
||||
my_module_repository: 16 }
|
||||
|
||||
# Data type name should match corresponding model's name
|
||||
REPOSITORY_DATA_TYPES = { RepositoryTextValue: 0,
|
||||
|
|
|
@ -108,10 +108,11 @@ module ReportExtends
|
|||
# ADD REPORT ELEMENT TYPE WHICH YOU WANT TO PASS 'ORDER' LOCAL IN THE PARTIAL
|
||||
SORTED_ELEMENTS = %w(my_module_activity
|
||||
my_module_samples
|
||||
my_module_repository
|
||||
step_comments
|
||||
result_comments)
|
||||
# sets local :my_module to the listed my_module child elements
|
||||
MY_MODULE_ELEMENTS = %w(my_module my_module_activity my_module_samples)
|
||||
MY_MODULE_ELEMENTS = %w(my_module my_module_activity my_module_samples my_module_repository)
|
||||
|
||||
# sets local name to first element of the listed elements
|
||||
FIRST_PART_ELEMENTS = %w(result_comments
|
||||
|
@ -124,9 +125,9 @@ module ReportExtends
|
|||
# path: app/models/report_element.rb
|
||||
# method: set_element_reference
|
||||
|
||||
ElementReference = Struct.new(:checker, :element) do
|
||||
def initialize(checker, element = :element_reference_needed!)
|
||||
super(checker, element)
|
||||
ElementReference = Struct.new(:checker, :elements) do
|
||||
def initialize(checker, elements = :element_reference_needed!)
|
||||
super(checker, elements)
|
||||
end
|
||||
|
||||
def check(report_element)
|
||||
|
@ -141,22 +142,23 @@ module ReportExtends
|
|||
report_element.project_activity? ||
|
||||
report_element.project_samples?
|
||||
end,
|
||||
'project_id'
|
||||
['project_id']
|
||||
),
|
||||
ElementReference.new(proc(&:experiment?), 'experiment_id'),
|
||||
ElementReference.new(proc(&:experiment?), ['experiment_id']),
|
||||
ElementReference.new(
|
||||
proc do |report_element|
|
||||
report_element.my_module? ||
|
||||
report_element.my_module_activity? ||
|
||||
report_element.my_module_samples?
|
||||
end,
|
||||
'my_module_id'
|
||||
['my_module_id']
|
||||
),
|
||||
ElementReference.new(proc(&:my_module_repository?), ['my_module_id', 'repository_id']),
|
||||
ElementReference.new(
|
||||
proc do |report_element|
|
||||
report_element.step? || report_element.step_comments?
|
||||
end,
|
||||
'step_id'
|
||||
['step_id']
|
||||
),
|
||||
ElementReference.new(
|
||||
proc do |report_element|
|
||||
|
@ -165,11 +167,11 @@ module ReportExtends
|
|||
report_element.result_text? ||
|
||||
report_element.result_comments?
|
||||
end,
|
||||
'result_id'
|
||||
['result_id']
|
||||
),
|
||||
ElementReference.new(proc(&:step_checklist?), 'checklist_id'),
|
||||
ElementReference.new(proc(&:step_asset?), 'asset_id'),
|
||||
ElementReference.new(proc(&:step_table?), 'table_id')
|
||||
ElementReference.new(proc(&:step_checklist?), ['checklist_id']),
|
||||
ElementReference.new(proc(&:step_asset?), ['asset_id']),
|
||||
ElementReference.new(proc(&:step_table?), ['table_id'])
|
||||
]
|
||||
|
||||
# path: app/models/report_element.rb
|
||||
|
@ -182,23 +184,24 @@ module ReportExtends
|
|||
report_element.project_activity? ||
|
||||
report_element.project_samples?
|
||||
end,
|
||||
'project_id'
|
||||
['project_id']
|
||||
),
|
||||
ElementReference.new(proc(&:experiment?), 'experiment_id'),
|
||||
ElementReference.new(proc(&:experiment?), ['experiment_id']),
|
||||
ElementReference.new(
|
||||
proc do |report_element|
|
||||
report_element.my_module? ||
|
||||
report_element.my_module_activity? ||
|
||||
report_element.my_module_samples?
|
||||
end,
|
||||
'my_module_id'
|
||||
['my_module_id']
|
||||
),
|
||||
ElementReference.new(proc(&:my_module_repository?), ['my_module_id', 'repository_id']),
|
||||
ElementReference.new(
|
||||
proc do |report_element|
|
||||
report_element.step? ||
|
||||
report_element.step_comments?
|
||||
end,
|
||||
'step_id'
|
||||
['step_id']
|
||||
),
|
||||
ElementReference.new(
|
||||
proc do |report_element|
|
||||
|
@ -207,10 +210,10 @@ module ReportExtends
|
|||
report_element.result_text? ||
|
||||
report_element.result_comments?
|
||||
end,
|
||||
'result_id'
|
||||
['result_id']
|
||||
),
|
||||
ElementReference.new(proc(&:step_checklist?), 'checklist_id'),
|
||||
ElementReference.new(proc(&:step_asset?), 'asset_id'),
|
||||
ElementReference.new(proc(&:step_table?), 'table_id')
|
||||
ElementReference.new(proc(&:step_checklist?), ['checklist_id']),
|
||||
ElementReference.new(proc(&:step_asset?), ['asset_id']),
|
||||
ElementReference.new(proc(&:step_table?), ['table_id'])
|
||||
]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddRepositoryIdToReportElement < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :report_elements, :repository_id, :integer
|
||||
add_index :report_elements, :repository_id
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue