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

[2024-11-07] TinyMCE: Insert contact, but track using linkcheck #3169

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

PeterNerlich
Copy link
Collaborator

@PeterNerlich PeterNerlich commented Nov 1, 2024

Short description

We want to embed contacts on pages and in other content. This PR is an alternative to #3124.
Contact cards contain a hidden link, allowing us to track where a contact is used with the linkchecker.

Proposed changes

  • Add a URL to each contact, making it trackable by linkcheck
  • Add a custom TinyMCE plugin to embed contacts via a button and dialog, similar to our custom link plugin
  • In the contact form, show where contacts are being embedded
  • saving changes to a contact will update all translation objects referencing the contact

Side effects

  • linkcheck will check the contact links and find that no resource is being served at those URIs. THey are shown as valid, but we could also hide them.
  • The URI contains the region slug, but it is never relevant in the code for now

Known issues

Adding a contact to a page/poi/event is not immediately reflected in the contact form. It is reflected eventually, once the linkchecker has run again. (You can manually trigger this with ./tools/integreat-cms-cli findlinks, although even that is not 100% reliable...)
This is not ideal; IDK if we could trigger a linkcheck run every time a contact is saved...? Or can a Link manually be inserted into the DB?

Open quetions

The shortcut for adding a "[K]ontakt" is Ctrl+L, the shortcut for adding a "[L]ink" is Ctrl+K...
That's not exactly intuitive. @osmers is it feasible to switch these two, even though users might already be used to inserting links with Ctrl+K?

Resolved issues

Fixes: #2959


Pull Request Review Guidelines

@PeterNerlich PeterNerlich force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 03928ef to 9e1ff12 Compare November 1, 2024 18:44
@charludo charludo self-assigned this Nov 2, 2024
@PeterNerlich
Copy link
Collaborator Author

Adding TomSelect could easily be its own PR, but we already have so many of those. Feel free to split this up if you find a sensible way how

@PeterNerlich PeterNerlich force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 11f8851 to 36b8c05 Compare November 7, 2024 05:27
@charludo charludo force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from af2ce21 to 5e76e83 Compare December 2, 2024 09:17
@charludo charludo marked this pull request as ready for review December 2, 2024 09:18
@charludo
Copy link
Contributor

charludo commented Dec 2, 2024

This is now ready for review @PeterNerlich @david-venhoff @JoeyStk @MizukiTemma

@MizukiTemma
Copy link
Member

MizukiTemma commented Dec 3, 2024

