-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Replicate) Push up batch 3 of playlist functionality
- Loading branch information
1 parent
b44b1c5
commit 370b9e2
Showing
23 changed files
with
627 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
This file is part of FreeTube. | ||
FreeTube is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
FreeTube is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with FreeTube. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* | ||
* Credit goes to pavelvaravko for making this css. | ||
* https://codepen.io/pavelvaravko/pen/qjojOr | ||
*/ | ||
|
||
/* select starting stylings ------------------------------*/ | ||
.center { | ||
text-align: center; | ||
} | ||
|
||
.playlistNameInput { | ||
width: 80%; | ||
max-width: 600px; | ||
} |
93 changes: 93 additions & 0 deletions
93
src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import Vue from 'vue' | ||
import { mapActions } from 'vuex' | ||
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue' | ||
import FtPrompt from '../ft-prompt/ft-prompt.vue' | ||
import FtButton from '../ft-button/ft-button.vue' | ||
import FtInput from '../ft-input/ft-input.vue' | ||
import FtPlaylistSelector from '../ft-playlist-selector/ft-playlist-selector.vue' | ||
|
||
export default Vue.extend({ | ||
name: 'FtCreatePlaylistPrompt', | ||
components: { | ||
FtFlexBox, | ||
FtPrompt, | ||
FtButton, | ||
FtInput, | ||
FtPlaylistSelector | ||
}, | ||
data: function () { | ||
return { | ||
playlistName: '', | ||
playlistAddVideoPromptValues: [ | ||
'save', | ||
'cancel' | ||
], | ||
selectedPlaylists: [] | ||
} | ||
}, | ||
computed: { | ||
allPlaylists: function () { | ||
return this.$store.getters.getAllPlaylists | ||
}, | ||
newPlaylistVideoObject: function () { | ||
return this.$store.getters.getNewPlaylistVideoObject | ||
}, | ||
videoImportLength: function () { | ||
return this.newPlaylistVideoObject.videos.length | ||
} | ||
}, | ||
mounted: function () { | ||
this.playlistName = this.newPlaylistVideoObject.title | ||
}, | ||
methods: { | ||
handleCreatePlaylistPrompt: function (option) { | ||
this.hideCreatePlaylistPrompt() | ||
}, | ||
|
||
createNewPlaylist: function () { | ||
const videosObject = this.videoImportLength > 0 ? this.newPlaylistVideoObject.videos : [] | ||
|
||
const playlistObject = { | ||
playlistName: this.playlistName, | ||
protected: false, | ||
removeOnWatched: false, | ||
description: '', | ||
videos: videosObject | ||
} | ||
|
||
const nameExists = this.allPlaylists.findIndex((playlist) => { | ||
return playlist.playlistName.toLowerCase() === this.playlistName.toLowerCase() | ||
}) | ||
|
||
if (this.playlistName === '') { | ||
this.showToast({ | ||
message: 'Playlist name cannot be empty. Please input a name.' | ||
}) | ||
} else if (nameExists !== -1) { | ||
this.showToast({ | ||
message: 'There is already a playlist with this name. Please pick a different name.' | ||
}) | ||
} else { | ||
try { | ||
this.addPlaylist(playlistObject) | ||
this.showToast({ | ||
message: `Playlist ${this.playlistName} has been successfully created.` | ||
}) | ||
} catch (e) { | ||
this.showToast({ | ||
message: 'There was an issue with creating the playlist.' | ||
}) | ||
console.error(e) | ||
} finally { | ||
this.hideCreatePlaylistPrompt() | ||
} | ||
} | ||
}, | ||
|
||
...mapActions([ | ||
'showToast', | ||
'addPlaylist', | ||
'hideCreatePlaylistPrompt' | ||
]) | ||
} | ||
}) |
39 changes: 39 additions & 0 deletions
39
src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<ft-prompt | ||
@click="handleCreatePlaylistPrompt" | ||
> | ||
<h2 class="center"> | ||
New Playlist Name | ||
</h2> | ||
<ft-flex-box> | ||
<ft-input | ||
placeholder="Playlist Name" | ||
:show-action-button="false" | ||
:show-label="false" | ||
:value="playlistName" | ||
class="playlistNameInput" | ||
@input="(input) => playlistName = input" | ||
@click="createNewPlaylist" | ||
/> | ||
</ft-flex-box> | ||
<p | ||
v-if="videoImportLength > 0" | ||
class="center" | ||
> | ||
{{ videoImportLength }} video(s) will also be imported when created | ||
</p> | ||
<ft-flex-box> | ||
<ft-button | ||
label="Create" | ||
@click="createNewPlaylist" | ||
/> | ||
<ft-button | ||
label="Cancel" | ||
@click="handleCreatePlaylistPrompt(null)" | ||
/> | ||
</ft-flex-box> | ||
</ft-prompt> | ||
</template> | ||
|
||
<script src="./ft-create-playlist-prompt.js" /> | ||
<style scoped src="./ft-create-playlist-prompt.css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.