Ascending/Descending order by button for projects dashboard page. (#1100)
This commit is contained in:
parent
521e21072e
commit
7a59b2b25d
@ -192,8 +192,11 @@
|
|||||||
:close-on-select="true"
|
:close-on-select="true"
|
||||||
:show-labels="false"
|
:show-labels="false"
|
||||||
:allow-empty="false"
|
:allow-empty="false"
|
||||||
@update:model-value="projects = updateSort(projects, sortBy)"
|
@update:model-value="projects = updateSort(projects, sortBy, descending)"
|
||||||
/>
|
/>
|
||||||
|
<button class="square-button" @click="updateDescending()">
|
||||||
|
<ArrowIcon :transform="`rotate(${descending ? -90 : 90})`" />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -308,6 +311,7 @@ import PlusIcon from '~/assets/images/utils/plus.svg'
|
|||||||
import CrossIcon from '~/assets/images/utils/x.svg'
|
import CrossIcon from '~/assets/images/utils/x.svg'
|
||||||
import EditIcon from '~/assets/images/utils/edit.svg'
|
import EditIcon from '~/assets/images/utils/edit.svg'
|
||||||
import SaveIcon from '~/assets/images/utils/save.svg'
|
import SaveIcon from '~/assets/images/utils/save.svg'
|
||||||
|
import ArrowIcon from '~/assets/images/utils/left-arrow.svg'
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
export default defineNuxtComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -325,6 +329,7 @@ export default defineNuxtComponent({
|
|||||||
ModalCreation,
|
ModalCreation,
|
||||||
Multiselect,
|
Multiselect,
|
||||||
CopyCode,
|
CopyCode,
|
||||||
|
ArrowIcon,
|
||||||
},
|
},
|
||||||
async setup() {
|
async setup() {
|
||||||
const user = await useUser()
|
const user = await useUser()
|
||||||
@ -340,6 +345,7 @@ export default defineNuxtComponent({
|
|||||||
versions: [],
|
versions: [],
|
||||||
selectedProjects: [],
|
selectedProjects: [],
|
||||||
sortBy: 'Name',
|
sortBy: 'Name',
|
||||||
|
descending: false,
|
||||||
editLinks: {
|
editLinks: {
|
||||||
showAffected: false,
|
showAffected: false,
|
||||||
source: {
|
source: {
|
||||||
@ -375,10 +381,15 @@ export default defineNuxtComponent({
|
|||||||
this.DELETE_PROJECT = 1 << 7
|
this.DELETE_PROJECT = 1 << 7
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateSort(projects, sort) {
|
updateDescending() {
|
||||||
|
this.descending = !this.descending
|
||||||
|
this.projects = this.updateSort(this.projects, this.sortBy, this.descending)
|
||||||
|
},
|
||||||
|
updateSort(projects, sort, descending) {
|
||||||
|
let sortedArray = projects
|
||||||
switch (sort) {
|
switch (sort) {
|
||||||
case 'Name':
|
case 'Name':
|
||||||
return projects.slice().sort((a, b) => {
|
sortedArray = projects.slice().sort((a, b) => {
|
||||||
if (a.title < b.title) {
|
if (a.title < b.title) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@ -387,8 +398,9 @@ export default defineNuxtComponent({
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
break
|
||||||
case 'Status':
|
case 'Status':
|
||||||
return projects.slice().sort((a, b) => {
|
sortedArray = projects.slice().sort((a, b) => {
|
||||||
if (a.status < b.status) {
|
if (a.status < b.status) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@ -397,8 +409,9 @@ export default defineNuxtComponent({
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
break
|
||||||
case 'Type':
|
case 'Type':
|
||||||
return projects.slice().sort((a, b) => {
|
sortedArray = projects.slice().sort((a, b) => {
|
||||||
if (a.project_type < b.project_type) {
|
if (a.project_type < b.project_type) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@ -407,9 +420,16 @@ export default defineNuxtComponent({
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (descending) {
|
||||||
|
sortedArray = sortedArray.reverse()
|
||||||
|
}
|
||||||
|
|
||||||
|
return sortedArray
|
||||||
},
|
},
|
||||||
async bulkEditLinks() {
|
async bulkEditLinks() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user