Fix page redirect after changing an organisation name (slug) from the organisation info page (Fixes #9)
This commit is contained in:
@@ -39,9 +39,13 @@ function attachOrganisationForm() {
|
|||||||
// Set up the form for submission
|
// Set up the form for submission
|
||||||
form.ufForm({
|
form.ufForm({
|
||||||
validator: page.validators
|
validator: page.validators
|
||||||
}).on("submitSuccess.ufForm", function() {
|
}).on("submitSuccess.ufForm", function(e, data) {
|
||||||
// Reload page on success
|
// Reload page on success
|
||||||
|
if (data.redirect) {
|
||||||
|
window.location = data.redirect;
|
||||||
|
} else {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,6 +268,8 @@ class OrganisationController extends SimpleController
|
|||||||
return $response->withJson([], 400);
|
return $response->withJson([], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$oldSlug = $organisation->slug;
|
||||||
|
|
||||||
// Begin transaction - DB will be rolled back if an exception occurs
|
// Begin transaction - DB will be rolled back if an exception occurs
|
||||||
Capsule::transaction(function () use ($data, $organisation, $currentUser) {
|
Capsule::transaction(function () use ($data, $organisation, $currentUser) {
|
||||||
// Update the organisation and generate success messages
|
// Update the organisation and generate success messages
|
||||||
@@ -290,8 +292,14 @@ class OrganisationController extends SimpleController
|
|||||||
'name' => $organisation->name,
|
'name' => $organisation->name,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($oldSlug != $organisation->slug) {
|
||||||
|
return $response->withJson([
|
||||||
|
'redirect' => $this->ci->router->pathFor('uri_organisation', ['slug' => $organisation->slug])
|
||||||
|
], 200);
|
||||||
|
} else {
|
||||||
return $response->withJson([], 200);
|
return $response->withJson([], 200);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the request to merge two organisations.
|
* Processes the request to merge two organisations.
|
||||||
@@ -997,7 +1005,8 @@ class OrganisationController extends SimpleController
|
|||||||
* @throws ForbiddenException If user is not authorized to access page
|
* @throws ForbiddenException If user is not authorized to access page
|
||||||
*/
|
*/
|
||||||
public function pageInfo(Request $request, Response $response, $args)
|
public function pageInfo(Request $request, Response $response, $args)
|
||||||
{ /** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager $authorizer */
|
{
|
||||||
|
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager $authorizer */
|
||||||
$authorizer = $this->ci->authorizer;
|
$authorizer = $this->ci->authorizer;
|
||||||
|
|
||||||
/** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */
|
/** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */
|
||||||
|
|||||||
Reference in New Issue
Block a user