aboutsummaryrefslogtreecommitdiff
path: root/src/site/components/image-modal/AlbumInfo.vue
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-22 02:12:24 +0300
committerZephyrrus <[email protected]>2020-07-22 02:12:24 +0300
commit1a4744de3cfe74524cd0415416fa9da0a322e86c (patch)
treeeb36db1cd890829a29668c3f006645276c9d141e /src/site/components/image-modal/AlbumInfo.vue
parentfeat: add experimental search parser (diff)
downloadhost.fuwn.me-1a4744de3cfe74524cd0415416fa9da0a322e86c.tar.xz
host.fuwn.me-1a4744de3cfe74524cd0415416fa9da0a322e86c.zip
feat: show selected albums first when modal is first opened
fix: change the color of the dropdown for tags to match the base theme chore: pass props into some of the components instead of fetching from store inside of components
Diffstat (limited to 'src/site/components/image-modal/AlbumInfo.vue')
-rw-r--r--src/site/components/image-modal/AlbumInfo.vue33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/site/components/image-modal/AlbumInfo.vue b/src/site/components/image-modal/AlbumInfo.vue
index 9d57e55..8974a11 100644
--- a/src/site/components/image-modal/AlbumInfo.vue
+++ b/src/site/components/image-modal/AlbumInfo.vue
@@ -13,12 +13,12 @@
</button>
<b-dropdown-item
- v-for="album in albums"
+ v-for="album in orderedAlbums"
:key="album.id"
:value="album.id"
aria-role="listitem"
@click="handleClick(album.id)">
- <span>{{ album. name }}</span>
+ <span>{{ album.name }}</span>
</b-dropdown-item>
</b-dropdown>
</template>
@@ -37,18 +37,37 @@ export default {
type: Array,
default: () => [],
},
+ albums: {
+ type: Array,
+ default: () => [],
+ },
},
data() {
return {
- selectedOptions: this.imageAlbums.map((e) => e.id),
+ selectedOptions: [],
+ orderedAlbums: [],
};
},
- computed: {
- ...mapState({
- albums: (state) => state.albums.tinyDetails,
- }),
+ created() {
+ this.orderedAlbums = this.getOrderedAlbums();
+ // we're sorting here instead of computed because we want sort on creation
+ // then the array's values should be frozen
+ this.selectedOptions = this.imageAlbums.map((e) => e.id);
},
methods: {
+ getOrderedAlbums() {
+ return [...this.albums].sort(
+ (a, b) => {
+ const selectedA = this.imageAlbums.findIndex(({ name }) => name === a.name) !== -1;
+ const selectedB = this.imageAlbums.findIndex(({ name }) => name === b.name) !== -1;
+
+ if (selectedA !== selectedB) {
+ return selectedA ? -1 : 1;
+ }
+ return a.name.localeCompare(b.name);
+ },
+ );
+ },
isAlbumSelected(id) {
if (!this.showingModalForFile) return false;
const found = this.showingModalForFile.albums.find((el) => el.id === id);