Skip to content

Commit dabcfc4

Browse files
authored
Merge pull request #338 from citation-file-format/319-allow-thing-under-edit-to-be-moved
2 parents 4df2280 + 1bb0662 commit dabcfc4

4 files changed

Lines changed: 46 additions & 6 deletions

File tree

src/components/AuthorCardEditing.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@
9898
/>
9999
</div>
100100
<q-card-actions align="right">
101+
<q-btn
102+
color="blue"
103+
dense
104+
icon="ion-arrow-up"
105+
tabindex="-1"
106+
v-on:click="$emit('moveUp')"
107+
/>
108+
<q-btn
109+
color="blue"
110+
dense
111+
icon="ion-arrow-down"
112+
tabindex="-1"
113+
v-on:click="$emit('moveDown')"
114+
/>
101115
<q-btn
102116
color="negative"
103117
dense
@@ -166,7 +180,7 @@ export default defineComponent({
166180
validateOrcid: makeOptionalFieldValidator('/definitions/person/properties/orcid') // or /definitions/orcid ?
167181
}
168182
},
169-
emits: ['closePressed', 'removePressed', 'update']
183+
emits: ['closePressed', 'removePressed', 'update', 'moveUp', 'moveDown']
170184
})
171185
</script>
172186
<style scoped>

src/components/IdentifierCardEditing.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@
4646
</div>
4747
</q-card-section>
4848
<q-card-actions align="right">
49+
<q-btn
50+
dense
51+
color="blue"
52+
icon="ion-arrow-up"
53+
tabindex="-1"
54+
v-on:click="$emit('moveUp')"
55+
/>
56+
<q-btn
57+
dense
58+
color="blue"
59+
icon="ion-arrow-down"
60+
tabindex="-1"
61+
v-on:click="$emit('moveDown')"
62+
/>
4963
<q-btn
5064
color="negative"
5165
dense
@@ -107,6 +121,6 @@ export default defineComponent({
107121
]
108122
}
109123
},
110-
emits: ['closePressed', 'removePressed', 'updateType', 'updateValue', 'updateDescription']
124+
emits: ['closePressed', 'removePressed', 'updateType', 'updateValue', 'updateDescription', 'moveUp', 'moveDown']
111125
})
112126
</script>

src/components/ScreenAuthors.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
v-on:update="setAuthorField"
3434
v-on:closePressed="() => (editingId = -1)"
3535
v-on:removePressed="removeAuthor"
36+
v-on:moveDown="moveAuthorDown(index)"
37+
v-on:moveUp="moveAuthorUp(index)"
3638
/>
3739
</div>
3840
</div>
@@ -98,13 +100,17 @@ export default defineComponent({
98100
}
99101
const moveAuthorUp = (index: number) => {
100102
moveUp(index, authors.value, setAuthors)
101-
if (editingId.value === index - 1) {
103+
if (editingId.value === index && index > 0) {
104+
editingId.value = editingId.value - 1
105+
} else if (editingId.value === index - 1) {
102106
editingId.value = editingId.value + 1
103107
}
104108
}
105109
const moveAuthorDown = (index: number) => {
106110
moveDown(index, authors.value, setAuthors)
107-
if (editingId.value === index + 1) {
111+
if (editingId.value === index && index < authors.value.length - 1) {
112+
editingId.value = editingId.value + 1
113+
} else if (editingId.value === index + 1) {
108114
editingId.value = editingId.value - 1
109115
}
110116
}

src/components/ScreenIdentifiers.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
v-on:updateDescription="setIdentifierDescriptionField"
4646
v-on:closePressed="() => (editingId = -1)"
4747
v-on:removePressed="removeIdentifier"
48+
v-on:moveDown="moveIdentifierDown(index)"
49+
v-on:moveUp="moveIdentifierUp(index)"
4850
/>
4951
</div>
5052
</div>
@@ -126,13 +128,17 @@ export default defineComponent({
126128
}
127129
const moveIdentifierUp = (index: number) => {
128130
moveUp(index, identifiers.value, setIdentifiers)
129-
if (editingId.value === index - 1) {
131+
if (editingId.value === index && index > 0) {
132+
editingId.value = editingId.value - 1
133+
} else if (editingId.value === index - 1) {
130134
editingId.value = editingId.value + 1
131135
}
132136
}
133137
const moveIdentifierDown = (index: number) => {
134138
moveDown(index, identifiers.value, setIdentifiers)
135-
if (editingId.value === index + 1) {
139+
if (editingId.value === index && index < identifiers.value.length - 1) {
140+
editingId.value = editingId.value + 1
141+
} else if (editingId.value === index + 1) {
136142
editingId.value = editingId.value - 1
137143
}
138144
}

0 commit comments

Comments
 (0)