Compare commits
2 Commits
848e4b9b0f
...
655b789e06
| Author | SHA1 | Date | |
|---|---|---|---|
| 655b789e06 | |||
| 50df055794 |
@@ -175,9 +175,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field-row">
|
<div class="field-row">
|
||||||
<div class="field" style="max-width:120px">
|
<div class="field" style="max-width:130px">
|
||||||
<label>Anrede</label>
|
<label>Anrede</label>
|
||||||
<InputText v-model="contactForm.prefix" />
|
<Select v-model="contactForm._salutation" :options="salutationOptions"
|
||||||
|
showClear placeholder="–" />
|
||||||
|
</div>
|
||||||
|
<div class="field" style="max-width:160px">
|
||||||
|
<label>Titel</label>
|
||||||
|
<Select v-model="contactForm._title" :options="titleOptions"
|
||||||
|
editable showClear placeholder="–" />
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Vorname</label>
|
<label>Vorname</label>
|
||||||
@@ -409,10 +415,27 @@ const urlTypes = [
|
|||||||
{ label: 'Privat', value: 'home' }, { label: 'Geschäftlich', value: 'work' },
|
{ label: 'Privat', value: 'home' }, { label: 'Geschäftlich', value: 'work' },
|
||||||
{ label: 'Sonstige', value: 'other' },
|
{ label: 'Sonstige', value: 'other' },
|
||||||
]
|
]
|
||||||
|
const salutationOptions = ['Herr', 'Frau', 'Divers']
|
||||||
|
const titleOptions = ['Dr.', 'Dr. med.', 'Dr.-Ing.', 'Prof.', 'Prof. Dr.', 'Dipl.-Ing.', 'Dipl.-Kfm.', 'Mag.', 'M.Sc.', 'B.Sc.']
|
||||||
|
|
||||||
|
function splitPrefix(prefix) {
|
||||||
|
// "Herr Dr." -> { salutation: 'Herr', title: 'Dr.' }
|
||||||
|
const s = (prefix || '').trim()
|
||||||
|
if (!s) return { salutation: '', title: '' }
|
||||||
|
for (const sal of salutationOptions) {
|
||||||
|
if (s === sal) return { salutation: sal, title: '' }
|
||||||
|
if (s.startsWith(sal + ' ')) return { salutation: sal, title: s.slice(sal.length + 1).trim() }
|
||||||
|
}
|
||||||
|
return { salutation: '', title: s }
|
||||||
|
}
|
||||||
|
function joinPrefix(salutation, title) {
|
||||||
|
return [salutation, title].filter(x => x && x.trim()).join(' ').trim()
|
||||||
|
}
|
||||||
|
|
||||||
function emptyContact() {
|
function emptyContact() {
|
||||||
return {
|
return {
|
||||||
prefix: '', first_name: '', middle_name: '', last_name: '', suffix: '',
|
prefix: '', _salutation: '', _title: '',
|
||||||
|
first_name: '', middle_name: '', last_name: '', suffix: '',
|
||||||
display_name: '', nickname: '',
|
display_name: '', nickname: '',
|
||||||
organization: '', department: '', job_title: '',
|
organization: '', department: '', job_title: '',
|
||||||
emails: [], phones: [], addresses: [], websites: [], impp: [], categories: [],
|
emails: [], phones: [], addresses: [], websites: [], impp: [], categories: [],
|
||||||
@@ -594,8 +617,11 @@ async function openEditContact(row) {
|
|||||||
editingContactId.value = row.id
|
editingContactId.value = row.id
|
||||||
const res = await apiClient.get(`/contacts/${row.id}`)
|
const res = await apiClient.get(`/contacts/${row.id}`)
|
||||||
const c = res.data
|
const c = res.data
|
||||||
|
const split = splitPrefix(c.prefix)
|
||||||
Object.assign(contactForm, emptyContact(), {
|
Object.assign(contactForm, emptyContact(), {
|
||||||
prefix: c.prefix || '',
|
prefix: c.prefix || '',
|
||||||
|
_salutation: split.salutation,
|
||||||
|
_title: split.title,
|
||||||
first_name: c.first_name || '',
|
first_name: c.first_name || '',
|
||||||
middle_name: c.middle_name || '',
|
middle_name: c.middle_name || '',
|
||||||
last_name: c.last_name || '',
|
last_name: c.last_name || '',
|
||||||
@@ -636,6 +662,9 @@ function onPhotoSelected(ev) {
|
|||||||
|
|
||||||
async function saveContact() {
|
async function saveContact() {
|
||||||
const payload = { ...contactForm }
|
const payload = { ...contactForm }
|
||||||
|
payload.prefix = joinPrefix(contactForm._salutation, contactForm._title)
|
||||||
|
delete payload._salutation
|
||||||
|
delete payload._title
|
||||||
payload.categories = categoriesString.value.split(',').map(s => s.trim()).filter(Boolean)
|
payload.categories = categoriesString.value.split(',').map(s => s.trim()).filter(Boolean)
|
||||||
// Drop empty sub-rows
|
// Drop empty sub-rows
|
||||||
payload.emails = payload.emails.filter(e => e.value.trim())
|
payload.emails = payload.emails.filter(e => e.value.trim())
|
||||||
|
|||||||
Reference in New Issue
Block a user