2017-05-04 21:49:07 -04:00
|
|
|
import Vue from 'vue';
|
2017-10-04 10:10:24 -04:00
|
|
|
import Translate from '../vue_shared/translate';
|
2017-05-10 14:30:30 -04:00
|
|
|
import GroupFilterableList from './groups_filterable_list';
|
2017-10-04 10:10:24 -04:00
|
|
|
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-05-04 21:49:07 -04:00
|
|
|
|
2017-05-31 19:29:11 -04:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2017-10-04 10:10:24 -04:00
|
|
|
const el = document.getElementById('js-groups-tree');
|
2017-05-04 21:49:07 -04:00
|
|
|
|
2017-06-01 17:47:39 -04:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2017-10-04 10:10:24 -04:00
|
|
|
Vue.component('group-folder', groupFolderComponent);
|
|
|
|
Vue.component('group-item', groupItemComponent);
|
|
|
|
|
2017-06-01 17:47:39 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2017-05-31 19:29:11 -04:00
|
|
|
el,
|
2017-10-04 10:10:24 -04:00
|
|
|
components: {
|
|
|
|
groupsApp,
|
|
|
|
},
|
2017-05-10 04:06:51 -04:00
|
|
|
data() {
|
2017-10-04 10:10:24 -04:00
|
|
|
const dataset = this.$options.el.dataset;
|
|
|
|
const hideProjects = dataset.hideProjects === 'true';
|
|
|
|
const store = new GroupsStore(hideProjects);
|
|
|
|
const service = new GroupsService(dataset.endpoint);
|
2017-05-31 19:29:11 -04:00
|
|
|
|
2017-05-10 04:06:51 -04:00
|
|
|
return {
|
2017-10-04 10:10:24 -04:00
|
|
|
store,
|
|
|
|
service,
|
|
|
|
hideProjects,
|
2017-06-06 10:01:42 -04:00
|
|
|
loading: true,
|
2017-05-10 04:06:51 -04:00
|
|
|
};
|
|
|
|
},
|
2017-05-31 19:29:11 -04:00
|
|
|
beforeMount() {
|
2017-10-04 10:10:24 -04:00
|
|
|
const dataset = this.$options.el.dataset;
|
2017-05-29 17:52:33 -04:00
|
|
|
let groupFilterList = null;
|
2017-10-04 10:10:24 -04:00
|
|
|
const form = document.querySelector(dataset.formSel);
|
|
|
|
const filter = document.querySelector(dataset.filterSel);
|
|
|
|
const holder = document.querySelector(dataset.holderSel);
|
2017-05-29 17:52:33 -04:00
|
|
|
|
2017-06-06 01:06:08 -04:00
|
|
|
const opts = {
|
|
|
|
form,
|
|
|
|
filter,
|
|
|
|
holder,
|
2017-10-04 10:10:24 -04:00
|
|
|
filterEndpoint: dataset.endpoint,
|
|
|
|
pagePath: dataset.path,
|
|
|
|
dropdownSel: dataset.dropdownSel,
|
|
|
|
filterInputField: 'filter',
|
2017-06-06 01:06:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
groupFilterList = new GroupFilterableList(opts);
|
2017-05-10 14:30:30 -04:00
|
|
|
groupFilterList.initSearch();
|
2017-05-31 19:29:11 -04:00
|
|
|
},
|
2017-10-04 10:10:24 -04:00
|
|
|
render(createElement) {
|
|
|
|
return createElement('groups-app', {
|
|
|
|
props: {
|
|
|
|
store: this.store,
|
|
|
|
service: this.service,
|
|
|
|
hideProjects: this.hideProjects,
|
|
|
|
},
|
|
|
|
});
|
2017-06-07 11:05:17 -04:00
|
|
|
},
|
2017-05-04 21:49:07 -04:00
|
|
|
});
|
|
|
|
});
|