提交 5e0e3971 编写于 作者: A Alfredo Sumaran

List groups with basic details

- Adds Groups component
- Adds GroupItem component
上级 26573605
<script>
export default {
props: {
group: {
type: Object,
required: true,
}
}
};
</script>
<template>
<tr>
<td>
<div>
<a :href="group.web_url">{{group.full_name}}</a>
</div>
<div>{{group.description}}</div>
</td>
</tr>
</template>
<script>
import GroupsStore from '../stores/groups_store';
import GroupsService from '../services/groups_service';
import GroupItem from '../components/group_item.vue';
export default {
components: {
'group-item': GroupItem,
},
data() {
const store = new GroupsStore();
return {
store,
state: store.state,
}
},
created() {
const appEl = document.querySelector('#dashboard-group-app');
this.service = new GroupsService(appEl.dataset.endpoint);
this.fetchGroups();
},
methods: {
fetchGroups() {
this.service.getGroups()
.then((response) => {
this.store.setGroups(response.json());
})
.catch(() => {
// TODO: Handler error
});
},
}
};
</script>
<template>
<table class="table table-bordered">
<group-item :group="group" v-for="group in state.groups" />
</table>
</template>
/* eslint-disable no-unused-vars */
import Vue from 'vue';
import GroupsStore from './stores/groups_store';
import GroupsService from './services/groups_service';
import GroupsComponent from './components/groups.vue'
$(() => {
const appEl = document.querySelector('.js-groups-list-holder');
const groupsStore = new GroupsStore();
const groupsService = new GroupsService(appEl.dataset.endpoint);
const appEl = document.querySelector('#dashboard-group-app');
const GroupsApp = new Vue({
el: appEl,
data: groupsStore,
mounted() {
groupsService.getGroups()
.then((response) => {
this.groups = response.json();
})
.catch(() => {
// TODO: Handle error
});
components: {
'groups-component': GroupsComponent
},
render: createElement => createElement('groups-component'),
});
});
export default class GroupsStore {
constructor() {
this.groups = [];
this.state = {};
this.state.groups = [];
return this;
}
setGroups(groups) {
this.state.groups = groups;
return groups;
}
}
.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)
= render 'shared/groups/group', group: group_member.group, group_member: group_member
= paginate @groups, theme: 'gitlab'
.js-groups-list-holder#dashboard-group-app{ data: { endpoint: dashboard_groups_path(format: :json) } }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册