1616 @keydown.enter =" saveChanges"
1717 @keydown.escape =" cancelEdit" >
1818 <div class =" align-center" :class =" { 'is-loading': localLoading }" >
19- <NcButton type="tertiary"
20- :aria-label =" t (' tables' , ' Reduce stars' )"
21- :disabled =" localLoading || editValue <= 0 || ! canEditCell ()"
22- @click =" less " >
23- <template #icon >
24- <span class =" minus-icon" >-</span >
25- </template >
26- </NcButton >
27- <div class =" stars" >
28- {{ getEditValue }}
19+ <div class =" clickable-stars" >
20+ <span v-for =" star in 5"
21+ :key =" star"
22+ class =" star"
23+ :class =" { 'filled': star <= editValue, 'clickable': !localLoading && canEditCell() }"
24+ :aria-label =" t('tables', 'Set {star} stars', { star })"
25+ @click =" setStar(star)" >
26+ {{ star <= editValue ? '★' : '☆' }}
27+ </span >
2928 </div >
30- <NcButton type="tertiary"
31- :aria-label =" t (' tables' , ' Increase stars' )"
32- :disabled =" localLoading || editValue >= 5 || ! canEditCell ()"
33- @click =" more " >
34- <template #icon >
35- <span class =" plus-icon" >+</span >
36- </template >
37- </NcButton >
3829 <div v-if =" localLoading" class =" icon-loading-small icon-loading-inline" />
3930 </div >
4031 </div >
4132 </div >
4233</template >
4334
4435<script >
45- import { NcButton } from ' @nextcloud/vue'
4636import cellEditMixin from ' ../mixins/cellEditMixin.js'
4737import { translate as t } from ' @nextcloud/l10n'
4838
4939export default {
5040 name: ' TableCellStars' ,
5141
52- components: {
53- NcButton,
54- },
55-
5642 mixins: [cellEditMixin],
5743
5844 props: {
@@ -89,11 +75,9 @@ export default {
8975 isEditing (newValue ) {
9076 if (newValue) {
9177 this .$nextTick (() => {
92- // Add click outside listener
9378 document .addEventListener (' click' , this .handleClickOutside )
9479 })
9580 } else {
96- // Remove click outside listener
9781 document .removeEventListener (' click' , this .handleClickOutside )
9882 }
9983 },
@@ -102,15 +86,14 @@ export default {
10286 methods: {
10387 t,
10488
105- more () {
106- if (this .editValue < 5 && ! this .localLoading && this .canEditCell ()) {
107- this .editValue ++
108- }
109- },
110-
111- less () {
112- if (this .editValue > 0 && ! this .localLoading && this .canEditCell ()) {
113- this .editValue --
89+ setStar (starNumber ) {
90+ if (! this .localLoading && this .canEditCell ()) {
91+ // If clicking on a star that represents the current rating, clear to 0
92+ if (starNumber === this .editValue ) {
93+ this .editValue = 0
94+ } else {
95+ this .editValue = starNumber
96+ }
11497 }
11598 },
11699
@@ -172,6 +155,30 @@ export default {
172155 padding : 7px ;
173156}
174157
158+ .clickable-stars {
159+ display : flex ;
160+ align-items : center ;
161+ gap : 2px ;
162+ }
163+
164+ .star {
165+ font-size : 1.4em ;
166+ padding : 4px ;
167+ transition : transform 0.1s ease ;
168+
169+ & .clickable {
170+ cursor : pointer ;
171+
172+ & :hover {
173+ transform : scale (1.1 );
174+ }
175+ }
176+
177+ & .filled {
178+ color : var (--color-warning );
179+ }
180+ }
181+
175182.editor-buttons {
176183 display : flex ;
177184 gap : 8px ;
@@ -182,9 +189,4 @@ export default {
182189.icon-loading-inline {
183190 margin-left : 4px ;
184191}
185-
186- .minus-icon , .plus-icon {
187- font-size : 20px ;
188- font-weight : bold ;
189- }
190192 </style >
0 commit comments