2020-06-23 00:09:42 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
import Vue from 'vue';
|
2021-04-29 21:17:54 +05:30
|
|
|
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
|
2021-03-11 19:13:27 +05:30
|
|
|
import csrf from '~/lib/utils/csrf';
|
|
|
|
import Translate from '~/vue_shared/translate';
|
2022-06-21 17:19:12 +05:30
|
|
|
import GLForm from '~/gl_form';
|
|
|
|
import ZenMode from '~/zen_mode';
|
2020-06-23 00:09:42 +05:30
|
|
|
import deleteWikiModal from './components/delete_wiki_modal.vue';
|
2021-04-17 20:07:23 +05:30
|
|
|
import wikiAlert from './components/wiki_alert.vue';
|
2021-04-29 21:17:54 +05:30
|
|
|
import wikiForm from './components/wiki_form.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const createModalVueApp = () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const deleteWikiModalWrapperEl = document.getElementById('delete-wiki-modal-wrapper');
|
|
|
|
|
|
|
|
if (deleteWikiModalWrapperEl) {
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
|
|
|
const { deleteWikiUrl, pageTitle } = deleteWikiModalWrapperEl.dataset;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: deleteWikiModalWrapperEl,
|
2021-09-30 23:02:18 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
deleteWikiUrl: '',
|
|
|
|
};
|
2020-06-23 00:09:42 +05:30
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(deleteWikiModal, {
|
|
|
|
props: {
|
|
|
|
pageTitle,
|
|
|
|
deleteWikiUrl,
|
|
|
|
csrfToken: csrf.token,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
const createAlertVueApp = () => {
|
|
|
|
const el = document.getElementById('js-wiki-error');
|
|
|
|
if (el) {
|
|
|
|
const { error, wikiPagePath } = el.dataset;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(wikiAlert, {
|
|
|
|
props: {
|
|
|
|
error,
|
|
|
|
wikiPagePath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
const createWikiFormApp = () => {
|
|
|
|
const el = document.getElementById('js-wiki-form');
|
|
|
|
|
|
|
|
if (el) {
|
|
|
|
const { pageInfo, formatOptions } = el.dataset;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
provide: {
|
|
|
|
formatOptions: JSON.parse(formatOptions),
|
|
|
|
pageInfo: convertObjectPropsToCamelCase(JSON.parse(pageInfo)),
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(wikiForm);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
export const mountApplications = () => {
|
|
|
|
new ZenMode(); // eslint-disable-line no-new
|
|
|
|
new GLForm($('.wiki-form')); // eslint-disable-line no-new
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
createModalVueApp();
|
|
|
|
createAlertVueApp();
|
2021-04-29 21:17:54 +05:30
|
|
|
createWikiFormApp();
|
2021-04-17 20:07:23 +05:30
|
|
|
};
|