From f12fe0047f3c46c143d64f2840d1be206b417914 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Thu, 24 May 2018 00:05:14 +0200 Subject: [PATCH] See #228: use action table component for federation library tracks --- .../federation/LibraryTrackTable.vue | 193 +++++++----------- 1 file changed, 73 insertions(+), 120 deletions(-) diff --git a/front/src/components/federation/LibraryTrackTable.vue b/front/src/components/federation/LibraryTrackTable.vue index ad8b801a6..551fb992a 100644 --- a/front/src/components/federation/LibraryTrackTable.vue +++ b/front/src/components/federation/LibraryTrackTable.vue @@ -16,89 +16,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- -
-
- -
-
- {{ track.title|truncate(30) }} - - {{ track.artist_name|truncate(30) }} - - {{ track.album_title|truncate(20) }} - - - - {{ track.library.actor.domain }} -
- + + + + + +
+ -
- {{ $t('Showing results {%start%}-{%end%} on {%total%}', {start: ((page-1) * paginateBy) + 1 , end: ((page-1) * paginateBy) + result.results.length, total: result.count})}} - - - - {{ $t('Import #{% id %} launched', {id: importBatch.id}) }} - -
+ + {{ $t('Showing results {%start%}-{%end%} on {%total%}', {start: ((page-1) * paginateBy) + 1 , end: ((page-1) * paginateBy) + result.results.length, total: result.count})}} + + @@ -107,6 +81,7 @@ import axios from 'axios' import _ from 'lodash' import Pagination from '@/components/Pagination' +import ActionTable from '@/components/common/ActionTable' export default { props: { @@ -114,7 +89,8 @@ export default { showLibrary: {type: Boolean, default: false} }, components: { - Pagination + Pagination, + ActionTable }, data () { return { @@ -123,9 +99,6 @@ export default { page: 1, paginateBy: 25, search: '', - checked: {}, - isImporting: false, - importBatch: null, importedFilter: null } }, @@ -153,47 +126,26 @@ export default { self.errors = error.backendErrors }) }, - launchImport () { - let self = this - self.isImporting = true - let payload = { - objects: this.checked, - action: 'import' - } - axios.post('/federation/library-tracks/action/', payload).then((response) => { - self.importBatch = response.data.result.batch - self.isImporting = false - self.fetchData() - }, error => { - self.isImporting = false - self.errors = error.backendErrors - }) - }, - toggleCheckAll () { - if (this.checked.length === this.result.results.length) { - // we uncheck - this.checked = [] - } else { - this.checked = this.result.results.filter(t => { - return t.local_track_file === null - }).map(t => { return t.id }) - } - }, - toggleCheck (id) { - if (this.checked.indexOf(id) > -1) { - // we uncheck - this.checked.splice(this.checked.indexOf(id), 1) - } else { - this.checked.push(id) - } - }, selectPage: function (page) { this.page = page } }, + computed: { + actionFilters () { + var currentFilters = { + q: this.search + } + if (this.filters) { + return _.merge(currentFilters, this.filters) + } else { + return currentFilters + } + } + }, watch: { search (newValue) { if (newValue.length > 0) { + this.page = 1 this.fetchData() } }, @@ -201,6 +153,7 @@ export default { this.fetchData() }, importedFilter () { + this.page = 1 this.fetchData() } }