Skip to content

Commit

Permalink
#10444 Improve dialog component design (#10510)
Browse files Browse the repository at this point in the history
* #10444 Remove titleIcon and instead add modalStyle param the to Modal classes

* #10444 Add modalStyle to template files that use dialog component

* #10444 Use isWarnable button when using 'negative' modalStyle

* #10444 Define modalStyle when using dialog component

* #10444 Add modalStyle when using AjaxModal

* #10444 Add modalStyle when using ConfirmationModal modal

* #10444 Add modalStyle when using RedirectConfirmationModal modal

* #10444 Add notes for modalStyle parameter to FormBuilderVocabulary.php and formButtons template

* #10444 Add modalStyle when using RemoteActionConfirmationModal modal

* #10444 Add modalStyle when using AjaxModal modal

* #10444 Remove unexpected comma on ConfirmationModalHandler.js file

* #10444 Update button click when showing an error on DOI modal

* #10444 DOI cypress - use correct text when clicking the button

* #10444 Use primary modal style when showing install confirmation modal

* #10444 Remove modalStyle param when using AjaxModal class

* #10444 Use modalStyle 'default' for Modal class

* #10444 Use basic modalStyle for legacy use of Dialog component

* #10444 Update documentation for Modal classes

* #10444 DOI - Cypress: Click button that contains text OK instead of Close
  • Loading branch information
