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