Skip to content

Commit f234998

Browse files
authored
Merge pull request #777 from citation-file-format/774-generalize-banner
2 parents 8f7912b + d6c34b8 commit f234998

5 files changed

Lines changed: 46 additions & 37 deletions

File tree

cypress/e2e/errors.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('From a fixed advanced app', () => {
7979
.click()
8080
cy.checkThatStepperValidityIs(false, 'authors')
8181
cy.checkThatAppValidityIs(false)
82-
cy.get('.q-banner')
82+
cy.dataCy('banner-error-messages')
8383
.should('contain.text', 'Use the button to add an author')
8484
cy.dataCy('btn-add-author')
8585
.click()
@@ -106,7 +106,7 @@ describe('From a fixed advanced app', () => {
106106
.should('have.class', 'red-border')
107107
cy.checkThatStepperValidityIs(false, 'authors')
108108
cy.checkThatAppValidityIs(false)
109-
cy.get('.q-banner')
109+
cy.dataCy('banner-error-messages')
110110
.should('contain.text', 'There are duplicate authors')
111111

112112
cy.dataCy('btn-remove0')
@@ -211,7 +211,7 @@ describe('From a fixed advanced app', () => {
211211
.click()
212212
cy.dataCy('card-identifier0')
213213
.should('have.class', 'red-border')
214-
cy.get('.q-banner')
214+
cy.dataCy('banner-error-messages')
215215
.should('contain.text', 'There are duplicate identifier')
216216
cy.checkThatStepperValidityIs(false, 'identifiers')
217217
cy.checkThatAppValidityIs(false)
@@ -272,7 +272,7 @@ describe('From a fixed advanced app', () => {
272272
.click()
273273
cy.checkThatInputValidityIs(false, 'keyword0')
274274
cy.checkThatInputValidityIs(false, 'keyword1')
275-
cy.get('.q-banner')
275+
cy.dataCy('banner-error-messages')
276276
.should('contain.text', 'There are duplicate keywords')
277277
cy.checkThatStepperValidityIs(false, 'keywords')
278278
cy.checkThatAppValidityIs(false)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<p
3+
v-if="errorMessages.length > 0"
4+
class="q-pt-md"
5+
data-cy="banner-error-messages"
6+
>
7+
<q-icon
8+
class="text-negative q-pr-md q"
9+
name="warning"
10+
size="32px"
11+
/>
12+
<span
13+
v-bind:key="index"
14+
v-for="(errorMessage, index) in errorMessages"
15+
>
16+
{{ errorMessage }}
17+
</span>
18+
</p>
19+
</template>
20+
21+
<script lang="ts">
22+
import { defineComponent } from 'vue'
23+
24+
export default defineComponent({
25+
name: 'BannerErrorMessages',
26+
props: {
27+
errorMessages: {
28+
type: Array,
29+
required: true
30+
}
31+
}
32+
})
33+
</script>

src/components/ScreenAuthors.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,7 @@
4949
Add author
5050
</q-btn>
5151

52-
<q-banner
53-
v-if="authorsErrors.length > 0"
54-
v-bind:class="['bg-warning', 'text-negative', authorsErrors.length > 0 ? 'has-error' : '']"
55-
>
56-
<div
57-
v-bind:key="index"
58-
v-for="(screenMessage, index) in authorsErrors"
59-
>
60-
{{ screenMessage }}
61-
</div>
62-
</q-banner>
52+
<BannerErrorMessages v-bind:error-messages="authorsErrors" />
6353
</template>
6454

6555
<script lang="ts">
@@ -69,6 +59,7 @@ import { moveDown, moveUp } from 'src/updown'
6959
import AuthorCardEditing from 'components/AuthorCardEditing.vue'
7060
import AuthorCardViewing from 'components/AuthorCardViewing.vue'
7161
import { AuthorType } from 'src/types'
62+
import BannerErrorMessages from 'src/components/BannerErrorMessages.vue'
7263
import InfoDialog from 'components/InfoDialog.vue'
7364
import { scrollToBottom } from 'src/scroll-to-bottom'
7465
import { useCff } from 'src/store/cff'
@@ -79,6 +70,7 @@ export default defineComponent({
7970
components: {
8071
AuthorCardEditing,
8172
AuthorCardViewing,
73+
BannerErrorMessages,
8274
InfoDialog
8375
},
8476
setup () {

src/components/ScreenIdentifiers.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,15 @@
5050
Add identifier
5151
</q-btn>
5252

53-
<q-banner
54-
v-if="identifiersErrors.length > 0"
55-
v-bind:class="['bg-warning', 'text-negative', identifiersErrors.length > 0 ? 'has-error' : '']"
56-
>
57-
<div
58-
v-bind:key="index"
59-
v-for="(screenMessage, index) in identifiersErrors"
60-
>
61-
{{ screenMessage }}
62-
</div>
63-
</q-banner>
53+
<BannerErrorMessages v-bind:error-messages="identifiersErrors" />
6454
</template>
6555

6656
<script lang="ts">
6757
import { IdentifierType, IdentifierTypeType } from 'src/types'
6858
import { byError, identifiersQueries } from 'src/error-filtering'
6959
import { computed, defineComponent, nextTick, ref } from 'vue'
7060
import { moveDown, moveUp } from 'src/updown'
61+
import BannerErrorMessages from 'src/components/BannerErrorMessages.vue'
7162
import IdentifierCardEditing from 'components/IdentifierCardEditing.vue'
7263
import IdentifierCardViewing from 'components/IdentifierCardViewing.vue'
7364
import InfoDialog from 'components/InfoDialog.vue'
@@ -78,6 +69,7 @@ import { useValidation } from 'src/store/validation'
7869
export default defineComponent({
7970
name: 'ScreenIdentifiers',
8071
components: {
72+
BannerErrorMessages,
8173
InfoDialog,
8274
IdentifierCardEditing,
8375
IdentifierCardViewing

src/components/ScreenKeywords.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,14 @@
3535
Add keyword
3636
</q-btn>
3737

38-
<q-banner
39-
v-if="keywordsErrors.length > 0"
40-
v-bind:class="['bg-warning', 'text-negative', keywordsErrors.length > 0 ? 'has-error' : '']"
41-
>
42-
<div
43-
v-bind:key="index"
44-
v-for="(screenMessage, index) in keywordsErrors"
45-
>
46-
{{ screenMessage }}
47-
</div>
48-
</q-banner>
38+
<BannerErrorMessages v-bind:error-messages="keywordsErrors" />
4939
</template>
5040

5141
<script lang="ts">
5242
import { byError, keywordsQueries } from 'src/error-filtering'
5343
import { computed, defineComponent, nextTick } from 'vue'
5444
import { moveDown, moveUp } from 'src/updown'
45+
import BannerErrorMessages from 'src/components/BannerErrorMessages.vue'
5546
import InfoDialog from 'components/InfoDialog.vue'
5647
import Keyword from 'components/Keyword.vue'
5748
import { scrollToBottom } from 'src/scroll-to-bottom'
@@ -61,6 +52,7 @@ import { useValidation } from 'src/store/validation'
6152
export default defineComponent({
6253
name: 'ScreenKeywords',
6354
components: {
55+
BannerErrorMessages,
6456
InfoDialog,
6557
Keyword
6658
},

0 commit comments

Comments
 (0)