Skip to content

Commit

Permalink
fix: wrong selection list behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Aug 8, 2019
1 parent b9d307d commit feb8ee9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
29 changes: 24 additions & 5 deletions src/renderer/windows/main/ModSettingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
<v-flex d-flex xs6 style="padding-right: 5px;">
<v-card dark class="card-list" @drop="onDropLeft" @dragover="onDragOver" @mousewheel="onMouseWheel">
<v-card-title>
<span class="text-sm-center" style="width: 100%; font-size: 16px;"> {{ $t('mod.unselected') }} </span>
<span v-if="filteringSpecModVersion === ''" class="text-sm-center" style="width: 100%; font-size: 16px;">
{{ $t('mod.unselected') }}
</span>
<v-chip v-else outline color="white" class="text-sm-center" close label @input="filteringSpecModVersion = ''">
{{ $t('mod.backToAllMods') }}
</v-chip>
</v-card-title>
<p v-if="mods[1].length === 0" class="text-xs-center headline"
style="position: absolute; top: 120px; right: 0px; user-select: none;">
Expand All @@ -24,8 +29,8 @@
<mod-card v-for="(mod, index) in unselectedMods" :key="mod.hash" v-observe-visibility="{
callback: (v) => checkBuffer(v, index, false),
once: true,
}" :data="mod"
:is-selected="false" :index="index" :hash="mod.hash" />
}" :data="mod" :is-selected="false"
:index="index" :hash="mod.hash" @click="showOnlyThisMod(mod)" />
</div>
</v-card>
</v-flex>
Expand Down Expand Up @@ -65,13 +70,21 @@ export default {
return {
refreshing: false,
filterInCompatible: true,
filterNonMatchedMinecraftVersion: false,
filterText: '',
filteringSpecModVersion: '',
};
},
computed: {
profile() { return this.$repo.getters.selectedProfile; },
unselectedMods() {
return this.mods[1].filter(m => this.filterMod(this.filterText, m))
if (this.filteringSpecModVersion !== '') {
return this.mods[1].filter(m => m.metadata[0].modid === this.filteringSpecModVersion);
}
return this.mods[1]
.filter(m => this.filterMod(this.filterText, m))
.filter((_, i) => i < this.unselectedBuffer);
},
selectedMods() {
Expand All @@ -86,7 +99,10 @@ export default {
},
},
unselectedItems() {
return this.mods[1];
return this.unselectedMods;
},
selecetedItems() {
return this.selectedMods;
},
mods() {
const mods = this.$repo.getters.mods;
Expand All @@ -108,6 +124,9 @@ export default {
mounted() {
},
methods: {
showOnlyThisMod(modRes) {
this.filteringSpecModVersion = modRes.metadata[0].modid;
},
dropFile(path) {
this.$repo.dispatch('importResource', { path }).catch((e) => { console.error(e); });
},
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/windows/main/ResourcePackSettingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export default {
return [selectedPacks, unselectedPacks];
},
unselectedItems() {
return this.resourcePacks[1];
return this.unselectedPacks;
},
selecetedItems() {
return this.selectedPacks;
},
items: {
get() {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/windows/main/components/ModCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<template v-slot:activator="{ on }">
<v-card color="darken-1" flat hover :class="{ incompatible: !compatible }"
class="draggable-card mod-card white--text" style="margin-top: 10px; padding: 0 10px;"
draggable v-on="on" @dragstart="onDragStart" @dblclick="tryOpen">
draggable v-on="on" @dragstart="onDragStart" @dblclick="tryOpen" @click="$emit('click', $event)">
<v-layout justify-center align-center fill-height>
<v-flex v-if="icon" xs4 style="padding: 0 10px 0 0;" fill-height>
<v-img :src="icon" style="height: 100%" contain />
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/windows/main/mixin/SelectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default {
doInsert(index, toIndex) {
if (index === toIndex) return;
const items = [...this.items || []];
console.log('insert');
const inserted = items.splice(index, 1);
items.splice(toIndex, 0, ...inserted);
this.items = items;
Expand All @@ -39,8 +38,10 @@ export default {
this.items = items;
},
doUnselect(index) {
const items = [...this.items || []];
Vue.delete(items, index);
const selecetedItems = [...this.selecetedItems || []];
const willDelete = selecetedItems[index];
const items = [...this.items];
Vue.delete(items, items.indexOf(this.mapItem(willDelete)));
this.items = items;
},
mapItem(i) {
Expand Down

0 comments on commit feb8ee9

Please sign in to comment.