mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-12 09:56:24 +08:00
Merge pull request #98 from Ducz0r/lm-sci-385
Fix bug with linked tasks
This commit is contained in:
commit
c082bceafc
1 changed files with 22 additions and 17 deletions
|
@ -11,13 +11,13 @@ class ProtocolLinkedChildrenDatatable < AjaxDatatablesRails::Base
|
||||||
|
|
||||||
def sortable_columns
|
def sortable_columns
|
||||||
@sortable_columns ||= [
|
@sortable_columns ||= [
|
||||||
"Protocol.id"
|
'Protocol.id'
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def sortable_displayed_columns
|
def sortable_displayed_columns
|
||||||
@sortable_displayed_columns ||= [
|
@sortable_displayed_columns ||= [
|
||||||
"0"
|
'0'
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ class ProtocolLinkedChildrenDatatable < AjaxDatatablesRails::Base
|
||||||
def data
|
def data
|
||||||
records.map do |record|
|
records.map do |record|
|
||||||
{
|
{
|
||||||
"DT_RowId": record.id,
|
'DT_RowId' => record.id,
|
||||||
"1": record_html(record)
|
'1' => record_html(record)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -42,33 +42,38 @@ class ProtocolLinkedChildrenDatatable < AjaxDatatablesRails::Base
|
||||||
def get_raw_records
|
def get_raw_records
|
||||||
records =
|
records =
|
||||||
Protocol
|
Protocol
|
||||||
.joins(my_module: :project)
|
.joins(my_module: { experiment: :project })
|
||||||
.includes(my_module: :project)
|
.includes(my_module: { experiment: :project })
|
||||||
.references(my_module: :project)
|
.references(my_module: { experiment: :project })
|
||||||
.where(protocol_type: Protocol.protocol_types[:linked])
|
.where(protocol_type: Protocol.protocol_types[:linked])
|
||||||
.where(parent: @protocol)
|
.where(parent: @protocol)
|
||||||
records.distinct
|
records.distinct
|
||||||
end
|
end
|
||||||
|
|
||||||
# Helper methods
|
# Helper methods
|
||||||
|
|
||||||
def record_html(record)
|
def record_html(record)
|
||||||
res = ""
|
res = ''
|
||||||
res += "<ol class='breadcrumb'>"
|
res += "<ol class='breadcrumb'>"
|
||||||
res += "<li><span class='glyphicon glyphicon-blackboard'></span> "
|
res += "<li><span class='glyphicon glyphicon-blackboard'></span> "
|
||||||
res += @controller.render_to_string(
|
res += @controller.render_to_string(
|
||||||
partial: "search/results/partials/project_text.html.erb",
|
partial: 'search/results/partials/project_text.html.erb',
|
||||||
locals: { project: record.my_module.project }
|
locals: { project: record.my_module.experiment.project }
|
||||||
)
|
)
|
||||||
res += "</li>"
|
res += '</li>'
|
||||||
|
res += "<li><i class='fa fa-flask'></i> "
|
||||||
|
res += @controller.render_to_string(
|
||||||
|
partial: 'search/results/partials/experiment_text.html.erb',
|
||||||
|
locals: { experiment: record.my_module.experiment }
|
||||||
|
)
|
||||||
|
res += '</li>'
|
||||||
res += "<li><span class='glyphicon glyphicon-credit-card'></span> "
|
res += "<li><span class='glyphicon glyphicon-credit-card'></span> "
|
||||||
res += @controller.render_to_string(
|
res += @controller.render_to_string(
|
||||||
partial: "search/results/partials/my_module_text.html.erb",
|
partial: 'search/results/partials/my_module_text.html.erb',
|
||||||
locals: { my_module: record.my_module, link_to_page: :protocols }
|
locals: { my_module: record.my_module, link_to_page: :protocols }
|
||||||
)
|
)
|
||||||
res += "</li>"
|
res += '</li>'
|
||||||
res += "</ol>"
|
res += '</ol>'
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue