chg: [requestProcessor:user-registration] Slightly improved UI

pull/41/head
mokaddem 2021-03-16 08:45:37 +01:00
parent 77fe4e6505
commit 1729d4b6ed
2 changed files with 49 additions and 47 deletions

View File

@ -38,17 +38,13 @@ class RegistrationProcessor extends UserRequestProcessor implements GenericProce
protected function addValidatorRules($validator)
{
return $validator
->requirePresence('username')
->notEmpty('name', 'A username must be provided.')
->requirePresence('email')
->notEmpty('username', 'A username must be provided.')
->add('email', 'validFormat', [
'rule' => 'email',
'message' => 'E-mail must be valid'
])
->requirePresence('first_name')
->notEmpty('name', 'A first name must be provided.')
->requirePresence('last_name')
->notEmpty('name', 'A last name must be provided.');
->notEmpty('first_name', 'A first name must be provided')
->notEmpty('last_name', 'A last name must be provided');
}
public function create($requestData) {

View File

@ -1,4 +1,40 @@
<?php
$formUser = $this->element('genericElements/Form/genericForm', [
'entity' => $userEntity,
'ajax' => false,
'raw' => true,
'data' => [
'description' => __('Create user account'),
'model' => 'User',
'fields' => [
[
'field' => 'individual_id',
'type' => 'dropdown',
'label' => __('Associated individual'),
'options' => $dropdownData['individual'],
],
[
'field' => 'username',
'autocomplete' => 'off',
],
[
'field' => 'role_id',
'type' => 'dropdown',
'label' => __('Role'),
'options' => $dropdownData['role']
],
[
'field' => 'disabled',
'type' => 'checkbox',
'label' => 'Disable'
]
],
'submit' => [
'action' => $this->request->getParam('action')
]
]
]);
$formIndividual = $this->element('genericElements/Form/genericForm', [
'entity' => $individualEntity,
'ajax' => false,
@ -36,51 +72,15 @@
]
]);
$formUser = $this->element('genericElements/Form/genericForm', [
'entity' => $userEntity,
'ajax' => false,
'raw' => true,
'data' => [
'description' => __('Create user account'),
'model' => 'User',
'fields' => [
[
'field' => 'individual_id',
'type' => 'dropdown',
'label' => __('Associated individual'),
'options' => $dropdownData['individual'],
],
[
'field' => 'username',
'autocomplete' => 'off',
],
[
'field' => 'role_id',
'type' => 'dropdown',
'label' => __('Role'),
'options' => $dropdownData['role']
],
[
'field' => 'disabled',
'type' => 'checkbox',
'label' => 'Disable'
]
],
'submit' => [
'action' => $this->request->getParam('action')
]
]
]);
echo $this->Bootstrap->modal([
'title' => __('Register user'),
'size' => 'lg',
'type' => 'confirm',
'bodyHtml' => sprintf('<div class="individual-container">%s</div><div class="user-container">%s</div>',
$formIndividual,
$formUser
'bodyHtml' => sprintf('<div class="user-container">%s</div><div class="individual-container">%s</div>',
$formUser,
$formIndividual
),
'confirmText' => __('Submit'),
'confirmText' => __('Create user'),
'confirmFunction' => 'submitRegistration(clicked)'
]);
?>
@ -120,3 +120,9 @@
}, {})
}
</script>
<style>
div.individual-container > div, div.user-container > div {
font-size: 1.5rem;
}
</style>