Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#47 - multiple UX improvements #144

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Actions/ActivateSemesterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function execute(Semester $semester): void

$semester->update(["active" => !$semester->active]);

if ($semester->active) {
Semester::query()->whereNot("id", $semester->id)->update(["active" => false]);
}

$this->db->commit();
} catch (Exception $exception) {
$this->db->rollBack();
Expand Down
7 changes: 6 additions & 1 deletion app/DTOs/CoursePublicData.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Keating\Enums\ClassType;
use Keating\Enums\SemesterName;
use Keating\Models\Course;
use Keating\Models\CourseSemester;

readonly class CoursePublicData
{
Expand Down Expand Up @@ -40,7 +41,11 @@ public static function fromModel(Course $course, ?Collection $activeSemesters =
typeAbbreviation: ClassType::abbreviationLabels()[$course->type],
field: $course->field->name,
fieldAbbreviation: $course->field->abbreviation,
active: $activeSemesters && ($activeSemesters->contains($course->getRomanizedSemester()) || $activeSemesters->contains($course->semester)),
active: CourseSemester::query()
->join("semesters", "course_semester.semester_id", "=", "semesters.id")
->where("semesters.active", true)
->where("course_semester.course_id", $course->id)
->count() > 0,
);
}
}
2 changes: 2 additions & 0 deletions app/DTOs/CourseSemesterData.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public function __construct(
public string $id,
public string $course,
public string $courseId,
public string $semester,
public string $semesterId,
public int $groupsCount,
Expand All @@ -21,6 +22,7 @@ public static function fromModel(CourseSemester $course): self
return new self(
id: $course->id,
course: $course->course->name,
courseId: $course->course->id,
semester: $course->semester->name,
semesterId: $course->semester->id,
groupsCount: $course->groups_count ?? $course->groups->count(),
Expand Down
25 changes: 13 additions & 12 deletions app/Http/Controllers/Dashboard/CourseSemesterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Keating\Http\Controllers\Dashboard;

use Exception;
use Illuminate\Http\RedirectResponse;
use Inertia\Response;
use Keating\DTOs\CourseSemesterData;
Expand All @@ -20,7 +21,12 @@ class CourseSemesterController
public function index(): Response
{
$courses = CourseSemester::query()
->join("semesters", "semesters.id", "=", "course_semester.semester_id")
->join("courses", "courses.id", "=", "course_semester.course_id")
->withCount("groups")
->orderByDesc("semesters.active")
->orderByDesc("semesters.id")
->orderBy("courses.semester")
->orderBy("created_at")
->get();

Expand Down Expand Up @@ -49,22 +55,17 @@ public function store(CourseSemesterRequest $request): RedirectResponse
->with("success", "Dodano kurs");
}

public function show(CourseSemester $course): Response
{
return inertia("Dashboard/CourseSemester/Show", [
"course" => CourseSemesterData::fromModel($course),
"groups" => $course->groups->map(fn($group): GroupData => GroupData::fromModel($group)),
"studyForms" => Options::forEnum(StudyForm::class)->toArray(),
]);
}

/**
* @throws Exception
*/
public function edit(CourseSemester $course): Response
{
return inertia("Dashboard/CourseSemester/Edit", [
"course" => $course,
"course" => CourseSemesterData::fromModel($course),
"courses" => Course::query()->get(["id", "name"]),
"semesters" => Semester::query()->orderByDesc("id")->get(["id", "name"]),
"groups" => $course->groups->map(fn($group): GroupData => GroupData::fromModel($group)),
"studyForms" => Options::forEnum(StudyForm::class)->toArray(),
"courses" => Course::all(["id", "name"]),
"semesters" => Semester::all(["id", "name"]),
]);
}

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Dashboard/SemesterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class SemesterController
public function index(): Response
{
$semesters = Semester::query()
->orderByDesc("active")
->orderByDesc("created_at")
->orderByDesc("id")
->get();

return inertia("Dashboard/Semester/Index", [
Expand Down Expand Up @@ -71,7 +73,7 @@ public function toggleActive(Semester $semester, ActivateSemesterAction $activat

return redirect()->back()
->with("success", "Semestr aktywny");
} catch (Exception $e) {
} catch (Exception) {
return redirect()->back()
->with("error", "Wystąpił nieoczekiwany problem");
}
Expand Down
7 changes: 1 addition & 6 deletions app/Http/Controllers/Public/CourseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@
use Inertia\Response;
use Keating\DTOs\CoursePublicData;
use Keating\Models\Course;
use Keating\Models\Semester;

class CourseController
{
public function index(): Response
{
$activeSemesters = Semester::query()
->where("active", true)
->pluck("name");

$courses = Course::query()
->with("field")
->get()
->map(fn(Course $course): CoursePublicData => CoursePublicData::fromModel($course, $activeSemesters))
->map(fn(Course $course): CoursePublicData => CoursePublicData::fromModel($course))
->sortBy("semester")
->sortByDesc("active");

Expand Down
7 changes: 3 additions & 4 deletions app/Http/Controllers/Public/GradeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ public function __invoke(Request $request, ?Semester $semester = null, ?CourseSe
->where("active", true)
->orderBy("priority")
->get();

$students = $group->students()
->whereNot("index_number", $index)
->inRandomOrder()
->take(8)
->get()
->push($studentByIndex)
->sortBy("index_number")
->prepend($studentByIndex)
->map(fn(Student $student): StudentData => StudentData::fromModels($student, $studentByIndex, $gradeColumns));
}
}

return inertia("Public/Grade", [
"semesters" => Semester::query()->get(["name", "id"]),
"semesters" => Semester::query()->orderByDesc("id")->get(["name", "id"]),
"semester" => $semester,
"courses" => $courses,
"course" => $course,
Expand Down
1 change: 1 addition & 0 deletions app/Models/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Field extends Model
use HasUlids;

protected $fillable = [
"id",
"name",
"abbreviation",
];
Expand Down
2 changes: 1 addition & 1 deletion database/factories/GroupFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GroupFactory extends Factory
public function definition(): array
{
return [
"name" => fake()->asciify("******"),
"name" => fake()->numerify("s#INF#"),
"course_semester_id" => CourseSemester::factory(),
"form" => StudyForm::Stationary->value,
];
Expand Down
2 changes: 1 addition & 1 deletion database/factories/SemesterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SemesterFactory extends Factory
public function definition(): array
{
return [
"name" => fake()->numberBetween(1, 7),
"name" => fake()->randomElement(["zimowy", "letni"]) . " " . fake()->year(),
"active" => fake()->boolean,
];
}
Expand Down
62 changes: 59 additions & 3 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Keating\Enums\SemesterName;
use Keating\Models\Course;
use Keating\Models\CourseSemester;
use Keating\Models\Field;
use Keating\Models\Grade;
use Keating\Models\GradeColumn;
use Keating\Models\Group;
use Keating\Models\Section;
use Keating\Models\SectionSettings;
use Keating\Models\Semester;
use Keating\Models\Setting;
use Keating\Models\Student;
use Keating\Models\User;
Expand All @@ -20,6 +24,7 @@ class DatabaseSeeder extends Seeder
public function run(): void
{
User::factory()->create(["email" => "admin@example.com"]);

Setting::factory()->create();
Section::factory(4)->counter()->create();
Section::factory(3)->about()->create();
Expand All @@ -29,12 +34,63 @@ public function run(): void
"counters_enabled" => true,
"contact_enabled" => true,
]);
$this->seedGrades();

$this->seedRealData();
}

protected function seedGrades(): void
protected function seedRealData(): void
{
$courses = CourseSemester::factory(5)->create();
$semesters = Semester::factory()->count(5)->sequence(
["name" => "zimowy 2022/23", "active" => false],
["name" => "letni 2022/23", "active" => false],
["name" => "zimowy 2023/24", "active" => false],
["name" => "letni 2023/24", "active" => false],
["name" => "zimowy 2024/25", "active" => true],
)->create();

$fields = Field::factory()->count(3)->sequence(
["name" => "Informatyka", "abbreviation" => "INF"],
["name" => "Informatyka, specjalność Programowanie", "abbreviation" => "INF/PAM"],
["name" => "Informatyka, specjalność Grafika", "abbreviation" => "INF/GK"],
)->create();

$courses = Course::factory()->count(3)->sequence(
[
"name" => "Programowanie obiektowe",
"abbreviation" => "PO",
"semester" => 3,
"type" => "laboratory",
"field_id" => $fields[1]->id,
"semester_name" => SemesterName::Winter->value,
],
[
"name" => "Programowanie systemów internetowych",
"abbreviation" => "PSI",
"semester" => 4,
"type" => "lecture",
"field_id" => $fields[2]->id,
"semester_name" => SemesterName::Summer->value,
],
[
"name" => "Programowanie systemów internetowych",
"abbreviation" => "PSI",
"semester" => 4,
"type" => "project",
"field_id" => $fields[2]->id,
"semester_name" => SemesterName::Summer->value,
],
)->create();

$courses = CourseSemester::factory(7)->sequence(
["course_id" => $courses[0]->id, "semester_id" => $semesters[4]->id],
["course_id" => $courses[1]->id, "semester_id" => $semesters[3]->id],
["course_id" => $courses[2]->id, "semester_id" => $semesters[3]->id],
["course_id" => $courses[0]->id, "semester_id" => $semesters[2]->id],
["course_id" => $courses[1]->id, "semester_id" => $semesters[1]->id],
["course_id" => $courses[2]->id, "semester_id" => $semesters[1]->id],
["course_id" => $courses[0]->id, "semester_id" => $semesters[0]->id],
)->create();

$students = Student::factory(100)->create();

foreach ($courses as $course) {
Expand Down
16 changes: 0 additions & 16 deletions database/seeders/DemoSeeder.php

This file was deleted.

2 changes: 1 addition & 1 deletion resources/js/Components/SectionHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
<slot name="header" />
</h2>
<p class="mt-1 text-lg leading-8 text-gray-600">
<p class="mt-1 text-lg leading-6 text-gray-600">
<slot name="subheader" />
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Layouts/PublicLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const mobileMenuOpen = ref(false)
<div class="mx-auto max-w-7xl px-6 py-12 md:flex md:items-center md:justify-center lg:px-8">
<div class="mt-8 md:order-1 md:mt-0">
<p class="text-center text-xs leading-5 text-gray-500">
2023
2024
<EllipsisHorizontalIcon class="mx-2 inline-block w-6" />
<a class="font-semibold" href="https://github.com/blumilksoftware/keating" target="_blank">keating
management system</a> developed at <a class="font-semibold" href="https://blumilk.pl/" target="_blank">Blumilk</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Dashboard/ContactInfo/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function updateContactInfo() {
<FormLabel for="id">
Id
</FormLabel>
<TextInput class="opacity-75" placeholder="autogenerowany ulid" autocomplete="off" disabled />
<TextInput class="opacity-75" :placeholder="contactInfo.id" autocomplete="off" disabled />
</FormGroup>
<FormGroup>
<FormLabel for="label">
Expand Down
5 changes: 2 additions & 3 deletions resources/js/Pages/Dashboard/ContactInfo/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Button from '@/Shared/Components/Buttons/Button.vue'
import EmptyState from '@/Shared/Components/EmptyState/EmptyState.vue'
import RemoveModal from '@/Shared/Modals/RemoveModal.vue'
import { ref } from 'vue'
import { PencilSquareIcon, XCircleIcon } from '@heroicons/vue/24/outline'
import ManagementHeader from '@/Shared/Components/ManagementHeader.vue'
import ManagementHeaderItem from '@/Shared/Components/ManagementHeaderItem.vue'
import StyledLink from '@/Shared/Components/StyledLink.vue'
Expand Down Expand Up @@ -74,10 +73,10 @@ const contactInfoToDeleteId = ref(0)
</TableCell>
<TableCell class="flex justify-end gap-2">
<StyledLink :href="`contact-infos/${contact.id}/edit`">
<PencilSquareIcon class="w-5" />
edytuj
</StyledLink>
<Button class="text-red-600" @click="[showModal = true, contactInfoToDeleteId = contact.id]">
<XCircleIcon class="w-5" />
usuń
</Button>
</TableCell>
</TableRow>
Expand Down
4 changes: 1 addition & 3 deletions resources/js/Pages/Dashboard/Course/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import ManagementHeader from '@/Shared/Components/ManagementHeader.vue'
import ManagementHeaderItem from '@/Shared/Components/ManagementHeaderItem.vue'
import TextAreaEditor from '../../../Shared/Forms/TextAreaEditor.vue'


const props = defineProps({
course: Object,
classTypes: Array,
fields: Array,
semesterNames: Array,
})


const form = useForm({
name: props.course.name,
slug: props.course.slug,
Expand Down Expand Up @@ -58,7 +56,7 @@ function updateCourse() {
<FormLabel for="id">
Id
</FormLabel>
<TextInput class="opacity-75" placeholder="autogenerowany ulid" autocomplete="off" disabled />
<TextInput class="opacity-75" :placeholder="course.id" autocomplete="off" disabled />
</FormGroup>
<FormGroup>
<FormLabel for="name">
Expand Down
Loading
Loading