blesildaramirez authored Nov 17, 2024
1 parent abaf70a commit 8355f0c
Show file tree
Hide file tree
Showing 76 changed files with 124 additions and 141 deletions.
1 change: 0 additions & 1 deletion classes/controllers/grid/plugins/PluginGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public function initialize($request, $args = null)
new AjaxModal(
$router->url($request, null, null, 'uploadPlugin'),
__('manager.plugins.upload'),
'modal_add_file'
),
__('manager.plugins.upload'),
'add'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ public function initialize($request, $args = null)
new AjaxModal(
$router->url($request, null, null, 'showReviewerForm', null, $actionArgs),
__('editor.submission.addReviewer'),
'modal_add_user'
),
__('editor.submission.addReviewer'),
'add_user'
Expand Down
2 changes: 2 additions & 0 deletions classes/form/FormBuilderVocabulary.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* hideCancel (optional): Whether the submit button should be disabled
* cancelAction (optional): A LinkAction object to execute when cancel is clicked
* cancelUrl (optional): URL to redirect to when cancel is clicked
* modalStyle (optional): The modal state/style that should be used. (default is 'basic')
* Form elements are created with {fbvElement type="type"} plus any additional parameters.
* Each specific element type may have other additional attributes (see their method comments)
* Parameters:
Expand Down Expand Up @@ -239,6 +240,7 @@ public function smartyFBVFormButtons($params, $smarty)
'FBV_cancelUrlTarget' => $params['cancelUrlTarget'] ?? '',
'FBV_translate' => $params['translate'] ?? true,
'FBV_saveText' => $params['saveText'] ?? null,
'FBV_modalStyle' => $params['modalStyle'] ?? null,
]);
return $smarty->fetch('form/formButtons.tpl');
}
Expand Down
6 changes: 3 additions & 3 deletions classes/linkAction/request/AjaxModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AjaxModal extends Modal
*
* @param string $url The URL of the AJAX resource to load into the modal.
* @param string $title (optional) The localized modal title.
* @param string $titleIcon (optional) The icon to be used in the modal title bar.
* @param string $modalStyle (optional) The modal state/style to be used. (default is 'basic')
* @param bool $canClose (optional) Whether the modal will have a close button.
* @param string $closeOnFormSuccessId (optional) Close the modal when the
* form with this id fires a formSuccess event.
Expand All @@ -35,12 +35,12 @@ class AjaxModal extends Modal
public function __construct(
$url,
$title = null,
$titleIcon = null,
$modalStyle = 'basic',
$canClose = true,
$closeOnFormSuccessId = null,
$closeCleanVueInstances = []
) {
parent::__construct($title, $titleIcon, $canClose, $closeOnFormSuccessId, $closeCleanVueInstances);
parent::__construct($title, $modalStyle, $canClose, $closeOnFormSuccessId, $closeCleanVueInstances);

$this->_url = $url;
}
Expand Down
7 changes: 3 additions & 4 deletions classes/linkAction/request/ConfirmationModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@ class ConfirmationModal extends Modal
* @param string $dialogText The localized text to appear
* in the dialog modal.
* @param string $title (optional) The localized modal title.
* @param string $titleIcon (optional) The icon to be used
* in the modal title bar.
* @param string $modalStyle (optional) The modal state/style to be used. (default is 'basic')
* @param string $okButton (optional) The localized text to
* appear on the confirmation button.
* @param string $cancelButton (optional) The localized text to
* appear on the cancel button.
* @param bool $canClose (optional) Whether the modal will
* have a close button.
*/
public function __construct($dialogText, $title = null, $titleIcon = 'modal_confirm', $okButton = null, $cancelButton = null, $canClose = true)
public function __construct($dialogText, $title = null, $modalStyle = 'basic', $okButton = null, $cancelButton = null, $canClose = true)
{
$title = (is_null($title) ? __('common.confirm') : $title);
parent::__construct($title, $titleIcon, $canClose);
parent::__construct($title, $modalStyle, $canClose);

$this->_okButton = (is_null($okButton) ? __('common.ok') : $okButton);
$this->_cancelButton = (is_null($cancelButton) ? __('common.cancel') : $cancelButton);
Expand Down
7 changes: 3 additions & 4 deletions classes/linkAction/request/JsEventConfirmationModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ class JsEventConfirmationModal extends ConfirmationModal
* @param string $event the name of the JS event.
* @param array $extraArguments (optional) extra information to be passed as JSON data with the event.
* @param string $title (optional) The localized modal title.
* @param string $titleIcon (optional) The icon to be used
* in the modal title bar.
* @param string $modalStyle (optional) The modal state/style to be used. (default is 'basic')
* @param string $okButton (optional) The localized text to
* appear on the confirmation button.
* @param string $cancelButton (optional) The localized text to
* appear on the cancel button.
* @param bool $canClose (optional) Whether the modal will
* have a close button.
*/
public function __construct($dialogText, $event = 'confirmationModalConfirmed', $extraArguments = null, $title = null, $titleIcon = null, $okButton = null, $cancelButton = null, $canClose = true)
public function __construct($dialogText, $event = 'confirmationModalConfirmed', $extraArguments = null, $title = null, $modalStyle = 'basic', $okButton = null, $cancelButton = null, $canClose = true)
{
parent::__construct($dialogText, $title, $titleIcon, $okButton, $cancelButton, $canClose);
parent::__construct($dialogText, $title, $modalStyle, $okButton, $cancelButton, $canClose);

$this->_event = $event;
$this->_extraArguments = $extraArguments;
Expand Down
16 changes: 8 additions & 8 deletions classes/linkAction/request/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Modal extends LinkActionRequest
public $_title;

/** @var string The icon to be displayed in the title bar. */
public $_titleIcon;
public $_modalStyle;

/** @var bool Whether the modal has a close icon in the title bar. */
public $_canClose;
Expand All @@ -43,7 +43,7 @@ class Modal extends LinkActionRequest
* Constructor
*
* @param string $title (optional) The localized modal title.
* @param string $titleIcon (optional) The icon to be used in the modal title bar.
* @param string $modalStyle (optional) The modal state/style to be used. (default is 'basic')
* @param bool $canClose (optional) Whether the modal will have a close button.
* @param string $closeOnFormSuccessId (optional) Close the modal when the
* form with this id fires a formSuccess event.
Expand All @@ -52,14 +52,14 @@ class Modal extends LinkActionRequest
*/
public function __construct(
$title = null,
$titleIcon = null,
$modalStyle = 'basic',
$canClose = true,
$closeOnFormSuccessId = null,
$closeCleanVueInstances = []
) {
parent::__construct();
$this->_title = $title;
$this->_titleIcon = $titleIcon;
$this->_modalStyle = $modalStyle;
$this->_canClose = $canClose;
$this->_closeOnFormSuccessId = $closeOnFormSuccessId;
$this->_closeCleanVueInstances = $closeCleanVueInstances;
Expand All @@ -82,13 +82,13 @@ public function getTitle()
}

/**
* Get the title bar icon.
* Get the modal style.
*
* @return string
*/
public function getTitleIcon()
public function getModalStyle()
{
return $this->_titleIcon;
return $this->_modalStyle;
}

/**
Expand Down Expand Up @@ -128,7 +128,7 @@ public function getLocalizedOptions()
{
return [
'title' => $this->getTitle(),
'titleIcon' => $this->getTitleIcon(),
'modalStyle' => $this->getModalStyle(),
'canClose' => ($this->getCanClose() ? '1' : '0'),
'closeOnFormSuccessId' => $this->_closeOnFormSuccessId,
'closeCleanVueInstances' => $this->_closeCleanVueInstances,
Expand Down
7 changes: 3 additions & 4 deletions classes/linkAction/request/RedirectConfirmationModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ class RedirectConfirmationModal extends ConfirmationModal
* @param string $title (optional) The localized modal title.
* @param string $remoteUrl (optional) A URL to be
* redirected to when the confirmation button is clicked.
* @param string $titleIcon (optional) The icon to be used
* in the modal title bar.
* @param string $modalStyle (optional) The modal state/style to be used. (default is 'basic')
* @param string $okButton (optional) The localized text to
* appear on the confirmation button.
* @param string $cancelButton (optional) The localized text to
* appear on the cancel button.
* @param bool $canClose (optional) Whether the modal will
* have a close button.
*/
public function __construct($dialogText, $title = null, $remoteUrl = null, $titleIcon = null, $okButton = null, $cancelButton = null, $canClose = true)
public function __construct($dialogText, $title = null, $remoteUrl = null, $modalStyle = 'basic', $okButton = null, $cancelButton = null, $canClose = true)
{
parent::__construct($dialogText, $title, $titleIcon, $okButton, $cancelButton, $canClose);
parent::__construct($dialogText, $title, $modalStyle, $okButton, $cancelButton, $canClose);

$this->_remoteUrl = $remoteUrl;
}
Expand Down
7 changes: 3 additions & 4 deletions classes/linkAction/request/RemoteActionConfirmationModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@ class RemoteActionConfirmationModal extends ConfirmationModal
* @param string $title (optional) The localized modal title.
* @param string $remoteAction (optional) A URL to be
* called when the confirmation button is clicked.
* @param string $titleIcon (optional) The icon to be used
* in the modal title bar.
* @param string $modalStyle (optional) The modal state/style to be used. (default is 'basic')
* @param string $okButton (optional) The localized text to
* appear on the confirmation button.
* @param string $cancelButton (optional) The localized text to
* appear on the cancel button.
* @param bool $canClose (optional) Whether the modal will
* have a close button.
*/
public function __construct($session, $dialogText, $title = null, $remoteAction = null, $titleIcon = null, $okButton = null, $cancelButton = null, $canClose = true)
public function __construct($session, $dialogText, $title = null, $remoteAction = null, $modalStyle = 'basic', $okButton = null, $cancelButton = null, $canClose = true)
{
parent::__construct($dialogText, $title, $titleIcon, $okButton, $cancelButton, $canClose);
parent::__construct($dialogText, $title, $modalStyle, $okButton, $cancelButton, $canClose);

$this->_remoteAction = $remoteAction;
$this->_csrfToken = $session->token();
Expand Down
2 changes: 1 addition & 1 deletion classes/plugins/PKPPubIdPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getActions($request, $actionArgs)
'settings',
new AjaxModal(
$router->url($request, null, null, 'manage', null, $actionArgs),
$this->getDisplayName()
$this->getDisplayName(),
),
__('manager.plugins.settings'),
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function fetch($request, $template = null, $display = false)
new ConfirmationModal(
__('reviewer.aboutDueDates.text'),
__('reviewer.aboutDueDates'),
'modal_information',
'primary',
null,
'',
false
Expand All @@ -104,7 +104,7 @@ public function fetch($request, $template = null, $display = false)
'declineReview',
new AjaxModal(
$request->url(null, null, 'showDeclineReview', [$reviewAssignment->getSubmissionId()]),
__('reviewer.submission.declineReview')
__('reviewer.submission.declineReview'),
)
);
$templateMgr->assign('declineReviewAction', $declineReviewLinkAction);
Expand Down
1 change: 0 additions & 1 deletion controllers/api/file/linkAction/BaseAddFileLinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public function __construct(
$actionArgs
),
$wizardTitle,
'modal_add_file'
);

// Configure the link action.
Expand Down
2 changes: 1 addition & 1 deletion controllers/api/file/linkAction/DeleteFileLinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct($request, $submissionFile, $stageId, $localeKey = 'g
null,
$this->getActionArgs($submissionFile, $stageId)
),
'modal_delete'
'negative'
),
__($localeKey),
'delete'
Expand Down
1 change: 0 additions & 1 deletion controllers/api/file/linkAction/EditFileLinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function __construct($request, $submissionFile, $stageId)
$this->getActionArgs($submissionFile, $stageId)
),
__('grid.action.editFile'),
'modal_information'
);

