2022-06-06 19:56:22 +08:00
|
|
|
<template>
|
|
|
|
<div class="protocol-metadata">
|
2022-06-22 00:20:52 +08:00
|
|
|
<p class="data-block">
|
2022-07-15 16:00:50 +08:00
|
|
|
<span class="fas block-icon fa-calendar-alt fa-fw"></span>
|
2022-06-06 19:56:22 +08:00
|
|
|
{{ i18n.t("protocols.header.created_at") }}
|
2022-06-22 00:20:52 +08:00
|
|
|
<b>{{ protocol.attributes.created_at_formatted }}</b>
|
|
|
|
</p>
|
|
|
|
<p class="data-block">
|
2022-07-15 16:00:50 +08:00
|
|
|
<span class="fas block-icon fa-user fa-fw"></span>
|
2022-06-06 19:56:22 +08:00
|
|
|
{{ i18n.t("protocols.header.added_by") }}
|
|
|
|
<img :src="protocol.attributes.added_by.avatar"/>
|
|
|
|
{{ protocol.attributes.added_by.name }}
|
2022-06-22 00:20:52 +08:00
|
|
|
</p>
|
|
|
|
<p class="data-block">
|
2022-07-15 16:00:50 +08:00
|
|
|
<span class="fas block-icon fa-edit fa-fw"></span>
|
2022-06-06 19:56:22 +08:00
|
|
|
{{ i18n.t("protocols.header.updated_at") }}
|
2022-06-22 00:20:52 +08:00
|
|
|
<b>{{ protocol.attributes.updated_at_formatted }}</b>
|
|
|
|
</p>
|
|
|
|
<p class="data-block authors-data">
|
2022-07-15 16:00:50 +08:00
|
|
|
<span class="fas block-icon fa-graduation-cap fa-fw"></span>
|
2022-06-22 00:20:52 +08:00
|
|
|
<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"
|
2022-07-15 16:00:50 +08:00
|
|
|
:placeholder="i18n.t('protocols.header.add_authors')"
|
2022-06-22 00:20:52 +08:00
|
|
|
:allowBlank="true"
|
|
|
|
:attributeName="`${i18n.t('Protocol')} ${i18n.t('authors')}`"
|
|
|
|
@update="updateAuthors"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<span class="authors-list" v-else>
|
2022-06-06 19:56:22 +08:00
|
|
|
{{ protocol.attributes.authors }}
|
|
|
|
</span>
|
2022-06-22 00:20:52 +08:00
|
|
|
</p>
|
|
|
|
<p class="data-block keywords-data">
|
2022-07-15 16:00:50 +08:00
|
|
|
<span class="fas block-icon fa-font fa-fw"></span>
|
2022-06-22 00:20:52 +08:00
|
|
|
<span>{{ i18n.t("protocols.header.keywords") }}</span>
|
|
|
|
<span class="keywords-list">
|
|
|
|
<DropdownSelector
|
|
|
|
:inputTagMode="true"
|
|
|
|
:options="this.protocol.attributes.keywords"
|
2022-07-15 16:00:50 +08:00
|
|
|
:placeholder="i18n.t('protocols.header.add_keywords')"
|
2022-06-22 00:20:52 +08:00
|
|
|
:selectorId="'keywordsSelector'"
|
|
|
|
:singleSelect="false"
|
|
|
|
:closeOnSelect="false"
|
|
|
|
:noEmptyOption="false"
|
|
|
|
:selectAppearance="'tag'"
|
|
|
|
:viewMode="protocol.attributes.urls.update_protocol_keywords_url == null"
|
|
|
|
@dropdown:changed="updateKeywords"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
</p>
|
2022-06-06 19:56:22 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import InlineEdit from 'vue/shared/inline_edit.vue'
|
|
|
|
import DropdownSelector from 'vue/shared/dropdown_selector.vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ProtocolMetadata',
|
|
|
|
components: { InlineEdit, DropdownSelector },
|
|
|
|
props: {
|
|
|
|
protocol: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|