Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 4x 4x | <script> import { GlCollapsibleListbox, GlButton } from '@gitlab/ui'; import { s__ } from '~/locale'; const ANY_WEIGHT = 'Any weight'; const NO_WEIGHT = 'None'; export default { components: { GlButton, GlCollapsibleListbox, }, props: { board: { type: Object, required: true, }, canEdit: { type: Boolean, required: false, default: false, }, weights: { type: Array, required: true, }, }, data() { return { dropdownHidden: true, selected: this.board.weight, }; }, computed: { listBoxItems() { return this.weights.map((item) => ({ value: item, text: item })); }, valueClass() { Iif (this.valueText === ANY_WEIGHT) { return 'text-secondary'; } return 'bold'; }, valueText() { const weight = this.selected; Iif (weight > 0 || weight === 0) return weight.toString(); Iif (weight === -2) return NO_WEIGHT; return ANY_WEIGHT; }, }, methods: { showDropdown() { this.dropdownHidden = false; this.$nextTick(() => { this.$refs.dropdown.open(); }); }, selectWeight(rawWeight) { const weight = this.weightInt(rawWeight); this.selected = weight; this.dropdownHidden = true; this.$emit('set-weight', weight); }, weightInt(weight) { Iif (weight >= 0) { return weight; } Iif (weight === NO_WEIGHT) { return -2; } return null; }, toggleEdit() { if (this.dropdownHidden) { this.showDropdown(); } else { this.dropdownHidden = true; } }, }, i18n: { label: s__('BoardScope|Weight'), edit: s__('BoardScope|Edit'), }, }; </script> <template> <div class="block weight"> <div class="title gl-mb-3"> {{ $options.i18n.label }} <gl-button v-if="canEdit" category="tertiary" size="small" class="edit-link gl-float-right" @click="toggleEdit" > {{ $options.i18n.edit }} </gl-button> </div> <div v-if="dropdownHidden" :class="valueClass" data-testid="selected-weight"> {{ valueText }} </div> <gl-collapsible-listbox v-if="!dropdownHidden" ref="dropdown" block toggle-class="gl-w-full" :items="listBoxItems" :selected="selected" :toggle-text="valueText" @select="selectWeight" /> </div> </template> |