2019-12-13 18:08:06 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
2020-08-17 21:09:56 +00:00
|
|
|
import Translate from '~/vue_shared/translate';
|
2019-12-13 18:08:06 +00:00
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
|
2020-04-21 15:21:10 +00:00
|
|
|
import SnippetsShow from './components/show.vue';
|
|
|
|
import SnippetsEdit from './components/edit.vue';
|
2019-12-13 18:08:06 +00:00
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
2020-03-24 15:08:44 +00:00
|
|
|
function appFactory(el, Component) {
|
2019-12-13 18:08:06 +00:00
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
render(createElement) {
|
2020-03-24 15:08:44 +00:00
|
|
|
return createElement(Component, {
|
2019-12-13 18:08:06 +00:00
|
|
|
props: {
|
2020-03-24 15:08:44 +00:00
|
|
|
...el.dataset,
|
2019-12-13 18:08:06 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-03-24 15:08:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const SnippetShowInit = () => {
|
2020-04-21 15:21:10 +00:00
|
|
|
appFactory(document.getElementById('js-snippet-view'), SnippetsShow);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SnippetEditInit = () => {
|
|
|
|
appFactory(document.getElementById('js-snippet-edit'), SnippetsEdit);
|
2019-12-13 18:08:06 +00:00
|
|
|
};
|