#71: Albums edit page now shows if an album is inheriting permissions, and this can be changed on edit album screen

This commit is contained in:
Andy Heathershaw 2018-09-16 09:12:35 +01:00
parent 90e9061ebc
commit 9ad52359df
8 changed files with 157 additions and 79 deletions

View File

@ -21,7 +21,7 @@ class Album extends Model
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'name', 'description', 'url_alias', 'user_id', 'storage_id', 'default_view', 'parent_album_id', 'url_path' 'name', 'description', 'url_alias', 'user_id', 'storage_id', 'default_view', 'parent_album_id', 'url_path', 'is_permissions_inherited'
]; ];
/** /**

View File

@ -164,6 +164,7 @@ class AlbumController extends Controller
$albumService = new AlbumService(); $albumService = new AlbumService();
return Theme::render('admin.edit_album', [ return Theme::render('admin.edit_album', [
'active_tab' => $request->get('tab'),
'album' => $album, 'album' => $album,
'parent_albums' => $albumService->getFlattenedAlbumTree() 'parent_albums' => $albumService->getFlattenedAlbumTree()
]); ]);
@ -512,6 +513,7 @@ class AlbumController extends Controller
$currentParentID = $album->parent_album_id; $currentParentID = $album->parent_album_id;
$album->fill($request->only(['name', 'description', 'parent_album_id'])); $album->fill($request->only(['name', 'description', 'parent_album_id']));
$album->is_permissions_inherited = $request->has('is_permissions_inherited');
if (strlen($album->parent_album_id) == 0) if (strlen($album->parent_album_id) == 0)
{ {

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAlbumInheritPermissionsColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('albums', function (Blueprint $table)
{
$table->boolean('is_permissions_inherited')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('albums', function (Blueprint $table)
{
$table->dropColumn('is_permissions_inherited');
});
}
}

View File

@ -46,6 +46,24 @@ function AboutViewModel(urls) {
}; };
} }
/**
* This model is used by admin/edit_album.blade.php.
* @constructor
*/
function EditAlbumViewModel() {
this.el = '#edit-album-app';
this.data = {
parent_id: ''
};
this.computed = {
isParentAlbum: function() {
return this.parent_id == '';
}
}
}
/** /**
* This model is used by admin/settings.blade.php. * This model is used by admin/settings.blade.php.
* @constructor * @constructor

View File

@ -32,6 +32,8 @@ return [
'album_cameras_heading' => 'Cameras used in this album', 'album_cameras_heading' => 'Cameras used in this album',
'album_cameras_tab' => 'Cameras', 'album_cameras_tab' => 'Cameras',
'album_cameras_text' => 'Blue Twilight analyses the Exif data in your photos to determine which cameras have been used. The cameras that were found are displayed below.', 'album_cameras_text' => 'Blue Twilight analyses the Exif data in your photos to determine which cameras have been used. The cameras that were found are displayed below.',
'album_inheriting_permissions_p1' => 'Permissions inherited from parent album',
'album_inheriting_permissions_p2' => 'This album is inheriting permissions from its parent album. You can change the permissions applied to this album from the :l_parent_startparent album\'s permissions tab:l_parent_end. ',
'album_no_cameras_found_p1' => 'No cameras were found', 'album_no_cameras_found_p1' => 'No cameras were found',
'album_no_cameras_found_p2' => 'Upload more photos to this album or ensure the cameras you use support Exif image tagging.', 'album_no_cameras_found_p2' => 'Upload more photos to this album or ensure the cameras you use support Exif image tagging.',
'album_no_photos_p1' => 'No photos in this album', 'album_no_photos_p1' => 'No photos in this album',

View File

@ -26,6 +26,7 @@ return [
'edit_action' => 'Edit', 'edit_action' => 'Edit',
'email_label' => 'E-mail address:', 'email_label' => 'E-mail address:',
'enable_profile_page_label' => 'Allow others to see my profile page', 'enable_profile_page_label' => 'Allow others to see my profile page',
'inherit_album_permissions' => 'Inherit permissions from parent album',
'labels_label' => 'Labels:', 'labels_label' => 'Labels:',
'login_action' => 'Login', 'login_action' => 'Login',
'name_label' => 'Name:', 'name_label' => 'Name:',

View File

@ -10,7 +10,7 @@
@endsection @endsection
@section('content') @section('content')
<div class="container"> <div class="container" id="edit-album-app">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h1>@lang('admin.edit_album', ['album_name' => $album->name])</h1> <h1>@lang('admin.edit_album', ['album_name' => $album->name])</h1>
@ -46,14 +46,23 @@
<div class="form-group"> <div class="form-group">
<label class="form-control-label" for="parent-album">@lang('forms.parent_album_label')</label> <label class="form-control-label" for="parent-album">@lang('forms.parent_album_label')</label>
<select class="form-control" name="parent_album_id" id="parent-album"> <select class="form-control" name="parent_album_id" id="parent-album" v-model="parent_id">
<option value="">@lang('forms.parent_album_placeholder')</option> <option value="">@lang('forms.parent_album_placeholder')</option>
@foreach ($parent_albums as $key => $value) @foreach ($parent_albums as $key => $value)
<option value="{{ $key }}"{{ $key == $album->id || $value->isChildOf($album) ? ' disabled="disabled"' : '' }}{{ $key == old('parent_album_id') ? ' selected="selected"' : '' }}>{{ $value->display_name }}{{ $key == old('parent_album_id') ? ' ' . trans('forms.select_current_text') : '' }}</option> <option value="{{ $key }}"{{ $key == $album->id || $value->isChildOf($album) ? ' disabled="disabled"' : '' }}>{{ $value->display_name }}{{ $key == old('parent_album_id') ? ' ' . trans('forms.select_current_text') : '' }}</option>
@endforeach @endforeach
</select> </select>
</div> </div>
<div class="form-group" v-if="!isParentAlbum">
<div class="mt-3 form-check">
<input type="checkbox" class="form-check-input" id="inherit-permissions" name="is_permissions_inherited"{{ $album->is_permissions_inherited ? ' checked="checked"' : '' }}>
<label class="form-check-label" for="inherit-permissions">
<strong>@lang('forms.inherit_album_permissions')</strong>
</label>
</div>
</div>
<div id="change-parent-warning" class="alert alert-warning" style="display: none;"> <div id="change-parent-warning" class="alert alert-warning" style="display: none;">
@lang('admin.edit_album_change_parent_warning') @lang('admin.edit_album_change_parent_warning')
@ -77,7 +86,12 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
var editAlbumViewModel = new EditAlbumViewModel();
editAlbumViewModel.data.parent_id = '{{ old('parent_album_id', $album->parent_album_id) }}';
$(document).ready(function() { $(document).ready(function() {
var app = new Vue(editAlbumViewModel);
// Show the change parent warning // Show the change parent warning
var current_parent_id = '{{ $album->parent_album_id }}'; var current_parent_id = '{{ $album->parent_album_id }}';
$('#parent-album').change(function() { $('#parent-album').change(function() {

View File

@ -3,6 +3,12 @@
<p>@lang('admin.security_text')</p> <p>@lang('admin.security_text')</p>
<hr/> <hr/>
@if ($album->is_permissions_inherited)
<div class="text-center mt-4">
<h4 class="text-success"><b>@lang('admin.album_inheriting_permissions_p1')</b></h4>
<p class="mb-0">@lang('admin.album_inheriting_permissions_p2', ['l_parent_start' => '<a href="' . route('albums.show', [$album->parent_album_id]) . '?tab=permissions">', 'l_parent_end' => '</a>'])</p>
</div>
@else
<h5 style="font-weight: bold;">@lang('admin.security_groups_heading')</h5> <h5 style="font-weight: bold;">@lang('admin.security_groups_heading')</h5>
<form action="{{ route('albums.set_group_permissions', ['id' => $album->id]) }}" method="post"> <form action="{{ route('albums.set_group_permissions', ['id' => $album->id]) }}" method="post">
@ -86,4 +92,5 @@
</div> </div>
</div> </div>
</form> </form>
@endif
</div> </div>