Skip to content

Commit

Permalink
feat: add next reminder date to stayintouch (#5491)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusDick authored Sep 13, 2021
1 parent 166bdbc commit c544deb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public function vCard(Contact $contact)
*
* @param Request $request
* @param Contact $contact
* @return int|RedirectResponse
* @return array
*/
public function stayInTouch(Request $request, Contact $contact)
{
Expand All @@ -632,7 +632,10 @@ public function stayInTouch(Request $request, Contact $contact)

$contact->setStayInTouchTriggerDate($frequency);

return $frequency;
return [
'frequency' => $frequency,
'trigger_date' => $contact->stay_in_touch_trigger_date,
];
}

/**
Expand Down
16 changes: 15 additions & 1 deletion resources/js/components/people/StayInTouch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
display: block;
color:#f57f6c;
}
.dashed {
border-bottom-style: dashed;
}
</style>

<template>
Expand All @@ -23,7 +27,7 @@

<!-- Contact has a frequency set -->
<div v-else class="di">
<span>
<span v-tooltip.bottom="$t('people.stay_in_touch_next_date', { date: formatDate(next_trigger_date) })" class="bb dashed dib pointer nowrap-link">
{{ $tc('people.stay_in_touch_frequency', frequency, { count: frequency }) }}
</span>
<a class="pointer" href="" @click.prevent="showUpdate">
Expand Down Expand Up @@ -227,6 +231,7 @@ export default {
this.frequency = 0;
} else {
this.frequency = parseInt(this.contact.stay_in_touch_frequency);
this.next_trigger_date = this.contact.stay_in_touch_trigger_date;
}
this.isActive = (this.frequency > 0);
Expand All @@ -236,6 +241,14 @@ export default {
this.stateInput = this.isActive;
this.frequencyInput = this.frequency;
},
formatDate(dateAsString) {
const moment = require('moment-timezone');
moment.locale(this._i18n.locale);
moment.tz.setDefault('UTC');
var date = moment.tz(moment(dateAsString), this.$root.timezone);
return date.format('LL');
},
showUpdate() {
this.errorMessage = '';
Expand Down Expand Up @@ -266,6 +279,7 @@ export default {
this.$refs.updateModal.close();
this.isActive = this.stateInput;
this.frequency = this.frequencyInput;
this.next_trigger_date = response.data.trigger_date;
this.$notify({
group: 'main',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/people.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
// Stay in touch
'stay_in_touch' => 'Stay in touch',
'stay_in_touch_frequency' => 'Stay in touch every day|Stay in touch every {count} days',
'stay_in_touch_next_date' => 'Next due: {date}',
'stay_in_touch_invalid' => 'The frequency must be a number greater than 0.',
'stay_in_touch_premium' => 'You need to upgrade your account to make use of this feature',
'stay_in_touch_modal_title' => 'Stay in touch',
Expand Down

0 comments on commit c544deb

Please sign in to comment.