From e906e79d975a7932850560a8e69a1aef91b57184 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 9 May 2023 15:43:47 +0200 Subject: [PATCH] Allow the `No` field variants of the poll editor to be absent --- ts/WoltLabSuite/Core/Ui/Poll/Editor.ts | 16 ++++++++-------- .../files/js/WoltLabSuite/Core/Ui/Poll/Editor.js | 12 ++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts b/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts index 700227bb99..1d0afc3973 100644 --- a/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts +++ b/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts @@ -57,18 +57,18 @@ type PollData = { class UiPollEditor { private readonly container: HTMLElement; private readonly endTimeField: HTMLInputElement; - private readonly isChangeableNoField: HTMLInputElement; + private readonly isChangeableNoField: HTMLInputElement | null; private readonly isChangeableYesField: HTMLInputElement; - private readonly isPublicNoField: HTMLInputElement; + private readonly isPublicNoField: HTMLInputElement | null; private readonly isPublicYesField: HTMLInputElement; private readonly maxVotesField: HTMLInputElement; private optionCount: number; private readonly options: UiPollEditorOptions; private readonly optionList: HTMLOListElement; private readonly questionField: HTMLInputElement; - private readonly resultsRequireVoteNoField: HTMLInputElement; + private readonly resultsRequireVoteNoField: HTMLInputElement | null; private readonly resultsRequireVoteYesField: HTMLInputElement; - private readonly sortByVotesNoField: HTMLInputElement; + private readonly sortByVotesNoField: HTMLInputElement | null; private readonly sortByVotesYesField: HTMLInputElement; private readonly wysiwygId: string; @@ -303,13 +303,13 @@ class UiPollEditor { this.maxVotesField.value = "1"; this.isChangeableYesField.checked = false; - this.isChangeableNoField.checked = true; + if (this.isChangeableNoField) this.isChangeableNoField.checked = true; this.isPublicYesField.checked = false; - this.isPublicNoField.checked = true; + if (this.isPublicNoField) this.isPublicNoField.checked = true; this.resultsRequireVoteYesField.checked = false; - this.resultsRequireVoteNoField.checked = true; + if (this.resultsRequireVoteNoField) this.resultsRequireVoteNoField.checked = true; this.sortByVotesYesField.checked = false; - this.sortByVotesNoField.checked = true; + if (this.sortByVotesNoField) this.sortByVotesNoField.checked = true; EventHandler.fire("com.woltlab.wcf.poll.editor", "reset", { pollEditor: this, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js index 1fd8e86757..7d31f1da76 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js @@ -217,13 +217,17 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta DatePicker.clear(this.endTimeField); this.maxVotesField.value = "1"; this.isChangeableYesField.checked = false; - this.isChangeableNoField.checked = true; + if (this.isChangeableNoField) + this.isChangeableNoField.checked = true; this.isPublicYesField.checked = false; - this.isPublicNoField.checked = true; + if (this.isPublicNoField) + this.isPublicNoField.checked = true; this.resultsRequireVoteYesField.checked = false; - this.resultsRequireVoteNoField.checked = true; + if (this.resultsRequireVoteNoField) + this.resultsRequireVoteNoField.checked = true; this.sortByVotesYesField.checked = false; - this.sortByVotesNoField.checked = true; + if (this.sortByVotesNoField) + this.sortByVotesNoField.checked = true; EventHandler.fire("com.woltlab.wcf.poll.editor", "reset", { pollEditor: this, }); -- 2.20.1