Skip to content

Commit 0179c0f

Browse files
committed
* Update user playlists page to add search playlists with matching videos function
1 parent b65f730 commit 0179c0f

File tree

4 files changed

+55
-16
lines changed

4 files changed

+55
-16
lines changed

src/renderer/views/UserPlaylists/UserPlaylists.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616
vertical-align: middle;
1717
}
1818

19+
.searchInputsRow {
20+
display: grid;
21+
22+
/* 2 columns */
23+
grid-template-columns: 1fr auto;
24+
column-gap: 16px;
25+
26+
@media only screen and (max-width: 800px) {
27+
/* Switch to 2 rows from 2 columns */
28+
grid-template-columns: auto;
29+
grid-template-rows: auto auto;
30+
}
31+
}
32+
1933
.sortSelect {
2034
/* Put it on the right */
2135
margin-inline-start: auto;

src/renderer/views/UserPlaylists/UserPlaylists.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import FtSelect from '../../components/ft-select/ft-select.vue'
1010
import FtElementList from '../../components/ft-element-list/ft-element-list.vue'
1111
import FtInput from '../../components/ft-input/ft-input.vue'
1212
import FtIconButton from '../../components/ft-icon-button/ft-icon-button.vue'
13+
import FtToggleSwitch from '../../components/ft-toggle-switch/ft-toggle-switch.vue'
1314

1415
const SORT_BY_VALUES = {
1516
NameAscending: 'name_ascending',
@@ -37,6 +38,7 @@ export default defineComponent({
3738
'ft-element-list': FtElementList,
3839
'ft-icon-button': FtIconButton,
3940
'ft-input': FtInput,
41+
'ft-toggle-switch': FtToggleSwitch,
4042
},
4143
data: function () {
4244
return {
@@ -45,6 +47,7 @@ export default defineComponent({
4547
searchDataLimit: 100,
4648
showLoadMoreButton: false,
4749
query: '',
50+
doSearchPlaylistsWithMatchingVideos: false,
4851
activeData: [],
4952
sortBy: SORT_BY_VALUES.LatestPlayedFirst,
5053
}
@@ -165,6 +168,10 @@ export default defineComponent({
165168
this.searchDataLimit = 100
166169
this.filterPlaylistAsync()
167170
},
171+
doSearchPlaylistsWithMatchingVideos() {
172+
this.searchDataLimit = 100
173+
this.filterPlaylistAsync()
174+
},
168175
fullData() {
169176
this.activeData = this.fullData
170177
this.filterPlaylist()
@@ -209,15 +216,22 @@ export default defineComponent({
209216
if (this.lowerCaseQuery === '') {
210217
this.activeData = this.fullData
211218
this.showLoadMoreButton = this.allPlaylists.length > this.activeData.length
212-
} else {
213-
const filteredPlaylists = this.allPlaylists.filter((playlist) => {
214-
if (typeof (playlist.playlistName) !== 'string') { return false }
215-
216-
return playlist.playlistName.toLowerCase().includes(this.lowerCaseQuery)
217-
})
218-
this.showLoadMoreButton = filteredPlaylists.length > this.searchDataLimit
219-
this.activeData = filteredPlaylists.length < this.searchDataLimit ? filteredPlaylists : filteredPlaylists.slice(0, this.searchDataLimit)
219+
return
220220
}
221+
222+
const filteredPlaylists = this.allPlaylists.filter((playlist) => {
223+
if (typeof (playlist.playlistName) !== 'string') { return false }
224+
225+
if (this.doSearchPlaylistsWithMatchingVideos) {
226+
if (playlist.videos.some((v) => v.title.toLowerCase().includes(this.lowerCaseQuery))) {
227+
return true
228+
}
229+
}
230+
231+
return playlist.playlistName.toLowerCase().includes(this.lowerCaseQuery)
232+
})
233+
this.showLoadMoreButton = filteredPlaylists.length > this.searchDataLimit
234+
this.activeData = filteredPlaylists.length < this.searchDataLimit ? filteredPlaylists : filteredPlaylists.slice(0, this.searchDataLimit)
221235
},
222236

223237
createNewPlaylist: function () {

src/renderer/views/UserPlaylists/UserPlaylists.vue

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,25 @@
1919
class="newPlaylistButton"
2020
@click="createNewPlaylist"
2121
/>
22-
<ft-input
22+
<div
2323
v-if="fullData.length > 1"
24-
ref="searchBar"
25-
:placeholder="$t('User Playlists.Search bar placeholder')"
26-
:show-clear-text-button="true"
27-
:show-action-button="false"
28-
@input="(input) => query = input"
29-
@clear="query = ''"
30-
/>
24+
class="searchInputsRow"
25+
>
26+
<ft-input
27+
ref="searchBar"
28+
:placeholder="$t('User Playlists.Search bar placeholder')"
29+
:show-clear-text-button="true"
30+
:show-action-button="false"
31+
@input="(input) => query = input"
32+
@clear="query = ''"
33+
/>
34+
<ft-toggle-switch
35+
:label="$t('User Playlists.Search in Videos')"
36+
:compact="true"
37+
:default-value="doSearchPlaylistsWithMatchingVideos"
38+
@change="doSearchPlaylistsWithMatchingVideos = !doSearchPlaylistsWithMatchingVideos"
39+
/>
40+
</div>
3141
<ft-select
3242
v-if="fullData.length > 1"
3343
class="sortSelect"

static/locales/en-US.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ User Playlists:
141141
You have no playlists. Click on the create new playlist button to create a new one.: You have no playlists. Click on the create new playlist button to create a new one.
142142
Empty Search Message: There are no videos in this playlist that matches your search
143143
Search bar placeholder: Search in Playlist
144+
Search in Videos: Search in Videos
144145

145146
This playlist currently has no videos.: This playlist currently has no videos.
146147

0 commit comments

Comments
 (0)