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;
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) {
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) {
}
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;
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,
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;
}
[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,
};
}
class UiPollEditor {
container;
endTimeField;
+ isChangeableNoField;
isChangeableYesField;
- isPublicField;
+ isPublicNoField;
+ isPublicYesField;
maxVotesField;
optionCount;
options;
questionField;
resultsRequireVoteNoField;
resultsRequireVoteYesField;
- sortByVotesField;
+ sortByVotesNoField;
+ sortByVotesYesField;
wysiwygId;
constructor(containerId, pollOptions, wysiwygId, options) {
const container = document.getElementById(containerId);
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,
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,
});
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();
[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,
};
}
/**