-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contract): add javascript validation (#148) [norelease]
This pull request includes several changes to the admin contract and tree type views, as well as improvements to form validation and database schema updates. The most important changes include updating URLs, adding form validation, and modifying the database schema. ### URL Updates: * Updated URLs in `app/src/app/Views/Admin/Contract/Create.php`, `Edit.php`, and `Contracts.php` to include the `/admin` prefix for better organization and consistency. [[1]](diffhunk://#diff-38a9b8706ade2452bf354d849198cc6f40fb103c6fcc4365307fafccc71b77a9L2-L69) [[2]](diffhunk://#diff-311cfe2714a9939b4100544862231bed7e1bb24a54dcf0297e4d3ce748b2eee5L2-L4) [[3]](diffhunk://#diff-f42bf66d127a9e77d1fa1d01e2177ea5ab22354f4acb3279b19760b992d0f923L15-R15) ### Form Validation Enhancements: * Enhanced form validation in `app/src/public/assets/js/app.js` by adding reusable validation functions and event listeners for contract and tree type forms. This includes checks for empty fields, regex pattern validation, date range validation, positive integer validation, and maximum value validation. ### Database Schema Modifications: * Modified the `contracts` table in `database/start-scripts/0-init.sql` to change the data type of `start_date` and `end_date` from `timestamp` to `date` for better accuracy and consistency. ### UI and Form Adjustments: * Added error message divs and adjusted form IDs in `app/src/app/Views/Admin/Contract/Create.php` and `Edit.php` to improve user experience and error handling. [[1]](diffhunk://#diff-38a9b8706ade2452bf354d849198cc6f40fb103c6fcc4365307fafccc71b77a9L2-L69) [[2]](diffhunk://#diff-311cfe2714a9939b4100544862231bed7e1bb24a54dcf0297e4d3ce748b2eee5L14-L68) * Updated form IDs and removed unnecessary divs for submit buttons in `app/src/app/Views/Admin/TreeType/Create.php` and `Edit.php` to streamline the UI. [[1]](diffhunk://#diff-44d3d8172b626b0986e1ec03c382c4a1ea15ff0c7ae3df656290f9e83bb2126eL15-R15) [[2]](diffhunk://#diff-78a2b54262dc0a49ba0f676ccd46806c3483d7f6a76d921b3edc39e50f240536L14-R15)
- Loading branch information
Showing
7 changed files
with
308 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,65 @@ | ||
<div class="mb-4 flex justify-end"> | ||
<a href="/contracts" | ||
<a href="/admin/contracts" | ||
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg shadow focus:outline-none focus:ring focus:ring-green-500 flex items-center space-x-2"> | ||
<!-- Heroicon for return/back (chevron-left) --> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path> | ||
</svg> | ||
<span>Return to Contract</span> | ||
<span>Return to Contracts</span> | ||
</a> | ||
</div> | ||
|
||
<div class="bg-white p-8 border border-gray-300 rounded-lg shadow-md"> | ||
<h2 class="text-2xl font-semibold text-gray-800 mb-6">Create Contract</h2> | ||
<form action="/contract/store" method="POST" class="space-y-6"> | ||
<!-- Name --> | ||
<form id="contractForm" action="/admin/contract/store" method="POST" class="space-y-6"> | ||
<div id="errorMessages" | ||
class="hidden bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-6"></div> | ||
<div> | ||
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name</label> | ||
<input type="text" id="name" name="name" | ||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500" | ||
required> | ||
</div> | ||
<!-- Start Date --> | ||
<div> | ||
<label for="start_date" class="block text-sm font-medium text-gray-700 mb-1">Start Date</label> | ||
<input type="date" id="start_date" name="start_date" | ||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500" | ||
required> | ||
</div> | ||
<!-- End Date --> | ||
<div> | ||
<label for="end_date" class="block text-sm font-medium text-gray-700 mb-1">End Date</label> | ||
<input type="date" id="end_date" name="end_date" | ||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500" | ||
required> | ||
</div> | ||
<!-- Invoice Proposed --> | ||
<div> | ||
<label for="invoice_proposed" class="block text-sm font-medium text-gray-700 mb-1">Invoice Proposed</label> | ||
<input type="number" step="0.01" id="invoice_proposed" name="invoice_proposed" | ||
<input type="number" step="0.01" id="invoice_proposed" name="invoice_proposed" max="999999999.99" | ||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500" | ||
required> | ||
</div> | ||
<!-- Invoice Agreed --> | ||
<div> | ||
<label for="invoice_agreed" class="block text-sm font-medium text-gray-700 mb-1">Invoice agreed</label> | ||
<input type="number" id="invoice_agreed" name="invoice_agreed" | ||
<label for="invoice_agreed" class="block text-sm font-medium text-gray-700 mb-1">Invoice Agreed</label> | ||
<input type="number" id="invoice_agreed" name="invoice_agreed" max="999999999.99" | ||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500" | ||
required> | ||
</div> | ||
<!-- Invoice Paid --> | ||
<div> | ||
<label for="invoice_paid" class="block text-sm font-medium text-gray-700 mb-1">Invoice paid</label> | ||
<input type="number" id="invoice_paid" name="invoice_paid" | ||
<label for="invoice_paid" class="block text-sm font-medium text-gray-700 mb-1">Invoice Paid</label> | ||
<input type="number" id="invoice_paid" name="invoice_paid" max="999999999.99" | ||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500" | ||
required> | ||
</div> | ||
<!-- Submit Button --> | ||
<div class="flex items-center"> | ||
<button type="submit" | ||
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500"> | ||
Create Contract | ||
</button> | ||
</div> | ||
<button type="submit" | ||
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500"> | ||
Create Contract | ||
</button> | ||
</form> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.