Fixed broken dataset rendering if key exists but is empty

This commit is contained in:
Joel Collins 2020-12-01 17:13:20 +00:00
parent ac667c3e2a
commit fd42e2e2b6

View file

@ -24,7 +24,7 @@
<a href="#">Filter</a> <a href="#">Filter</a>
<div <div
:class="{ :class="{
'uk-light uk-background-secondary': $store.state.darkMode 'uk-light uk-background-secondary': $store.state.darkMode,
}" }"
class="uk-navbar-dropdown" class="uk-navbar-dropdown"
> >
@ -159,7 +159,7 @@ export default {
captureCard, captureCard,
scanCard, scanCard,
ZipDownloader, ZipDownloader,
Paginate Paginate,
}, },
data: function () { data: function () {
@ -171,7 +171,7 @@ export default {
scanTag: "scan", scanTag: "scan",
unwatchStoreFunction: null, unwatchStoreFunction: null,
maxitems: 10, maxitems: 10,
page: 1 page: 1,
}; };
}, },
@ -197,7 +197,11 @@ export default {
var captures = []; var captures = [];
for (var capture of this.captures) { for (var capture of this.captures) {
// Add to capture list if matched // Add to capture list if matched
if (!capture.dataset) { if (
!capture.dataset || // If no dataset key
(capture.dataset.constructor === Object && // Or dataset is an object...
Object.keys(capture.dataset).length === 0) // ...but it's empty
) {
captures.push(capture); captures.push(capture);
} }
} }
@ -300,7 +304,7 @@ export default {
numberOfPages: function () { numberOfPages: function () {
return Math.floor(this.sortedItems.length / this.maxitems); return Math.floor(this.sortedItems.length / this.maxitems);
} },
}, },
mounted() { mounted() {
@ -318,7 +322,7 @@ export default {
(state, getters) => { (state, getters) => {
return getters.ready; return getters.ready;
}, },
ready => { (ready) => {
if (ready) { if (ready) {
// If the connection is now ready, update capture list // If the connection is now ready, update capture list
this.updateCaptures(); this.updateCaptures();
@ -352,10 +356,10 @@ export default {
if (this.$store.state.available) { if (this.$store.state.available) {
axios axios
.get(this.capturesUri) .get(this.capturesUri)
.then(response => { .then((response) => {
this.captures = response.data; this.captures = response.data;
}) })
.catch(error => { .catch((error) => {
this.modalError(error); // Let mixin handle error this.modalError(error); // Let mixin handle error
}); });
} }
@ -370,7 +374,7 @@ export default {
// Filter by selected tags // Filter by selected tags
var tags = capture.tags; var tags = capture.tags;
let checker = (arr, target) => target.every(v => arr.includes(v)); let checker = (arr, target) => target.every((v) => arr.includes(v));
// True if all tags match // True if all tags match
includeCapture = checker(tags, filterTags); includeCapture = checker(tags, filterTags);
@ -405,8 +409,8 @@ export default {
selectFolder: function (folderID) { selectFolder: function (folderID) {
this.galleryFolder = folderID; this.galleryFolder = folderID;
} },
} },
}; };
</script> </script>