diff --git a/Build/Sources/TypeScript/linkvalidator/linkvalidator.ts b/Build/Sources/TypeScript/linkvalidator/linkvalidator.ts index c3ff0487de0664480db89ba69e39afb6fad76f31..667589b7b8488d2adc059452575c6c8d09399ac6 100644 --- a/Build/Sources/TypeScript/linkvalidator/linkvalidator.ts +++ b/Build/Sources/TypeScript/linkvalidator/linkvalidator.ts @@ -29,8 +29,6 @@ enum Identifier { */ class Linkvalidator { constructor() { - this.toggleTriggerCheckBox(); - this.toggleActionButton(); this.initializeEvents(); } diff --git a/typo3/sysext/linkvalidator/Classes/Controller/LinkValidatorController.php b/typo3/sysext/linkvalidator/Classes/Controller/LinkValidatorController.php index e970df84ab620be937771783095675e94e579e6d..62a555dc938c661a770108b9e377f9d82e3a9954 100644 --- a/typo3/sysext/linkvalidator/Classes/Controller/LinkValidatorController.php +++ b/typo3/sysext/linkvalidator/Classes/Controller/LinkValidatorController.php @@ -427,6 +427,7 @@ class LinkValidatorController { $brokenLinksInformation = $this->linkAnalyzer->getLinkCounts(); $options = [ + 'anyOptionChecked' => false, 'totalCountLabel' => $this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:overviews.nbtotal'), 'totalCount' => $brokenLinksInformation['total'] ?: '0', 'optionsByType' => [], @@ -436,14 +437,19 @@ class LinkValidatorController if (!in_array($type, $linkTypes, true)) { continue; } + $isChecked = !empty($this->checkOpt[$prefix][$type]); + if ($isChecked) { + $options['anyOptionChecked'] = true; + } $options['optionsByType'][$type] = [ 'id' => $prefix . '_SET_' . $type, 'name' => $prefix . '_SET[' . $type . ']', 'label' => $this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:hooks.' . $type) ?: $type, - 'checked' => !empty($this->checkOpt[$prefix][$type]) ? ' checked="checked"' : '', + 'checked' => $isChecked, 'count' => (!empty($brokenLinksInformation[$type]) ? $brokenLinksInformation[$type] : '0'), ]; } + $options['allOptionsChecked'] = array_filter($options['optionsByType'], static fn(array $option): bool => !$option['checked']) === []; return $options; } diff --git a/typo3/sysext/linkvalidator/Resources/Private/Partials/CheckOptions.html b/typo3/sysext/linkvalidator/Resources/Private/Partials/CheckOptions.html index 5d84e8a3ebaa9e08aaf837b2156571892ef2be29..6941ddd082ee6aa7fb2559cd6ee8fd60307390d2 100644 --- a/typo3/sysext/linkvalidator/Resources/Private/Partials/CheckOptions.html +++ b/typo3/sysext/linkvalidator/Resources/Private/Partials/CheckOptions.html @@ -13,7 +13,7 @@ <tr> <th> <div class="form-check form-switch"> - <input id="options-by-type-toggle-all" class="options-by-type-toggle-all form-check-input" type="checkbox" title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall')}"> + <input id="options-by-type-toggle-all" class="options-by-type-toggle-all form-check-input" type="checkbox" title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall')}" {f:if(condition: '{options.allOptionsChecked}', then: 'checked')}> <label class="form-check-label" for="options-by-type-toggle-all"><f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall"/></label> </div> </th> @@ -25,7 +25,7 @@ <tr> <td> <div class="form-check form-switch"> - <input type="checkbox" class="form-check-input options-by-type" value="1" id="{optionByType.id}" name="{optionByType.name}" {optionByType.checked}/> + <input type="checkbox" class="form-check-input options-by-type" value="1" id="{optionByType.id}" name="{optionByType.name}" {f:if(condition: '{optionByType.checked}', then: 'checked')} /> <label class="form-check-label" for="{optionByType.id}">{optionByType.label}</label> </div> </td> diff --git a/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/CheckLinks.html b/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/CheckLinks.html index d7f8eff2c167d959c08d54f469dac147f1b7eda7..765a9e84e82ebd87ffb47d52ea7b5dc7c5111b58 100644 --- a/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/CheckLinks.html +++ b/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/CheckLinks.html @@ -32,7 +32,7 @@ type="submit" class="btn btn-default t3js-linkvalidator-action-button" name="updateLinkList" - disabled + {f:if(condition: '!{options.anyOptionChecked}', then: 'disabled')} value="{f:translate(key: 'LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:label_update')}" data-notification-message="{f:translate(key: 'LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:label_update-link-list')}" /> diff --git a/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/Report.html b/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/Report.html index fc1f7d767fc3d9220076b8337d53401ca6c27361..d6198e24ec00e9216a06d669c76b7540c60a46b7 100644 --- a/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/Report.html +++ b/typo3/sysext/linkvalidator/Resources/Private/Templates/Backend/Report.html @@ -32,7 +32,7 @@ type="submit" class="btn btn-default t3js-linkvalidator-action-button" name="refreshLinkList" - disabled + {f:if(condition: '!{options.anyOptionChecked}', then: 'disabled')} value="{f:translate(key: 'LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:label_refresh')}" data-notification-message="{f:translate(key: 'LLL:EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf:label_refresh-link-list')}" /> diff --git a/typo3/sysext/linkvalidator/Resources/Public/JavaScript/linkvalidator.js b/typo3/sysext/linkvalidator/Resources/Public/JavaScript/linkvalidator.js index 352c73aea4f7cca3e61e71bec112fabf57550108..f2ee8f45f76067ed5e6c8cb26ade7ecbf7d1ab72 100644 --- a/typo3/sysext/linkvalidator/Resources/Public/JavaScript/linkvalidator.js +++ b/typo3/sysext/linkvalidator/Resources/Public/JavaScript/linkvalidator.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import Notification from"@typo3/backend/notification.js";import RegularEvent from"@typo3/core/event/regular-event.js";var Selectors,Identifier;!function(e){e.actionButtonSelector=".t3js-linkvalidator-action-button",e.toggleAllLinktypesSelector='.t3js-linkvalidator-settings input[type="checkbox"].options-by-type-toggle-all',e.linktypesSelector='.t3js-linkvalidator-settings input[type="checkbox"].options-by-type'}(Selectors||(Selectors={})),function(e){e.toggleAllLinktypesId="options-by-type-toggle-all"}(Identifier||(Identifier={}));class Linkvalidator{constructor(){this.toggleTriggerCheckBox(),this.toggleActionButton(),this.initializeEvents()}static allCheckBoxesAreChecked(e){const t=Array.from(e);return e.length===t.filter((e=>e.checked)).length}toggleActionButton(){document.querySelector(Selectors.actionButtonSelector)?.toggleAttribute("disabled",!document.querySelectorAll('input[type="checkbox"]:checked').length)}toggleTriggerCheckBox(){const e=document.querySelectorAll(Selectors.linktypesSelector);document.getElementById(Identifier.toggleAllLinktypesId).checked=Linkvalidator.allCheckBoxesAreChecked(e)}initializeEvents(){new RegularEvent("change",((e,t)=>{const o=document.querySelectorAll(Selectors.linktypesSelector),l=!Linkvalidator.allCheckBoxesAreChecked(o);o.forEach((e=>{e.checked=l})),t.checked=l,this.toggleActionButton()})).delegateTo(document,Selectors.toggleAllLinktypesSelector),new RegularEvent("change",(()=>{this.toggleTriggerCheckBox(),this.toggleActionButton()})).delegateTo(document,Selectors.linktypesSelector),new RegularEvent("click",((e,t)=>{Notification.success(t.dataset.notificationMessage||"Event triggered","",2)})).delegateTo(document,Selectors.actionButtonSelector)}}export default new Linkvalidator; \ No newline at end of file +import Notification from"@typo3/backend/notification.js";import RegularEvent from"@typo3/core/event/regular-event.js";var Selectors,Identifier;!function(e){e.actionButtonSelector=".t3js-linkvalidator-action-button",e.toggleAllLinktypesSelector='.t3js-linkvalidator-settings input[type="checkbox"].options-by-type-toggle-all',e.linktypesSelector='.t3js-linkvalidator-settings input[type="checkbox"].options-by-type'}(Selectors||(Selectors={})),function(e){e.toggleAllLinktypesId="options-by-type-toggle-all"}(Identifier||(Identifier={}));class Linkvalidator{constructor(){this.initializeEvents()}static allCheckBoxesAreChecked(e){const t=Array.from(e);return e.length===t.filter((e=>e.checked)).length}toggleActionButton(){document.querySelector(Selectors.actionButtonSelector)?.toggleAttribute("disabled",!document.querySelectorAll('input[type="checkbox"]:checked').length)}toggleTriggerCheckBox(){const e=document.querySelectorAll(Selectors.linktypesSelector);document.getElementById(Identifier.toggleAllLinktypesId).checked=Linkvalidator.allCheckBoxesAreChecked(e)}initializeEvents(){new RegularEvent("change",((e,t)=>{const o=document.querySelectorAll(Selectors.linktypesSelector),l=!Linkvalidator.allCheckBoxesAreChecked(o);o.forEach((e=>{e.checked=l})),t.checked=l,this.toggleActionButton()})).delegateTo(document,Selectors.toggleAllLinktypesSelector),new RegularEvent("change",(()=>{this.toggleTriggerCheckBox(),this.toggleActionButton()})).delegateTo(document,Selectors.linktypesSelector),new RegularEvent("click",((e,t)=>{Notification.success(t.dataset.notificationMessage||"Event triggered","",2)})).delegateTo(document,Selectors.actionButtonSelector)}}export default new Linkvalidator; \ No newline at end of file