Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering phone entries #175

Closed
legrostdg opened this issue Apr 5, 2018 · 14 comments
Closed

Ordering phone entries #175

legrostdg opened this issue Apr 5, 2018 · 14 comments

Comments

@legrostdg
Copy link

It would be nice to be able to change the ordering of phone number entries.

Right now, khard SEARCH will only display one phone number per contact, which is OK for me, but I would like to specify which number should be displayed if several are available (for example, cell > home > work > fax > ...).

@lucc
Copy link
Owner

lucc commented Apr 9, 2018

Did you try to use the pref tag on the phon numbers?

@legrostdg
Copy link
Author

@lucc I don't get how to set this tag using khard... You mean the same pref as in vcard specification?

TEL;PREF=1;TYPE="home":+1-555-555-5555

@scheibler
Copy link
Collaborator

Please try out the latest code from develop.

From the change log:
New config variable for the contact table: preferred_phone_number_type

  • If the preferred type is set in khard's config file and there is a match, the corresponding
    phone number is displayed
  • If there is no match or the preferred type is not set manually, search for the
    auto-set preferred phone number indicated by the vcard attribute "pref"
  • If there is still no match, sort the types alphabetically and show the first phone number

Set the preferred_phone_number_type in the config file at the "contact table" section:

preferred_phone_number_type = home

Have a look into khard's example config file at misc/khard/khard.conf.example for more details.

@legrostdg
Copy link
Author

It seems to work great. I would have prefered to be able to sort the phone number types (cell > home > work > ...), but I guess I can live without.

@legrostdg
Copy link
Author

Just to be sure, how do you set the pref attribute? (by setting work, pref : +1111 in the editor?)

@legrostdg
Copy link
Author

And is it possible to set a number to pref (for example pref=10)?

@scheibler
Copy link
Collaborator

It seems to work great. I would have prefered to be able to sort the phone number types (cell > home > work > ...), but I guess I can live without.
Yes, a priority list. Thought about that too. Maybe I'll extend the preferred_phone_type_value setting in the future.

Just to be sure, how do you set the pref attribute?
Just add a "pref" behind the type value in khard's contact editor.
For example: cell, pref : +49 xxx xxxxxxx

And is it possible to set a number to pref (for example pref=10)?
Unfortunately that's not supported at the moment. But only vcard version 4.0 uses a weighted pref
value. Vcard version 3.0 only specifies pref or not pref. So it would be a bit complicated to
implement and with some "luck" you still use version 3.0 for your contacts anyway. Just execute khard src your_contact and check the version number.

Now that the general idea is approved I will add a similar setting for the email address just for completion.

@scheibler
Copy link
Collaborator

preferred_phone_number_type extended to hold a list of types instead of a single one
preferred_email_address_type: Same behavior as preferred_phone_number_type but for email address selection

Please have a look into misc/khard/khard.conf.example again.

@legrostdg
Copy link
Author

I tested your code, with the following setting:

preferred_phone_number_type = pref, cell, work, home

And a contact with:

TEL;TYPE=cell:+1111
TEL;TYPE=work,pref:+2222

khard "my contact" returns the cell number, so there seems to be an issue somewhere...

@legrostdg
Copy link
Author

Woops, my mistake... I ran the wrong version of khard. It returns work, pref, as expected.

@legrostdg
Copy link
Author

Thanks!

@scheibler
Copy link
Collaborator

Ok, I set your type list:
preferred_phone_number_type = pref, cell, work, home

Then I created the following vcard:

BEGIN:VCARD
VERSION:3.0
UID:hqp5q10v1du11n4uex1rkdg5aj0krrruopmp
FN:helge
N:;helge;;;
REV:20180501T115651Z
TEL;TYPE=cell:+1111
TEL;TYPE=work,pref:+2222
END:VCARD

khard details helge returns:

Name: helge
Address book: familie
Phone
    cell: +1111
    work, pref: +2222
Miscellaneous
    UID: hqp5q10v1du11n4uex1rkdg5aj0krrruopmp

Then I listed all phone numbers with khard phone helge:

Name     Type          Phone
helge    cell          +1111
helge    work, pref    +2222

The "phone" action should list all available matching phone numbers - therefore so far so good.

And now the contact table with khard ls helge:

Index    Name     Phone                E-Mail    UID
1        helge    work, pref: +2222              h

Here you get the work phone number cause "pref" was the first type in preferred_phone_number_type.

If you only enter khard "my contact" you call the default action in khard's config file implicitly
and I assumed, you mean "ls" for the contact table. But maybe we misunderstood each other in that point.

@legrostdg
Copy link
Author

No, that's the expected behaviour, I think we are in total agreement :-). As I said, I just ran the wrong version of khard.

@scheibler
Copy link
Collaborator

Oh, some message overlapping ... Now I see your previous message about the wrong khard version too.
Then everything is all right. Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants