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();
|
$image->saveOrFail();
|
||||||
return "OK";
|
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,26 +32,28 @@
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<form method="post" id="imageEditForm">
|
||||||
<img src="" id="imagePreview" style="width: 100%;">
|
@csrf
|
||||||
<input style="display: none;" name="name" id="edit-name" placeholder="Name" class="form-control">
|
<div class="modal-body">
|
||||||
<input style="display: none;" name="edit-id" id="edit-id" placeholder="ID" class="form-control">
|
<img src="" id="imagePreview" style="width: 100%;">
|
||||||
<b>Name</b>
|
<input style="display: none;" name="name" id="edit-name" placeholder="Name" class="form-control">
|
||||||
<input name="name" id="name" class="form-control">
|
<input style="display: none;" name="edit-id" id="edit-id" placeholder="ID" class="form-control">
|
||||||
<b>Beschreibung</b>
|
<b>Name</b>
|
||||||
<textarea name="description" class="form-control" id="description"></textarea>
|
<input name="name" id="name" class="form-control">
|
||||||
<b>Rating</b>
|
<b>Beschreibung</b>
|
||||||
<input name="rating" class="form-control" id="rating">
|
<textarea name="description" class="form-control" id="description"></textarea>
|
||||||
|
<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>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" id="deleteImage" class="btn btn-danger">Delete</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
<button type="button" id="makeGalleryDefault" class="btn btn-warning">Make Galery Preview</button>
|
<button type="button" id="saveForm" class="btn btn-success" data-dismiss="modal">Save</button>
|
||||||
|
</div>
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
</form>
|
||||||
<!--<button type="button" class="btn btn-primary">Save changes</button>!-->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -59,7 +61,9 @@
|
||||||
@endsection
|
@endsection
|
||||||
@section('js')
|
@section('js')
|
||||||
<script>
|
<script>
|
||||||
|
var g = null;
|
||||||
$(".editImage").click(function () {
|
$(".editImage").click(function () {
|
||||||
|
g = this
|
||||||
$("#imagePreview").attr("src", $(this).attr("x-image-url"));
|
$("#imagePreview").attr("src", $(this).attr("x-image-url"));
|
||||||
$("#edit-name").val($(this).attr("x-name"));
|
$("#edit-name").val($(this).attr("x-name"));
|
||||||
$("#edit-id").val($(this).attr("x-id"));
|
$("#edit-id").val($(this).attr("x-id"));
|
||||||
|
@ -78,6 +82,15 @@
|
||||||
alert("Image deleted");
|
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>
|
</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::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}/setDefault", [\App\Http\Controllers\GalleryController::class, 'setDefault']);
|
||||||
Route::get("/g/{url}/delete", [\App\Http\Controllers\GalleryController::class, 'deleteImage']);
|
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]);
|
Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||||
|
|
Loading…
Reference in a new issue