Skip to content

Commit

Permalink
Rework views (#124)
Browse files Browse the repository at this point in the history
add simple navigation system
various fixes
  • Loading branch information
lugopi authored Dec 16, 2023
1 parent d3f5dda commit 97cdc40
Show file tree
Hide file tree
Showing 20 changed files with 669 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function index(string $id)
"page" => "Invitations index",
"pageTitle" => "Invitations",
"pageDescription" => "Gérer les invitations de l'organisation $organization->name",
"pageParent" => ["management.organizations.index"=>[]],
"invitations" => Paginate::paginate($invitations),
"org" => $organization
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Laundry;
use App\Models\Machine;
use App\Utils\Paginate;
use Illuminate\Support\Facades\Auth;

Expand All @@ -28,6 +27,7 @@ public function index(string $orgId)
"page" => "laundries management index",
"pageTitle" => "Laundries Management",
"pageDescription" => "Gérez vos buandries",
"pageParent" => ["management.organizations.index" => []],
],
compact('laundries','orgId')
);
Expand All @@ -53,6 +53,7 @@ public function show(string $orgId, string $id)
"page" => "laundries",
"pageTitle" => "Laundries",
"pageDescription" => "Gérez vos buandries",
"pageParent" => ["management.laundries.index" => [$orgId]],
],
compact('laundry','machines')
);
Expand All @@ -66,6 +67,7 @@ public function create(string $orgId)
"page" => "laundries create",
"pageTitle" => "Laundries Creation",
"pageDescription" => "Créez votre buandrie",
"pageParent" => ["management.organizations.index" => []],
],
compact('orgId')
);
Expand Down Expand Up @@ -121,6 +123,7 @@ public function edit(string $orgId, string $id)
"page" => "laundries edit",
"pageTitle" => "Edit laundries",
"pageDescription" => "Modifier vos buandries",
"pageParent" => ["management.laundries.index" => [$orgId]],
],
compact('laundry','machines')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function index(string $orgId, string $laundryId)
"page" => "machines management index",
"pageTitle" => "Machines Management",
"pageDescription" => "Gérez vos machines",
"pageParent" => ["management.laundries.index" => ["orgId" => $orgId]],
],
compact('machines', 'orgId', 'laundryId')
);
Expand Down Expand Up @@ -73,23 +74,24 @@ public function show(string $orgId, string $laundryId, string $id)
"page" => "machines management show",
"pageTitle" => "Machines Management",
"pageDescription" => "Gérez vos machines",

"pageParent" => ["management.machines.index" => ["orgId" => $orgId, "laundryId" => $laundryId]],
],
compact('machine', 'orgId', 'laundryId')
);
}

public function create(string $orgId, string $laundryId)
{

$types = MachineType::all();
return view(
'management.machines.create',
[
"page" => "machine create",
"pageTitle" => "Machine Creation",
"pageDescription" => "Créez votre machine",
"pageParent" => ["management.machines.index" => ["orgId" => $orgId, "laundryId" => $laundryId]],
],
compact(MachineType::cases(), 'orgId', 'laundryId')
compact('types', 'orgId', 'laundryId')
);
}

Expand Down Expand Up @@ -163,7 +165,7 @@ public function edit(string $orgId, string $laundryId, string $id)
"page" => "machines management show",
"pageTitle" => "Machines Management",
"pageDescription" => "Gérez vos machines",

"pageParent" => ["management.machines.index" => ["orgId" => $orgId, "laundryId" => $laundryId]],
],
compact('laundries', 'machine', 'types', 'orgId', 'laundryId')
);
Expand Down Expand Up @@ -232,7 +234,7 @@ public function destroy(string $orgId, string $laundryId, string $id)

Machine::find($id)->delete();

