mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 23:16:15 +08:00
Finalize protocol repository [SCI-6870]
This commit is contained in:
parent
f2785bbff6
commit
46631a1f46
|
@ -16,7 +16,6 @@ function init() {
|
|||
initKeywordFiltering();
|
||||
initProtocolPreviewModal();
|
||||
initLinkedChildrenModal();
|
||||
initCreateNewModal();
|
||||
initModals();
|
||||
initImport();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
.content-pane.protocols-show {
|
||||
background-color: $color-alto;
|
||||
margin: 0 -16px;
|
||||
min-height: calc(100vh - var(--navbar-height));
|
||||
overflow: hidden;
|
||||
padding: 36px 10px 10px;
|
||||
width: calc(100% + 31px);
|
||||
|
|
|
@ -35,8 +35,10 @@ module StepElements
|
|||
end
|
||||
|
||||
def log_step_activity(element_type_of, message_items)
|
||||
message_items[:my_module] = @protocol.my_module.id if @protocol.in_module?
|
||||
|
||||
Activities::CreateActivityService.call(
|
||||
activity_type: "#{@step.protocol.in_module? ? 'protocol_step_' : 'task_step_'}#{element_type_of}",
|
||||
activity_type: "#{!@step.protocol.in_module? ? 'protocol_step_' : 'task_step_'}#{element_type_of}",
|
||||
owner: current_user,
|
||||
team: @protocol.in_module? ? @protocol.my_module.experiment.project.team : @protocol.team,
|
||||
project: @protocol.in_module? ? @protocol.my_module.experiment.project : nil,
|
||||
|
@ -47,7 +49,6 @@ module StepElements
|
|||
id: @step.id,
|
||||
value_for: 'position_plus_one'
|
||||
},
|
||||
my_module: @protocol.my_module.id
|
||||
}.merge(message_items)
|
||||
)
|
||||
end
|
||||
|
|
|
@ -124,7 +124,7 @@ module StepElements
|
|||
owner: current_user,
|
||||
subject: @step.protocol,
|
||||
team: @step.protocol.team,
|
||||
project: @step.protocol.my_module.experiment.project,
|
||||
project: @step.protocol.in_module? ? @step.protocol.my_module.experiment.project : nil,
|
||||
message_items: message_items
|
||||
)
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ module StepElements
|
|||
log_step_activity(:checklist_edited, { checklist_name: @checklist.name })
|
||||
end
|
||||
|
||||
render json: @checklist, serializer: ChecklistSerializer
|
||||
render json: @checklist, serializer: ChecklistSerializer, user: current_user
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
head :unprocessable_entity
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ module StepElements
|
|||
log_step_activity(:table_edited, { table_name: @table.name })
|
||||
end
|
||||
|
||||
render json: @table, serializer: TableSerializer
|
||||
render json: @table, serializer: TableSerializer, user: current_user
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
head :unprocessable_entity
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module StepElements
|
|||
log_step_activity(:text_edited, { text_name: @step_text.name })
|
||||
end
|
||||
|
||||
render json: @step_text, serializer: StepTextSerializer
|
||||
render json: @step_text, serializer: StepTextSerializer, user: current_user
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
head :unprocessable_entity
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
{{ protocol.attributes.name }}
|
||||
</span>
|
||||
</div>
|
||||
<ProtocolMetadata v-if="protocol.attributes" :protocol="protocol" @update="updateProtocol"/>
|
||||
<ProtocolMetadata v-if="protocol.attributes && protocol.attributes.in_repository" :protocol="protocol" @update="updateProtocol"/>
|
||||
<Tinymce
|
||||
v-if="urls.update_protocol_description_url"
|
||||
:value="protocol.attributes.description"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global ActiveStorage GLOBAL_CONSTANTS Promise i18n */
|
||||
/* global ActiveStorage GLOBAL_CONSTANTS Promise I18n */
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
@ -40,7 +40,7 @@ export default {
|
|||
}
|
||||
};
|
||||
if (file.size > GLOBAL_CONSTANTS.FILE_MAX_SIZE_MB * 1024 * 1024) {
|
||||
fileObject.error = i18n.t('protocols.steps.attachments.new.file_too_big');
|
||||
fileObject.error = I18n.t('protocols.steps.attachments.new.file_too_big');
|
||||
this.attachments.push(fileObject);
|
||||
return;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export default {
|
|||
|
||||
upload.create((error, blob) => {
|
||||
if (error) {
|
||||
fileObject.error = i18n.t('protocols.steps.attachments.new.general_error');
|
||||
fileObject.error = I18n.t('protocols.steps.attachments.new.general_error');
|
||||
reject(error);
|
||||
} else {
|
||||
const signedId = blob.signed_id;
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<a href="#"
|
||||
v-if="!inRepository"
|
||||
ref="comments"
|
||||
class="open-comments-sidebar btn icon-btn btn-light"
|
||||
data-turbolinks="false"
|
||||
|
@ -111,6 +112,7 @@
|
|||
:is="elements[index].attributes.orderable_type"
|
||||
:key="index"
|
||||
:element.sync="elements[index]"
|
||||
:inRepository="inRepository"
|
||||
:reorderElementUrl="urls.reorder_elements_url"
|
||||
@component:delete="deleteElement"
|
||||
@update="updateElement"
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
:checklistItem="checklistItem"
|
||||
:locked="locked"
|
||||
:reorderChecklistItemUrl="element.attributes.orderable.urls.reorder_url"
|
||||
:inRepository="inRepository"
|
||||
@editStart="editingItem = true"
|
||||
@editEnd="editingItem = false"
|
||||
@update="saveItem"
|
||||
|
@ -80,6 +81,10 @@
|
|||
type: Object,
|
||||
required: true
|
||||
},
|
||||
inRepository: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
reorderElementUrl: {
|
||||
type: String
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<i class="fas fa-grip-vertical"></i>
|
||||
</div>
|
||||
<div class="step-element-name" :class="{ 'done': checklistItem.attributes.checked }">
|
||||
<div class="sci-checkbox-container" :class="{ 'disabled': !checklistItem.attributes.urls.update_url}">
|
||||
<div class="sci-checkbox-container" :class="{ 'disabled': !updateUrl || inRepository}">
|
||||
<input ref="checkbox"
|
||||
type="checkbox"
|
||||
class="sci-checkbox"
|
||||
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
<div class="step-checklist-text">
|
||||
<InlineEdit
|
||||
v-if="checklistItem.attributes.urls.update_url"
|
||||
v-if="!checklistItem.attributes.urls || updateUrl"
|
||||
:value="checklistItem.attributes.text"
|
||||
:characterLimit="10000"
|
||||
:placeholder="''"
|
||||
|
@ -35,10 +35,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="step-element-controls">
|
||||
<button v-if="checklistItem.attributes.urls.update_url" class="btn icon-btn btn-light" @click="enableTextEdit">
|
||||
<button v-if="!checklistItem.attributes.urls || updateUrl" class="btn icon-btn btn-light" @click="enableTextEdit">
|
||||
<i class="fas fa-pen"></i>
|
||||
</button>
|
||||
<button v-if="checklistItem.attributes.urls.delete_url" class="btn icon-btn btn-light" @click="showDeleteModal">
|
||||
<button v-if="!checklistItem.attributes.urls || deleteUrl" class="btn icon-btn btn-light" @click="showDeleteModal">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -65,6 +65,10 @@
|
|||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
inRepository: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
reorderChecklistItemUrl: {
|
||||
type: String
|
||||
}
|
||||
|
@ -82,6 +86,16 @@
|
|||
position: this.checklistItem.attributes.position
|
||||
}
|
||||
});
|
||||
},
|
||||
updateUrl() {
|
||||
if (!this.checklistItem.attributes.urls) return
|
||||
|
||||
return this.checklistItem.attributes.urls.update_url;
|
||||
},
|
||||
deleteUrl() {
|
||||
if (!this.checklistItem.attributes.urls) return
|
||||
|
||||
return this.checklistItem.attributes.urls.delete_url;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -94,7 +108,7 @@
|
|||
this.$emit('editEnd');
|
||||
},
|
||||
toggleChecked(e) {
|
||||
if (!this.checklistItem.attributes.urls.update_url) return
|
||||
if (!this.updateUrl) return
|
||||
this.checklistItem.attributes.checked = this.$refs.checkbox.checked;
|
||||
this.update();
|
||||
},
|
||||
|
|
|
@ -66,6 +66,10 @@
|
|||
type: Object,
|
||||
required: true
|
||||
},
|
||||
inRepository: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
reorderElementUrl: {
|
||||
type: String
|
||||
}
|
||||
|
|
|
@ -46,6 +46,10 @@
|
|||
type: Object,
|
||||
required: true
|
||||
},
|
||||
inRepository: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
reorderElementUrl: {
|
||||
type: String
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class ChecklistSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def urls
|
||||
return {} if object.destroyed? || !can_manage_step?(scope[:user], object.step)
|
||||
return {} if object.destroyed? || !can_manage_step?(scope[:user] || @instance_options[:user], object.step)
|
||||
|
||||
{
|
||||
delete_url: step_checklist_path(object.step, object),
|
||||
|
|
|
@ -15,8 +15,8 @@ class ProtocolSerializer < ActiveModel::Serializer
|
|||
|
||||
def added_by
|
||||
{
|
||||
avatar: object.added_by.avatar_url(:icon_small),
|
||||
name: object.added_by.full_name
|
||||
avatar: object.added_by&.avatar_url(:icon_small),
|
||||
name: object.added_by&.full_name
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class StepTextSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def urls
|
||||
return {} if object.destroyed? || !can_manage_step?(scope[:user], object.step)
|
||||
return {} if object.destroyed? || !can_manage_step?(scope[:user] || @instance_options[:user], object.step)
|
||||
|
||||
{
|
||||
delete_url: step_text_path(object.step, object),
|
||||
|
|
|
@ -19,7 +19,7 @@ class TableSerializer < ActiveModel::Serializer
|
|||
|
||||
object.reload unless object.step
|
||||
|
||||
return {} unless can_manage_step?(scope[:user], object.step)
|
||||
return {} unless can_manage_step?(scope[:user] || @instance_options[:user], object.step)
|
||||
|
||||
{
|
||||
delete_url: step_table_path(object.step, object),
|
||||
|
|
Loading…
Reference in a new issue