Skip to content

Commit

Permalink
#2313 Make sure at least 1 non-monetary is required in Contributions …
Browse files Browse the repository at this point in the history
…page (#2321)

* add a logic where at least 1 is required

* make sure the tests pass
  • Loading branch information
SebinSong authored Aug 29, 2024
1 parent c1b2191 commit 8cf5e10
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion frontend/views/containers/contributions/Contribution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ transition(name='replace-list')
@keydown.esc='cancel'
@keydown.enter.prevent='handleEnter'
)

.c-helper(v-if='receiverHasOnlyOneItem')
i.icon-info-circle
i18n At least one non-monetary contribution is required.

.buttons
button-submit.is-small.is-danger.is-outlined(
v-if='isEditing && !isAdding'
v-if='showRemoveBtn'
@click='handleDelete'
data-test='buttonRemoveNonMonetaryContribution'
) {{ L('Remove') }}
Expand Down Expand Up @@ -94,6 +99,7 @@ export default ({
initialValue: {
type: String
},
needsIncome: Boolean,
contributionsList: Array
},
data () {
Expand Down Expand Up @@ -121,6 +127,12 @@ export default ({
isUnfilled () {
return this.variant === 'unfilled'
},
receiverHasOnlyOneItem () {
return this.needsIncome && this.contributionsList?.length === 1
},
showRemoveBtn () {
return this.isEditing && !this.isAdding && !this.receiverHasOnlyOneItem
},
editAriaLabel () {
return L('Edit contribution settings')
},
Expand Down Expand Up @@ -237,6 +249,15 @@ export default ({
}
}
.c-helper {
display: flex;
align-items: flex-start;
column-gap: 0.25rem;
color: $text_1;
margin-top: 0.5rem;
font-size: $size_4;
}
.buttons {
padding-top: 1rem;
padding-bottom: 0.25rem;
Expand Down
1 change: 1 addition & 0 deletions frontend/views/pages/Contributions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ page(pageTestName='contributionsPage' pageTestHeaderName='contributionsTitle')
contribution.has-text-weight-bold(
v-for='(contribution, index) in ourGroupProfile.nonMonetaryContributions'
:key='`contribution-${index}`'
:needs-income='needsIncome'
variant='editable'
:contributions-list='ourGroupProfile.nonMonetaryContributions'
:initial-value='contribution'
Expand Down

0 comments on commit 8cf5e10

Please sign in to comment.