Skip to content

Update the dynamic schedule calculator#96

Open
Bilaljanir wants to merge 1 commit intomainfrom
planninghours
Open

Update the dynamic schedule calculator#96
Bilaljanir wants to merge 1 commit intomainfrom
planninghours

Conversation

@Bilaljanir
Copy link
Collaborator

No description provided.

@Bilaljanir Bilaljanir requested review from fuzoh and pymorand February 4, 2026 13:58
@gemini-code-assist
Copy link

Summary of Changes

Hello @Bilaljanir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience and functionality of the form creation and editing pages. It introduces a more flexible and robust dynamic schedule calculator, improves search capabilities, and refines the overall form layout and user feedback mechanisms. The changes aim to make data entry and management more intuitive and efficient.

Highlights

  • Case-Insensitive Search: The form search functionality has been updated to perform case-insensitive searches on form names, improving usability.
  • Dynamic Schedule Calculator Refactor: The planning calculator in both create and edit forms has been significantly refactored. It now features a dynamic toggle between hours and percentage modes, with automatic conversion and robust rounding error correction. The UI for displaying total planned values has also been enhanced with status indicators.
  • Improved Form UI/UX: Session alerts and validation error displays have been restyled for better consistency and user experience. Input fields now support pre-filling data, and phone number inputs include Swiss-specific formatting.
  • Form Structure and Comments: The form templates have been reorganized with clear HTML comments delineating sections, making the code more readable and maintainable. Unnecessary hidden inputs and client-side validation popups have been removed or streamlined.
Changelog
  • app/Http/Controllers/FormController.php
    • Added a blank line for PSR-2 compliance.
    • Implemented case-insensitive search for form names using strtolower and LOWER(name) LIKE ?.
    • Removed an unnecessary blank line.
  • resources/views/admin/users/edit.blade.php
    • Added an empty style attribute to a label tag (minor formatting change).
  • resources/views/forms/create.blade.php
    • Added transition class to a link for smoother UI interactions.
    • Improved styling and structure for session alerts and validation errors.
    • Integrated prefillData for initial form field values.
    • Introduced a dedicated 'Horaires de travail' section with specific morning/afternoon time inputs.
    • Implemented Swiss phone number formatting using an Alpine.js function.
    • Replaced the static planning calculator with a dynamic Alpine.js component (planningCalculator) allowing toggling between hours and percentage, with automatic conversion and rounding error correction.
    • Added HTML comments to delineate form sections for better readability.
    • Simplified custom field handling, focusing on key-value pairs and removing name/label inputs.
  • resources/views/forms/edit.blade.php
    • Added transition class to a link.
    • Updated header title to dynamically include the form's name.
    • Improved styling and structure for session alerts and validation errors.
    • Introduced a val helper function for cleaner data access in Blade templates.
    • Removed hidden inputs for form metadata (name, description, is_active).
    • Introduced a dedicated 'Horaires de travail' section with specific morning/afternoon time inputs.
    • Implemented Swiss phone number formatting using an Alpine.js function.
    • Updated the dynamic planning calculator (planningCalculatorEdit) with similar logic as the create form, including mode switching and rounding correction.
    • Removed client-side validation popup for planning, relying on server-side validation.
    • Removed the custom fields section from this template.
Activity
  • The author, Bilaljanir, has focused on refining the user interface and underlying logic for form management.
  • Key changes include enhancing search functionality, introducing dynamic scheduling capabilities, and improving form data pre-filling and validation feedback.
  • The updates reflect a move towards a more interactive and user-friendly form experience, particularly with the Alpine.js-driven planning calculator.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly refactors and improves the form creation and editing views, particularly with the introduction of a new dynamic planning calculator, which is a great enhancement. The code is now cleaner and more maintainable. However, I've identified a few regressions in the edit form (edit.blade.php) that need attention: the UI for managing custom fields has been removed, a required attribute is missing from a key field, and a client-side validation on form submission has been removed. I've also included a minor UX suggestion for the create form.

I am having trouble creating individual review comments. Click here to see my feedback.

resources/views/forms/edit.blade.php (48)

critical

The functionality to manage custom fields (edit, add, delete) has been removed from the UI in this file. The x-data="cdcFormBuilder()" directive was removed from the <form> tag, and all associated HTML and JavaScript for handling custom fields are gone. However, the backend FormController@update method still expects and processes data for existing, new, and deleted custom fields. This is a critical feature regression that prevents users from managing custom fields on existing forms. Please restore the UI for custom field management.

resources/views/forms/edit.blade.php (386-392)

high

The descriptif_projet field is marked as required in the FormController@update validation rules, but the required attribute is missing from the <x-markdown-editor> component here. This will allow form submission with an empty project description, which will then fail server-side validation. Please add the required attribute back.

                        <x-markdown-editor
                            name="descriptif_projet"
                            :value="$val('descriptif_projet')"
                            label="Description complète du projet"
                            placeholder="Le projet consiste à réaliser une application..."
                            help="Utilisez Markdown pour structurer et formater votre texte"
                            required
                        />

resources/views/forms/edit.blade.php (742-793)

high

The previous version of this file included a JavaScript listener on form submission to prevent submitting the form if the planning distribution was invalid (e.g., total hours exceeded or percentage was not 100%). This client-side validation has been removed. While the new UI displays a warning, it doesn't block the submission, leading to a poorer user experience as the user will only see the validation error after a full page reload. It is recommended to re-implement the client-side submission block.

resources/views/forms/create.blade.php (585-587)

medium

The confirmation dialog for removing a custom field has been removed. This could lead to users accidentally deleting fields. It's recommended to re-introduce the confirm() check to improve user experience.

                removeField(index) {
                    if (confirm('Êtes-vous sûr de vouloir supprimer ce champ ?')) {
                        this.fields.splice(index, 1);
                    }
                }


if ($request->filled('search')) {
$search = $request->search;
$search = strtolower($request->search);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to use https://www.php.net/manual/en/function.mb-strtolower.php

In php, we should always use mb_ prefixed function when working with strings. These functions support multi bytes charachters encoding like utf-8

In laravel you can use Str::lower()

$search = strtolower($request->search);
$query->where(function($q) use ($search) {
$q->where('name', 'ILIKE', '%' . $search . '%');
$q->whereRaw('LOWER(name) LIKE ?', ["%{$search}%"]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you put again in lowercase with SQL, why putting two times in lowercase.

This is wasting cpu cycles

@@ -562,89 +471,119 @@ class="px-6 py-3 bg-green-600 text-white rounded-md hover:bg-green-700 transitio
</div>

<script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there is script here... separate the javascript logic in a js file.

You should not mix language.

Respect "separation of concerns"

this.fields.splice(index, 1);
}
this.fields.splice(index, 1);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is way too long, extract js, separate the form into more maintainable code. Using blade parts could be an idea

}
};
}
</script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems to have massive deduplications with the other one.

Refactor the code to have the logic written only once

@fuzoh fuzoh mentioned this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants