Allow the `No` field variants of the poll editor to be absent
authorAlexander Ebert <ebert@woltlab.com>
Tue, 9 May 2023 13:43:47 +0000 (15:43 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 9 May 2023 13:43:47 +0000 (15:43 +0200)
ts/WoltLabSuite/Core/Ui/Poll/Editor.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js

index 700227bb99fb511cc3fc2109fdadcf8d38b89879..1d0afc39736cdc959e30a39dd85b492fa0221a82 100644 (file)
@@ -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,
index 1fd8e86757dfb7012f2d89c77d01c1a96c8caafb..7d31f1da76bfb79f99e3be4646c86ce996430409 100644 (file)
@@ -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,
             });