mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Fix editing of assets. This also uses the asset form request for validation.
This commit is contained in:
parent
044695cb02
commit
4e74c553bd
|
@ -296,7 +296,7 @@ class AssetsController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return Redirect
|
* @return Redirect
|
||||||
*/
|
*/
|
||||||
public function postEdit($assetId = null)
|
public function postEdit($assetId = null, AssetRequest $request)
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (is_null($asset = Asset::find($assetId))) {
|
if (is_null($asset = Asset::find($assetId))) {
|
||||||
|
@ -390,10 +390,11 @@ class AssetsController extends Controller
|
||||||
// Was the asset updated?
|
// Was the asset updated?
|
||||||
if ($asset->save()) {
|
if ($asset->save()) {
|
||||||
// Redirect to the new asset page
|
// Redirect to the new asset page
|
||||||
return redirect()->to("hardware/$assetId/view")->with('success', trans('admin/hardware/message.update.success'));
|
\Session::flash('success', trans('admin/hardware/message.update.success'));
|
||||||
|
return response()->json(['redirect_url' => route("view/hardware", $assetId)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back()->withInput()->withErrors($asset->getErrors());
|
return response()->json(['errors' => $asset->getErrors()]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -511,7 +511,7 @@ $(function () {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// AssetController flashes success to session, redirect to hardware page.
|
// AssetController flashes success to session, redirect to hardware page.
|
||||||
window.location.href = successRoute;
|
window.location.href = data.redirect_url;
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
// AssetRequest Validator will flash all errors to session, this just refreshes to see them.
|
// AssetRequest Validator will flash all errors to session, this just refreshes to see them.
|
||||||
|
|
Loading…
Reference in a new issue