Stuff
This commit is contained in:
parent
de07eee4d1
commit
b92a83554f
3 changed files with 47 additions and 19 deletions
|
@ -230,4 +230,18 @@ class GalleryController extends BaseController
|
|||
$image->saveOrFail();
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public function saveImage($name, Request $request) {
|
||||
$gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name);
|
||||
$image = Image::query()->where("id", "=", $request->input("id"))->firstOrFail();
|
||||
if($image->gallery != $gallery->id) {
|
||||
abort(400);
|
||||
}
|
||||
|
||||
$image->name = $request->input("name");
|
||||
$image->description = $request->input("description");
|
||||
$image->rating = $request->input("rating");
|
||||
$image->saveOrFail();
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form method="post" id="imageEditForm">
|
||||
@csrf
|
||||
<div class="modal-body">
|
||||
<img src="" id="imagePreview" style="width: 100%;">
|
||||
<input style="display: none;" name="name" id="edit-name" placeholder="Name" class="form-control">
|
||||
|
@ -40,18 +42,18 @@
|
|||
<input name="name" id="name" class="form-control">
|
||||
<b>Beschreibung</b>
|
||||
<textarea name="description" class="form-control" id="description"></textarea>
|
||||
<b>Rating</b>
|
||||
<b>Sorting</b>
|
||||
<input name="rating" class="form-control" id="rating">
|
||||
<hr>
|
||||
<button type="button" id="makeGalleryDefault" class="btn btn-warning" style="width: 100%;" data-dismiss="modal">Make Gallery Preview Image</button>
|
||||
<button type="button" id="deleteImage" class="btn btn-danger" style="width: 100%;" data-dismiss="modal">Delete</button>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="deleteImage" class="btn btn-danger">Delete</button>
|
||||
<button type="button" id="makeGalleryDefault" class="btn btn-warning">Make Galery Preview</button>
|
||||
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<!--<button type="button" class="btn btn-primary">Save changes</button>!-->
|
||||
|
||||
<button type="button" id="saveForm" class="btn btn-success" data-dismiss="modal">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -59,7 +61,9 @@
|
|||
@endsection
|
||||
@section('js')
|
||||
<script>
|
||||
var g = null;
|
||||
$(".editImage").click(function () {
|
||||
g = this
|
||||
$("#imagePreview").attr("src", $(this).attr("x-image-url"));
|
||||
$("#edit-name").val($(this).attr("x-name"));
|
||||
$("#edit-id").val($(this).attr("x-id"));
|
||||
|
@ -78,6 +82,15 @@
|
|||
alert("Image deleted");
|
||||
});
|
||||
});
|
||||
$("#saveForm").click(function () {
|
||||
var form = $("#imageEditForm").serialize();
|
||||
$.post("/g/{{ $gallery->url }}/save?id="+$("#edit-id").val(), form, function () {
|
||||
$(g).attr("data-name", $("#name").val());
|
||||
$(g).attr("data-rating", $("#rating").val());
|
||||
$(g).attr("data-description", $("#description").val());
|
||||
alert("Saved");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -44,6 +44,7 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function
|
|||
Route::post("/g/{url}/edit", [\App\Http\Controllers\GalleryController::class, 'editGallery']);
|
||||
Route::get("/g/{url}/setDefault", [\App\Http\Controllers\GalleryController::class, 'setDefault']);
|
||||
Route::get("/g/{url}/delete", [\App\Http\Controllers\GalleryController::class, 'deleteImage']);
|
||||
Route::post("/g/{url}/save", [\App\Http\Controllers\GalleryController::class, 'saveImage']);
|
||||
});
|
||||
|
||||
Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||
|
|
Loading…
Reference in a new issue