2022-06-06 19:56:22 +08:00
|
|
|
<template>
|
2023-09-21 16:19:31 +08:00
|
|
|
<div class="protocol-section protocol-information mb-4">
|
2023-01-05 18:42:59 +08:00
|
|
|
<div id="protocol-details" class="protocol-section-header">
|
|
|
|
<div class="protocol-details-container">
|
|
|
|
<a class="protocol-section-caret" role="button" data-toggle="collapse" href="#details-container" aria-expanded="false" aria-controls="details-container">
|
2023-06-15 21:12:51 +08:00
|
|
|
<i class="sn-icon sn-icon-right"></i>
|
2023-01-05 18:42:59 +08:00
|
|
|
<span id="protocolDetailsLabel" class="protocol-section-title">
|
|
|
|
<h2>
|
|
|
|
{{ i18n.t("protocols.header.details") }}
|
|
|
|
</h2>
|
|
|
|
<span class="protocol-code" >{{ protocol.attributes.code }}</span>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="actions-block">
|
2023-03-07 18:25:59 +08:00
|
|
|
<a class="btn btn-light icon-btn pull-right" :href="protocol.attributes.urls.print_protocol_url" target="_blank">
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-printer" aria-hidden="true"></span>
|
2023-01-05 18:42:59 +08:00
|
|
|
</a>
|
2023-02-24 23:17:36 +08:00
|
|
|
<button class="btn btn-light" @click="openVersionsModal">{{ i18n.t("protocols.header.versions") }}</button>
|
2023-03-09 01:12:29 +08:00
|
|
|
<button v-if="protocol.attributes.urls.publish_url" @click="$emit('publish')" class="btn btn-primary">{{ i18n.t("protocols.header.publish") }}</button>
|
2023-03-21 17:59:31 +08:00
|
|
|
<button v-if="protocol.attributes.urls.save_as_draft_url" v-bind:disabled="protocol.attributes.has_draft" @click="saveAsdraft" class="btn btn-secondary">{{ i18n.t("protocols.header.save_as_draft") }}</button>
|
2023-01-05 18:42:59 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="details-container" class="protocol-details collapse in">
|
|
|
|
<div class="protocol-metadata">
|
|
|
|
<p class="data-block">
|
2023-03-13 16:38:15 +08:00
|
|
|
<span>{{ i18n.t("protocols.header.version") }}</span>
|
2023-04-11 21:00:21 +08:00
|
|
|
<b>{{ titleVersion }}</b>
|
2023-01-05 18:42:59 +08:00
|
|
|
</p>
|
2023-04-05 21:08:31 +08:00
|
|
|
<p class="data-block" v-if="protocol.attributes.published">
|
|
|
|
<span>{{ i18n.t("protocols.header.published_on") }}</span>
|
|
|
|
<b>{{ protocol.attributes.published_on_formatted }}</b>
|
|
|
|
</p>
|
|
|
|
<p class="data-block" v-if="protocol.attributes.published">
|
|
|
|
<span>{{ i18n.t("protocols.header.published_by") }}</span>
|
2023-08-12 00:47:02 +08:00
|
|
|
<img :src="protocol.attributes.published_by.avatar" class="rounded-full"/>
|
2023-04-05 21:08:31 +08:00
|
|
|
{{ protocol.attributes.published_by.name }}
|
|
|
|
</p>
|
2023-01-05 18:42:59 +08:00
|
|
|
<p class="data-block">
|
2023-03-13 16:38:15 +08:00
|
|
|
<span>{{ i18n.t("protocols.header.updated_at") }}</span>
|
2023-01-05 18:42:59 +08:00
|
|
|
<b>{{ protocol.attributes.updated_at_formatted }}</b>
|
|
|
|
</p>
|
|
|
|
<p class="data-block">
|
2023-03-13 16:38:15 +08:00
|
|
|
<span>{{ i18n.t("protocols.header.created_at") }}</span>
|
2023-01-05 18:42:59 +08:00
|
|
|
<b>{{ protocol.attributes.created_at_formatted }}</b>
|
|
|
|
</p>
|
|
|
|
<p class="data-block">
|
2023-03-13 16:38:15 +08:00
|
|
|
<span>{{ i18n.t("protocols.header.added_by") }}</span>
|
2023-08-12 00:47:02 +08:00
|
|
|
<img :src="protocol.attributes.added_by.avatar" class="rounded-full"/>
|
2023-01-05 18:42:59 +08:00
|
|
|
{{ protocol.attributes.added_by.name }}
|
|
|
|
</p>
|
|
|
|
<p class="data-block authors-data">
|
|
|
|
<span>{{ i18n.t("protocols.header.authors") }}</span>
|
|
|
|
<span class="authors-list" v-if="protocol.attributes.urls.update_protocol_authors_url">
|
|
|
|
<InlineEdit
|
|
|
|
:value="protocol.attributes.authors"
|
|
|
|
:placeholder="i18n.t('protocols.header.add_authors')"
|
|
|
|
:allowBlank="true"
|
2023-09-01 23:18:13 +08:00
|
|
|
:attributeName="`${i18n.t('Protocol')} ${i18n.t('protocols.header.authors_list')}`"
|
|
|
|
:characterLimit="10000"
|
2023-01-05 18:42:59 +08:00
|
|
|
@update="updateAuthors"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<span class="authors-list" v-else>
|
|
|
|
{{ protocol.attributes.authors }}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<p class="data-block keywords-data">
|
|
|
|
<span>{{ i18n.t("protocols.header.keywords") }}</span>
|
2023-03-16 16:15:22 +08:00
|
|
|
<span
|
|
|
|
class="keywords-list"
|
|
|
|
v-if="protocol.attributes.urls.update_protocol_authors_url || protocol.attributes.keywords.length">
|
2023-01-05 18:42:59 +08:00
|
|
|
<DropdownSelector
|
|
|
|
:inputTagMode="true"
|
|
|
|
:options="this.protocol.attributes.keywords"
|
|
|
|
:placeholder="i18n.t('protocols.header.add_keywords')"
|
|
|
|
:selectorId="'keywordsSelector'"
|
|
|
|
:singleSelect="false"
|
|
|
|
:closeOnSelect="false"
|
|
|
|
:noEmptyOption="false"
|
|
|
|
:selectAppearance="'tag'"
|
|
|
|
:viewMode="protocol.attributes.urls.update_protocol_keywords_url == null"
|
|
|
|
@dropdown:changed="updateKeywords"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-06 19:56:22 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
|
2023-03-30 19:27:10 +08:00
|
|
|
import InlineEdit from '../shared/inline_edit.vue'
|
2023-11-29 18:36:44 +08:00
|
|
|
import DropdownSelector from '../shared/legacy/dropdown_selector.vue'
|
2022-06-06 19:56:22 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ProtocolMetadata',
|
|
|
|
components: { InlineEdit, DropdownSelector },
|
|
|
|
props: {
|
|
|
|
protocol: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
2023-04-11 21:00:21 +08:00
|
|
|
computed: {
|
|
|
|
titleVersion() {
|
2023-04-14 15:56:35 +08:00
|
|
|
const createdFromVersion = this.protocol.attributes.created_from_version;
|
2023-04-11 21:00:21 +08:00
|
|
|
|
|
|
|
if (this.protocol.attributes.published) {
|
2023-04-14 15:56:35 +08:00
|
|
|
return this.protocol.attributes.version;
|
2023-04-11 21:00:21 +08:00
|
|
|
}
|
|
|
|
|
2023-04-14 15:56:35 +08:00
|
|
|
if (!createdFromVersion) {
|
|
|
|
return this.i18n.t('protocols.draft');
|
2023-04-11 21:00:21 +08:00
|
|
|
}
|
|
|
|
|
2023-04-14 15:56:35 +08:00
|
|
|
return this.i18n.t('protocols.header.draft_with_from_version', {nr: createdFromVersion});
|
2023-04-11 21:00:21 +08:00
|
|
|
}
|
|
|
|
},
|
2022-06-06 19:56:22 +08:00
|
|
|
methods: {
|
2023-02-22 21:59:48 +08:00
|
|
|
saveAsdraft() {
|
|
|
|
$.post(this.protocol.attributes.urls.save_as_draft_url)
|
|
|
|
},
|
2022-06-06 19:56:22 +08:00
|
|
|
updateAuthors(authors) {
|
|
|
|
$.ajax({
|
|
|
|
type: 'PATCH',
|
|
|
|
url: this.protocol.attributes.urls.update_protocol_authors_url,
|
|
|
|
data: { protocol: { authors: authors } },
|
|
|
|
success: (result) => {
|
|
|
|
this.$emit('update', result.data.attributes)
|
2023-04-13 21:34:36 +08:00
|
|
|
},
|
|
|
|
error: (data) => {
|
|
|
|
HelperModule.flashAlertMsg(data.responseJSON ? Object.values(data.responseJSON).join(', ') : I18n.t('errors.general'), 'danger');
|
2022-06-06 19:56:22 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
updateKeywords(keywords) {
|
|
|
|
$.ajax({
|
|
|
|
type: 'PATCH',
|
|
|
|
url: this.protocol.attributes.urls.update_protocol_keywords_url,
|
|
|
|
data: { keywords: keywords },
|
|
|
|
success: (result) => {
|
|
|
|
this.$emit('update', result.data.attributes)
|
|
|
|
}
|
|
|
|
});
|
2023-02-24 23:17:36 +08:00
|
|
|
},
|
|
|
|
openVersionsModal() {
|
|
|
|
$.get(this.protocol.attributes.urls.versions_modal_url, (data) => {
|
|
|
|
let versionsModal = '#protocol-versions-modal'
|
|
|
|
$('.protocols-show').append($.parseHTML(data.html));
|
|
|
|
$(versionsModal).modal('show');
|
|
|
|
inlineEditing.init();
|
|
|
|
$(versionsModal).find('[data-toggle="tooltip"]').tooltip();
|
|
|
|
|
|
|
|
// Remove modal when it gets closed
|
|
|
|
$(versionsModal).on('hidden.bs.modal', () => {
|
|
|
|
$(versionsModal).remove();
|
|
|
|
});
|
|
|
|
});
|
2022-06-06 19:56:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|