Skip to content

Commit

Permalink
🐞 question-extra-invalid_vote_policy doesn't work (#432) (#433)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#678
  • Loading branch information
Findeton committed Mar 20, 2024
1 parent b2e55eb commit 0acfd74
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 23 deletions.
47 changes: 39 additions & 8 deletions avBooth/error-checker-generator-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ angular.module('avUi')
},
validator: function (question)
{
if (!!question.extra_options.force_allow_blank_vote)
if (!question.extra_options ||
(
checkerTypeFlag !== "soft" &&
question.extra_options.invalid_vote_policy === 'allowed'
) ||
!!question.extra_options.force_allow_blank_vote
)
{
return true;
}
Expand Down Expand Up @@ -197,6 +203,7 @@ angular.module('avUi')
validator: function (question)
{
if (
!question.extra_options ||
question.extra_options.invalid_vote_policy === 'allowed' ||
service.numSelectedOptions(question, invalidVoteAnswer) === 0 ||
(
Expand Down Expand Up @@ -235,6 +242,7 @@ angular.module('avUi')
validator: function (question)
{
if (
!question.extra_options ||
question.extra_options.invalid_vote_policy === 'allowed' ||
(
question.invalidVoteAnswer &&
Expand Down Expand Up @@ -271,6 +279,7 @@ angular.module('avUi')
question.invalidVoteAnswer &&
question.invalidVoteAnswer.selected > -1
) ||
!question.extra_options ||
question.extra_options.invalid_vote_policy === 'allowed' ||
(
(
Expand Down Expand Up @@ -361,15 +370,21 @@ angular.module('avUi')
});
return {
max: foundField && foundField.max,
name: foundField && ($filter('customI18n')(foundField, 'placeholder') || foundField.id),
name: foundField && ($filter('customI18n')(foundField, 'label') || $filter('customI18n')(foundField, 'placeholder') || foundField.id),
question_id: question.index
};
},
validator: function (question)
{
if (
!question.extra_options ||
!question.extra_options.allow_writeins
!question.extra_options.allow_writeins || (
question.extra_options.invalid_vote_policy === 'allowed' &&
checkerTypeFlag !== "soft"
) || (
checkerTypeFlag === "show-stoppers" &&
question.extra_options.invalid_vote_policy !== 'not-allowed'
)
) {
return true;
}
Expand Down Expand Up @@ -416,15 +431,21 @@ angular.module('avUi')

return {
min: foundField && foundField.min,
name: foundField && ($filter('customI18n')(foundField, 'placeholder') || foundField.id),
name: foundField && ($filter('customI18n')(foundField, 'label') || $filter('customI18n')(foundField, 'placeholder') || foundField.id),
question_id: question.index
};
},
validator: function (question)
{
if (
!question.extra_options ||
!question.extra_options.allow_writeins
!question.extra_options.allow_writeins || (
question.extra_options.invalid_vote_policy === 'allowed' &&
checkerTypeFlag !== "soft"
) || (
checkerTypeFlag === "show-stoppers" &&
question.extra_options.invalid_vote_policy !== 'not-allowed'
)
) {
return true;
}
Expand Down Expand Up @@ -478,7 +499,12 @@ angular.module('avUi')
question.invalidVoteAnswer &&
question.invalidVoteAnswer.selected > -1
) ||
checkerTypeFlag === "show-stoppers" ||
!question.extra_options || (
question.extra_options.invalid_vote_policy === 'allowed' &&
checkerTypeFlag !== "soft"
) ||
(checkerTypeFlag === "show-stoppers" &&
question.extra_options.invalid_vote_policy !== 'not-allowed') ||
!question.extra_options ||
!question.extra_options.allow_writeins
)
Expand Down Expand Up @@ -518,9 +544,14 @@ angular.module('avUi')
question.invalidVoteAnswer &&
question.invalidVoteAnswer.selected > -1
) ||
checkerTypeFlag === "show-stoppers" ||
!question.extra_options ||
!question.extra_options.allow_writeins
!question.extra_options.allow_writeins || (
question.extra_options.invalid_vote_policy === 'allowed' &&
checkerTypeFlag !== "soft"
) || (
checkerTypeFlag === "show-stoppers" &&
question.extra_options.invalid_vote_policy !== 'not-allowed'
)
)
{
return true;
Expand Down
15 changes: 11 additions & 4 deletions avBooth/invalid-answers-controller/invalid-answers-controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ <h4 class="modal-title" id="modal-title">
<ul ng-if="data.errors.length > 0">
<li
class="error"
ng-repeat="error in data.errors"
data-i18n="{{error.data}}"
ng-i18next>
[html:i18next]({{error.data}}){{error.key}}
ng-repeat="error in data.errors">
<span
ng-if="!error.translation"
ng-i18next>
[html:i18next]({{error.data}}){{error.key}}
</span>
<span
ng-if="error.translation"
ng-bind-html="error.translation">
</span>

</li>
</ul>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- title -->
<div class="title-container">
<h1 aria-level="2" class="text-brand-success question-title" id="question-{{ question.index }}">
<span>{{$index + 1}}.</span>
<span class="title-numeration">{{$index + 1}}.</span>
<span class="question-title title-text" ng-bind-html="question | customI18n : 'title'"></span>
</h1>
</div>
Expand Down Expand Up @@ -84,7 +84,7 @@ <h1 aria-level="2" class="text-brand-success question-title" id="question-{{ que
</div>
<div
ng-if="!question.hasCategories"
ng-repeat="answer in question.answers | avbSelectedOptions"
ng-repeat="answer in (question.answers | avbSelectedOptions)"
class="question-answer-wrapper"
class="col-xs-12"
>
Expand Down Expand Up @@ -140,7 +140,7 @@ <h1 aria-level="2" class="text-brand-success question-title" id="question-{{ que
ng-if="!question.isPairWise && mapQuestion(question).ordered"
>
<li
ng-repeat="answer in question.answers | avbSelectedOptions"
ng-repeat="answer in (question.answers | avbSelectedOptions)"
ng-if="!question.invalidVoteAnswer || answer.id !== question.invalidVoteAnswer.id"
ng-class="{'striked-text': markedAsInvalid(question)}"
class="animate-repeat selected-answer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<!-- show answer texts -->
<div
ng-if="!isWriteIn"
ng-if="!isWriteIn || !!isBlankVoteAnswer"
class="vertilize-col vert-align-top answer-texts"
>
<span
Expand Down Expand Up @@ -71,7 +71,7 @@

<!-- show write-in text input if applicable -->
<div
ng-if="isWriteIn"
ng-if="isWriteIn && !isBlankVoteAnswer"
class="vertilize-col answer-texts write-in"
ng-class="{'has-warning': (question.writeInBytesLeft.bytesLeft >= 0 && question.writeInBytesLeft.bytesLeft < 10), 'has-error': question.writeInBytesLeft.bytesLeft < 0, 'text-left': !!hideCheck()}"
>
Expand Down Expand Up @@ -106,6 +106,7 @@
type="text"
ng-readonly="!!hideCheck()"
class="form-control write-in-extra-field-input"
ng-class="{'invalid': (field.value && field.min && field.value.length < field.min) || (field.value && field.max && field.value.length > field.max)}"
autocomplete="off"
id="question_{{question.index}}_answer_{{answer.id}}_{{field.id}}"
placeholder="{{field | customI18n: 'placeholder'}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
background-color: inherit;
}

.write-in-extra-field-input.invalid {
border-color: @error-primary-color;
}

.write-in-extra-field-input.form-control[readonly] {
&:hover {
cursor: text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3 class="category-heading" id="question_{{question.index}}_answer_{{category.c
</div>
<div
ng-if="isReview"
ng-repeat="answer in category.answers | avbSelectedOptions"
ng-repeat="answer in (category.answers | avbSelectedOptions)"
class="question-answer-wrapper"
ng-class="{
'flex-col-12': (question.extra_options.answer_columns_size === 12),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
<div
class="warn-text"
role="alert"
data-i18n="{{error.data}}"
ng-i18next>
[html:i18next]({{error.data}}){{error.key}}
ng-bind-html="error.translation">
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ angular.module('avBooth')
$modal,
$cookies,
$window,
$i18next,
ConfigService,
CheckerService,
ErrorCheckerGeneratorService,
Expand Down Expand Up @@ -118,9 +119,11 @@ angular.module('avBooth')
data: scope.election,
onError: function (errorKey, errorData)
{
errorData.interpolation = {'escapeValue': false};
scope.errors.push({
data: errorData,
key: errorKey
key: errorKey,
translation: $i18next.t(errorKey, errorData)
});
}
});
Expand Down Expand Up @@ -654,9 +657,11 @@ angular.module('avBooth')
data: scope.election,
onError: function (errorKey, errorData)
{
errorData.interpolation = {'escapeValue': false};
errors.push({
data: errorData,
key: errorKey
key: errorKey,
translation: $i18next.t(errorKey, errorData)
});
}
});
Expand Down

0 comments on commit 0acfd74

Please sign in to comment.