2021-02-22 17:27:13 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import Translate from '~/vue_shared/translate';
|
|
|
|
import GroupFilter from './components/group_filter.vue';
|
|
|
|
import ProjectFilter from './components/project_filter.vue';
|
|
|
|
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
|
|
|
const mountSearchableDropdown = (store, { id, component }) => {
|
|
|
|
const el = document.getElementById(id);
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let { initialData } = el.dataset;
|
|
|
|
|
|
|
|
initialData = JSON.parse(initialData);
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
store,
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(component, {
|
|
|
|
props: {
|
|
|
|
initialData,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const searchableDropdowns = [
|
|
|
|
{
|
|
|
|
id: 'js-search-group-dropdown',
|
|
|
|
component: GroupFilter,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'js-search-project-dropdown',
|
|
|
|
component: ProjectFilter,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
export const initTopbar = (store) =>
|
|
|
|
searchableDropdowns.map((dropdown) => mountSearchableDropdown(store, dropdown));
|