BigW Consortium Gitlab

Commit 26573605 by Alfredo Sumaran

Add GroupsService to fetch data from server

parent d67ab685
/* eslint-disable no-unused-vars */
import Vue from 'vue';
import GroupsStore from './stores/groups_store';
import GroupsService from './services/groups_service';
$(() => {
const appEl = document.querySelector('.js-groups-list-holder');
const groupsStore = new GroupsStore();
const groupsService = new GroupsService(appEl.dataset.endpoint);
const GroupsApp = new Vue({
el: document.querySelector('.js-groups-list-holder'),
el: appEl,
data: groupsStore,
mounted() {
groupsService.getGroups()
.then((response) => {
this.groups = response.json();
})
.catch(() => {
// TODO: Handle error
});
},
});
});
import Vue from 'vue';
import VueResource from 'vue-resource';
Vue.use(VueResource);
export default class GroupsService {
constructor(endpoint) {
this.groups = Vue.resource(endpoint);
}
getGroups() {
return this.groups.get();
}
}
.js-groups-list-holder
.js-groups-list-holder{ data: { endpoint: dashboard_groups_path(format: :json) } }
%ul.content-list
- @groups.each do |group|
- group_member = group.group_members.find_by(user_id: current_user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment