fix submitter names

pull/440/head
Pete Matsyburka 9 months ago
parent e0c6a4e08b
commit 87b039e709

@ -219,6 +219,14 @@ import { IconUserPlus, IconTrashX, IconPlus, IconChevronUp, IconChevronDown } fr
import Contenteditable from './contenteditable'
import { v4 } from 'uuid'
function getOrdinalSuffix (num) {
if (num % 10 === 1 && num % 100 !== 11) return 'st'
if (num % 10 === 2 && num % 100 !== 12) return 'nd'
if (num % 10 === 3 && num % 100 !== 13) return 'rd'
return 'th'
}
export default {
name: 'FieldSubmitter',
components: {
@ -292,6 +300,14 @@ export default {
]
},
names () {
const generatedNames = []
for (let i = 21; i < 101; i++) {
const suffix = getOrdinalSuffix(i)
generatedNames.push(`${i}${suffix} ${this.t('party')}`)
}
return [
this.t('first_party'),
this.t('second_party'),
@ -313,20 +329,9 @@ export default {
this.t('eighteenth_party'),
this.t('nineteenth_party'),
this.t('twentieth_party'),
...this.generatedNames
...generatedNames
]
},
generatedNames () {
const names = []
for (let i = 21; i < 101; i++) {
const suffix = this.getOrdinalSuffix(i)
names.push(`${i}${suffix} ${this.t('party')}`)
}
return names
},
lastPartyIndex () {
const index = Math.max(...this.submitters.map((s) => this.names.indexOf(s.name)))
@ -344,13 +349,6 @@ export default {
selectSubmitter (submitter) {
this.$emit('update:model-value', submitter.uuid)
},
getOrdinalSuffix (num) {
if (num % 10 === 1 && num % 100 !== 11) return 'st'
if (num % 10 === 2 && num % 100 !== 12) return 'nd'
if (num % 10 === 3 && num % 100 !== 13) return 'rd'
return 'th'
},
remove (submitter) {
if (window.confirm(this.t('are_you_sure_'))) {
this.$emit('remove', submitter)

Loading…
Cancel
Save