Skip to content

Commit

Permalink
rework front end
Browse files Browse the repository at this point in the history
  • Loading branch information
ok200lyndon committed Aug 16, 2024
1 parent 69694dc commit 6a0d38d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class ApiMyTeamAuditItemsController extends Controller
/**
* Set the related data the GET request is allowed to ask for
*/
public array $availableRelations = [];
public array $availableRelations = [
'team',
];

public static array $searchableFields = [];

Expand Down
6 changes: 3 additions & 3 deletions app/Models/AuditItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class AuditItem extends Model
'auditable_id',
'auditable_type',
'auditable_text',
'team_id',
'user_id',
'auditable_team_id',
'actioning_user_id',
];

public function auditable(): MorphTo
Expand All @@ -26,6 +26,6 @@ public function auditable(): MorphTo

public function team(): BelongsTo
{
return $this->belongsTo(Team::class, 'team_id', 'id');
return $this->belongsTo(Team::class, 'auditable_team_id', 'id');
}
}
41 changes: 23 additions & 18 deletions resources/js/Components/AuditItemsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,37 @@ const $props = defineProps(['auditItems', 'isAdmin'])

<div v-for="auditItem in $props.auditItems.data"
class="flex justify-between items-center border-b border-gray-200 p-4">
<div class="space-x-3">
<span class="font-bold">
<div class="">
<span :class="{
'text-green-500': auditItem.auditable_text.includes('created'),
'text-orange-500': auditItem.auditable_text.includes('updated'),
'text-red-500': auditItem.auditable_text.includes('deleted')
}"
class="capitalize font-bold"
>
{{ auditItem.auditable_text }}
</span>

<span class="ml-6">
{{ auditItem.auditable_type.substring(auditItem.auditable_type.lastIndexOf("\\") + 1) }}
</span>

<a :href="'/admin/team/' + auditItem.team.id">
<span v-if="isAdmin" class="text-sm text-gray-600 hover:underline hover:text-blue-500">

<span class="text-sm text-gray-600 ml-2">
# {{ auditItem.auditable_id }}
</span>

<a v-if="isAdmin && auditItem.team?.id" :href="'/admin/team/' + auditItem.team.id">
<span class="text-sm text-gray-600 hover:underline hover:text-blue-500">
{{ auditItem.team.name }}
</span>
</a>

<span class="text-sm text-gray-600">
#{{ auditItem.auditable_id }}
</span>
</div>

<div class="">
<span :class="{
'text-green-500': auditItem.auditable_text === 'created',
'text-orange-500': auditItem.auditable_text === 'updated',
'text-red-500': auditItem.auditable_text === 'deleted'
}"
class="capitalize font-bold"
>
{{ auditItem.auditable_text }}
</span>
on {{ moment(auditItem.updated_at).format("dddd, MMMM Do YYYY [at] h:mm:ss a") }}


{{ moment(auditItem.updated_at).format("dddd, MMMM Do YYYY [at] h:mm:ss a") }}
</div>
</div>

Expand Down
14 changes: 0 additions & 14 deletions resources/js/Pages/AuditItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@ onMounted(() => {
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">


<div class="mb-8 p-4">
<div class="mb-4">
Filter to:
</div>
<div class="flex justify-start space-x-6">
<div class="hover:cursor-pointer hover:underline" @click="filterTo('')">User</div>
<div class="hover:cursor-pointer hover:underline" @click="filterTo('')">Team</div>
<div class="hover:cursor-pointer hover:underline" @click="filterTo('')">Voucher Set</div>
<div class="hover:cursor-pointer hover:underline" @click="filterTo('')">Voucher</div>
<div class="hover:cursor-pointer hover:underline" @click="filterTo('')">No Filter</div>
</div>
</div>


<AuditItemsComponent :audit-items="auditItems" :is-admin="isAdmin"/>

</div>
Expand Down

0 comments on commit 6a0d38d

Please sign in to comment.