fix submitter names
This commit is contained in:
@@ -219,6 +219,14 @@ import { IconUserPlus, IconTrashX, IconPlus, IconChevronUp, IconChevronDown } fr
|
|||||||
import Contenteditable from './contenteditable'
|
import Contenteditable from './contenteditable'
|
||||||
import { v4 } from 'uuid'
|
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 {
|
export default {
|
||||||
name: 'FieldSubmitter',
|
name: 'FieldSubmitter',
|
||||||
components: {
|
components: {
|
||||||
@@ -292,6 +300,14 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
names () {
|
names () {
|
||||||
|
const generatedNames = []
|
||||||
|
|
||||||
|
for (let i = 21; i < 101; i++) {
|
||||||
|
const suffix = getOrdinalSuffix(i)
|
||||||
|
|
||||||
|
generatedNames.push(`${i}${suffix} ${this.t('party')}`)
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
this.t('first_party'),
|
this.t('first_party'),
|
||||||
this.t('second_party'),
|
this.t('second_party'),
|
||||||
@@ -313,20 +329,9 @@ export default {
|
|||||||
this.t('eighteenth_party'),
|
this.t('eighteenth_party'),
|
||||||
this.t('nineteenth_party'),
|
this.t('nineteenth_party'),
|
||||||
this.t('twentieth_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 () {
|
lastPartyIndex () {
|
||||||
const index = Math.max(...this.submitters.map((s) => this.names.indexOf(s.name)))
|
const index = Math.max(...this.submitters.map((s) => this.names.indexOf(s.name)))
|
||||||
|
|
||||||
@@ -344,13 +349,6 @@ export default {
|
|||||||
selectSubmitter (submitter) {
|
selectSubmitter (submitter) {
|
||||||
this.$emit('update:model-value', submitter.uuid)
|
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) {
|
remove (submitter) {
|
||||||
if (window.confirm(this.t('are_you_sure_'))) {
|
if (window.confirm(this.t('are_you_sure_'))) {
|
||||||
this.$emit('remove', submitter)
|
this.$emit('remove', submitter)
|
||||||
|
|||||||
Reference in New Issue
Block a user