Skip to content

Commit 9683164

Browse files
authored
Merge pull request #691 from citation-file-format/567-remove-button-card-viewing
2 parents 7c7f852 + 887dcfa commit 9683164

4 files changed

Lines changed: 36 additions & 10 deletions

File tree

src/components/AuthorCardViewing.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
title="Edit"
3939
v-on:click="$emit('editPressed')"
4040
/>
41+
<q-btn
42+
class="author-button"
43+
color="negative"
44+
hover-color="negative"
45+
icon="delete"
46+
title="Remove author"
47+
v-on:click="$emit('removePressed')"
48+
/>
4149
</div>
4250
</q-card>
4351
</template>
@@ -92,7 +100,7 @@ export default defineComponent({
92100
authorErrors
93101
}
94102
},
95-
emits: ['editPressed', 'moveDown', 'moveUp']
103+
emits: ['editPressed', 'moveDown', 'moveUp', 'removePressed']
96104
})
97105
</script>
98106
<style scoped>

src/components/IdentifierCardViewing.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
title="Edit"
3838
v-on:click="$emit('editPressed')"
3939
/>
40+
<q-btn
41+
class="identifier-button"
42+
color="negative"
43+
hover-color="negative"
44+
icon="delete"
45+
title="Remove Identifier"
46+
v-on:click="$emit('removePressed')"
47+
/>
4048
</div>
4149
</q-card>
4250
</template>
@@ -81,7 +89,7 @@ export default defineComponent({
8189
identifierErrors
8290
}
8391
},
84-
emits: ['editPressed', 'moveDown', 'moveUp']
92+
emits: ['editPressed', 'moveDown', 'moveUp', 'removePressed']
8593
})
8694
</script>
8795
<style scoped>

src/components/ScreenAuthors.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
v-on:editPressed="() => (editingId = index)"
3333
v-on:moveDown="moveAuthorDown(index)"
3434
v-on:moveUp="moveAuthorUp(index)"
35+
v-on:removePressed="removeAuthor(index)"
3536
/>
3637
<AuthorCardEditing
3738
v-else
3839
v-bind:index="index"
3940
v-bind="author"
4041
v-on:update="setAuthorField"
4142
v-on:closePressed="() => (editingId = -1)"
42-
v-on:removePressed="removeAuthor"
43+
v-on:removePressed="removeAuthor(editingId)"
4344
/>
4445
</div>
4546
</div>
@@ -110,11 +111,15 @@ export default defineComponent({
110111
await nextTick()
111112
scrollToBottom()
112113
}
113-
const removeAuthor = () => {
114+
const removeAuthor = (index: number) => {
114115
const newAuthors = [...authors.value]
115-
newAuthors.splice(editingId.value, 1)
116+
newAuthors.splice(index, 1)
116117
setAuthors(newAuthors)
117-
editingId.value = -1
118+
if (index < editingId.value) {
119+
editingId.value -= 1
120+
} else if (index === editingId.value) {
121+
editingId.value = -1
122+
}
118123
}
119124
const setAuthorField = (field: keyof AuthorType, value: string) => {
120125
const newAuthor = { ...authors.value[editingId.value] }

src/components/ScreenIdentifiers.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
v-on:editPressed="() => (editingId = index)"
3333
v-on:moveDown="moveIdentifierDown(index)"
3434
v-on:moveUp="moveIdentifierUp(index)"
35+
v-on:removePressed="removeIdentifier(index)"
3536
/>
3637
<IdentifierCardEditing
3738
v-else
@@ -41,7 +42,7 @@
4142
v-on:updateValue="setIdentifierValueField"
4243
v-on:updateDescription="setIdentifierDescriptionField"
4344
v-on:closePressed="() => (editingId = -1)"
44-
v-on:removePressed="removeIdentifier"
45+
v-on:removePressed="removeIdentifier(editingId)"
4546
/>
4647
</div>
4748
</div>
@@ -119,12 +120,16 @@ export default defineComponent({
119120
await nextTick()
120121
scrollToBottom()
121122
}
122-
const removeIdentifier = () => {
123+
const removeIdentifier = (index: number) => {
123124
if (identifiers.value !== undefined) {
124125
const newIdentifiers = [...identifiers.value]
125-
newIdentifiers.splice(editingId.value, 1)
126+
newIdentifiers.splice(index, 1)
126127
setIdentifiers(newIdentifiers)
127-
editingId.value = -1
128+
if (index < editingId.value) {
129+
editingId.value -= 1
130+
} else if (index === editingId.value) {
131+
editingId.value = -1
132+
}
128133
if (Array.isArray(newIdentifiers) && newIdentifiers.length === 0) {
129134
setIdentifiers(undefined)
130135
}

0 commit comments

Comments
 (0)