Select range of photos by pressing Shift (#159)
* Frontend: fix lazy loading for albums * Frontend: start working on a range select for photos * Frontend: add range select to tiles and details view * Frontend: remove keydown EventListener when component is destroyed
This commit is contained in:
parent
722f18ee5d
commit
73fc6ac5b3
|
@ -25,7 +25,7 @@
|
|||
v-bind:class="{ selected: $clipboard.has(photo) }"
|
||||
style="cursor: pointer"
|
||||
class="accent lighten-2"
|
||||
@click="openPhoto(index)"
|
||||
@click.exact="openPhoto(index)"
|
||||
|
||||
>
|
||||
<v-layout
|
||||
|
@ -41,7 +41,8 @@
|
|||
<v-btn v-if="hover || selection.length > 0" :flat="!hover" :ripple="false"
|
||||
icon large absolute
|
||||
class="p-photo-select"
|
||||
@click.stop.prevent="$clipboard.toggle(photo)">
|
||||
@click.shift.prevent="selectRange(photo)"
|
||||
@click.exact.stop.prevent="$clipboard.toggle(photo)">
|
||||
<v-icon v-if="selection.length && $clipboard.has(photo)" color="white" class="t-select t-on">check_circle</v-icon>
|
||||
<v-icon v-else color="accent lighten-3" class="t-select t-off">radio_button_off</v-icon>
|
||||
</v-btn>
|
||||
|
@ -93,6 +94,20 @@
|
|||
album: Object,
|
||||
},
|
||||
methods: {
|
||||
selectRange(photo) {
|
||||
var selection = this.$clipboard.getIds();
|
||||
if (selection.length) {
|
||||
var lastAddedId = selection[selection.length - 1];
|
||||
var rangeStart = this.photos.findIndex((photo) => photo.getId() == lastAddedId);
|
||||
var rangeEnd = this.photos.indexOf(photo);
|
||||
var photosToBeAdded = this.photos.slice(Math.min(rangeStart, rangeEnd), Math.max(rangeStart, rangeEnd) + 1);
|
||||
for (var photo of photosToBeAdded) {
|
||||
this.$clipboard.add(photo);
|
||||
}
|
||||
} else {
|
||||
this.$clipboard.add(photo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
aspect-ratio="1"
|
||||
class="accent lighten-2"
|
||||
style="cursor: pointer"
|
||||
@click="openPhoto(index)"
|
||||
@click.exact="openPhoto(index)"
|
||||
>
|
||||
<v-layout
|
||||
slot="placeholder"
|
||||
|
@ -40,7 +40,8 @@
|
|||
<v-btn v-if="hover || selection.length > 0" :flat="!hover" :ripple="false"
|
||||
icon small absolute
|
||||
class="p-photo-select"
|
||||
@click.stop.prevent="$clipboard.toggle(photo)">
|
||||
@click.shift.prevent="selectRange(photo)"
|
||||
@click.exact.stop.prevent="$clipboard.toggle(photo)">
|
||||
<v-icon v-if="selection.length && $clipboard.has(photo)" color="white" class="t-select t-on">check_circle</v-icon>
|
||||
<v-icon v-else color="accent lighten-3" class="t-select t-off">radio_button_off</v-icon>
|
||||
</v-btn>
|
||||
|
@ -70,6 +71,20 @@
|
|||
album: Object,
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
selectRange(photo) {
|
||||
var selection = this.$clipboard.getIds();
|
||||
if (selection.length) {
|
||||
var lastAddedId = selection[selection.length - 1];
|
||||
var rangeStart = this.photos.findIndex((photo) => photo.getId() == lastAddedId);
|
||||
var rangeEnd = this.photos.indexOf(photo);
|
||||
var photosToBeAdded = this.photos.slice(Math.min(rangeStart, rangeEnd), Math.max(rangeStart, rangeEnd) + 1);
|
||||
for (var photo of photosToBeAdded) {
|
||||
this.$clipboard.add(photo);
|
||||
}
|
||||
} else {
|
||||
this.$clipboard.add(photo);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
aspect-ratio="1"
|
||||
class="accent lighten-2"
|
||||
style="cursor: pointer"
|
||||
@click="openPhoto(index)"
|
||||
@click.exact="openPhoto(index)"
|
||||
>
|
||||
<v-layout
|
||||
slot="placeholder"
|
||||
|
@ -40,7 +40,8 @@
|
|||
<v-btn v-if="hover || selection.length > 0" :flat="!hover" :ripple="false"
|
||||
icon large absolute
|
||||
class="p-photo-select"
|
||||
@click.stop.prevent="$clipboard.toggle(photo)">
|
||||
@click.shift.prevent="selectRange(photo)"
|
||||
@click.exact.stop.prevent="$clipboard.toggle(photo)">
|
||||
<v-icon v-if="selection.length && $clipboard.has(photo)" color="white" class="t-select t-on">check_circle</v-icon>
|
||||
<v-icon v-else-if="!$clipboard.has(photo)" color="accent lighten-3" class="t-select t-off">radio_button_off</v-icon>
|
||||
</v-btn>
|
||||
|
@ -70,6 +71,20 @@
|
|||
album: Object,
|
||||
},
|
||||
methods: {
|
||||
selectRange(photo) {
|
||||
var selection = this.$clipboard.getIds();
|
||||
if (selection.length) {
|
||||
var lastAddedId = selection[selection.length - 1];
|
||||
var rangeStart = this.photos.findIndex((photo) => photo.getId() == lastAddedId);
|
||||
var rangeEnd = this.photos.indexOf(photo);
|
||||
var photosToBeAdded = this.photos.slice(Math.min(rangeStart, rangeEnd), Math.max(rangeStart, rangeEnd) + 1);
|
||||
for (var photo of photosToBeAdded) {
|
||||
this.$clipboard.add(photo);
|
||||
}
|
||||
} else {
|
||||
this.$clipboard.add(photo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -221,9 +221,18 @@
|
|||
}
|
||||
}).catch(() => this.loading = false);
|
||||
},
|
||||
onKeypress(event) {
|
||||
if (event.key == "Escape") {
|
||||
this.$clipboard.clear();
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.search();
|
||||
window.addEventListener('keydown', this.onKeypress);
|
||||
},
|
||||
destroyed() {
|
||||
window.removeEventListener('keydown', this.onKeypress);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue