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

Fix activity tokens #21489

Merged
merged 1 commit into from
Sep 17, 2021
Merged

Fix activity tokens #21489

merged 1 commit into from
Sep 17, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Sep 15, 2021

Overview

Fix activity tokens

Before

In testing for another PR @demeritcowboy and I were finding not all advertised tokens were being resolved

After

Working, test cover extended, still passes action schedule token tests.

Technical Details

I wasn't gonna touch these until the end since my plan was to get comprehensive test cover in place
and migrate the ambigous tokens to the new style before figuring out the 'final look' of whatever
combo of parent class/ trait we use - but it turns out there is some active breakage.

This is not intended to be the 'final word' but just 'enough to get it working again & supported
the preferred tokens'

It leaves out of scope a final cleanup pass and
the reconcilliation between the trait & parent class
and any decisions about any finalised interface.

Existing tokens still work but new-style are advertised with this

This is the block I've been testing with - I also tried {activity.location}


Subject: {activity.subject}
Date: {activity.activity_date_time}
Duration: {activity.duration}
Location: {activity.location}
Details: {activity.details}
Status ID: {activity.status_id}
(legacy) Status: {activity.status}
Status: {activity.status_id:label}
Activity Type ID: {activity.activity_type_id}
(legacy) Activity Type: {activity.activity_type}
Activity Type: {activity.activity_type_id:label}
Activity ID: {activity.activity_id}
(legacy) Activity ID: {activity.id}

(just weird) Case ID: {activity.case_id}

Comments

Tests cover the changes to tokens and
testActivityDateTimeMatchRepeatableSchedule covers the schedule rendering

Note that if this is merged I'll action the updates to scheduled reminders, docs, and the form rules for pdf & email but I won't add any noise / break the legacy style tokens as there is higher risk this class is being used outside of core. At some point we can

@civibot
Copy link

civibot bot commented Sep 15, 2021

(Standard links)

@civibot civibot bot added the master label Sep 15, 2021
@eileenmcnaughton eileenmcnaughton changed the title ccccccjelcgbthulekvbknlbvegcrnhfkdviegjtrtdcFix activity tokens cgbbjtenjuicjvhfuihdrkjbencenud[gcejlejccccccFix activity tokens Sep 15, 2021
@eileenmcnaughton eileenmcnaughton changed the title cgbbjtenjuicjvhfuihdrkjbencenud[gcejlejccccccFix activity tokens [wip]Fix activity tokens Sep 15, 2021
/**
* @inheritDoc
*/
public function getActiveTokens(TokenValueEvent $e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just copied back from the trait - this overrides the parent to

a) add in the old-style tokens and
b) do weird stuff - which is the general issue with this class

@eileenmcnaughton eileenmcnaughton force-pushed the act_toke branch 2 times, most recently from a5fd58d to d491ed0 Compare September 15, 2021 23:57
I wasn't gonna touch these until the end but there
seems to be some active breakage so this does enough to get the following to
work - but leaves a full cleanup pass out of scope as it does
the reconcilliation between the trait & parent class
and any decisions about any finalised interface.

Tests cover the changes to tokens and
testActivityDateTimeMatchRepeatableSchedule covers the schedule rendering

Existing tokens still work but new-style are advertised with this

```

Subject: {activity.subject}
Date: {activity.activity_date_time}
Duration: {activity.duration}
Location: {activity.location}
Details: {activity.details}
Status ID: {activity.status_id}
(legacy) Status: {activity.status}
Status: {activity.status_id:label}
Activity Type ID: {activity.activity_type_id}
(legacy) Activity Type: {activity.activity_type}
Activity Type: {activity.activity_type_id:label}
Activity ID: {activity.activity_id}
(legacy) Activity ID: {activity.id}

(just weird) Case ID: {activity.case_id}
```
@eileenmcnaughton eileenmcnaughton changed the title [wip]Fix activity tokens Fix activity tokens Sep 16, 2021
@seamuslee001
Copy link
Contributor

I think this will work for me but need to get @demeritcowboy to check as well

@eileenmcnaughton
Copy link
Contributor Author

test this please

}
elseif (in_array($field, ['case_id'])) {
// An activity can be linked to multiple cases so case_id is always an array.
// We just return the first case ID for the token.
$row->tokens($entity, $field, is_array($activity['case_id']) ? reset($activity['case_id']) : $activity['case_id']);
// this weird hack might exist because apiv3 is weird &
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't reviewed this fully yet just commenting on this - it's not api. You can have a single activity on multiple cases. Link-cases is an example in core. But returning a random case id when there's more than one maybe isn't a useful token.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@demeritcowboy do you think I can just remove it? It's pre-existing but I'd be happy to kill it.... although maybe I need to socialise that / make it a follow up?

Copy link
Contributor

Choose a reason for hiding this comment

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

When there's only one case it lives in, which is most of the time, it could be a useful token.

I am curious about hearing more about the use-cases for activity print/merge in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@demeritcowboy yeah that stuff was added by @aydun

I'd like to see if we can resolve this to get the existing tokens working & move that question to gitlab (since I just sorts keep it working here)

@demeritcowboy demeritcowboy merged commit 19b59db into civicrm:master Sep 17, 2021
@eileenmcnaughton
Copy link
Contributor Author

thanks @demeritcowboy

@eileenmcnaughton eileenmcnaughton deleted the act_toke branch September 17, 2021 19:31
@eileenmcnaughton
Copy link
Contributor Author

@demeritcowboy I opened https://lab.civicrm.org/dev/core/-/issues/2848 to ask the question about the tokens....

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.

3 participants