scinote-web/app/javascript/packs/vue/protocol.js
Soufiane 58782131a8
Flash message for delete draft [SCI-8245] (#5300)
Add redirect flash message after draft delete and before the location redirect [SCI-8245]
2023-05-03 11:16:59 +02:00

40 lines
1.1 KiB
JavaScript

/* global HelperModule */
import TurbolinksAdapter from 'vue-turbolinks';
import Vue from 'vue/dist/vue.esm';
import ProtocolContainer from '../../vue/protocol/container.vue';
Vue.use(TurbolinksAdapter);
Vue.prototype.i18n = window.I18n;
Vue.prototype.inlineEditing = window.inlineEditing;
Vue.prototype.ActiveStoragePreviews = window.ActiveStoragePreviews;
window.initProtocolComponent = () => {
Vue.prototype.dateFormat = $('#protocolContainer').data('date-format');
$('.protocols-show').on('click', '#protocol-versions-modal .delete-draft', (e) => {
const url = e.currentTarget.dataset.url;
const modal = $('#deleteDraftModal');
$('#protocol-versions-modal').modal('hide');
modal.modal('show');
modal.find('form').attr('action', url);
});
$('#deleteDraftModal form').on('ajax:error', function(_ev, data) {
HelperModule.flashAlertMsg(data.responseJSON.message, 'danger');
});
new Vue({
el: '#protocolContainer',
components: {
'protocol-container': ProtocolContainer
},
data() {
return {
protocolUrl: $('#protocolContainer').data('protocol-url')
};
}
});
};
initProtocolComponent();