-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💄 Transition validation markup #666
base: support/3.2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1301,6 +1301,8 @@ function DisplayNavigatorGroupTab($oP) | |
if (count($aErrors) == 0) | ||
{ | ||
$sIssues = ''; | ||
/** @var CoreCannotSaveObjectException|null $oException */ | ||
$oException = null; | ||
$bApplyStimulus = true; | ||
list($bRes, $aIssues) = $oObj->CheckToWrite(); // Check before trying to write the object | ||
if ($bRes) | ||
|
@@ -1315,6 +1317,11 @@ function DisplayNavigatorGroupTab($oP) | |
$oObj = MetaModel::GetObject(get_class($oObj), $oObj->GetKey()); | ||
$oObj->UpdateObjectFromPostedForm('', array_keys($aExpectedAttributes), $aExpectedAttributes); | ||
$sIssues = $e->getMessage(); | ||
|
||
if($e instanceof CoreCannotSaveObjectException) { | ||
$oException = $e; | ||
} | ||
|
||
} | ||
} | ||
else | ||
|
@@ -1355,7 +1362,7 @@ function DisplayNavigatorGroupTab($oP) | |
$sMessage = $e->getMessage(); | ||
$sSeverity = 'info'; | ||
} | ||
$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten',$sIssues); | ||
$sIssueDesc = ($oException !== null ? '<div style="display: block;"><style scoped> ul { list-style-type: disc; } </style>'.$oException->getHtmlMessage().'</div>' : Dict::Format('UI:ObjectCouldNotBeWritten', $sIssues)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While not ideal, this will be easier to maintain than a CSS rule somewhere in a file. The main issues:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ErrorModal should be fixed IMHO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, in the backoffice when you want HTML to retrieve its standard style like for lists, surround it with the I would strongly be against inline style like this. A dedicated rule in the right file would be better. That being said, you should ping @jf-cbd or @rquetiez , they worked on error messages and removing/sanitizing HTML errors last summer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try the |
||
$oP->add_ready_script("CombodoModal.OpenErrorModal('".addslashes($sIssueDesc)."');"); | ||
} | ||
else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you would do this instead? Then there's no need to do the if/else later on.
(correct styling would still something to be done in CSS, maybe separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether or not we can expect other exceptions here, which don't support the
getHtmlMessage()
, so I was being cautious :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right,
CoreException
doesn’t seem to have this method 🤔Then maybe just do getHtmlMessage when it exists and the normal getMessage otherwise?