return redirect()->route('management.laundries.show', [$orgId, $laundryId])->with([
return redirect()->route('management.machines.index', [$orgId, $laundryId])->with([
'success' => 'Machine supprimé avec succes',
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function show(string $id)
"page" => "organizations",
"pageTitle" => "Organizations",
"pageDescription" => "Gérez vos Organisations",
"pageParent" => ["management.organizations.index"=>[]],
],
compact('organization'));
}
Expand All @@ -54,6 +55,7 @@ public function create()
"page" => "organizations create",
"pageTitle" => "Organizations Creation",
"pageDescription" => "Créez votre organisation",
"pageParent" => ["management.organizations.index"=>[]],
]);
}
public function store(Request $request)
Expand All @@ -67,9 +69,9 @@ public function store(Request $request)
return back()->withErrors(["Organization already exists."])->withInput();
}

Auth::user()->organizations()->create([
Organization::create([
'name' => $request->name,
]);
])->users()->attach(Auth::user()->id);

return redirect()->route('management.organizations.index')->with([
'success' => 'Organisation créée avec succès',
Expand All @@ -89,6 +91,7 @@ public function edit(string $id)
"page" => "organizations edit",
"pageTitle" => "Edit organizations",
"pageDescription" => "Modifier vos Organisations",
"pageParent" => ["management.organizations.index"=>[]],
],

compact('organization'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function index(string $orgID)
"page" => "user management",
"pageTitle" => "Gestion des utilisateurs",
"pageDescription" => "Gérez les utilisateurs de votre organisation",
"pageParent" => ["management.organizations.index"=>[]],
"org" => $organization,
"users" => Paginate::paginate($users, 15)
]);
Expand Down Expand Up @@ -67,6 +68,7 @@ public function add(string $orgID){
"page" => "user management",
"pageTitle" => "Gestion des utilisateurs",
"pageDescription" => "Gérez les utilisateurs de votre organisation",
"pageParent" => ['management.users.index' => [$orgID]],
"orgID" => $orgID,
]);
}
Expand Down Expand Up @@ -129,10 +131,19 @@ public function userDetails(string $orgID, string $userID)
return Auth::user()->organizations->contains($reservation->organization);
});

// change machine type to machine name for each reservation
$reservations = $reservations->map(function (Reservation $reservation){
$reservation->machine->typeName = $reservation->machine->typeName();
return $reservation;
});

$reservations = Paginate::paginate(collect($reservations)->sortBy('start')->reverse()->toArray(), 15);

return view('management.users.show', [
"page" => "user management",
"pageTitle" => "Détail de l'utilisateur",
"pageDescription" => "Visualiser le détail de votre utilisateur",
"pageParent" => ['management.users.index' => [$orgID]],
"reservations" => $reservations,
"orgID" => $orgID,
]);
Expand Down
3 changes: 3 additions & 0 deletions calm-webserver/app/Http/Controllers/ReservationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function create()
"pageTitle" => "Nouvelle réservation",
"pageDescription" => "Créez,une réservation. Choisissez l'organisation, la buanderie, le type de machine, la date et
la durée.",
"pageParent" => ["reservations.index"=>[]],
"reserving" => false,
'organizations' => Auth::user()->organizations,
"machinesTypes" => MachineType::all(),
Expand Down Expand Up @@ -160,6 +161,7 @@ public function show_propositions(Request $request){
"page" => "reservations",
"pageTitle" => "Choix d'une réservation",
"pageDescription" => "Choisissez une réservation parmi les propositions.",
"pageParent" => ["reservations.create"=>[]],
"proposition" => $param,
]);
}
Expand Down Expand Up @@ -212,6 +214,7 @@ public function show(string $id)
"page" => "reservations",
"pageTitle" => "Details de la réservation",
"pageDescription" => "Affiche les details de la reservation",
"pageParent" => ["reservations.index"=>[]],
"reservation" => $reservation
],
);
Expand Down
39 changes: 18 additions & 21 deletions calm-webserver/resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
label {
@apply block text-sm font-medium leading-6 text-gray-900;
}

