|
7 | 7 | icon-right="arrow_drop_down"
|
8 | 8 | button-class="flat round"
|
9 | 9 | >
|
10 |
| - <VueDropdownButton |
11 |
| - v-for="project of favoriteProjects" |
12 |
| - :key="project.id" |
13 |
| - :label="project.name" |
14 |
| - icon-left="star" |
15 |
| - @click="openProject(project)" |
16 |
| - /> |
| 10 | + <template v-if="projectCurrent"> |
| 11 | + <VueSwitch |
| 12 | + :value="projectCurrent.favorite" |
| 13 | + :icon="projectCurrent.favorite ? 'star' : 'star_border'" |
| 14 | + class="extend-left" |
| 15 | + @input="toggleCurrentFavorite()" |
| 16 | + > |
| 17 | + {{ $t('org.vue.components.project-select-list-item.tooltips.favorite') }} |
| 18 | + </VueSwitch> |
| 19 | + </template> |
| 20 | + |
| 21 | + <div class="dropdown-separator"/> |
17 | 22 |
|
18 | 23 | <div v-if="!favoriteProjects.length" class="vue-ui-empty">{{ $t('org.vue.components.top-bar.no-favorites') }}</div>
|
19 | 24 |
|
| 25 | + <template v-else> |
| 26 | + <div class="section-title"> |
| 27 | + {{ $t('org.vue.components.top-bar.favorite-projects') }} |
| 28 | + </div> |
| 29 | + |
| 30 | + <VueDropdownButton |
| 31 | + v-for="project of favoriteProjects" |
| 32 | + :key="project.id" |
| 33 | + :label="project.name" |
| 34 | + icon-left="star" |
| 35 | + @click="openProject(project)" |
| 36 | + /> |
| 37 | + </template> |
| 38 | + |
20 | 39 | <div class="dropdown-separator"/>
|
21 | 40 |
|
22 | 41 | <VueDropdownButton
|
@@ -44,6 +63,7 @@ import { resetApollo } from '../vue-apollo'
|
44 | 63 | import PROJECT_CURRENT from '../graphql/projectCurrent.gql'
|
45 | 64 | import PROJECTS from '../graphql/projects.gql'
|
46 | 65 | import PROJECT_OPEN from '../graphql/projectOpen.gql'
|
| 66 | +import PROJECT_SET_FAVORITE from '../graphql/projectSetFavorite.gql' |
47 | 67 |
|
48 | 68 | export default {
|
49 | 69 | apollo: {
|
@@ -72,6 +92,18 @@ export default {
|
72 | 92 | })
|
73 | 93 |
|
74 | 94 | await resetApollo()
|
| 95 | + }, |
| 96 | +
|
| 97 | + async toggleCurrentFavorite () { |
| 98 | + if (this.projectCurrent) { |
| 99 | + await this.$apollo.mutate({ |
| 100 | + mutation: PROJECT_SET_FAVORITE, |
| 101 | + variables: { |
| 102 | + id: this.projectCurrent.id, |
| 103 | + favorite: this.projectCurrent.favorite ? 0 : 1 |
| 104 | + } |
| 105 | + }) |
| 106 | + } |
75 | 107 | }
|
76 | 108 | }
|
77 | 109 | }
|
|
0 commit comments