// Configure the file link action.
Expand Down
1 change: 0 additions & 1 deletion controllers/api/task/SendReminderLinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct($request, $modalTitle, $actionArgs)
$ajaxModal = new AjaxModal(
$router->url($request, null, null, 'editReminder', null, $actionArgs),
__($modalTitle),
'review_reminder'
);

// Configure the link action.
Expand Down
1 change: 0 additions & 1 deletion controllers/api/task/SendThankYouLinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct($request, $modalTitle, $actionArgs)
$ajaxModal = new AjaxModal(
$router->url($request, null, null, 'editThankReviewer', null, $actionArgs),
__($modalTitle),
'modal_email'
);

// Configure the link action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($request)
$viewCompetingInterestsModal = new ConfirmationModal(
$context->getLocalizedData('competingInterests'),
__('reviewer.submission.competingInterests'),
null,
'primary',
null,
false,
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct($request, $stageId)
$viewGuidelinesModal = new ConfirmationModal(
$this->getGuidelines(),
__('reviewer.submission.guidelines'),
null,
'primary',
null,
false
);
Expand Down
2 changes: 1 addition & 1 deletion controllers/grid/admin/context/ContextGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function initialize($request, $args = null)
new AjaxModal(
$router->url($request, null, null, 'createContext', null, null),
__('admin.contexts.create'),
'modal_add_item',
null,
true,
'context',
['editContext']
Expand Down
7 changes: 4 additions & 3 deletions controllers/grid/admin/context/ContextGridRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function initialize($request, $template = null)
new AjaxModal(
$router->url($request, null, null, 'editContext', null, ['rowId' => $rowId]),
__('grid.action.edit'),
'modal_edit',
null,
true,
'context',
['editContext']
Expand All @@ -67,7 +67,8 @@ public function initialize($request, $template = null)
$request->getSession(),
__('admin.contexts.confirmDelete', ['contextName' => $element->getLocalizedName()]),
null,
$router->url($request, null, null, 'deleteContext', null, ['rowId' => $rowId])
$router->url($request, null, null, 'deleteContext', null, ['rowId' => $rowId]),
'negative'
),
__('grid.action.remove'),
'delete'
Expand All @@ -88,7 +89,7 @@ public function initialize($request, $template = null)
new AjaxModal(
$router->url($request, $element->getPath(), null, 'users', null),
__('manager.users'),
'modal_edit',
null,
true
),
__('manager.users'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function initialize($request, $args = null)
new AjaxModal(
$router->url($request, null, null, 'addAnnouncementType', null, null),
__('grid.action.addAnnouncementType'),
'modal_add_item',
null,
true
),
__('grid.action.addAnnouncementType'),
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/announcements/AnnouncementTypeGridRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function initialize($request, $template = null)
new AjaxModal(
$router->url($request, null, null, 'editAnnouncementType', null, $actionArgs),
__('grid.action.edit'),
'modal_edit',
null,
true
),
__('grid.action.edit'),
Expand All @@ -68,7 +68,7 @@ public function initialize($request, $template = null)
__('common.confirmDelete'),
__('common.remove'),
$router->url($request, null, null, 'deleteAnnouncementType', null, $actionArgs),
'modal_delete'
'negative'
),
__('grid.action.remove'),
'delete'
Expand Down
1 change: 0 additions & 1 deletion controllers/grid/eventLog/linkAction/EmailLinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function __construct($request, $modalTitle, $actionArgs)
$ajaxModal = new AjaxModal(
$router->url($request, null, null, 'viewEmail', null, $actionArgs),
$modalTitle,
'modal_email'
);

// Configure the link action.
Expand Down
1 change: 0 additions & 1 deletion controllers/grid/files/LibraryFileGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public function initialize($request, $args = null)
new AjaxModal(
$router->url($request, null, null, 'addFile', null, $this->getActionArgs()),
__('grid.action.addFile'),
'modal_add_file'
),
__('grid.action.addFile'),
'add'
Expand Down
3 changes: 1 addition & 2 deletions controllers/grid/files/LibraryFileGridRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function initialize($request, $template = null)
new AjaxModal(
$router->url($request, null, null, 'editFile', null, $actionArgs),
__('grid.action.edit'),
'modal_edit'
),
__('grid.action.edit'),
'edit'
Expand All @@ -111,7 +110,7 @@ public function initialize($request, $template = null)
__('common.confirmDelete'),
__('common.delete'),
$router->url($request, null, null, 'deleteFile', null, $actionArgs),
'modal_delete'
'negative'
),
__('grid.action.delete'),
'delete'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function __construct($request, $actionArgs, $actionLabel, $modalTitle = n
$ajaxModal = new AjaxModal(
$router->url($request, null, null, 'selectFiles', null, $actionArgs),
$modalTitle,
'modal_add_file'
);

// Configure the link action.
Expand Down
Loading

0 comments on commit 8355f0c

Please sign in to comment.