Commit 5e60decd authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Prevent Uncaught TypeError in Recordlist JavaScript

Since translated records do not contain a checkbox
for the clipboard functionality, we have to check the
element before accessing the "checked" property.

Note: There is still a problem in master, which will
be tackled in a separate patch.

Resolves: #94293
Releases: master, 10.4
Change-Id: I795b99f7112e8ae5d8eef79b6161b19b5bb77e0e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69420

Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent b6278a9a
......@@ -229,7 +229,7 @@ class Recordlist {
private getCheckboxState(CBname: string): boolean {
const fullName = 'CBC[' + CBname + ']';
const checkbox: HTMLInputElement = document.querySelector('form[name="dblistForm"] [name="' + fullName + '"]');
return checkbox.checked;
return checkbox !== null ? checkbox.checked : false;
}
private registerPaginationEvents = (): void => {
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","TYPO3/CMS/Backend/Icons","TYPO3/CMS/Backend/Storage/Persistent","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Core/DocumentService"],(function(t,e,a,i,l,n,s,d){"use strict";a=__importDefault(a);return new class{constructor(){this.identifier={entity:".t3js-entity",toggle:".t3js-toggle-recordlist",localize:".t3js-action-localize",icons:{collapse:"actions-view-list-collapse",expand:"actions-view-list-expand",editMultiple:".t3js-record-edit-multiple"}},this.toggleClick=t=>{t.preventDefault();const e=a.default(t.currentTarget),n=e.data("table"),s=a.default(e.data("bs-target")),d="expanded"===s.data("state"),r=e.find(".collapseIcon"),o=d?this.identifier.icons.expand:this.identifier.icons.collapse;i.getIcon(o,i.sizes.small).done(t=>{r.html(t)});let c={};l.isset("moduleData.list")&&(c=l.get("moduleData.list"));const u={};u[n]=d?1:0,a.default.extend(c,u),l.set("moduleData.list",c).done(()=>{s.data("state",d?"collapsed":"expanded")})},this.onEditMultiple=t=>{let e,i,l,n,s;t.preventDefault(),e=a.default(t.currentTarget).closest("[data-table]"),0!==e.length&&(n=a.default(t.currentTarget).data("uri"),i=e.data("table"),l=e.find(this.identifier.entity+'[data-uid][data-table="'+i+'"]').map((t,e)=>a.default(e).data("uid")).toArray().join(","),s=n.match(/{[^}]+}/g),a.default.each(s,(t,e)=>{const s=e.substr(1,e.length-2).split(":");let d;switch(s.shift()){case"entityIdentifiers":d=l;break;case"T3_THIS_LOCATION":d=T3_THIS_LOCATION;break;default:return}a.default.each(s,(t,e)=>{"editList"===e&&(d=this.editList(i,d))}),n=n.replace(e,d)}),window.location.href=n)},this.disableButton=t=>{a.default(t.currentTarget).prop("disable",!0).addClass("disabled")},this.deleteRow=t=>{const e=a.default(`table[data-table="${t.table}"]`),i=e.find(`tr[data-uid="${t.uid}"]`),l=e.closest(".panel"),n=l.find(".panel-heading"),s=e.find(`[data-l10nparent="${t.uid}"]`),d=a.default().add(i).add(s);if(d.fadeTo("slow",.4,()=>{d.slideUp("slow",()=>{d.remove(),0===e.find("tbody tr").length&&l.slideUp("slow")})}),"0"===i.data("l10nparent")||""===i.data("l10nparent")){const t=Number(n.find(".t3js-table-total-items").html());n.find(".t3js-table-total-items").text(t-1)}"pages"===t.table&&top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))},this.registerPaginationEvents=()=>{document.querySelectorAll(".t3js-recordlist-paging").forEach(t=>{t.addEventListener("keyup",e=>{e.preventDefault();let a=parseInt(t.value,10);a<parseInt(t.min,10)&&(a=parseInt(t.min,10)),a>parseInt(t.max,10)&&(a=parseInt(t.max,10)),"Enter"===e.key&&a!==parseInt(t.dataset.currentpage,10)&&(window.location.href=t.dataset.currenturl+a.toString())})})},this.registerColumnSelectorEvents=()=>{document.querySelectorAll(".recordlist-select-allcolumns").forEach(t=>{t.addEventListener("change",e=>{t.closest("form").querySelectorAll(".recordlist-select-column").forEach(t=>{t.disabled||(t.checked=!t.checked)})})})},a.default(document).on("click",this.identifier.toggle,this.toggleClick),a.default(document).on("click",this.identifier.icons.editMultiple,this.onEditMultiple),a.default(document).on("click",this.identifier.localize,this.disableButton),d.ready().then(()=>{s.initialize(".table-fit a[title]"),this.registerPaginationEvents()}),d.ready().then(()=>{this.registerColumnSelectorEvents()}),new n("typo3:datahandler:process",this.handleDataHandlerResult.bind(this)).bindTo(document)}editList(t,e){const a=[];let i=0,l=e.indexOf(",");for(;-1!==l;)this.getCheckboxState(t+"|"+e.substr(i,l-i))&&a.push(e.substr(i,l-i)),i=l+1,l=e.indexOf(",",i);return this.getCheckboxState(t+"|"+e.substr(i))&&a.push(e.substr(i)),a.length>0?a.join(","):e}handleDataHandlerResult(t){const e=t.detail.payload;e.hasErrors||"datahandler"!==e.component&&"delete"===e.action&&this.deleteRow(e)}getCheckboxState(t){const e="CBC["+t+"]";return document.querySelector('form[name="dblistForm"] [name="'+e+'"]').checked}}}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","TYPO3/CMS/Backend/Icons","TYPO3/CMS/Backend/Storage/Persistent","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Core/DocumentService"],(function(t,e,a,i,l,n,s,d){"use strict";a=__importDefault(a);return new class{constructor(){this.identifier={entity:".t3js-entity",toggle:".t3js-toggle-recordlist",localize:".t3js-action-localize",icons:{collapse:"actions-view-list-collapse",expand:"actions-view-list-expand",editMultiple:".t3js-record-edit-multiple"}},this.toggleClick=t=>{t.preventDefault();const e=a.default(t.currentTarget),n=e.data("table"),s=a.default(e.data("bs-target")),d="expanded"===s.data("state"),r=e.find(".collapseIcon"),o=d?this.identifier.icons.expand:this.identifier.icons.collapse;i.getIcon(o,i.sizes.small).done(t=>{r.html(t)});let c={};l.isset("moduleData.list")&&(c=l.get("moduleData.list"));const u={};u[n]=d?1:0,a.default.extend(c,u),l.set("moduleData.list",c).done(()=>{s.data("state",d?"collapsed":"expanded")})},this.onEditMultiple=t=>{let e,i,l,n,s;t.preventDefault(),e=a.default(t.currentTarget).closest("[data-table]"),0!==e.length&&(n=a.default(t.currentTarget).data("uri"),i=e.data("table"),l=e.find(this.identifier.entity+'[data-uid][data-table="'+i+'"]').map((t,e)=>a.default(e).data("uid")).toArray().join(","),s=n.match(/{[^}]+}/g),a.default.each(s,(t,e)=>{const s=e.substr(1,e.length-2).split(":");let d;switch(s.shift()){case"entityIdentifiers":d=l;break;case"T3_THIS_LOCATION":d=T3_THIS_LOCATION;break;default:return}a.default.each(s,(t,e)=>{"editList"===e&&(d=this.editList(i,d))}),n=n.replace(e,d)}),window.location.href=n)},this.disableButton=t=>{a.default(t.currentTarget).prop("disable",!0).addClass("disabled")},this.deleteRow=t=>{const e=a.default(`table[data-table="${t.table}"]`),i=e.find(`tr[data-uid="${t.uid}"]`),l=e.closest(".panel"),n=l.find(".panel-heading"),s=e.find(`[data-l10nparent="${t.uid}"]`),d=a.default().add(i).add(s);if(d.fadeTo("slow",.4,()=>{d.slideUp("slow",()=>{d.remove(),0===e.find("tbody tr").length&&l.slideUp("slow")})}),"0"===i.data("l10nparent")||""===i.data("l10nparent")){const t=Number(n.find(".t3js-table-total-items").html());n.find(".t3js-table-total-items").text(t-1)}"pages"===t.table&&top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))},this.registerPaginationEvents=()=>{document.querySelectorAll(".t3js-recordlist-paging").forEach(t=>{t.addEventListener("keyup",e=>{e.preventDefault();let a=parseInt(t.value,10);a<parseInt(t.min,10)&&(a=parseInt(t.min,10)),a>parseInt(t.max,10)&&(a=parseInt(t.max,10)),"Enter"===e.key&&a!==parseInt(t.dataset.currentpage,10)&&(window.location.href=t.dataset.currenturl+a.toString())})})},this.registerColumnSelectorEvents=()=>{document.querySelectorAll(".recordlist-select-allcolumns").forEach(t=>{t.addEventListener("change",e=>{t.closest("form").querySelectorAll(".recordlist-select-column").forEach(t=>{t.disabled||(t.checked=!t.checked)})})})},a.default(document).on("click",this.identifier.toggle,this.toggleClick),a.default(document).on("click",this.identifier.icons.editMultiple,this.onEditMultiple),a.default(document).on("click",this.identifier.localize,this.disableButton),d.ready().then(()=>{s.initialize(".table-fit a[title]"),this.registerPaginationEvents()}),d.ready().then(()=>{this.registerColumnSelectorEvents()}),new n("typo3:datahandler:process",this.handleDataHandlerResult.bind(this)).bindTo(document)}editList(t,e){const a=[];let i=0,l=e.indexOf(",");for(;-1!==l;)this.getCheckboxState(t+"|"+e.substr(i,l-i))&&a.push(e.substr(i,l-i)),i=l+1,l=e.indexOf(",",i);return this.getCheckboxState(t+"|"+e.substr(i))&&a.push(e.substr(i)),a.length>0?a.join(","):e}handleDataHandlerResult(t){const e=t.detail.payload;e.hasErrors||"datahandler"!==e.component&&"delete"===e.action&&this.deleteRow(e)}getCheckboxState(t){const e="CBC["+t+"]",a=document.querySelector('form[name="dblistForm"] [name="'+e+'"]');return null!==a&&a.checked}}}));
\ No newline at end of file
Supports Markdown
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