Commit 21279506 authored by Jean Rabreau's avatar Jean Rabreau
Browse files

馃嵄 CrudList allow header button list

parent ae8829ba
......@@ -6,13 +6,15 @@
<v-toolbar-title>{{ title }}</v-toolbar-title>
<v-spacer />
<v-btn
v-if="button.isDisplayed"
v-for="button in buttons"
:key="button.label"
tile
elevation="0"
color="secondary"
:to="button.to"
class="mr-2"
v-bind="button"
>
{{ button.text }}
{{ button.label }}
</v-btn>
</v-toolbar>
<v-divider />
......@@ -143,9 +145,9 @@ export default {
type: String,
required: true,
},
button: {
type: Object,
required: true,
buttons: {
type: Array,
default: () => [],
},
items: {
type: Array,
......
......@@ -2,7 +2,7 @@
<v-container>
<crud-list
:title="$t('project.plural')"
:button="crudListButton"
:buttons="crudListButtons"
:items="crudListItems"
:items-length="projectsLength"
:show-select="isCreator"
......@@ -32,12 +32,11 @@ export default {
pages: (state) => state.pageCount,
}),
...mapGetters('contrib', ['isCreator']),
crudListButton() {
return {
isDisplayed: this.isCreator,
to: '/projects/create',
text: this.$t('project.create'),
};
crudListButtons() {
return this.isCreator ? [{
to: {name: 'projectCreate'},
label: this.$t('project.create'),
}]: [];
},
crudListItems() {
return this.projects.map((project) => {
......
......@@ -3,7 +3,7 @@
<crud-list
class="mt-2"
:title="$t('group.project')"
:button="crudListButton"
:buttons="crudListButtons"
:items="crudListItems"
:paginated="false"
@remove-group="onRemoveGroup"
......@@ -44,12 +44,14 @@ export default {
groups() {
return this.projectGroups.filter((group) => !group.isDefaultGroup);
},
crudListButton() {
return {
isDisplayed: this.isManager,
to: `/projects/${this.projectId}/groups/create`,
text: this.$t('group.create'),
};
crudListButtons() {
return this.isManager ? [{
to: {
name: 'projectGroupCreate',
params: {projectId: this.projectId}
},
label: this.$t('group.create'),
}] : null;
},
crudListItems() {
return this.groups.map((group) => ({
......
......@@ -3,7 +3,7 @@
<crud-list
class="mt-2"
:title="$t('group.members.project')"
:button="crudListButton"
:buttons="crudListButtons"
:items="crudListItems"
:paginated="false"
@remove-member="onRemoveMember"
......@@ -43,12 +43,14 @@ export default {
...mapGetters('contrib', ['myId']),
...mapGetters('project', ['isManager', 'projectId']),
...mapGetters('group', ['projectMembers', 'projectGroup']),
crudListButton() {
return {
isDisplayed: this.isManager,
to: `/projects/${this.projectId}/members/invite`,
text: this.$t('group.members.invite'),
};
crudListButtons() {
return this.isManager ? [{
to: {
name: 'projectMemberInvite',
params: {projectId: this.projectId}
},
label: this.$t('group.members.invite'),
}] : [];
},
crudListItems() {
return this.projectMembers.map((member) => ({
......
......@@ -2,7 +2,7 @@
<crud-list
class="mt-2"
:title="$t('set.plural')"
:button="crudListButton"
:buttons="crudListButtons"
:items="crudListItems"
:items-length="setsLength"
:show-select="isManager"
......@@ -31,12 +31,11 @@ export default {
pages: 'pageCount',
}),
...mapGetters('project', ['isManager', 'projectId']),
crudListButton() {
return {
isDisplayed: this.isManager,
to: `/projects/${this.projectId}/sets/create`,
text: this.$t('set.create'),
};
crudListButtons() {
return this.isManager ? [{
to: {name: 'setCreate', params: {projectId: this.projectId}},
label: this.$t('set.create'),
}] : [];
},
crudListItems() {
return this.sets.map((set) => ({
......
......@@ -2,7 +2,7 @@
<crud-list
class="mt-2"
:title="$t('template.plural')"
:button="crudListButton"
:buttons="crudListButtons"
:items="crudListItems"
:paginated="false"
/>
......@@ -30,12 +30,14 @@ export default {
projectTemplates: 'projectList',
}),
...mapGetters('project', ['isManager', 'projectId']),
crudListButton() {
return {
isDisplayed: this.isManager,
to: `/projects/${this.projectId}/templates/create`,
text: this.$t('template.create'),
};
crudListButtons() {
return this.isManager ? [{
to: {
name: 'projectTemplateCreate',
params: {projectId: this.projectId}
},
label: this.$t('template.create'),
}] : [];
},
crudListItems() {
const templates = [
......
......@@ -2,7 +2,7 @@
<crud-list
class="mt-2"
:title="$t('item.plural')"
:button="crudListButton"
:buttons="crudListButtons"
:items="crudListItems"
:items-length="itemsLength"
:show-select="canContribute"
......@@ -35,21 +35,23 @@ export default {
'setId',
'templateId',
]),
crudListButton() {
return {
isDisplayed: this.canContribute,
crudListButtons() {
return this.canContribute ? [{
to: { name: 'setItemCreate' },
text: this.$t('item.create'),
};
label: this.$t('item.create'),
}, {
to: { name: 'setItemImport' },
label: this.$t('item.import.button')
}] : [];
},
crudListItems() {
return this.items.map((item) => ({
id: item.id,
name: this.textTruncate(item.title, 50),
thumbnail: item.thumbnails.s,
subtitles: [
subtitles: item.description ? [
this.textTruncate(this.stripHtml(item.description), 75),
],
] : [],
isSelectable: item.canEdit,
updatedAt: item.updatedAt,
to: {
......
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