2022-05-03 21:18:48 +08:00
|
|
|
<template>
|
2022-06-24 17:21:47 +08:00
|
|
|
<div>
|
|
|
|
<div class="dropdown sci-dropdown protocol-options-dropdown">
|
|
|
|
<button
|
|
|
|
class="btn btn-secondary dropdown-toggle"
|
|
|
|
type="button"
|
|
|
|
id="dropdownProtocolOptions"
|
|
|
|
data-toggle="dropdown"
|
|
|
|
aria-haspopup="true"
|
|
|
|
aria-expanded="true"
|
2022-07-06 20:31:55 +08:00
|
|
|
tabindex="0"
|
2022-06-24 17:21:47 +08:00
|
|
|
>
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-settings"></span>
|
2022-06-24 17:21:47 +08:00
|
|
|
<span>{{ i18n.t("my_modules.protocol.options_dropdown.title") }}</span>
|
|
|
|
<span class="caret"></span>
|
|
|
|
</button>
|
|
|
|
<ul
|
|
|
|
class="dropdown-menu dropdown-menu-right"
|
|
|
|
aria-labelledby="dropdownProtocolOptions"
|
|
|
|
>
|
2023-04-06 22:29:19 +08:00
|
|
|
<li v-if="protocol.attributes.urls.load_from_repo_url">
|
2022-06-24 17:21:47 +08:00
|
|
|
<a
|
|
|
|
ref="loadProtocol"
|
|
|
|
data-action="load-from-repository"
|
|
|
|
@click="loadProtocol"
|
|
|
|
>
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-protocols-templates"></span>
|
2022-06-24 17:21:47 +08:00
|
|
|
<span>{{ i18n.t("my_modules.protocol.options_dropdown.load_from_repo") }}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a
|
2023-02-17 21:27:20 +08:00
|
|
|
data-toggle="modal"
|
|
|
|
data-target="#newProtocolModal"
|
2022-06-24 17:21:47 +08:00
|
|
|
:class="{ disabled: !protocol.attributes.urls.save_to_repo_url }"
|
|
|
|
>
|
2023-02-07 17:39:49 +08:00
|
|
|
<span class="fas fa-save"></span>
|
2022-06-24 17:21:47 +08:00
|
|
|
<span>{{
|
|
|
|
i18n.t("my_modules.protocol.options_dropdown.save_to_repo")
|
|
|
|
}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
data-turbolinks="false"
|
|
|
|
:href="protocol.attributes.urls.export_url"
|
|
|
|
:class="{ disabled: !protocol.attributes.urls.export_url }"
|
|
|
|
>
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-import"></span>
|
2022-06-24 17:21:47 +08:00
|
|
|
<span>{{
|
|
|
|
i18n.t("my_modules.protocol.options_dropdown.export")
|
|
|
|
}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
2023-02-07 17:39:49 +08:00
|
|
|
<li v-if="protocol.attributes.urls.update_protocol_url">
|
|
|
|
<a
|
|
|
|
ref="updateProtocol"
|
|
|
|
data-action="update-self"
|
|
|
|
@click="updateProtocol"
|
|
|
|
>
|
|
|
|
<span class="fas fa-sync-alt"></span>
|
|
|
|
<span>{{
|
|
|
|
i18n.t("my_modules.protocol.options_dropdown.update_protocol")
|
|
|
|
}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li v-if="protocol.attributes.urls.unlink_url">
|
|
|
|
<a
|
|
|
|
ref="unlinkProtocol"
|
|
|
|
data-action="unlink"
|
|
|
|
@click="unlinkProtocol"
|
|
|
|
>
|
|
|
|
<span class="fas fa-unlink"></span>
|
|
|
|
<span>{{
|
|
|
|
i18n.t("my_modules.protocol.options_dropdown.unlink")
|
|
|
|
}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li v-if="protocol.attributes.urls.revert_protocol_url">
|
|
|
|
<a
|
|
|
|
ref="revertProtocol"
|
|
|
|
data-action="revert"
|
|
|
|
@click="revertProtocol"
|
|
|
|
>
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-restore"></span>
|
2023-02-07 17:39:49 +08:00
|
|
|
<span>{{
|
|
|
|
i18n.t("my_modules.protocol.options_dropdown.revert_protocol")
|
|
|
|
}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
2022-06-24 17:21:47 +08:00
|
|
|
<li v-if="canDeleteSteps">
|
|
|
|
<a
|
|
|
|
data-turbolinks="false"
|
2022-07-07 21:56:36 +08:00
|
|
|
@click.prevent="openStepsDeletingModal()"
|
2022-06-24 17:21:47 +08:00
|
|
|
>
|
2023-06-08 14:33:37 +08:00
|
|
|
<span class="sn-icon sn-icon-delete"></span>
|
2022-06-24 17:21:47 +08:00
|
|
|
<span>{{
|
|
|
|
i18n.t("my_modules.protocol.options_dropdown.delete_steps")
|
|
|
|
}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<DeleteStepsModals v-if="stepsDeleting" @confirm="deleteSteps" @close="closeStartStepsDeletingModal" />
|
2022-05-03 21:18:48 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-03-30 19:27:10 +08:00
|
|
|
import DeleteStepsModals from './modals/delete_steps'
|
2022-06-24 17:21:47 +08:00
|
|
|
|
2022-05-03 21:18:48 +08:00
|
|
|
export default {
|
2022-06-24 17:21:47 +08:00
|
|
|
|
2022-05-03 21:18:48 +08:00
|
|
|
name: "ProtocolOptions",
|
2022-06-24 17:21:47 +08:00
|
|
|
components: { DeleteStepsModals },
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
stepsDeleting: false
|
|
|
|
}
|
|
|
|
},
|
2022-05-03 21:18:48 +08:00
|
|
|
props: {
|
|
|
|
protocol: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-24 17:21:47 +08:00
|
|
|
canDeleteSteps: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
}
|
2022-05-03 21:18:48 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
// Legacy global functions from app/assets/javascripts/my_modules/protocols.js
|
|
|
|
initLoadFromRepository();
|
|
|
|
initImport();
|
2023-02-07 17:39:49 +08:00
|
|
|
initLinkUpdate();
|
2022-05-03 21:18:48 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2022-06-24 17:21:47 +08:00
|
|
|
openStepsDeletingModal() {
|
|
|
|
this.stepsDeleting = true;
|
|
|
|
},
|
|
|
|
closeStartStepsDeletingModal() {
|
|
|
|
this.stepsDeleting = false;
|
|
|
|
},
|
2022-05-03 21:18:48 +08:00
|
|
|
loadProtocol() {
|
|
|
|
$.get(
|
|
|
|
this.protocol.attributes.urls.load_from_repo_url + "?type=recent"
|
|
|
|
).success((data) => {
|
|
|
|
$(this.$refs.loadProtocol).trigger("ajax:success", data);
|
|
|
|
});
|
|
|
|
},
|
2023-02-07 17:39:49 +08:00
|
|
|
unlinkProtocol() {
|
|
|
|
$.get(this.protocol.attributes.urls.unlink_url).success((data) => {
|
|
|
|
$(this.$refs.unlinkProtocol).trigger("ajax:success", data);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
updateProtocol() {
|
|
|
|
$.get(this.protocol.attributes.urls.update_protocol_url).success((data) => {
|
|
|
|
$(this.$refs.updateProtocol).trigger("ajax:success", data);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
revertProtocol() {
|
|
|
|
$.get(this.protocol.attributes.urls.revert_protocol_url).success((data) => {
|
|
|
|
$(this.$refs.revertProtocol).trigger("ajax:success", data);
|
|
|
|
});
|
|
|
|
},
|
2022-06-24 17:21:47 +08:00
|
|
|
deleteSteps() {
|
|
|
|
this.$emit('protocol:delete_steps')
|
2022-05-03 21:18:48 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|