Skip to content

Commit

Permalink
Added CSV export. Closes #26.
Browse files Browse the repository at this point in the history
  • Loading branch information
joonaspaakko committed May 9, 2021
1 parent cee8ed8 commit b46860c
Show file tree
Hide file tree
Showing 16 changed files with 651 additions and 108 deletions.
21 changes: 16 additions & 5 deletions src/output-page/_components/aleNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</router-link>
</div>

<div class="text-button parent-item" v-if="$store.state.library.books">
<div class="text-button parent-item" v-if="$store.state.library.books && routeExists('anySubPage')">
<div class="icon" :class="{ 'router-link-active': $route.meta && $route.meta.subPage }">
<font-awesome fas icon="chevron-down" />
<span>Sub pages</span>
Expand All @@ -30,7 +30,7 @@
</router-link>
</div>

<div class="text-button" v-if="routeExists('series')">
<div class="text-button" v-if="routeExists('all-series')">
<router-link :to="{ name: 'all-series' }" @click.native="linkClicked('all-series')">
<div class="icon">
<font-awesome fas icon="list-ol" />
Expand Down Expand Up @@ -252,9 +252,20 @@ export default {
},
routeExists: function( name ) {
let test = this.$router.resolve({ name: name });
return test.resolved.matched.length > 0;
if ( name === 'anySubPage' ) {
let subPageStates = _.get( this.$store.state, 'library.extras.subPageStates' );
if ( !subPageStates ) { return true; }
else {
let foundEnabled = _.find( subPageStates, { enabled: true });
if ( foundEnabled ) {
return true;
}
}
}
else {
let test = this.$router.resolve({ name: name });
return test.resolved.matched.length > 0;
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/output-page/_components/alePages/aleCategories.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div id="ale-categories" class="box-layout-wrapper" v-if="categories">

<page-title :pageTitle="pageTitle" :pageSubTitle="pageSubTitle"></page-title>
<page-title v-if="pageTitle || pageSubTitle" :pageTitle="pageTitle" :pageSubTitle="pageSubTitle"></page-title>

<div
class="single-box"
Expand Down
82 changes: 2 additions & 80 deletions src/output-page/_components/alePages/aleGallery/aleListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import aleHeader from "./aleListView/aleHeader";
import aleListRow from "./aleListView/aleRow";
import lazy from "@output-snippets/lazy.vue";
import stringifyArray from "@output-mixins/stringifyArray";
import prepareKeys from "@output-mixins/prepareKeys.js";
export default {
name: "aleBooks",
Expand All @@ -59,7 +60,7 @@ export default {
aleListRow,
bookDetails: () => import( /* webpackChunkName: "book-Details" */ "./aleGridView/bookDetails"),
},
mixins: [stringifyArray],
mixins: [stringifyArray, prepareKeys],
data: function() {
return {
spreadsheetTop: 170,
Expand Down Expand Up @@ -122,85 +123,6 @@ export default {
}
},
prepareKeys: function() {
const vue = this;
let collection = _.get(this.$store.state, this.$store.state.collectionSource);
// Flattens all available keys into an array: ['title', 'sample'] ...etc
let keys = _.union(_.flatten(_.map(collection, e => _.keys(e))));
keys = keys.concat([
'isbn10',
'isbn13'
]);
// Here I make sure these keys get prioritized to the front of the table...
let priorityKeys = [
"added",
"title",
"series",
"bookNumbers",
"authors",
"narrators",
"categories",
"length",
"progress",
"releaseDate",
"publishers",
"myRating",
"rating",
"ratings",
"fromPlusCatalog",
"unavailable",
];
let leftoverKeys = _.remove(keys, function(key) {
return !_.includes(priorityKeys, key);
});
keys = priorityKeys.concat(leftoverKeys);
priorityKeys = null;
leftoverKeys = null;
// All the keys we don't want to show in the table
let removeKeys = [
"titleShort",
"sample",
"blurb",
"url",
"summary",
"moreLikeThis",
"peopleAlsoBought",
"asin",
"cover",
"sample", // Slipped into titleShort in prepareData() method so they can be in a fixed column together
"sample", // Slipped into titleShort in prepareData() method so they can be in a fixed column together
"cover", // Same...
"isbns",
// "added",
// "series",
// "authors",
// "narrators",
// "categories",
// "summary",
// "length",
// "progress",
// "releaseDate",
// "publishers",
// "myRating",
// "rating",
// "ratings",
// "downloaded",
// "format",
// "language",
// "favorite",
// "storePageMissing",
// "storePageChanged",
];
keys = _.remove(keys, function(key) {
return !_.includes(removeKeys, key);
});
return keys;
}
}
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default {
},
data: function() {
return {
bookUrl: "",
// bookUrl: "",
coverUrl: "",
coverUrl27: "",
bookTitle: "",
Expand All @@ -55,7 +55,7 @@ export default {
created: function() {
this.bookUrl = this.makeFullUrl(this.book.url);
// this.bookUrl = this.makeFullUrl(this.book.url);
this.coverUrl = this.makeCoverUrl(this.book.cover);
if (this.coverUrl) this.coverUrl27 = this.coverUrl.replace("_SL500_", "_SL27_");
this.bookTitle = this.book.title || this.book.titleShort;
Expand Down Expand Up @@ -87,7 +87,6 @@ export default {
case "authors":
case "narrators":
case "categories":
case "series":
case "publishers":
col.text = vue.stringifyArray(
vue.book[ key ],
Expand All @@ -96,6 +95,15 @@ export default {
);
break;
case "series":
var series = vue.book.series;
if ( series ) series = _.map(series, function( series ) {
let numbers = series.bookNumbers ? (' (book '+ series.bookNumbers.join(", ") +')') : '';
return series.name + numbers;
}).join(", ");
col.text = series || '';
break;
case "title":
col.text = vue.book[ key ] || vue.book.titleShort;
col.class += " sticky-col";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>

<page-title :pageTitle="pageTitle" :pageSubTitle="pageSubTitle"></page-title>
<page-title v-if="pageTitle || pageSubTitle" :pageTitle="pageTitle" :pageSubTitle="pageSubTitle"></page-title>

<div
id="ale-search-wrap"
Expand Down
18 changes: 13 additions & 5 deletions src/output-page/_components/aleSaveLocally.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<div class="inner-wrap">

<save-gallery></save-gallery>
<save-csv></save-csv>

<div class="close-btn" @click="modalOpen = false" v-shortkey.once="['esc']" @shortkey="modalOpen = false">
<font-awesome fas icon="times" />
Expand All @@ -25,11 +26,13 @@

<script>
import saveGallery from "@output-snippets/save-gallery.vue";
import saveCsv from "@output-snippets/save-csv.vue";
export default {
name: "aleSaveLocally",
components: {
saveGallery
saveGallery,
saveCsv,
},
data: function() {
return {
Expand Down Expand Up @@ -80,7 +83,7 @@ export default {
.inner-wrap {
height: unset;
display: inline-block;
display: inline-block !important;
font-size: 14px;
line-height: 17px;
font-weight: 300;
Expand Down Expand Up @@ -116,6 +119,10 @@ export default {
&:first-child {
border-top: none;
}
h2 svg {
padding-right: 5px;
}
}
h2 {
Expand All @@ -127,15 +134,16 @@ export default {
}
h3 {
font-size: 1.2em;
font-weight: 200;
font-weight: 400;
margin: 20px 0 0 0;
display: inline-block;
width: 100%;
}
.description {
font-size: 0.85em;
color: rgba(#fff, 0.45);
font-size: 0.9em;
color: rgba(#fff, 0.55);
font-weight: 400;
}
.options {
Expand Down
7 changes: 7 additions & 0 deletions src/output-page/_components/snippets/page-title.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export default {
document.title = 'ALE • ' + (( this.$route.meta.title === this.pageTitle ) ? this.pageTitle : (this.$route.meta.title + ': ' + this.pageTitle));
}
if ( this.pageTitle ) this.$store.commit('prop', { key: 'pageTitle', value: this.pageTitle });
},
beforeDestroy: function() {
this.$store.commit('prop', { key: 'pageTitle', value: null });
},
};
</script>

Expand Down
Loading

0 comments on commit b46860c

Please sign in to comment.