Skip to content

Commit e53b7ac

Browse files
authored
fix: fix contact information without a protocol (monicahq/chandler#347)
1 parent 27f6309 commit e53b7ac

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

app/Domains/Contact/ManageContactInformation/Web/ViewHelpers/ModuleContactInformationViewHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public static function dto(Contact $contact, ContactInformation $info): array
4141
return [
4242
'id' => $info->id,
4343
'label' => $info->name,
44-
'data' => $info->contactInformationType->protocol ? $info->contactInformationType->protocol.$info->data : $info->data,
44+
'protocol' => $info->contactInformationType->protocol,
45+
'data' => $info->data,
46+
'data_with_protocol' => $info->contactInformationType->protocol ? $info->contactInformationType->protocol.$info->data : $info->data,
4547
'contact_information_type' => [
4648
'id' => $info->contactInformationType->id,
4749
'name' => $info->contactInformationType->name,

resources/js/Shared/Modules/ContactInformation.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
:type="'text'"
4949
:autofocus="true"
5050
:input-class="'block w-full'"
51-
:required="false"
51+
:required="true"
5252
:autocomplete="false"
5353
:maxlength="255"
5454
@esc-key-pressed="addContactInformationModalShown = false" />
@@ -81,7 +81,10 @@
8181
class="item-list border-b border-gray-200 hover:bg-slate-50 dark:border-gray-700 dark:bg-slate-900 hover:dark:bg-slate-800">
8282
<!-- contact information -->
8383
<div v-if="editedContactInformationId != info.id" class="flex items-center justify-between px-3 py-2">
84-
<a :href="info.data" class="text-blue-500 hover:underline">{{ info.label }} </a>
84+
<div>
85+
<a :href="info.data_with_protocol" class="text-blue-500 hover:underline">{{ info.data }}</a>
86+
<span class="ml-2 text-xs text-gray-500">({{ info.label }})</span>
87+
</div>
8588

8689
<!-- actions -->
8790
<ul class="text-sm">
@@ -197,7 +200,7 @@ export default {
197200
this.addContactInformationModalShown = true;
198201
this.form.errors = [];
199202
this.form.data = '';
200-
this.form.contact_information_type_id = 0;
203+
this.form.contact_information_type_id = this.data.contact_information_types[0].id;
201204
202205
this.$nextTick(() => {
203206
this.$refs.newData.focus();

tests/Unit/Domains/Contact/ManageContactInformation/Web/ViewHelpers/ModuleContactInformationViewHelperTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ public function it_gets_the_data_transfer_object(): void
7878
[
7979
'id' => $info->id,
8080
'label' => 'Facebook shit',
81-
'data' => 'mailto:'.$info->data,
81+
'protocol' => 'mailto:',
82+
'data' => $info->data,
83+
'data_with_protocol' => 'mailto:'.$info->data,
8284
'contact_information_type' => [
8385
'id' => $type->id,
8486
'name' => 'Facebook shit',

0 commit comments

Comments
 (0)