mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 05:34:55 +08:00
Add new protocol view to repository [SCI-6858]
This commit is contained in:
parent
3645200700
commit
61464b3780
9 changed files with 81 additions and 12 deletions
|
@ -4,6 +4,22 @@
|
||||||
@import "constants";
|
@import "constants";
|
||||||
@import "mixins";
|
@import "mixins";
|
||||||
|
|
||||||
|
.content-pane.protocols-show {
|
||||||
|
background-color: $color-alto;
|
||||||
|
margin: 0 -16px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 36px 10px 10px;
|
||||||
|
width: calc(100% + 31px);
|
||||||
|
|
||||||
|
.protocol-position-container {
|
||||||
|
background-color: $color-white;
|
||||||
|
box-shadow: $flyout-shadow;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 900px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.protocol-repository-header {
|
.protocol-repository-header {
|
||||||
|
|
||||||
.protocol-info {
|
.protocol-info {
|
||||||
|
|
|
@ -17,6 +17,7 @@ class ProtocolsController < ApplicationController
|
||||||
)
|
)
|
||||||
before_action :check_clone_permissions, only: [:clone]
|
before_action :check_clone_permissions, only: [:clone]
|
||||||
before_action :check_view_permissions, only: %i(
|
before_action :check_view_permissions, only: %i(
|
||||||
|
show
|
||||||
protocol_status_bar
|
protocol_status_bar
|
||||||
updated_at_label
|
updated_at_label
|
||||||
preview
|
preview
|
||||||
|
@ -161,6 +162,16 @@ class ProtocolsController < ApplicationController
|
||||||
current_team_switch(@protocol.team)
|
current_team_switch(@protocol.team)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
# Switch to correct team
|
||||||
|
current_team_switch(@protocol.team)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render json: @protocol, serializer: ProtocolSerializer, user: current_user }
|
||||||
|
format.html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_keywords
|
def update_keywords
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
# sanitize user input
|
# sanitize user input
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ProtocolsDatatable < CustomDatatable
|
||||||
def_delegator :@view, :can_clone_protocol_in_repository?
|
def_delegator :@view, :can_clone_protocol_in_repository?
|
||||||
def_delegator :@view, :clone_protocol_path
|
def_delegator :@view, :clone_protocol_path
|
||||||
def_delegator :@view, :linked_children_protocol_path
|
def_delegator :@view, :linked_children_protocol_path
|
||||||
def_delegator :@view, :preview_protocol_path
|
def_delegator :@view, :protocol_path
|
||||||
|
|
||||||
def initialize(view, team, type, user)
|
def initialize(view, team, type, user)
|
||||||
super(view)
|
super(view)
|
||||||
|
@ -176,10 +176,7 @@ class ProtocolsDatatable < CustomDatatable
|
||||||
end
|
end
|
||||||
|
|
||||||
def name_html(record)
|
def name_html(record)
|
||||||
"<a href='#' data-action='protocol-preview'" \
|
"<a href='#{protocol_path(record)}'>#{escape_input(record.name)}</a>"
|
||||||
"data-url='#{preview_protocol_path(record)}'>" \
|
|
||||||
"#{escape_input(record.name)}" \
|
|
||||||
"</a>"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def keywords_html(record)
|
def keywords_html(record)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="task-protocol">
|
<div class="task-protocol">
|
||||||
<div class="task-section-header">
|
<div class="task-section-header" v-if="!inRepository">
|
||||||
<a class="task-section-caret" role="button" data-toggle="collapse" href="#protocol-content" aria-expanded="true" aria-controls="protocol-content">
|
<a class="task-section-caret" role="button" data-toggle="collapse" href="#protocol-content" aria-expanded="true" aria-controls="protocol-content">
|
||||||
<i class="fas fa-caret-right"></i>
|
<i class="fas fa-caret-right"></i>
|
||||||
<div class="task-section-title">
|
<div class="task-section-title">
|
||||||
|
@ -61,6 +61,7 @@
|
||||||
<Step
|
<Step
|
||||||
:step.sync="steps[index]"
|
:step.sync="steps[index]"
|
||||||
@reorder="startStepReorder"
|
@reorder="startStepReorder"
|
||||||
|
:inRepository="inRepository"
|
||||||
@step:delete="updateStepsPosition"
|
@step:delete="updateStepsPosition"
|
||||||
@step:update="updateStep"
|
@step:update="updateStep"
|
||||||
/>
|
/>
|
||||||
|
@ -115,6 +116,11 @@
|
||||||
},
|
},
|
||||||
components: { Step, InlineEdit, ProtocolModals, ProtocolOptions, Tinymce, ReorderableItemsModal },
|
components: { Step, InlineEdit, ProtocolModals, ProtocolOptions, Tinymce, ReorderableItemsModal },
|
||||||
mixins: [UtilsMixin],
|
mixins: [UtilsMixin],
|
||||||
|
computed: {
|
||||||
|
inRepository() {
|
||||||
|
return this.protocol.attributes.in_repository
|
||||||
|
}
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
protocol: {
|
protocol: {
|
||||||
|
@ -134,6 +140,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
refreshProtocolStatus() {
|
refreshProtocolStatus() {
|
||||||
|
if (this.inRepository) return
|
||||||
// legacy method from app/assets/javascripts/my_modules/protocols.js
|
// legacy method from app/assets/javascripts/my_modules/protocols.js
|
||||||
refreshProtocolStatusBar();
|
refreshProtocolStatusBar();
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
data-remote="true">
|
data-remote="true">
|
||||||
<span class="fas fa-caret-right"></span>
|
<span class="fas fa-caret-right"></span>
|
||||||
</a>
|
</a>
|
||||||
<div class="step-complete-container">
|
<div v-if="!inRepository" class="step-complete-container">
|
||||||
<div :class="`step-state ${step.attributes.completed ? 'completed' : ''}`" @click="changeState"></div>
|
<div :class="`step-state ${step.attributes.completed ? 'completed' : ''}`" @click="changeState"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="step-position">
|
<div class="step-position">
|
||||||
|
@ -161,7 +161,11 @@
|
||||||
step: {
|
step: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
}
|
},
|
||||||
|
inRepository: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -6,7 +6,7 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include ActionView::Helpers::TextHelper
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
attributes :name, :id, :urls, :description, :description_view, :updated_at
|
attributes :name, :id, :urls, :description, :description_view, :updated_at, :in_repository
|
||||||
|
|
||||||
def updated_at
|
def updated_at
|
||||||
object.updated_at.to_i
|
object.updated_at.to_i
|
||||||
|
@ -34,6 +34,10 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def in_repository
|
||||||
|
!object.in_module?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_from_repo_url
|
def load_from_repo_url
|
||||||
|
|
|
@ -48,7 +48,7 @@ class StepSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def assets_order
|
def assets_order
|
||||||
object.current_view_state(@instance_options[:user]).state.dig('assets', 'sort')
|
object.current_view_state(@instance_options[:user]).state.dig('assets', 'sort') unless object.destroyed?
|
||||||
end
|
end
|
||||||
|
|
||||||
def urls
|
def urls
|
||||||
|
|
31
app/views/protocols/show.html.erb
Normal file
31
app/views/protocols/show.html.erb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<div class="content-pane protocols-show" >
|
||||||
|
<div class="protocol-position-container">
|
||||||
|
<div
|
||||||
|
id="protocolContainer"
|
||||||
|
data-protocol-url="<%= protocol_path(@protocol) %>"
|
||||||
|
data-add-step-url="<%= protocol_steps_path(protocol_id: @protocol.id) %>"
|
||||||
|
data-steps-url="<%= steps_path(protocol_id: @protocol) %>"
|
||||||
|
data-editable="<%= can_manage_protocol_in_module?(@protocol) %>"
|
||||||
|
data-date-format="<%= datetime_picker_format_date_only %>"
|
||||||
|
data-user-utc-offset="<%= ActiveSupport::TimeZone.find_tzinfo(current_user.time_zone).utc_offset %>"
|
||||||
|
>
|
||||||
|
<protocol-container
|
||||||
|
:protocol-url="protocolUrl"
|
||||||
|
:steps-url="stepsUrl"
|
||||||
|
:add-step-url="addStepUrl"
|
||||||
|
:editable="editable"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Create new office file modal -->
|
||||||
|
<%= render partial: 'assets/wopi/create_wopi_file_modal.html.erb' %>
|
||||||
|
|
||||||
|
|
||||||
|
<%= javascript_include_tag "handsontable.full" %>
|
||||||
|
<%= render partial: "shared/formulas_libraries.html.erb" %>
|
||||||
|
<%= javascript_pack_tag 'pdfjs/pdf_js' %>
|
||||||
|
<%= stylesheet_pack_tag 'pdfjs/pdf_js_styles' %>
|
||||||
|
|
||||||
|
<%= javascript_pack_tag 'vue/protocol' %>
|
|
@ -508,11 +508,10 @@ Rails.application.routes.draw do
|
||||||
get 'result_tables/:id/download' => 'result_tables#download',
|
get 'result_tables/:id/download' => 'result_tables#download',
|
||||||
as: :result_table_download
|
as: :result_table_download
|
||||||
|
|
||||||
resources :protocols, only: [:index, :edit, :create] do
|
resources :protocols, only: %i(index show edit create) do
|
||||||
resources :steps, only: [:new, :create] do
|
resources :steps, only: [:new, :create] do
|
||||||
post :reorder, on: :collection
|
post :reorder, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
member do
|
member do
|
||||||
get 'print', to: 'protocols#print'
|
get 'print', to: 'protocols#print'
|
||||||
get 'linked_children', to: 'protocols#linked_children'
|
get 'linked_children', to: 'protocols#linked_children'
|
||||||
|
|
Loading…
Add table
Reference in a new issue