thead {
@apply text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400
}
tr {
@apply border-b hover:bg-gray-50 text-center;
}
tr:last-child {
@apply border-b-0;
}
}

@layer components {
Expand Down Expand Up @@ -133,44 +143,31 @@
/*
Users management
*/



@media only screen and (max-width: 1023px) {

thead,
tbody,
th,
td,
tr {
display: block;
@apply block;
}

thead tr {
position: absolute;
top: -9999px;
left: -9999px;
@apply hidden;
}


td:first-child {
border-top: 1px solid #ccc;
@apply border-t-2 ;
}

td {
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding: 3rem 0 1rem;
white-space: normal;
text-align: right;
}

td:before {
position: absolute;
top: 25%;
left: 5%;
width: 45%;
white-space: nowrap;
text-align: left;
font-weight: bold;
color: rgb(107 114 128 / var(--tw-text-opacity));
@apply flex p-2 font-bold items-center text-gray-500;
content: attr(data-title);
}
}
37 changes: 37 additions & 0 deletions calm-webserver/resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ import 'flowbite';
form.action = "/management/reservations/" + button.dataset.reservationId;
}

function deleteOrganization(button, form)
{
form.action = "/management/" + button.dataset.organizationId;
}

function deleteLaundry(button, form)
{
form.action = "/management/" + button.dataset.organizationId + "/laundries/" + button.dataset.laundryId;
}

function deleteMachine(button, form)
{
form.action = "/management/" + button.dataset.organizationId + "/laundries/" + button.dataset.laundryId + "/machines/" + button.dataset.machineId;
}

/**
* Toggle the display of invitation lines based on the checkbox state.
*/
Expand Down Expand Up @@ -162,6 +177,28 @@ import 'flowbite';
});
});

const adminDeleteOrganizationButtons = getElements(".btn-admin-delete-organization");
adminDeleteOrganizationButtons.forEach((button) => {
addEvent(button, "click", () => {
deleteOrganization(button, getElement("#delete-organization-form"))
});
})

const adminDeleteLaundryButtons = getElements(".btn-admin-delete-laundry");
adminDeleteLaundryButtons.forEach((button) => {
addEvent(button, "click", () => {
deleteLaundry(button, getElement("#delete-laundry-form"))
});
})

const adminDeleteMachineButtons = getElements(".btn-admin-delete-machine");
adminDeleteMachineButtons.forEach((button) => {
addEvent(button, "click", () => {
deleteMachine(button, getElement("#delete-machine-form"))
});
})


const toggleInvitationShow = getElement("#showOnlyActivateInvitations");
addEvent(toggleInvitationShow, "change", toggleInvitaionDisplay);
}()); //mainProgram
Expand Down
16 changes: 15 additions & 1 deletion calm-webserver/resources/views/layout/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class="flex mr-3 text-sm bg-transparent text-white rounded-full md:mr-0 focus:ri

<ul class="py-2" aria-labelledby="user-menu-button">
<li>
<a href="{{ route('user.index') }}" class="block px-4 py-2 text-sm hover:bg-berylGreen">Compte</a>
<a href="{{ route('user.index') }}"
class="block px-4 py-2 text-sm hover:bg-berylGreen">Compte</a>
</li>
<li>
<form action="{{ route('logout') }}" method="post"
Expand Down Expand Up @@ -161,7 +162,20 @@ class="block py-2 pl-3 pr-4 rounded hover:bg-rollingStone md:hover:bg-transparen
</x-toast>
@endif

@if (isset($pageParent))
@foreach ($pageParent as $page => $args)
<a href="{{ route($page, $args) }}"
class="sticky top-2 btn btn-transparent flex lg:ml-2 lg:inline-flex justify-center">
<span class="icons">arrow_back</span>
Retour
</a>
@endforeach
@endif

@yield('content')



</main>

<footer class="bg-white rounded-lg m-4 text-center mt-auto mx-auto">
Expand Down
Loading

0 comments on commit 97cdc40

Please sign in to comment.