Skip to content

Commit

Permalink
users should not be able to add new options shortly before poll ends #…
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipDrabant committed Nov 6, 2023
1 parent 537095e commit 5bfd527
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 11 deletions.
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

0 comments on commit 5bfd527

Please sign in to comment.