Skip to content

Commit

Permalink
fix(data): Data gets reloaded without page refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
herrtxbias committed Mar 18, 2021
1 parent 0c845a0 commit 52471f5
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 116 deletions.
2 changes: 1 addition & 1 deletion app/Http/Livewire/Dashboard/Administration/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function render()
}

public function refreshData(){
$this->redirectRoute('dashboard.admin.users');
// Placeholder
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Dashboard/Components/Components.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public function changeVisibility($id, $oldVis){
}

public function refreshData(){
$this->redirectRoute('dashboard.components');
// Placeholder
}
}
27 changes: 14 additions & 13 deletions app/Http/Livewire/Dashboard/Components/Modals/ComponentAddModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class ComponentAddModal extends Component
public ComponentGroup $group;

public bool $modal = false;
public \App\Models\Component $model;
public \App\Models\Component $comp;

protected $rules = [
'model.name' => 'required|string|min:3',
'model.link' => 'url',
'model.description' => 'string|min:3',
'model.status_id' => 'required|integer|min:1|max:6',
'model.order' => 'integer',
'model.visibility' => 'boolean',
'comp.name' => 'required|string|min:3',
'comp.link' => 'url',
'comp.description' => 'string|min:3',
'comp.status_id' => 'required|integer|min:1|max:6',
'comp.order' => 'integer',
'comp.visibility' => 'boolean',
];

public function render()
Expand All @@ -34,23 +34,24 @@ public function render()
}

public function start(){
$this->model = new \App\Models\Component();
$this->model->status_id = 2;
$this->comp = new \App\Models\Component();
$this->comp->status_id = 2;
$this->comp->order = 0;
$this->modal = true;
}

public function save(){
$this->model->group = $this->group->id;
$this->model->user = Auth::id();
$this->comp->group = $this->group->id;
$this->comp->user = Auth::id();

$this->validate();

$this->model->save();
$this->comp->save();

ActionLog::dispatch(array(
'user' => Auth::id(),
'type' => 1,
'message' => 'Component '.$this->model->name.' (ID: '.$this->model->id.')',
'message' => 'Component '.$this->comp->name.' (ID: '.$this->comp->id.')',
));

$this->modal = false;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Dashboard/Incidents/Incidents.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function render()
}

public function refreshData(){
$this->redirectRoute('dashboard.incidents');
// Placeholder
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Dashboard/Incidents/PastIncidents.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function render()
}

public function refreshData(){
$this->redirectRoute('dashboard.incidents.past');
// Placeholder
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Dashboard/Maintenances/Maintenances.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function render()
}

public function refreshData(){
$this->redirectRoute('dashboard.incidents.maintenances');
// Placeholder
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function render()
}

public function refreshData(){
$this->redirectRoute('dashboard.incidents.past');
// Placeholder
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Dashboard/Metrics/Metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function render()
}

public function refreshData(){
$this->redirectRoute('dashboard.metrics');
// Placeholder
}
}
170 changes: 86 additions & 84 deletions resources/views/livewire/dashboard/components/components.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,96 +12,98 @@
@livewire('dashboard.components.modals.component-group-add-modal')
@endcan
@foreach($groups as $group)
<x-jet-section-title>
<x-slot name="title">
Group: {{ $group->name }}
@can('edit_componentgroups')
@livewire('dashboard.components.modals.component-group-update-modal', ['group' => $group], key($group->id))
@endcan
@can('delete_componentgroups')
@livewire('dashboard.components.modals.component-group-delete-modal', ['group' => $group], key($group->id))
@endcan
</x-slot>
<x-slot name="description">
ID: {{ $group->id }} | Visibility: {{ $group->visibility == 0 ? 'False' : 'True' }}
@can('edit_componentgroups')
<button wire:loading.attr="disabled" wire:click="changeVisibility({{ $group->id }}, {{ $group->visibility }})" class="text-indigo-600 hover:text-indigo-900">Switch Visibility</button>
@endcan
| Creator: {{ $group->user()->name }} | Order: {{ $group->order }}
</x-slot>
</x-jet-section-title>
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8 mt-2">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
ID
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Name
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Visibility
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Order
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Creator
</th>
<th scope="col" class="relative px-6 py-3">
@can('add_components')
@livewire('dashboard.components.modals.component-add-modal', ['group' => $group], key($group->id))
@endcan
</th>
</tr>
</thead>
<tbody>
@foreach($group->components() as $comp)
<tr class="bg-white">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{{ $comp->id }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{{ $comp->name }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $comp->visibility == 0 ? 'False' : 'True' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $comp->order }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<div>
<x-jet-section-title>
<x-slot name="title">
Group: {{ $group->name }}
@can('edit_componentgroups')
<livewire:dashboard.components.modals.component-group-update-modal :group="$group" :key="time().$group->id" />
@endcan
@can('delete_componentgroups')
<livewire:dashboard.components.modals.component-group-delete-modal :group="$group" :key="time().time().$group->id" />
@endcan
</x-slot>
<x-slot name="description">
ID: {{ $group->id }} | Visibility: {{ $group->visibility == 0 ? 'False' : 'True' }}
@can('edit_componentgroups')
<button wire:loading.attr="disabled" wire:click="changeVisibility({{ $group->id }}, {{ $group->visibility }})" class="text-indigo-600 hover:text-indigo-900">Switch Visibility</button>
@endcan
| Creator: {{ $group->user()->name }} | Order: {{ $group->order }}
</x-slot>
</x-jet-section-title>
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8 mt-2">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
ID
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Name
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Visibility
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Order
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Creator
</th>
<th scope="col" class="relative px-6 py-3">
@can('add_components')
<livewire:dashboard.components.modals.component-add-modal :group="$group" :key="time().time().time().$group->id" />
@endcan
</th>
</tr>
</thead>
<tbody>
@foreach($group->components() as $comp)
<tr class="bg-white">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{{ $comp->id }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{{ $comp->name }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $comp->visibility == 0 ? 'False' : 'True' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $comp->order }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full {{ str_replace('text-', 'bg-', $comp->status()->color) }} text-white">
&nbsp;&nbsp;
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $comp->user()->name }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<div class="inline">
@can('edit_components')
@livewire('dashboard.components.modals.component-update-modal', ['comp' => $comp], key($comp->id))
@endcan
@can('delete_components')
@livewire('dashboard.components.modals.component-delete-modal', ['comp' => $comp], key($comp->id))
@endcan
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $comp->user()->name }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<div class="inline">
@can('edit_components')
<livewire:dashboard.components.modals.component-update-modal :comp="$comp" :key="time().$comp->id" />
@endcan
@can('delete_components')
<livewire:dashboard.components.modals.component-delete-modal :comp="$comp" :key="time().time().$comp->id" />
@endcan
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<x-jet-section-border></x-jet-section-border>
</div>
<x-jet-section-border></x-jet-section-border>
@endforeach
</div>
</div>
Expand Down

0 comments on commit 52471f5

Please sign in to comment.