2017-09-10 17:25:29 +05:30
|
|
|
import Vue from 'vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import Translate from '../vue_shared/translate';
|
2017-09-10 17:25:29 +05:30
|
|
|
import GroupFilterableList from './groups_filterable_list';
|
2018-03-17 18:26:18 +05:30
|
|
|
import GroupsStore from './store/groups_store';
|
|
|
|
import GroupsService from './service/groups_service';
|
|
|
|
|
|
|
|
import groupsApp from './components/app.vue';
|
|
|
|
import groupFolderComponent from './components/group_folder.vue';
|
|
|
|
import groupItemComponent from './components/group_item.vue';
|
|
|
|
|
|
|
|
Vue.use(Translate);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export default () => {
|
|
|
|
const el = document.getElementById('js-groups-tree');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
// Don't do anything if element doesn't exist (No groups)
|
|
|
|
// This is for when the user enters directly to the page via URL
|
|
|
|
if (!el) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
Vue.component('group-folder', groupFolderComponent);
|
|
|
|
Vue.component('group-item', groupItemComponent);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
2018-03-17 18:26:18 +05:30
|
|
|
components: {
|
|
|
|
groupsApp,
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
data() {
|
2018-11-08 19:23:39 +05:30
|
|
|
const { dataset } = this.$options.el;
|
2018-03-17 18:26:18 +05:30
|
|
|
const hideProjects = dataset.hideProjects === 'true';
|
|
|
|
const store = new GroupsStore(hideProjects);
|
|
|
|
const service = new GroupsService(dataset.endpoint);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
return {
|
2018-03-17 18:26:18 +05:30
|
|
|
store,
|
|
|
|
service,
|
|
|
|
hideProjects,
|
2017-09-10 17:25:29 +05:30
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
beforeMount() {
|
2018-11-08 19:23:39 +05:30
|
|
|
const { dataset } = this.$options.el;
|
2017-09-10 17:25:29 +05:30
|
|
|
let groupFilterList = null;
|
2018-03-17 18:26:18 +05:30
|
|
|
const form = document.querySelector(dataset.formSel);
|
|
|
|
const filter = document.querySelector(dataset.filterSel);
|
|
|
|
const holder = document.querySelector(dataset.holderSel);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
const opts = {
|
|
|
|
form,
|
|
|
|
filter,
|
|
|
|
holder,
|
2018-03-17 18:26:18 +05:30
|
|
|
filterEndpoint: dataset.endpoint,
|
|
|
|
pagePath: dataset.path,
|
|
|
|
dropdownSel: dataset.dropdownSel,
|
|
|
|
filterInputField: 'filter',
|
2017-09-10 17:25:29 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
groupFilterList = new GroupFilterableList(opts);
|
|
|
|
groupFilterList.initSearch();
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement('groups-app', {
|
|
|
|
props: {
|
|
|
|
store: this.store,
|
|
|
|
service: this.service,
|
|
|
|
hideProjects: this.hideProjects,
|
|
|
|
},
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
};
|