forked from rauversion/rauversion-phx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
playlists create form (rauversion#15)
* playlists form * playlist create and profile playlist view * playlist show * modal on the playlist * user suggestions * track component optimize query with likes & reposts * playlist likes + on_delete callbacks * playlist likes view implementation * move share track modal to its own component * share playlist btn/modal * move playlist load to the playlist list component * ga fix migrations * infinite scroll on playlists * remove handler on playlist list * edit playlist modal * edit playlist form * upload playlist cover * ci test * track live show
- Loading branch information
Showing
57 changed files
with
2,238 additions
and
336 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// taken from: https://elixircasts.io/infinite-scroll-with-liveview | ||
|
||
let scrollAt = () => { | ||
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop | ||
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight | ||
let clientHeight = document.documentElement.clientHeight | ||
|
||
return scrollTop / (scrollHeight - clientHeight) * 100 | ||
} | ||
|
||
InfiniteScroll = { | ||
page() { return this.el.dataset.page }, | ||
mounted(){ | ||
this.pending = this.page() | ||
|
||
const target = this.el.dataset.phxComponent | ||
window.addEventListener("scroll", e => { | ||
if(this.pending == this.page() && scrollAt() > 90){ | ||
console.log(this.el.dataset.paginateEnd) | ||
this.pending = this.page() | ||
this.pushEventTo(target, "paginate", {}) | ||
} | ||
}) | ||
}, | ||
reconnected(){ this.pending = this.page() }, | ||
updated(){ this.pending = this.page() } | ||
} | ||
|
||
export default InfiniteScroll |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
defmodule Rauversion.CategoryTypes do | ||
def genres do | ||
[ | ||
"Alternative Rock", | ||
"Ambient", | ||
"Classical", | ||
"Country ", | ||
"Dance & EDM", | ||
"Dancehall", | ||
"Deep House", | ||
"Disco", | ||
"Drum & Bass", | ||
"Dubstep", | ||
"Electronic", | ||
"Folk & Singer-Songwriter", | ||
"Hip-hop & Rap", | ||
"House", | ||
"Indie", | ||
"Jazz & Blues", | ||
"Latin", | ||
"Metal", | ||
"Piano", | ||
"Pop", | ||
"R&B & Soul", | ||
"Reggae", | ||
"Reggaeton", | ||
"Rock", | ||
"Soundtrack", | ||
"Techno", | ||
"Trance", | ||
"Trap", | ||
"Triphop", | ||
"World" | ||
] | ||
end | ||
|
||
def music_genres do | ||
[ | ||
"Audiobooks", | ||
"Business", | ||
"Comedy", | ||
"Entertainment", | ||
"Learning", | ||
"News & Politics", | ||
"Religion & Spirituality", | ||
"Science", | ||
"Sports", | ||
"Storytelling", | ||
"Technology" | ||
] | ||
end | ||
|
||
def playlist_types do | ||
[ | ||
"playlist", | ||
"album", | ||
"ep", | ||
"single", | ||
"compilation" | ||
] | ||
end | ||
end |
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,104 @@ | ||
defmodule Rauversion.PlaylistLikes do | ||
@moduledoc """ | ||
The PlaylistLikes context. | ||
""" | ||
|
||
import Ecto.Query, warn: false | ||
alias Rauversion.Repo | ||
|
||
alias Rauversion.PlaylistLikes.PlaylistLike | ||
|
||
@doc """ | ||
Returns the list of playlist_likes. | ||
## Examples | ||
iex> list_playlist_likes() | ||
[%PlaylistLike{}, ...] | ||
""" | ||
def list_playlist_likes do | ||
Repo.all(PlaylistLike) | ||
end | ||
|
||
@doc """ | ||
Gets a single playlist_like. | ||
Raises `Ecto.NoResultsError` if the Playlist like does not exist. | ||
## Examples | ||
iex> get_playlist_like!(123) | ||
%PlaylistLike{} | ||
iex> get_playlist_like!(456) | ||
** (Ecto.NoResultsError) | ||
""" | ||
def get_playlist_like!(id), do: Repo.get!(PlaylistLike, id) | ||
|
||
@doc """ | ||
Creates a playlist_like. | ||
## Examples | ||
iex> create_playlist_like(%{field: value}) | ||
{:ok, %PlaylistLike{}} | ||
iex> create_playlist_like(%{field: bad_value}) | ||
{:error, %Ecto.Changeset{}} | ||
""" | ||
def create_playlist_like(attrs \\ %{}) do | ||
%PlaylistLike{} | ||
|> PlaylistLike.changeset(attrs) | ||
|> Repo.insert() | ||
end | ||
|
||
@doc """ | ||
Updates a playlist_like. | ||
## Examples | ||
iex> update_playlist_like(playlist_like, %{field: new_value}) | ||
{:ok, %PlaylistLike{}} | ||
iex> update_playlist_like(playlist_like, %{field: bad_value}) | ||
{:error, %Ecto.Changeset{}} | ||
""" | ||
def update_playlist_like(%PlaylistLike{} = playlist_like, attrs) do | ||
playlist_like | ||
|> PlaylistLike.changeset(attrs) | ||
|> Repo.update() | ||
end | ||
|
||
@doc """ | ||
Deletes a playlist_like. | ||
## Examples | ||
iex> delete_playlist_like(playlist_like) | ||
{:ok, %PlaylistLike{}} | ||
iex> delete_playlist_like(playlist_like) | ||
{:error, %Ecto.Changeset{}} | ||
""" | ||
def delete_playlist_like(%PlaylistLike{} = playlist_like) do | ||
Repo.delete(playlist_like) | ||
end | ||
|
||
@doc """ | ||
Returns an `%Ecto.Changeset{}` for tracking playlist_like changes. | ||
## Examples | ||
iex> change_playlist_like(playlist_like) | ||
%Ecto.Changeset{data: %PlaylistLike{}} | ||
""" | ||
def change_playlist_like(%PlaylistLike{} = playlist_like, attrs \\ %{}) do | ||
PlaylistLike.changeset(playlist_like, attrs) | ||
end | ||
end |
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,17 @@ | ||
defmodule Rauversion.PlaylistLikes.PlaylistLike do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
schema "playlist_likes" do | ||
belongs_to :user, Rauversion.Accounts.User | ||
belongs_to :playlist, Rauversion.Playlists.Playlist | ||
timestamps() | ||
end | ||
|
||
@doc false | ||
def changeset(playlist_like, attrs) do | ||
playlist_like | ||
|> cast(attrs, [:user_id, :playlist_id]) | ||
|> validate_required([:user_id, :playlist_id]) | ||
end | ||
end |
Oops, something went wrong.