From a07a04db48d12c9e4a325c682361220aa8add199 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 17 Jan 2024 15:29:28 +0100 Subject: [PATCH] Revert "Fix poll editor" This reverts commit bce2b7e5a7084e378f50a26aa821e12d7c48154d. --- ts/WoltLabSuite/Core/Ui/Poll/Editor.ts | 41 ++++++++++------- .../js/WoltLabSuite/Core/Ui/Poll/Editor.js | 44 ++++++++++++------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts b/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts index c59dcf7f56..993b88b569 100644 --- a/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts +++ b/ts/WoltLabSuite/Core/Ui/Poll/Editor.ts @@ -57,8 +57,10 @@ type PollData = { class UiPollEditor { private readonly container: HTMLElement; private readonly endTimeField: HTMLInputElement; + private readonly isChangeableNoField: HTMLInputElement | null; private readonly isChangeableYesField: HTMLInputElement; - private readonly isPublicField: HTMLInputElement; + private readonly isPublicNoField: HTMLInputElement | null; + private readonly isPublicYesField: HTMLInputElement; private readonly maxVotesField: HTMLInputElement; private optionCount: number; private readonly options: UiPollEditorOptions; @@ -66,7 +68,8 @@ class UiPollEditor { private readonly questionField: HTMLInputElement; private readonly resultsRequireVoteNoField: HTMLInputElement | null; private readonly resultsRequireVoteYesField: HTMLInputElement; - private readonly sortByVotesField: HTMLInputElement; + private readonly sortByVotesNoField: HTMLInputElement | null; + private readonly sortByVotesYesField: HTMLInputElement; private readonly wysiwygId: string; constructor(containerId: string, pollOptions: PollOption[], wysiwygId: string, options: UiPollEditorOptions) { @@ -81,7 +84,7 @@ class UiPollEditor { throw new Error("Unknown wysiwyg field with id '" + wysiwygId + "'."); } - this.questionField = document.getElementById(this.wysiwygId + "Poll_question") as HTMLInputElement; + this.questionField = document.getElementById(this.wysiwygId + "pollQuestion") as HTMLInputElement; const optionList = this.container.querySelector(".sortableList"); if (optionList === null) { @@ -89,17 +92,20 @@ class UiPollEditor { } this.optionList = optionList as HTMLOListElement; - this.endTimeField = document.getElementById(this.wysiwygId + "Poll_endTime") as HTMLInputElement; - this.maxVotesField = document.getElementById(this.wysiwygId + "Poll_maxVotes") as HTMLInputElement; - this.isChangeableYesField = document.getElementById(this.wysiwygId + "Poll_isChangeable") as HTMLInputElement; - this.isPublicField = document.getElementById(this.wysiwygId + "Poll_isPublic") as HTMLInputElement; + this.endTimeField = document.getElementById(this.wysiwygId + "pollEndTime") as HTMLInputElement; + this.maxVotesField = document.getElementById(this.wysiwygId + "pollMaxVotes") as HTMLInputElement; + this.isChangeableYesField = document.getElementById(this.wysiwygId + "pollIsChangeable") as HTMLInputElement; + this.isChangeableNoField = document.getElementById(this.wysiwygId + "pollIsChangeable_no") as HTMLInputElement; + this.isPublicYesField = document.getElementById(this.wysiwygId + "pollIsPublic") as HTMLInputElement; + this.isPublicNoField = document.getElementById(this.wysiwygId + "PollIsPublic_no") as HTMLInputElement; this.resultsRequireVoteYesField = document.getElementById( - this.wysiwygId + "Poll_resultsRequireVote", + this.wysiwygId + "pollResultsRequireVote", ) as HTMLInputElement; this.resultsRequireVoteNoField = document.getElementById( - this.wysiwygId + "Poll_resultsRequireVote_no", + this.wysiwygId + "pollResultsRequireVote_no", ) as HTMLInputElement; - this.sortByVotesField = document.getElementById(this.wysiwygId + "Poll_sortByVotes") as HTMLInputElement; + this.sortByVotesYesField = document.getElementById(this.wysiwygId + "pollSortByVotes") as HTMLInputElement; + this.sortByVotesNoField = document.getElementById(this.wysiwygId + "pollSortByVotes_no") as HTMLInputElement; this.optionCount = 0; @@ -299,10 +305,13 @@ class UiPollEditor { this.maxVotesField.value = "1"; this.isChangeableYesField.checked = false; - this.isPublicField.checked = false; + if (this.isChangeableNoField) this.isChangeableNoField.checked = true; + this.isPublicYesField.checked = false; + if (this.isPublicNoField) this.isPublicNoField.checked = true; this.resultsRequireVoteYesField.checked = false; if (this.resultsRequireVoteNoField) this.resultsRequireVoteNoField.checked = true; - this.sortByVotesField.checked = false; + this.sortByVotesYesField.checked = false; + if (this.sortByVotesNoField) this.sortByVotesNoField.checked = true; EventHandler.fire("com.woltlab.wcf.poll.editor", "reset", { pollEditor: this, @@ -347,11 +356,11 @@ class UiPollEditor { data.pollResultsRequireVote = true; } - if (this.sortByVotesField.checked) { + if (this.sortByVotesYesField.checked) { data.pollSortByVotes = true; } - if (this.isPublicField?.checked) { + if (this.isPublicYesField?.checked) { data.pollIsPublic = true; } @@ -405,9 +414,9 @@ class UiPollEditor { [this.endTimeField.id]: this.endTimeField.value, [this.maxVotesField.id]: this.maxVotesField.value, [this.isChangeableYesField.id]: !!this.isChangeableYesField.checked, - [this.isPublicField.id]: !!this.isPublicField.checked, + [this.isPublicYesField.id]: !!this.isPublicYesField.checked, [this.resultsRequireVoteYesField.id]: !!this.resultsRequireVoteYesField.checked, - [this.sortByVotesField.id]: !!this.sortByVotesField.checked, + [this.sortByVotesYesField.id]: !!this.sortByVotesYesField.checked, }; } 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 0b11bff28c..56a4f8d6a3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Poll/Editor.js @@ -16,8 +16,10 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta class UiPollEditor { container; endTimeField; + isChangeableNoField; isChangeableYesField; - isPublicField; + isPublicNoField; + isPublicYesField; maxVotesField; optionCount; options; @@ -25,7 +27,8 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta questionField; resultsRequireVoteNoField; resultsRequireVoteYesField; - sortByVotesField; + sortByVotesNoField; + sortByVotesYesField; wysiwygId; constructor(containerId, pollOptions, wysiwygId, options) { const container = document.getElementById(containerId); @@ -37,19 +40,22 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta if (wysiwygId !== "" && document.getElementById(wysiwygId) === null) { throw new Error("Unknown wysiwyg field with id '" + wysiwygId + "'."); } - this.questionField = document.getElementById(this.wysiwygId + "Poll_question"); + this.questionField = document.getElementById(this.wysiwygId + "pollQuestion"); const optionList = this.container.querySelector(".sortableList"); if (optionList === null) { throw new Error("Cannot find poll options list for container with id '" + containerId + "'."); } this.optionList = optionList; - this.endTimeField = document.getElementById(this.wysiwygId + "Poll_endTime"); - this.maxVotesField = document.getElementById(this.wysiwygId + "Poll_maxVotes"); - this.isChangeableYesField = document.getElementById(this.wysiwygId + "Poll_isChangeable"); - this.isPublicField = document.getElementById(this.wysiwygId + "Poll_isPublic"); - this.resultsRequireVoteYesField = document.getElementById(this.wysiwygId + "Poll_resultsRequireVote"); - this.resultsRequireVoteNoField = document.getElementById(this.wysiwygId + "Poll_resultsRequireVote_no"); - this.sortByVotesField = document.getElementById(this.wysiwygId + "Poll_sortByVotes"); + this.endTimeField = document.getElementById(this.wysiwygId + "pollEndTime"); + this.maxVotesField = document.getElementById(this.wysiwygId + "pollMaxVotes"); + this.isChangeableYesField = document.getElementById(this.wysiwygId + "pollIsChangeable"); + this.isChangeableNoField = document.getElementById(this.wysiwygId + "pollIsChangeable_no"); + this.isPublicYesField = document.getElementById(this.wysiwygId + "pollIsPublic"); + this.isPublicNoField = document.getElementById(this.wysiwygId + "PollIsPublic_no"); + this.resultsRequireVoteYesField = document.getElementById(this.wysiwygId + "pollResultsRequireVote"); + this.resultsRequireVoteNoField = document.getElementById(this.wysiwygId + "pollResultsRequireVote_no"); + this.sortByVotesYesField = document.getElementById(this.wysiwygId + "pollSortByVotes"); + this.sortByVotesNoField = document.getElementById(this.wysiwygId + "pollSortByVotes_no"); this.optionCount = 0; this.options = Core.extend({ isAjax: false, @@ -213,11 +219,17 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta DatePicker.clear(this.endTimeField); this.maxVotesField.value = "1"; this.isChangeableYesField.checked = false; - this.isPublicField.checked = false; + if (this.isChangeableNoField) + this.isChangeableNoField.checked = true; + this.isPublicYesField.checked = false; + if (this.isPublicNoField) + this.isPublicNoField.checked = true; this.resultsRequireVoteYesField.checked = false; if (this.resultsRequireVoteNoField) this.resultsRequireVoteNoField.checked = true; - this.sortByVotesField.checked = false; + this.sortByVotesYesField.checked = false; + if (this.sortByVotesNoField) + this.sortByVotesNoField.checked = true; EventHandler.fire("com.woltlab.wcf.poll.editor", "reset", { pollEditor: this, }); @@ -256,10 +268,10 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta if (this.resultsRequireVoteYesField.checked) { data.pollResultsRequireVote = true; } - if (this.sortByVotesField.checked) { + if (this.sortByVotesYesField.checked) { data.pollSortByVotes = true; } - if (this.isPublicField?.checked) { + if (this.isPublicYesField?.checked) { data.pollIsPublic = true; } data.pollOptions = this.getOptions(); @@ -308,9 +320,9 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../Sorta [this.endTimeField.id]: this.endTimeField.value, [this.maxVotesField.id]: this.maxVotesField.value, [this.isChangeableYesField.id]: !!this.isChangeableYesField.checked, - [this.isPublicField.id]: !!this.isPublicField.checked, + [this.isPublicYesField.id]: !!this.isPublicYesField.checked, [this.resultsRequireVoteYesField.id]: !!this.resultsRequireVoteYesField.checked, - [this.sortByVotesField.id]: !!this.sortByVotesField.checked, + [this.sortByVotesYesField.id]: !!this.sortByVotesYesField.checked, }; } /** -- 2.20.1