|
12 | 12 |
|
13 | 13 | <form asp-action="Create" method="post">
|
14 | 14 | <div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
15 |
| - <div class="form-check form-switch"> |
16 |
| - <input asp-for="IsAccepted" class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault"> |
17 |
| - <label asp-for="IsAccepted" class="form-check-label" for="flexSwitchCheckDefault">Qabul qilish</label> |
18 |
| - </div> |
19 |
| - <div class="form-group w-50"> |
| 15 | + <div class="form-group w-50 mt-2"> |
20 | 16 | <label asp-for="DriverId" class="control-label mt-2">Haydovchi</label>
|
21 | 17 | @if (ViewBag.SelectedDriverId != null && ViewBag.SelectedDriverId != 0)
|
22 | 18 | {
|
|
40 | 36 | <div class="form-group w-50">
|
41 | 37 | <input type="text" asp-for="MechanicId" class="form-control border border-dark d-none" />
|
42 | 38 | </div>
|
43 |
| - <div class="form-group w-50"> |
| 39 | + <div class="form-group w-50 mt-2"> |
44 | 40 | <label asp-for="CarId" class="control-label mt-2">Mashina</label>
|
45 | 41 | @if (ViewBag.Cars is SelectList)
|
46 | 42 | {
|
47 |
| - <select asp-for="CarId" class="form-control border border-dark" asp-items="@(ViewBag.Cars as SelectList)" value="@ViewBag.SelectedCarId" ></select> |
| 43 | + <select asp-for="CarId" class="form-control border border-dark" asp-items="@(ViewBag.Cars as SelectList)" value="@ViewBag.SelectedCarId"></select> |
48 | 44 | }
|
49 | 45 | else
|
50 | 46 | {
|
51 |
| - <input type="text" class="form-control" value="@ViewBag.Cars" /> |
52 |
| - <input type="hidden" asp-for="CarId" value="@ViewBag.SelectedCarId" /> |
| 47 | + <input type="text" class="form-control" value="@ViewBag.Cars" /> |
| 48 | + <input type="hidden" asp-for="CarId" value="@ViewBag.SelectedCarId" /> |
53 | 49 | }
|
54 | 50 | </div>
|
55 |
| - <div class="form-group w-50"> |
| 51 | + <div class="form-check form-switch mt-3"> |
| 52 | + <input asp-for="IsAccepted" class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault"> |
| 53 | + <label asp-for="IsAccepted" class="form-check-label" for="flexSwitchCheckDefault">Qabul qilish</label> |
| 54 | + </div> |
| 55 | + <div class="form-group w-50 mt-2"> |
56 | 56 | <label asp-for="Distance" class="control-label mt-2">Qabul qilish masofasi</label>
|
57 | 57 | <input asp-for="Distance" class="form-control" type="number" min="0" step="1" />
|
58 | 58 | </div>
|
59 |
| - <div class="form-group w-50"> |
| 59 | + <div class="form-group w-50 mt-2"> |
60 | 60 | <label asp-for="Comments" class="control-label mt-2">Izoh</label>
|
61 | 61 | <textarea asp-for="Comments" class="form-control" rows="4"></textarea>
|
62 | 62 | </div>
|
63 |
| - <div class="form-group mt-3 w-50"> |
| 63 | + <div class="form-group mt-3 w-50 mt-2"> |
64 | 64 | <a asp-action="PersonalIndex" class="btn btn-outline-info">
|
65 | 65 | <i class="fa-solid fa-arrow-left-long"></i> Orqaga
|
66 | 66 | </a>
|
|
74 | 74 |
|
75 | 75 | @section Scripts {
|
76 | 76 | <script type="text/javascript">
|
77 |
| - var shouldDisable = @ViewBag.SelectedDriverId != null ? "true" : "false"; |
78 |
| - if (shouldDisable === "true") { |
79 |
| - document.getElementById("driverIdDropdown").setAttribute("disabled", "disabled"); |
80 |
| - document.getElementById("carIdDropdown").setAttribute("disabled", "disabled"); |
81 |
| - } |
| 77 | + document.addEventListener('DOMContentLoaded', function () { |
| 78 | + var checkbox = document.getElementById('flexSwitchCheckDefault'); |
| 79 | + var checkboxLabel = document.querySelector('label[for="flexSwitchCheckDefault"]'); |
| 80 | +
|
| 81 | + function toggleCheckboxHighlight() { |
| 82 | + if (!checkbox.checked) { |
| 83 | + checkbox.classList.add('border-danger'); |
| 84 | + checkboxLabel.classList.add('text-danger'); |
| 85 | + } else { |
| 86 | + checkbox.classList.remove('border-danger'); |
| 87 | + checkboxLabel.classList.remove('text-danger'); |
| 88 | + } |
| 89 | + } |
| 90 | +
|
| 91 | + // Initialize the highlight on page load |
| 92 | + toggleCheckboxHighlight(); |
| 93 | +
|
| 94 | + // Add change event listener to toggle the highlight |
| 95 | + checkbox.addEventListener('change', toggleCheckboxHighlight); |
| 96 | +
|
| 97 | + var shouldDisable = '@ViewBag.SelectedDriverId' != '' ? "true" : "false"; |
| 98 | + if (shouldDisable === "true") { |
| 99 | + document.getElementById("driverIdDropdown").setAttribute("disabled", "disabled"); |
| 100 | + document.getElementById("carIdDropdown").setAttribute("disabled", "disabled"); |
| 101 | + } |
| 102 | + }); |
82 | 103 | </script>
|
83 | 104 | }
|
| 105 | + |
| 106 | +<style> |
| 107 | + .border-danger { |
| 108 | + border: 2px solid red !important; |
| 109 | + } |
| 110 | +
|
| 111 | + .text-danger { |
| 112 | + color: red !important; |
| 113 | + } |
| 114 | +</style> |
0 commit comments