Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

users should not be able to add new options shortly before poll ends … #263

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/poll.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,15 @@ export class Poll {
this.final_rand = rand;
}

can_add_option(): boolean {
if (this.remaining_time_fraction > environment.no_more_options_time_fraction){
return true;
} else {
return false;
}
}



}

Expand Down
12 changes: 9 additions & 3 deletions src/app/poll/poll.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -930,14 +930,20 @@ <h3><b>
<ng-container *ngIf="p.allow_voting">
<ion-item lines="none" class="ion-no-padding" style="padding-left: 10px; padding-top: 10px;">
<ion-fab-button
size="small" (click)="add_option($event)" fill="clear" color="primary">
size="small" (click)="add_option($event)" fill="clear" color="primary"
[disabled]="!p.can_add_option()">
<ion-icon name="add"></ion-icon>

</ion-fab-button>
<ion-button
<ion-button
class="ion-no-padding ion-no-margin" fill="clear" (click)="add_option($event)"
[innerHtml]="'poll.add-option' | translate">
[innerHtml]="'poll.add-option' | translate"
[disabled]="!p.can_add_option()">
</ion-button>
</ion-item>
<ion-item *ngIf="!p.can_add_option()" color="danger">
<strong [innerHtml]="'poll.add-option-expired' | translate"></strong>
</ion-item>
<ion-item lines="none" style="padding-bottom: 10px!important;">
<small [innerHtml]="'poll.add-option-info' | translate"></small>
</ion-item>
Expand Down
3 changes: 3 additions & 0 deletions src/app/poll/poll.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,9 @@ export class PollPage implements OnInit {
}

add_option(event: Event) {
if(!this.p.can_add_option()){
return;
}
/** open the add option dialog popover */
this.p.end_if_past_due();
if (this.p.allow_voting) {
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@
"explain": "Erklären",
"add-option": "Option hinzufügen",
"add-option-info": "Wenn Du denkst, eine wichtige Option fehlt noch und ist nicht von den anderen Optionen mit abgedeckt, kannst Du sie hinzufügen. Einmal hinzugefügte Optionen kann allerdings niemand mehr verändern oder löschen.",
"sorting": "Optionen werden neu sortiert..."
"sorting": "Optionen werden neu sortiert...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@
"explain": "Explain",
"add-option": "Add option",
"add-option-info": "If you believe some important option is missing and is not covered by any of the listed options, you can add it. Once added, options cannot be edited or removed again, however.",
"sorting": "Sorting options by approval..."
"sorting": "Sorting options by approval...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@
"explain": "Explicar",
"add-option": "Añadir opción",
"add-option-info": "Si crees que falta alguna opción importante y no está cubierta por ninguna de las anteriores, puedes añadirla. Una vez añadida, las opciones no podrán ser editadas o eliminadas.",
"sorting": "Ordenando opciones según su aprobación..."
"sorting": "Ordenando opciones según su aprobación...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@
"explain": "Selitä",
"add-option": "Lisää vaihtoehto",
"add-option-info": "Jos tärkeä vaihtoehto mielestäsi puuttuu vielä eikä yksikään muista vaihtoehdoista kata sitä, voit lisätä sen. Kun vaihtoehto on lisätty, sitä ei voi kuitenkaan enää muokata tai poistaa.",
"sorting": "Järjestetään vaihtoehtoja kannatuksen perusteella..."
"sorting": "Järjestetään vaihtoehtoja kannatuksen perusteella...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@
"explain": "समझाएँ",
"add-option": "विकल्प जोड़ें",
"add-option-info": "यदि आपको लगता है कि कुछ महत्वपूर्ण विकल्प गायब है और सूचीबद्ध विकल्पों में से किसी के द्वारा कवर नहीं किया गया है, तो आप इसे जोड़ सकते हैं। एक बार जोड़ने के बाद, विकल्पों को संपादित या फिर से हटाया नहीं जा सकता है।",
"sorting": "स्वीकृति के आधार पर विकल्पों को क्रमित किया जा रहा है..."
"sorting": "स्वीकृति के आधार पर विकल्पों को क्रमित किया जा रहा है...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@
"explain": "Explain",
"add-option": "Add option",
"add-option-info": "If you believe some important option is missing and is not covered by any of the listed options, you can add it. Once added, options cannot be edited or removed again, however.",
"sorting": "Sorting options by approval..."
"sorting": "Sorting options by approval...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@
"explain": "설명",
"add-option": "선택지 추가",
"add-option-info": "중요한 선택지가 위에 목록에 없다고 생각된다면 추가 할 수 있습니다. 하지만 추가된 이후에는 수정되거나 삭제할 수 없음을 유의해 주십시오.",
"sorting": "승인 수에 따라 선택지 정렬중..."
"sorting": "승인 수에 따라 선택지 정렬중...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@
"explain": "Wyjaśnij",
"add-option": "Dodaj opcję",
"add-option-info": "Jeśli uważasz, że brakuje jakiejś ważnej opcji i nie pokrywa się ona z żadną z już wymienionych, możesz ją dodać. Jednak po dodaniu opcji nie można jej ponownie edytować ani usunąć.",
"sorting": "Sortowanie opcji według poziomu akceptacji..."
"sorting": "Sortowanie opcji według poziomu akceptacji...",
"add-option-expired": "Time to add new options has expired."
},
"previewpoll": {
"_COMMENT_SECTION_": "[COMMENT] strings used on the Please Check (Poll Preview) page:",
Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const environment = {
enabled: false,
max_weight: 3
},
no_more_options_time_fraction: 1/14,
db_put_retry_delay_ms: 100,
default_lang: "en",
github_url: "https://github.com/pik-gane/vodle/",
Expand Down