I haven't yet finished reviewing but following functions seem to be behaving good:

  • No contact of other regions appears in the search result
  • No archived contact appears in the search result
  • String match in the search works
  • A contact can be embedded in a single content/multiple of contents
  • Multiple of contacts can be embedded in a single content
  • A contact can be embedded multiple of times in a single content
  • Changing an embedded contact to another works, the card is updated
  • Updating details of an embedded contact updates the card(s) in the content(s)
  • Embedded contact cards can be removed
  • Referencing contents are correctly recognised and shown in the contact form
  • DeepL, SUMM.AI and Google Translate can be used as before (for translation of contact cards see Translate point_of_contact_for content in contact cards #3259)

We probably need either protection of embedded contacts from deleting/archiving or automatic deletion of contact cards at the moment of contact deletion. An issue is opened for this topic #3260

@MizukiTemma
Copy link
Member

MizukiTemma commented Dec 3, 2024

Thank you so much for tackling this complicated issue 💪 This PR looks already super cool, the main functions seem to be working as expected 🥺 😻

I have some suggestions to the contact card.

  1. We may add the name of POI if the contact has neither point_of_contact_for nor name.
  2. Address of POI probably makes the contact card more informative (especially) if the contact has none of E-mail, phone number and website.
  3. No : if no name is provided? or we can probably look for an alternative, as : looks (in my opinion) a bit strange after : for gender-neutral position name.

Screenshot from 2024-12-03 14-39-04

@osmers Your opinion is important here 👂

ah, maybe a part of/related to #3258 ?

@osmers
Copy link

osmers commented Dec 4, 2024

I'd like to be able to test this myself to be able to say exactly what is missing, but from the things I can see here:

  1. We definitely need to include the address in a contact, if it's provided
  2. Do we already have the option now to select which contact details I want added to the contact card?
  3. Has the HIX problem been resolved? From the Mattermost thread I understand that it has been, right?

Everything else is a bit hard to decide without trying the function for myself and so far I don't see it on test yet, right?

Switching shortcuts - difficult question. I think it might confuse the people who are already using the existing shortcut, especially since it's the same for any other program to add a link. I think I would keep it, even though it's not intuitive... maybe @nikolahoff has some insight into user behaviour here as well?

@charludo
Copy link
Contributor

charludo commented Dec 4, 2024

  1. We may add the name of POI if the contact has neither point_of_contact_for nor name.

Do you mean that if the contact has no name, the user can enter one? If so, I think that is really difficult to achieve right now - it's also a bit contrary to the idea that users should manage contaacts in a central location. Or do yo mean that user can update existing contacts with a name on-the-fly and it gets saved to the contact model?
Sorry if I am misunderstanding you here 🙈

  1. Address of POI probably makes the contact card more informative (especially) if the contact has none of E-mail, phone number and website.

👍🏼 Good idea! Will add.

  1. No : if no name is provided? or we can probably look for an alternative, as : looks (in my opinion) a bit strange after : for gender-neutral position name.

Could we just drop the ":" altogether? Then it doesn't matter if a name is provided, and can't inferfer with ":" in titles. I think the bold font is probably enough separation? Not sure though.

@charludo
Copy link
Contributor

charludo commented Dec 4, 2024

I'd like to be able to test this myself to be able to say exactly what is missing

If you have a couple of minutes after the weekly, I could screenshare? Not the same as testing yourself, I know, but perhaps better than just reading about it 😄

  1. We definitely need to include the address in a contact, if it's provided

Will add. In the Grooming yesterday, opening hours were also mentioned - though I suspect that is something for down-the-line?

  1. Do we already have the option now to select which contact details I want added to the contact card?

No, this will be added after this PR is merged: #3258

  1. Has the HIX problem been resolved? From the Mattermost thread I understand that it has been, right?

No, not yet - just opened #3268 for this, thanks for the reminder 😅

Everything else is a bit hard to decide without trying the function for myself and so far I don't see it on test yet, right?

Yep, that'll only happen after this is merged.

Switching shortcuts - difficult question. I think it might confuse the people who are already using the existing shortcut, especially since it's the same for any other program to add a link. I think I would keep it, even though it's not intuitive... maybe @nikolahoff has some insight into user behaviour here as well?

Ah, fair point, I thought Ctrl+K for Links was "our invention", so to speak (I only knew it as "search globally" 😄).
But I am not sure if Ctrl_L is the best choice for contacts then. Maybe Ctrl+P for "Person"?

@osmers
Copy link

osmers commented Dec 4, 2024

@charludo that would be great - though I'm only free at 2pm for half an hour 😅

Regarding the shortcut - in word Ctrl+K is also for links :D and in Thunderbird as well...
Ctrl+P is known for printing, right? When I use it right now my browser wants to print the page...

Opening hours were initially planned by us but then dropped and the municipalities mentioned that they would need it bcs the opening hours for a contact can be quite different from the POI (which we had planned to just take). But I guess for the time being they could add them manually to the editor and we can implement it as an update afterwards...

@charludo
Copy link
Contributor

charludo commented Dec 4, 2024

Regarding the shortcut - in word Ctrl+K is also for links :D and in Thunderbird as well... Ctrl+P is known for printing, right? When I use it right now my browser wants to print the page...

Ctrl+P would be overriden by our own shortcut. IMO that's fine, I doubt anyone needs to print the CMS editor view... 😅

bcs the opening hours for a contact can be quite different from the POI

OK, so this is a planned feature, to be able to add "contact opening hours", and after tha't implemented we can add them here?

But I guess for the time being they could add them manually to the editor and we can implement it as an update afterwards...

Not 1005 sure what you mean - do you mean they can just add them as plain text in the editor? If so, sure, that's fine (albeit some extra work for them when we introduce the feature).
But they can not edit the contact card itself by changing text or adding fields.

@MizukiTemma
Copy link
Member

@charludo

  1. We may add the name of POI if the contact has neither point_of_contact_for nor name.

Do you mean that if the contact has no name, the user can enter one? If so, I think that is really difficult to achieve right now - it's also a bit contrary to the idea that users should manage contaacts in a central location. Or do yo mean that user can update existing contacts with a name on-the-fly and it gets saved to the contact model?
Sorry if I am misunderstanding you here 🙈

No no, I didn't mean that complicated 🙈
Each contact has a POI, and my idea is to display the name of this POI in the card in the position of point_of_contact_for and name.

@charludo
Copy link
Contributor

charludo commented Dec 4, 2024

@charludo

  1. We may add the name of POI if the contact has neither point_of_contact_for nor name.

Do you mean that if the contact has no name, the user can enter one? If so, I think that is really difficult to achieve right now - it's also a bit contrary to the idea that users should manage contaacts in a central location. Or do yo mean that user can update existing contacts with a name on-the-fly and it gets saved to the contact model?
Sorry if I am misunderstanding you here 🙈

No no, I didn't mean that complicated 🙈 Each contact has a POI, and my idea is to display the name of this POI in the card in the position of point_of_contact_for and name.

Ohhhhhh that makes sense. Sorry 😄
Will add!

@charludo
Copy link
Contributor

charludo commented Dec 7, 2024

@MizukiTemma how about this for avoiding the ":"?
image

Also, if I understood @osmers correctly, the POI name should not be shown afterall, only its address.

@osmers is the styling OK with you? Reduced the gaps as suggested. No gaps look kinda weird however.

@charludo charludo force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 49e066b to fa0f8e1 Compare December 7, 2024 10:25
Copy link
Member

@MizukiTemma MizukiTemma left a comment

Choose a reason for hiding this comment

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

Thank you so much 🥺 🙏 Looks good 🚀

@MizukiTemma MizukiTemma added the blocker This issue blocks another issue label Dec 9, 2024
@charludo
Copy link
Contributor

I've added a link to the Integreat Map, if it is shown there, to Google Maps otherwise. I've also updated the link shown in the contact edit view to use the same, consistent link to the Integreat Map.

@charludo charludo force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 3a4f17e to bebba4b Compare December 11, 2024 09:25
@MizukiTemma MizukiTemma added prio: urgent Needs to be resolved now(?) and removed prio: high Needs to be resolved ASAP. labels Dec 11, 2024
Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

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

Thank you so much for this massive pr, it looks really cool 🚀

I have a bunch of suggestions, but most of them are relatively minor or just nits.

integreat_cms/cms/templates/contacts/contact_card.html Outdated Show resolved Hide resolved
integreat_cms/cms/templates/contacts/contact_card.html Outdated Show resolved Hide resolved
integreat_cms/cms/templates/contacts/contact_card.html Outdated Show resolved Hide resolved
integreat_cms/cms/templates/contacts/contact_card.html Outdated Show resolved Hide resolved
integreat_cms/cms/models/contact/contact.py Outdated Show resolved Hide resolved
integreat_cms/cms/utils/internal_link_checker.py Outdated Show resolved Hide resolved
@charludo charludo force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 85877d0 to 1e51ce7 Compare December 12, 2024 10:44
@charludo
Copy link
Contributor

I have a bunch of suggestions, but most of them are relatively minor or just nits.

Thank you for the thorough review!! I think I was able to address most of it, apart from the unresolved conversation above.

@charludo charludo force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 1e51ce7 to 29a989f Compare December 16, 2024 08:32
Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

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

Awesome, let's give it a try 🥳

integreat_cms/cms/templates/contacts/contact_card.html Outdated Show resolved Hide resolved
integreat_cms/cms/templates/contacts/contact_card.html Outdated Show resolved Hide resolved
integreat_cms/static/src/css/tinymce_custom.css Outdated Show resolved Hide resolved
integreat_cms/static/src/css/contact_card.css Outdated Show resolved Hide resolved
integreat_cms/static/src/css/tinymce_custom.css Outdated Show resolved Hide resolved
integreat_cms/static/src/css/tinymce_custom.css Outdated Show resolved Hide resolved
@MizukiTemma
Copy link
Member

@charludo
Don't forget to squash the commits before merge 😸

@charludo
Copy link
Contributor

@david-venhoff fantastic, thank you, those changes all make perfect sense 👍🏼
@MizukiTemma 👀 👀 👀 👀

@charludo charludo force-pushed the feature/tinymce-insert-contact-use-linkcheck branch from 81a9c96 to 0944716 Compare December 18, 2024 07:01
@charludo charludo merged commit 2e01833 into develop Dec 18, 2024
5 checks passed
@charludo charludo deleted the feature/tinymce-insert-contact-use-linkcheck branch December 18, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker This issue blocks another issue deadline Needs to be fixed in the given time prio: urgent Needs to be resolved now(?)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[2024-11-07] Add contact as choice for "insert" in TinyMCE
5 participants