2020-01-01 13:55:28 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import Translate from '~/vue_shared/translate';
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
import SnippetsShow from './components/show.vue';
|
|
|
|
import SnippetsEdit from './components/edit.vue';
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
function appFactory(el, Component) {
|
2020-01-01 13:55:28 +05:30
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
render(createElement) {
|
2020-04-22 19:07:51 +05:30
|
|
|
return createElement(Component, {
|
2020-01-01 13:55:28 +05:30
|
|
|
props: {
|
2020-04-22 19:07:51 +05:30
|
|
|
...el.dataset,
|
2020-01-01 13:55:28 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-04-22 19:07:51 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export const SnippetShowInit = () => {
|
|
|
|
appFactory(document.getElementById('js-snippet-view'), SnippetsShow);
|
2020-01-01 13:55:28 +05:30
|
|
|
};
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
export const SnippetEditInit = () => {
|
|
|
|
appFactory(document.getElementById('js-snippet-edit'), SnippetsEdit);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default () => {};
|