Revert nickname idea (it's not updating as it was not observing)

This commit is contained in:
the-djmaze 2022-07-25 13:25:02 +02:00
parent 08ded5bb71
commit 859a18470e

View file

@ -29,7 +29,8 @@ export class ContactModel extends AbstractModel {
surName: '', // LastName
middleName: '', // MiddleName
namePrefix: '', // NamePrefix
nameSuffix: '' // NameSuffix
nameSuffix: '', // NameSuffix
nickname: null
});
// this.email = koArrayWithDestroy();
this.email = ko.observableArray();
@ -41,15 +42,6 @@ export class ContactModel extends AbstractModel {
fullName: () => (this.givenName() + ' ' + this.surName()).trim(),
nickname: {
read: () => {
let prop = this.jCard.getOne('nickname');
return prop && prop.value;
},
write: value =>
value ? this.jCard.set('nickname', value/*, params, group*/) : this.jCard.remove('nickname')
},
display: () => {
let a = this.jCard.getOne('fn')?.value,
b = this.fullName(),
@ -98,6 +90,9 @@ export class ContactModel extends AbstractModel {
value && contact[nProps[index]](value)
);
props = jCard.getOne('nickname');
props && contact.nickname(props.value);
['email', 'tel', 'url'].forEach(field => {
props = jCard.get(field);
props && props.forEach(prop => {
@ -161,6 +156,8 @@ export class ContactModel extends AbstractModel {
]/*, params, group*/);
// jCard.parseFullName({set:true});
this.nickname() ? jCard.set('nickname', this.nickname()/*, params, group*/) : jCard.remove('nickname');
['email', 'tel', 'url'].forEach(field => {
let values = this[field].map(item => item.value());
jCard.get(field).forEach(prop => {