Skip to content

Commit

Permalink
fix requested changes in review
Browse files Browse the repository at this point in the history
  • Loading branch information
ipula committed Oct 30, 2024
1 parent 23ceacb commit abadd5c
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 115 deletions.
4 changes: 2 additions & 2 deletions classes/components/forms/invitation/AcceptUserDetailsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
use PKP\components\forms\FormComponent;
use PKP\facades\Locale;

define('ACCEPT_FORM_USER_DETAILS', 'acceptUserDetails');
class AcceptUserDetailsForm extends FormComponent
{
public const ACCEPT_FORM_USER_DETAILS = 'acceptUserDetails';
/** @copydoc FormComponent::$id */
public $id = ACCEPT_FORM_USER_DETAILS;
public $id = self::ACCEPT_FORM_USER_DETAILS;

/** @copydoc FormComponent::$method */
public $method = 'POST';
Expand Down
7 changes: 3 additions & 4 deletions classes/components/forms/invitation/UserDetailsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;

define('FORM_USER_DETAILS', 'userDetails');
class UserDetailsForm extends FormComponent
{
public const FORM_USER_DETAILS = 'userDetails';
/** @copydoc FormComponent::$id */
public $id = FORM_USER_DETAILS;
public $id = self::FORM_USER_DETAILS;

/** @copydoc FormComponent::$method */
public $method = 'POST';
Expand All @@ -32,9 +32,8 @@ class UserDetailsForm extends FormComponent
*
* @param string $action URL to submit the form to
* @param array $locales Supported locales
* @param \PKP\context\Context $context Journal or Press to change settings for
*/
public function __construct($action, $locales, $context)
public function __construct(string $action, array $locales)
{
$this->action = $action;
$this->locales = $locales;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function getInvitation(): UserRoleAssignmentInvite
return $this->invitation;
}

/**
* Redirect to accept invitation page
* @param Request $request
* @return void
* @throws \Exception
*/
public function acceptHandle(Request $request): void
{
$templateMgr = TemplateManager::getManager($request);
Expand All @@ -39,7 +45,7 @@ public function acceptHandle(Request $request): void
$invitationModel = $this->invitation->invitationModel->toArray();
$user = $invitationModel['userId'] ?Repo::user()->get($invitationModel['userId']) : null;
$templateMgr->setState([
'steps' => $steps->getSteps($this->invitation, $context,$user),
'steps' => $steps->getSteps($this->invitation,$context,$user),
'primaryLocale' => $context->getData('primaryLocale'),
'pageTitle' => __('invitation.wizard.pageTitle'),
'invitationId' => (int)$request->getUserVar('id') ?: null,
Expand All @@ -52,10 +58,16 @@ public function acceptHandle(Request $request): void
$templateMgr->display('invitation/acceptInvitation.tpl');
}

/**
* Redirect to login page after decline invitation
* @param Request $request
* @return void
* @throws \Exception
*/
public function declineHandle(Request $request): void
{
if ($this->invitation->getStatus() !== InvitationStatus::PENDING) {
$request->getDispatcher()->handle404();
$request->getDispatcher()->handle404('The link is deactivated as the invitation was cancelled');
}

$context = $request->getContext();
Expand Down
11 changes: 11 additions & 0 deletions classes/invitation/sections/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function __construct(string $id, string $name, string $description, array
$this->recipients = $recipients;
}

/**
* @inheritDoc
*/
public function getState(): stdClass
{
$config = parent::getState();
Expand All @@ -59,6 +62,10 @@ public function getState(): stdClass
return $config;
}

/**
* Get all email recipients for email composer
* @return array
*/
protected function getRecipientOptions(): array
{
$recipientOptions = [];
Expand All @@ -75,6 +82,10 @@ protected function getRecipientOptions(): array
return $recipientOptions;
}

/**
* Get all email templates for email composer
* @return array
*/
protected function getEmailTemplates(): array
{
$request = Application::get()->getRequest();
Expand Down
4 changes: 4 additions & 0 deletions classes/invitation/sections/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function __construct(string $id, string $name, string $description, FormC
$this->form = $form;
}

/**
* @inheritDoc
* @throws Exception
*/
public function getState(): stdClass
{
$config = parent::getState();
Expand Down
7 changes: 6 additions & 1 deletion classes/invitation/sections/Sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ class Sections
public array $props = [];

/**
* @param string $id A unique id for this section
* @param string $name The name of this section
* @param string $type section type eg: form
* @param string $sectionComponent A vuejs component for this section
* @param string $description description of this section
*/
public function __construct(string $id, string $name, string $description = '', string $type, string $sectionComponent)
public function __construct(string $id, string $name, string $type, string $sectionComponent,string $description = '')
{
$this->id = $id;
$this->name = $name;
Expand Down
33 changes: 16 additions & 17 deletions classes/invitation/stepTypes/AcceptInvitationStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
namespace PKP\invitation\stepTypes;

use APP\facades\Repo;
use PKP\components\forms\invitation\AcceptUserDetailsForm;
use PKP\context\Context;
use PKP\invitation\core\Invitation;
Expand Down Expand Up @@ -56,9 +55,9 @@ private function verifyOrcidStep(): \stdClass
$sections = new Sections(
'userVerifyOrcid',
__('acceptInvitation.verifyOrcid.stepName'),
__('userInvitation.searchUser.stepDescription'),
'popup',
'AcceptInvitationVerifyOrcid'
'AcceptInvitationVerifyOrcid',
__('userInvitation.searchUser.stepDescription'),
);
$sections->addSection(
null,
Expand All @@ -69,10 +68,10 @@ private function verifyOrcidStep(): \stdClass
$step = new Step(
'verifyOrcid',
__('acceptInvitation.verifyOrcid.stepName'),
__('acceptInvitation.verifyOrcid.stepDescription'),
__('acceptInvitation.verifyOrcid.stepLabel'),
__('userInvitation.verifyOrcid.nextButtonLabel'),
'popup'
'popup',
__('acceptInvitation.verifyOrcid.stepDescription'),
);
$step->addSectionToStep($sections->getState());
return $step->getState();
Expand All @@ -86,9 +85,9 @@ private function userAccountDetailsStep(): \stdClass
$sections = new Sections(
'userCreateForm',
__('acceptInvitation.accountDetails.stepName'),
__('userInvitation.accountDetails.stepDescription'),
'form',
'AcceptInvitationUserAccountDetails'
'AcceptInvitationUserAccountDetails',
__('userInvitation.accountDetails.stepDescription'),
);
$sections->addSection(
null,
Expand All @@ -103,10 +102,10 @@ private function userAccountDetailsStep(): \stdClass
$step = new Step(
'userCreate',
__('acceptInvitation.accountDetails.stepName'),
__('acceptInvitation.accountDetails.stepDescription'),
__('acceptInvitation.accountDetails.stepLabel'),
__('acceptInvitation.accountDetails.nextButtonLabel'),
'form'
'form',
__('acceptInvitation.accountDetails.stepDescription'),
);
$step->addSectionToStep($sections->getState());
return $step->getState();
Expand All @@ -122,9 +121,9 @@ private function userDetailsStep(Context $context): \stdClass
$sections = new Sections(
'userCreateForm',
__('acceptInvitation.accountDetails.stepName'),
__('userInvitation.accountDetails.stepDescription'),
'form',
'AcceptInvitationUserDetailsForms'
'AcceptInvitationUserDetailsForms',
__('userInvitation.accountDetails.stepDescription'),
);
$sections->addSection(
new Form(
Expand All @@ -145,10 +144,10 @@ private function userDetailsStep(Context $context): \stdClass
$step = new Step(
'userDetails',
__('acceptInvitation.userDetails.stepName'),
__('acceptInvitation.userDetails.stepDescription'),
__('acceptInvitation.userDetails.stepLabel'),
__('acceptInvitation.userDetails.nextButtonLabel'),
'form'
'form',
__('acceptInvitation.userDetails.stepDescription'),
);
$step->addSectionToStep($sections->getState());
return $step->getState();
Expand All @@ -164,9 +163,9 @@ private function acceptInvitationReviewStep(Context $context): \stdClass
$sections = new Sections(
'userCreateRoles',
'',
'',
'table',
'AcceptInvitationReview'
'AcceptInvitationReview',
''
);
$sections->addSection(
new Form(
Expand All @@ -184,10 +183,10 @@ private function acceptInvitationReviewStep(Context $context): \stdClass
$step = new Step(
'userCreateReview',
__('acceptInvitation.detailsReview.stepName'),
__('acceptInvitation.detailsReview.stepDescription'),
__('acceptInvitation.detailsReview.stepLabel'),
__('acceptInvitation.detailsReview.nextButtonLabel'),
'review'
'review',
__('acceptInvitation.detailsReview.stepDescription'),
);
$step->addSectionToStep($sections->getState());
return $step->getState();
Expand Down
31 changes: 16 additions & 15 deletions classes/invitation/stepTypes/SendInvitationStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ private function invitationSearchUser(): stdClass
$sections = new Sections(
'searchUserForm',
__('userInvitation.searchUser.stepName'),
__('userInvitation.searchUser.stepDescription'),
'form',
'UserInvitationSearchFormStep',
true
__('userInvitation.searchUser.stepDescription'),
);
$sections->addSection(
null,
Expand All @@ -66,10 +65,10 @@ private function invitationSearchUser(): stdClass
$step = new Step(
'searchUser',
__('userInvitation.searchUser.stepName'),
__('userInvitation.searchUser.stepDescription'),
__('userInvitation.searchUser.stepLabel'),
__('userInvitation.searchUser.nextButtonLabel'),
'emptySection',
__('userInvitation.searchUser.stepDescription'),
true
);
$step->addSectionToStep($sections->getState());
Expand All @@ -94,29 +93,29 @@ private function invitationDetailsForm(Context $context): stdClass
$sections = new Sections(
'userDetails',
__('userInvitation.enterDetails.stepName'),
__('userInvitation.enterDetails.stepDescription'),
'form',
'UserInvitationDetailsFormStep'
'UserInvitationDetailsFormStep',
__('userInvitation.enterDetails.stepDescription'),
);
$sections->addSection(
new Form(
'userDetails',
__('userInvitation.enterDetails.stepName'),
__('userInvitation.enterDetails.stepDescription'),
new UserDetailsForm('users', $locales, $context),
new UserDetailsForm('users', $locales),
),
[
'validateFields' => [],
'userGroups' => $this->getAllUserGroup($context)
'userGroups' => $this->getAllUserGroups($context)
]
);
$step = new Step(
'userDetails',
__('userInvitation.enterDetails.stepName'),
__('userInvitation.enterDetails.stepDescription'),
__('userInvitation.enterDetails.stepLabel'),
__('userInvitation.enterDetails.nextButtonLabel'),
'form'
'form',
__('userInvitation.enterDetails.stepDescription'),
);
$step->addSectionToStep($sections->getState());
return $step->getState();
Expand All @@ -132,9 +131,9 @@ private function invitationInvitedEmail(Context $context): stdClass
$sections = new Sections(
'userInvitedEmail',
__('userInvitation.sendMail.stepLabel'),
__('userInvitation.sendMail.stepName'),
'email',
'UserInvitationEmailComposerStep'
'UserInvitationEmailComposerStep',
__('userInvitation.sendMail.stepName'),
);
$fakeInvitation = $this->getFakeInvitation();
$mailable = new UserRoleAssignmentInvitationNotify($context, $fakeInvitation);
Expand All @@ -157,19 +156,21 @@ private function invitationInvitedEmail(Context $context): stdClass
$step = new Step(
'userInvited',
__('userInvitation.sendMail.stepName'),
__('userInvitation.sendMail.stepDescription'),
__('userInvitation.sendMail.stepLabel'),
__('userInvitation.sendMail.nextButtonLabel'),
'email'
'email',
__('userInvitation.sendMail.stepDescription'),
);
$step->addSectionToStep($sections->getState());
return $step->getState();
}

/**
* get all user groups
* Get all user groups
* @param Context $context
* @return array
*/
private function getAllUserGroup(Context $context): array
private function getAllUserGroups(Context $context): array
{
$allUserGroups = [];
$userGroups = Repo::userGroup()->getCollector()
Expand Down
2 changes: 1 addition & 1 deletion classes/invitation/steps/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Step
* @param string $type A type of this step.
* @param bool $skipInvitationUpdate Skip invitation update.
*/
public function __construct(string $id, string $name, string $description = '', string $stepLabel, string $nextButtonLabel, string $type, bool $skipInvitationUpdate = false)
public function __construct(string $id, string $name, string $stepLabel, string $nextButtonLabel, string $type, string $description = '', bool $skipInvitationUpdate = false)
{
$this->id = $id;
$this->name = $name;
Expand Down
Loading

0 comments on commit abadd5c

Please sign in to comment.