girzel / ebdb

An EIEIO port of BBDB, Emacs' contact-management package
67 stars 12 forks source link

Q: is it possible to represent nested Organizations #111

Open nickgarber opened 1 year ago

nickgarber commented 1 year ago

Q: is it possible to represent nested Organizations, such as a Team within a Department within an Enterprise

From a Team Org, I tried to insert a role to a Department Org and received an error message:

cl-no-applicable-method: No Applicable method: ebdb-record-related, nil, #s(ebdb-field-role nil nil nil nil nil nil)

girzel commented 1 year ago

In principle there's no real barrier to doing this, one small adjustment to the code makes it possible, with the patch below (it basically just moves the (organizations . ebdb-field-role) element from one definition of ebdb-record-field-slot-query to another). As with many of these setups, the problem isn't the underlying structures so much as it is the UI. I'm not sure how this will shake out in terms of actual usage. Maybe give the below a shot, and let me know how you'd like things to work?

(I think there's one or two other adjustments that need to be made in order to avoid breakage, but this should be a start.)

diff --git a/ebdb.el b/ebdb.el
index c016dfbd88..67054c2f13 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -3494,7 +3494,8 @@ RECORD's FIELD anniversary, relative to NOW-YEAR."
    (append
     `((mail . ebdb-field-mail)
       (phone . ebdb-field-phone)
-      (address . ebdb-field-address))
+      (address . ebdb-field-address)
+      (organizations . ebdb-field-role))
     alist)))

 (cl-defmethod ebdb-record-current-fields ((record ebdb-record-entity)
@@ -3648,8 +3649,7 @@ ARGS are passed to `ebdb-compose-mail', and then to
    (append
     '((aka . ebdb-field-name-complex)
       (aka . ebdb-field-name-simple)
-      (relations . ebdb-field-relation)
-      (organizations . ebdb-field-role))
+      (relations . ebdb-field-relation))
     alist)))

 (cl-defmethod ebdb-record-firstname ((rec ebdb-record-person) &optional full)
girzel commented 1 year ago

I've pushed a change to this repo that should allow the creation of nested organizations. If you're comfortable running directly from the master branch you can try it out. I haven't done a release with this change yet, mostly because the UI side still needs some thought: a record's role fields need to be displayed differently depending on whether they are pointing to this record or from this record, and that will take some thought. The basics are there, though.

nickgarber commented 1 year ago

Awesome, thanks! I'll start poking around with it now.