Re-jigged some of the registration routes and modified the buttons/links to use them
This commit is contained in:
@@ -46,6 +46,48 @@ function attachOrganisationForm() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Approve/Reject organisation
|
||||||
|
*/
|
||||||
|
function approveOrganisation(slug, approve, options) {
|
||||||
|
var data = {};
|
||||||
|
data[site.csrf.keys.name] = site.csrf.name;
|
||||||
|
data[site.csrf.keys.value] = site.csrf.value;
|
||||||
|
|
||||||
|
var url = site.uri.public + '/api/organisations/o/' + slug + '/registration/' + (approve ? 'approve' : 'reject');
|
||||||
|
var debugAjax = (typeof site !== "undefined") && site.debug.ajax;
|
||||||
|
|
||||||
|
return $.ajax({
|
||||||
|
type: "PUT",
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
dataType: debugAjax ? 'html' : 'json',
|
||||||
|
}).fail(function(jqXHR) {
|
||||||
|
// Error messages
|
||||||
|
if (debugAjax && jqXHR.responseText) {
|
||||||
|
document.write(jqXHR.responseText);
|
||||||
|
document.close();
|
||||||
|
} else {
|
||||||
|
console.log("Error (" + jqXHR.status + "): " + jqXHR.responseText);
|
||||||
|
|
||||||
|
// Display errors on failure
|
||||||
|
// TODO: ufAlerts widget should have a 'destroy' method
|
||||||
|
if (!$("#alerts-page").data('ufAlerts')) {
|
||||||
|
$("#alerts-page").ufAlerts();
|
||||||
|
} else {
|
||||||
|
$("#alerts-page").ufAlerts('clear');
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#alerts-page").ufAlerts('fetch').ufAlerts('render');
|
||||||
|
}
|
||||||
|
|
||||||
|
return jqXHR;
|
||||||
|
}).done(function(response) {
|
||||||
|
if (!approve && options.delete_redirect) window.location.href = options.delete_redirect;
|
||||||
|
else window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link organisation action buttons, for example in a table or on a specific organisation's page.
|
* Link organisation action buttons, for example in a table or on a specific organisation's page.
|
||||||
* @param {module:jQuery} el jQuery wrapped element to target.
|
* @param {module:jQuery} el jQuery wrapped element to target.
|
||||||
@@ -183,6 +225,20 @@ function bindOrganisationButtons(el, options) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Cancel a registration request
|
||||||
|
el.find('.js-organisation-approveRegistration').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
approveOrganisation($(this).data('slug'), true, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cancel a registration request
|
||||||
|
el.find('.js-organisation-rejectRegistration').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
approveOrganisation($(this).data('slug'), false, options);
|
||||||
|
});
|
||||||
|
|
||||||
// Delete organisation button
|
// Delete organisation button
|
||||||
el.find('.js-organisation-delete').click(function(e) {
|
el.find('.js-organisation-delete').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ return [
|
|||||||
'TOKEN_NOT_FOUND' => 'Approval token does not exist / Organisation is already approved/rejected.',
|
'TOKEN_NOT_FOUND' => 'Approval token does not exist / Organisation is already approved/rejected.',
|
||||||
'APPROVED' => 'You have successfully approved the organisation <strong>{{name}}</strong>.',
|
'APPROVED' => 'You have successfully approved the organisation <strong>{{name}}</strong>.',
|
||||||
'REJECTED' => 'You have successfully rejected the organisation <strong>{{name}}</strong>.',
|
'REJECTED' => 'You have successfully rejected the organisation <strong>{{name}}</strong>.',
|
||||||
|
'APPROVE' => 'Approve organisation',
|
||||||
|
'REJECT' => 'Reject organisation',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,20 @@ use UserFrosting\Sprinkle\Core\Util\NoCache;
|
|||||||
/*
|
/*
|
||||||
* Routes for organisation registration workflows.
|
* Routes for organisation registration workflows.
|
||||||
*/
|
*/
|
||||||
$app->group('/organisations', function () {
|
$app->group('/organisations/registration', function () {
|
||||||
$this->get('/registration/approve', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:approveToken');
|
$this->get('/approve', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:approveToken');
|
||||||
$this->get('/registration/reject', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:rejectToken');
|
$this->get('/reject', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:rejectToken');
|
||||||
|
|
||||||
$this->post('/o/{slug}/registration/approve', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:approve');
|
|
||||||
$this->post('/o/{slug}/registration/reject', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:reject');
|
|
||||||
})->add('authGuard')->add(new NoCache());
|
})->add('authGuard')->add(new NoCache());
|
||||||
|
|
||||||
$app->group('/api/organisations', function () {
|
$app->group('/api/organisations', function () {
|
||||||
$this->post('/register', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:register');
|
$this->post('/registeration', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:register');
|
||||||
$this->delete('/o/{slug}/registration', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:cancel');
|
})->add('authGuard')->add(new NoCache());
|
||||||
|
|
||||||
|
$app->group('/api/organisations/o/{slug}/registration', function () {
|
||||||
|
$this->put('/approve', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:approve');
|
||||||
|
$this->put('/reject', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:reject');
|
||||||
|
|
||||||
|
$this->delete('', 'UserFrosting\Sprinkle\Organisations\Controller\OrganisationRegistrationController:cancel');
|
||||||
})->add('authGuard')->add(new NoCache());
|
})->add('authGuard')->add(new NoCache());
|
||||||
|
|
||||||
$app->group('/modals/organisations', function () {
|
$app->group('/modals/organisations', function () {
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ class OrganisationRegistrationController extends SimpleController
|
|||||||
'name' => $organisation->name
|
'name' => $organisation->name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $response->withRedirect($this->ci->router->pathFor('uri_organisation', ['slug' => $organisation->slug]));
|
return $response->withJson([], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,7 +433,7 @@ class OrganisationRegistrationController extends SimpleController
|
|||||||
'name' => $organisation->name
|
'name' => $organisation->name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $response->withRedirect($this->ci->router->pathFor('uri_organisations'));
|
return $response->withJson([], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -572,7 +572,7 @@ class OrganisationRegistrationController extends SimpleController
|
|||||||
return $this->ci->view->render($response, 'modals/organisation.html.twig', [
|
return $this->ci->view->render($response, 'modals/organisation.html.twig', [
|
||||||
'organisation' => $organisation,
|
'organisation' => $organisation,
|
||||||
'form' => [
|
'form' => [
|
||||||
'action' => 'api/organisations/register',
|
'action' => 'api/organisations/registeration',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'fields' => $fields,
|
'fields' => $fields,
|
||||||
'submit_text' => $translator->translate('REGISTER'),
|
'submit_text' => $translator->translate('REGISTER'),
|
||||||
|
|||||||
@@ -57,11 +57,8 @@
|
|||||||
</h4>
|
</h4>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
{% if checkAccess('approve_organisation') %}
|
{% if checkAccess('approve_organisation') %}
|
||||||
<form method="POST">
|
<button type="button" class="btn btn-success js-organisation-approveRegistration" data-slug="{{organisation.slug}}">{{translate('APPROVE')}}</button>
|
||||||
{% include "forms/csrf.html.twig" %}
|
<button type="button" class="btn btn-danger js-organisation-rejectRegistration" data-slug="{{organisation.slug}}">{{translate('REJECT')}}</button>
|
||||||
<button type="submit" class="btn btn-success" formaction="{{site.uri.public}}/organisations/o/{{organisation.slug}}/registration/approve">{{translate('APPROVE')}}</button>
|
|
||||||
<button type="submit" class="btn btn-danger" formaction="{{site.uri.public}}/organisations/o/{{organisation.slug}}/registration/reject">{{translate('REJECT')}}</button>
|
|
||||||
</form>
|
|
||||||
{% elseif isOrganisationAdmin(organisation) %}
|
{% elseif isOrganisationAdmin(organisation) %}
|
||||||
<button type="button" class="btn btn-danger js-organisation-cancelRegistration" data-slug="{{organisation.slug}}">{{translate('CANCEL_REGISTRATION')}}</button>
|
<button type="button" class="btn btn-danger js-organisation-cancelRegistration" data-slug="{{organisation.slug}}">{{translate('CANCEL_REGISTRATION')}}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -91,6 +91,18 @@
|
|||||||
<i class="fas fa-edit"></i> {% endverbatim %}{{translate("ORGANISATION.EDIT")}}{% verbatim %}
|
<i class="fas fa-edit"></i> {% endverbatim %}{{translate("ORGANISATION.EDIT")}}{% verbatim %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{#ifx row.flag_approved '==' 0 }}
|
||||||
|
<li>
|
||||||
|
<a href="#" data-slug="{{row.slug}}" class="js-organisation-approveRegistration">
|
||||||
|
<i class="fas fa-thumbs-up"></i> {% endverbatim %}{{translate("ORGANISATION.APPROVAL.APPROVE")}}{% verbatim %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#" data-slug="{{row.slug}}" class="js-organisation-rejectRegistration">
|
||||||
|
<i class="fas fa-thumbs-down"></i> {% endverbatim %}{{translate("ORGANISATION.APPROVAL.REJECT")}}{% verbatim %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{/ifx }}
|
||||||
<li>
|
<li>
|
||||||
<a href="#" data-slug="{{row.slug}}" class="js-organisation-merge">
|
<a href="#" data-slug="{{row.slug}}" class="js-organisation-merge">
|
||||||
<i class="fas fa-object-group"></i> {% endverbatim %}{{translate("ORGANISATION.MERGE")}}{% verbatim %}
|
<i class="fas fa-object-group"></i> {% endverbatim %}{{translate("ORGANISATION.MERGE")}}{% verbatim %}
|
||||||
|
|||||||
Reference in New Issue
Block a user