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

dev/core#5634 Add ImportTemplateField entity #31580

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Dec 6, 2024

Overview

Draft

Copy link

civibot bot commented Dec 6, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Dec 6, 2024
Copy link

civibot bot commented Dec 6, 2024

The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/5634

@colemanw colemanw force-pushed the importTemplateFields branch from b41e84d to 734a3b9 Compare December 6, 2024 20:30
@colemanw colemanw force-pushed the importTemplateFields branch from 734a3b9 to 0aadb92 Compare December 31, 2024 22:49
name: importRow.selectedField,
default_value: importRow.defaultValue,
// At this stage column_number is thrown away but we store it here to have it for when we change that.
column_number: index,
column_number: index + 1,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton what does the above comment mean? I'm adding the +1 here to start the count at 1 instead of zero, but... it's thrown away?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - I think the underlying code just isn't looking at it

<?php

return [
'name' => 'ImportTemplateField',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I have been thinking about is adding transformations - which could be simple - eg 'upper' or they might be more complex. Part of me wonders if we should accomodate them in this table - although perhaps it would be a many to one joined table

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton couldn't they be stored in the entity_data column in this table?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw I guess so - the entity_data was originally about storing entity info - ie 'I have a related contact that might be created here - what is it's contact type if I have to create it' vs transformations which are field-specific. The name entity_date is not a great fit for the latter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea it's confusing either way. E.g. why are we storing entity_data at the field level?

Maybe a more generic name for the column would serve better, like "settings" or "data"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw yeah - let's go with data

As to why - if you look to the contact import you can see you can have multiple rows that import to different entities - ie mother first name, father first name, mother home phone, father home phone

Really it should be a case of 'specifiy the entities we import to & then on each row specify which one is involved' - but I don't quite know how to move in that direction

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton ok, I looked at that example, and this is all starting to make more sense. So basically our starting point is what I fondly call "the mismash", where the list of "Contact" importable fields includes a bunch of stuff that doesn't actually belong to the civicrm_contact table (phone, email, street_address, city, etc). And we have some hacks sprinkled around to create the mismash (mixing those into the list of importable fields) and then more hacks to untangle the mismash during the import and put things where they belong.

Aside from being messy, another problem with this model is lack of flexibility. The contact importer has a limited ability to also import related entities... as long as those entities are also contacts! And that limitation comes from the model of "flat list of fields". The UI and data model are amenable to importing related contacts because they share the same list of fields.

But what if we wanted to import related entities that are not contacts (activities, notes, etc)? We either have to add it to the mismash, or, as you said, make it a multi-step process where first you pick the entity and the "how is this thing related to the contact", and then you pick the field.

I think the way we move in that direction is by adding an entity column to this new table. That would be a good start.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw I think we might need an entity & an identifier - ie entity would be 'Address' & identifier might be either some criteria like 'location_type=Home' OR a name that refers to some other place where those things are configured

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton yea although for max flexibility we can just stick that stuff in entity_data aka data.

@colemanw colemanw force-pushed the importTemplateFields branch 2 times, most recently from 6427d59 to eb99637 Compare January 2, 2025 00:33
@colemanw colemanw force-pushed the importTemplateFields branch from eb99637 to 0373769 Compare January 2, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants