mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-01-30 19:06:44 +01:00
#2: Nested all things account management under profile pages.
This commit is contained in:
parent
af760aa13f
commit
61e762dc13
10 changed files with 77 additions and 58 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace Poniverse\Ponyfm\Http\Controllers\Api\Web;
|
||||
|
||||
use Gate;
|
||||
use Poniverse\Ponyfm\Models\Album;
|
||||
use Poniverse\Ponyfm\Models\Comment;
|
||||
use Poniverse\Ponyfm\Models\Favourite;
|
||||
|
@ -158,7 +159,7 @@ class ArtistsController extends ApiControllerBase
|
|||
|
||||
return Response::json([
|
||||
'artist' => [
|
||||
'id' => (int)$user->id,
|
||||
'id' => $user->id,
|
||||
'name' => $user->display_name,
|
||||
'slug' => $user->slug,
|
||||
'is_archived' => (bool)$user->is_archived,
|
||||
|
@ -174,7 +175,10 @@ class ArtistsController extends ApiControllerBase
|
|||
'bio' => $user->bio,
|
||||
'mlpforums_username' => $user->username,
|
||||
'message_url' => $user->message_url,
|
||||
'user_data' => $userData
|
||||
'user_data' => $userData,
|
||||
'permissions' => [
|
||||
'edit' => Gate::allows('edit', $user)
|
||||
]
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
* @param string $roleName
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRole($roleName)
|
||||
public function hasRole($roleName):bool
|
||||
{
|
||||
foreach ($this->roles as $role) {
|
||||
if ($role->name === $roleName) {
|
||||
|
|
|
@ -31,4 +31,8 @@ class UserPolicy
|
|||
public function getImages(User $userToAuthorize, User $user) {
|
||||
return $userToAuthorize->id === $user->id || $userToAuthorize->hasRole('admin');
|
||||
}
|
||||
|
||||
public function edit(User $userToAuthorize, User $user) {
|
||||
return $userToAuthorize->id === $user->id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
<ul class="tabs">
|
||||
<li ng-class="{active: stateIncludes('account.tracks')}"><a href="/account/tracks">Tracks</a></li>
|
||||
<li ng-class="{active: stateIncludes('account.albums')}"><a href="/account/albums">Albums</a></li>
|
||||
<li ng-class="{active: stateIncludes('account.playlists')}"><a href="/account/playlists">Playlists</a></li>
|
||||
<li ng-class="{active: stateIncludes('account.settings')}"><a href="/account">Settings</a></li>
|
||||
<li ui-sref-active="active">
|
||||
<a ui-sref=".tracks">Tracks</a>
|
||||
</li>
|
||||
<li ui-sref-active="active">
|
||||
<a ui-sref=".albums">Albums</a>
|
||||
</li>
|
||||
<li ui-sref-active="active">
|
||||
<a ui-sref=".playlists">Playlists</a>
|
||||
</li>
|
||||
<li ui-sref-active="active">
|
||||
<a ui-sref=".settings">Settings</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ui-view></ui-view>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="list">
|
||||
<ul class="account-tracks-listing stretch-to-bottom">
|
||||
<li ng-repeat="track in tracks track by track.id" ng-class="{selected: track.id == data.selectedTrack.id, 'is-not-published': !track.is_published}">
|
||||
<a href="/account/tracks/edit/{{track.id}}" ng-click="selectTrack(track)">
|
||||
<a ui-sref=".edit({track_id: {{::track.id}}})" ng-click="selectTrack(track)">
|
||||
<img class="image" ng-src="{{track.cover_url}}" />
|
||||
<span class="title">{{track.title}}</span>
|
||||
<span class="published">{{track.created_at | date:'MM/dd/yyyy'}}</span>
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
<header>
|
||||
<h1>{{::artist.name}}</h1>
|
||||
<ul class="tabs">
|
||||
<li ng-class="{active: stateIncludes('content.artist.profile')}"><a ng-href="{{::artist.slug}}">Profile</a></li>
|
||||
<li ng-class="{active: stateIncludes('content.artist.content')}"><a ng-href="{{::artist.slug}}/content">Content</a></li>
|
||||
<li ng-hide="::artist.is_archived" ng-class="::{active: stateIncludes('content.artist.favourites')}">
|
||||
<a ng-href="{{::artist.slug}}/favourites">Favourites</a>
|
||||
<li ui-sref-active="active"><a ui-sref=".profile">Profile</a></li>
|
||||
<li ui-sref-active="active"><a ui-sref=".content">Content</a></li>
|
||||
<li ng-if="::!artist.is_archived" ui-sref-active="active">
|
||||
<a ui-sref=".favourites">Favourites</a>
|
||||
</li>
|
||||
<li ng-if="::artist.permissions.edit" ui-sref-active="active" ui-sref=".account"><a ui-sref=".account.settings">Manage Account</a></li>
|
||||
</ul>
|
||||
</header>
|
||||
<div class="stretch-to-bottom">
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
</div>
|
||||
<div class="span6 cover-image">
|
||||
<h2>Recent Tracks</h2>
|
||||
<pfm-tracks-list tracks="::artist.latest_tracks" class="two-columns no-artist" />
|
||||
<pfm-tracks-list tracks="::artist.latest_tracks" class="two-columns no-artist"></pfm-tracks-list>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</span>
|
||||
|
||||
<span ng-show="upload.success">
|
||||
<a href="/account/tracks/edit/{{upload.trackId}}" class="btn btn-small btn-primary">
|
||||
<a ui-sref="content.artist.account.tracks.edit({slug: auth.user.slug, track_id: upload.trackId})" class="btn btn-small btn-primary">
|
||||
Publish
|
||||
</a>
|
||||
{{upload.name}}
|
||||
|
|
|
@ -148,48 +148,6 @@ ponyfm.config [
|
|||
templateUrl: '/templates/uploader/index.html'
|
||||
controller: 'uploader'
|
||||
|
||||
# Account
|
||||
|
||||
state.state 'account',
|
||||
url: '/account'
|
||||
abstract: true
|
||||
templateUrl: '/templates/account/_layout.html'
|
||||
|
||||
state.state 'account.settings',
|
||||
url: ''
|
||||
templateUrl: '/templates/account/settings.html'
|
||||
controller: 'account-settings'
|
||||
|
||||
state.state 'account.tracks',
|
||||
url: '/tracks'
|
||||
templateUrl: '/templates/account/tracks.html'
|
||||
controller: 'account-tracks'
|
||||
|
||||
state.state 'account.tracks.edit',
|
||||
url: '/edit/:track_id'
|
||||
templateUrl: '/templates/account/track.html'
|
||||
controller: 'account-track'
|
||||
|
||||
state.state 'account.albums',
|
||||
url: '/albums'
|
||||
templateUrl: '/templates/account/albums.html'
|
||||
controller: 'account-albums'
|
||||
|
||||
state.state 'account.albums.create',
|
||||
url: '/create'
|
||||
templateUrl: '/templates/account/album.html'
|
||||
controller: 'account-albums-edit'
|
||||
|
||||
state.state 'account.albums.edit',
|
||||
url: '/edit/:album_id'
|
||||
templateUrl: '/templates/account/album.html'
|
||||
controller: 'account-albums-edit'
|
||||
|
||||
state.state 'account.playlists',
|
||||
url: '/playlists'
|
||||
templateUrl: '/templates/account/playlists.html'
|
||||
controller: 'account-playlists'
|
||||
|
||||
state.state 'favourites',
|
||||
url: '/account/favourites'
|
||||
abstract: true
|
||||
|
@ -368,6 +326,50 @@ ponyfm.config [
|
|||
templateUrl: '/templates/artists/favourites.html'
|
||||
controller: 'artist-favourites'
|
||||
|
||||
|
||||
# Account
|
||||
|
||||
state.state 'content.artist.account',
|
||||
url: '/account'
|
||||
abstract: true
|
||||
templateUrl: '/templates/account/_layout.html'
|
||||
|
||||
state.state 'content.artist.account.settings',
|
||||
url: ''
|
||||
templateUrl: '/templates/account/settings.html'
|
||||
controller: 'account-settings'
|
||||
|
||||
state.state 'content.artist.account.tracks',
|
||||
url: '/tracks'
|
||||
templateUrl: '/templates/account/tracks.html'
|
||||
controller: 'account-tracks'
|
||||
|
||||
state.state 'content.artist.account.tracks.edit',
|
||||
url: '/edit/:track_id'
|
||||
templateUrl: '/templates/account/track.html'
|
||||
controller: 'account-track'
|
||||
|
||||
state.state 'content.artist.account.albums',
|
||||
url: '/albums'
|
||||
templateUrl: '/templates/account/albums.html'
|
||||
controller: 'account-albums'
|
||||
|
||||
state.state 'content.artist.account.albums.create',
|
||||
url: '/create'
|
||||
templateUrl: '/templates/account/album.html'
|
||||
controller: 'account-albums-edit'
|
||||
|
||||
state.state 'content.artist.account.albums.edit',
|
||||
url: '/edit/:album_id'
|
||||
templateUrl: '/templates/account/album.html'
|
||||
controller: 'account-albums-edit'
|
||||
|
||||
state.state 'content.artist.account.playlists',
|
||||
url: '/playlists'
|
||||
templateUrl: '/templates/account/playlists.html'
|
||||
controller: 'account-playlists'
|
||||
|
||||
|
||||
location.html5Mode(true);
|
||||
$dialogProvider.options
|
||||
dialogFade: true
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{Auth::user()->url}}">Your Profile</a></li>
|
||||
<li ng-class="{active: stateIncludes('favourites')}"><a href="/account/favourites/tracks">Favourites</a></li>
|
||||
<li ng-class="{active: stateIncludes('account')}"><a href="/account/tracks">Account</a></li>
|
||||
<li ui-sref-active="active"><a ui-sref="content.artist.favourites({slug: auth.user.slug})">Favourites</a></li>
|
||||
<li ui-sref-active="active"><a ui-sref="content.artist.account.settings({slug: auth.user.slug})">Account</a></li>
|
||||
<li><a href="#" pfm-eat-click ng-click="logout()">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue