Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
fix: topics list is sortable
Browse files Browse the repository at this point in the history
  • Loading branch information
villetakanen committed Dec 8, 2021
1 parent 49ebdda commit eeae50b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/assets/icons/dark/move-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/icons/light/move-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/material/iconslist.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"keeper",
"lightbulb",
"mekanismi",
"move-up",
"monsters",
"pages",
"pathfinder-logo",
Expand Down
22 changes: 19 additions & 3 deletions src/components/site/SiteCategoriesCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@

<List>
<ListItem
v-for="category in site.pageCategories"
v-for="(category, index) in site.pageCategories"
:key="category.slug"
>
{{ category.name }}
<template #action>
<Icon
v-if="index > 0"
small
name="move-up"
@click="moveUp(index)"
/>
<Button
text
@click.prevent="dropCategory(category.slug)"
Expand All @@ -20,7 +26,6 @@
xs
name="delete"
/>
{{ $t('action.delete') }}
</Button>
</template>
</ListItem>
Expand Down Expand Up @@ -83,7 +88,18 @@ export default defineComponent({
})
}
return { addCategory, site, newCatName, newCatSlug, dropCategory }
const moveUp = (index: number) => {
const newCategories = [...site.value.pageCategories]
const tmp = newCategories[index]
newCategories[index] = newCategories[index - 1]
newCategories[index - 1] = tmp
updateSite({
id: site.value.id,
pageCategories: newCategories
})
}
return { addCategory, site, newCatName, newCatSlug, dropCategory, moveUp }
}
})
</script>

0 comments on commit eeae50b

Please sign in to comment.