Commit 760f209d authored by Andreas Fernandez's avatar Andreas Fernandez
Browse files

[BUGFIX] Use class instead of HTML comment to determine loading state of IRRE element

IRRE relied on the HTML comment `<!--notloaded-->` to detect whether a
record is already loaded or not. As this might collide with HTML
minification, the comment has been replaced with a class placed in the
panel.

Resolves: #91258
Releases: master
Change-Id: Ibe890317bdcb9707a71de1168de0d404fb3c67a4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64385

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 89793783
......@@ -46,6 +46,7 @@ enum States {
new = 'inlineIsNewRecord',
visible = 'panel-visible',
collapsed = 'panel-collapsed',
notLoaded = 't3js-not-loaded',
}
enum Separators {
......@@ -530,8 +531,9 @@ class InlineControlContainer {
*/
private loadRecordDetails(objectId: string): void {
const recordFieldsContainer = document.getElementById(objectId + '_fields');
const recordContainer = InlineControlContainer.getInlineRecordContainer(objectId);
const isLoading = typeof this.requestQueue[objectId] !== 'undefined';
const isLoaded = recordFieldsContainer !== null && recordFieldsContainer.innerHTML.substr(0, 16) !== '<!--notloaded-->';
const isLoaded = recordFieldsContainer !== null && !recordContainer.classList.contains(States.notLoaded);
if (!isLoaded) {
const progress = this.getProgress(objectId);
......@@ -544,6 +546,7 @@ class InlineControlContainer {
delete this.requestQueue[objectId];
delete this.progessQueue[objectId];
recordContainer.classList.remove(States.notLoaded);
recordFieldsContainer.innerHTML = response.data;
this.collapseExpandRecord(objectId);
......
......@@ -124,7 +124,7 @@ class InlineRecordContainer extends AbstractContainer
// Get the current naming scheme for DOM name/id attributes:
$appendFormFieldNames = '[' . $foreignTable . '][' . $record['uid'] . ']';
$objectId = $domObjectId . '-' . $foreignTable . '-' . $record['uid'];
$class = '';
$classes = [];
$html = '';
$combinationHtml = '';
$isNewRecord = $data['command'] === 'new';
......@@ -145,8 +145,8 @@ class InlineRecordContainer extends AbstractContainer
$html = $childArray['html'];
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childArray, false);
} else {
// This string is the marker for the JS-function to check if the full content has already been loaded
$html = '<!--notloaded-->';
// This class is the marker for the JS-function to check if the full content has already been loaded
$classes[] = 't3js-not-loaded';
}
if ($isNewRecord) {
// Add pid of record as hidden field
......@@ -173,7 +173,7 @@ class InlineRecordContainer extends AbstractContainer
}
}
// If this record should be shown collapsed
$class = $data['isInlineChildExpanded'] ? 'panel-visible' : 'panel-collapsed';
$classes[] = $data['isInlineChildExpanded'] ? 'panel-visible' : 'panel-collapsed';
}
$hiddenFieldHtml = implode(LF, $resultArray['additionalHiddenFields'] ?? []);
......@@ -183,12 +183,14 @@ class InlineRecordContainer extends AbstractContainer
} else {
// Render header row and content (if expanded)
if ($data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
$class .= ' t3-form-field-container-inline-placeHolder';
$classes[] = 't3-form-field-container-inline-placeHolder';
}
if (!empty($hiddenField) && isset($record[$hiddenField]) && (int)$record[$hiddenField]) {
$class .= ' t3-form-field-container-inline-hidden';
$classes[] = 't3-form-field-container-inline-hidden';
}
if ($isNewRecord) {
$classes[] = 'inlineIsNewRecord';
}
$class .= ($isNewRecord ? ' inlineIsNewRecord' : '');
$originalUniqueValue = '';
if (isset($data['inlineData']['unique'][$domObjectId . '-' . $foreignTable]['used'][$record['uid']])) {
......@@ -198,7 +200,7 @@ class InlineRecordContainer extends AbstractContainer
}
$containerAttributes = [
'id' => $objectId . '_div',
'class' => 'form-irre-object panel panel-default panel-condensed ' . trim($class),
'class' => 'form-irre-object panel panel-default panel-condensed ' . trim(implode(' ', $classes)),
'data-object-uid' => $record['uid'],
'data-object-id' => $objectId,
'data-field-name' => $appendFormFieldNames,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment