Skip to content

A free open source IT asset/license management system

Auto-hide the “new” button in modals via @aware

snipe0451525f6fd4
diff --git a/resources/views/blade/form/checkbox-inline.blade.php b/resources/views/blade/form/checkbox-inline.blade.php
index c6312bb70e..f05aa02f21 100644
--- a/resources/views/blade/form/checkbox-inline.blade.php
+++ b/resources/views/blade/form/checkbox-inline.blade.php
@@ -10,7 +10,7 @@
@php
// Old-input aware check-state. On a fresh render, session()->hasOldInput()
// is false, so we fall back to the model. On a validation-failure redisplay,
- // hasOldInput() is true and we trust the (possibly missing) old value — an
+ // hasOldInput() is true and we trust the (possibly missing) old value: an
// unchecked box comes back correctly unchecked instead of falling through
// to the stale $item->{$name}.
$is_redisplay = session()->hasOldInput();
diff --git a/resources/views/blade/form/checkbox-row.blade.php b/resources/views/blade/form/checkbox-row.blade.php
index b3e76e94e1..8115ee0a5f 100644
--- a/resources/views/blade/form/checkbox-row.blade.php
+++ b/resources/views/blade/form/checkbox-row.blade.php
@@ -52,7 +52,7 @@
// Old-input aware check-state. On a fresh render, session()->hasOldInput()
// is false, so we fall back to the model (or supplied :selected). On a
// validation-failure redisplay, hasOldInput() is true and we trust the
- // (possibly missing) old value — an unchecked box comes back correctly
+ // (possibly missing) old value: an unchecked box comes back correctly
// unchecked instead of falling through to the stale $item->{$name}.
$is_redisplay = session()->hasOldInput();
@@ -175,9 +175,9 @@
<x-form.help :name="$name" :icon="$help_icon">{!! $help_text !!}</x-form.help>
</div>
@elseif ($help_html)
- {{-- Raw HTML help — caller has opted in via help_html rather than
+ {{-- Raw HTML help. Caller has opted in via help_html rather than
help_text. Callers passing a trans() string with HTML MUST use
- the static-attribute form help_html="{!! trans('...') !!}" —
+ the static-attribute form help_html="{!! trans('...') !!}",
the dynamic-binding form :help_html="trans('...')" runs the
value through BladeCompiler::sanitizeComponentAttribute() and
turns <a> tags into &lt;a&gt; entities. See x-form.row for the
diff --git a/resources/views/blade/input/accessory-select.blade.php b/resources/views/blade/input/accessory-select.blade.php
index c66b8cc5ca..3cab4e8361 100644
--- a/resources/views/blade/input/accessory-select.blade.php
+++ b/resources/views/blade/input/accessory-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\Accessory', 'Accessory')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -13,6 +17,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/category-select.blade.php b/resources/views/blade/input/category-select.blade.php
index b68b95d093..6c53a64739 100644
--- a/resources/views/blade/input/category-select.blade.php
+++ b/resources/views/blade/input/category-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\Category', 'Category')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -14,6 +18,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/company-select.blade.php b/resources/views/blade/input/company-select.blade.php
index d2c92e4001..609fd964b1 100644
--- a/resources/views/blade/input/company-select.blade.php
+++ b/resources/views/blade/input/company-select.blade.php
@@ -12,6 +12,11 @@
a company picker with the same name (which would collide on the id and confuse select2,
leading to a broken select2 on the page if another "new" button is clicked.)
The form's submitted field name stays $name either way.--}}
+
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -26,6 +31,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/consumable-select.blade.php b/resources/views/blade/input/consumable-select.blade.php
index 9f24323b78..5b159f561b 100644
--- a/resources/views/blade/input/consumable-select.blade.php
+++ b/resources/views/blade/input/consumable-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\Consumable', 'Consumable')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -13,6 +17,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/image-upload.blade.php b/resources/views/blade/input/image-upload.blade.php
index 43ca23b079..98b35bb703 100644
--- a/resources/views/blade/input/image-upload.blade.php
+++ b/resources/views/blade/input/image-upload.blade.php
@@ -15,7 +15,7 @@
@endphp
@if ($imagePath && $existing_image)
- {{-- Delete-existing / reuse-cloned toggle. No label column — the checkbox
+ {{-- Delete-existing / reuse-cloned toggle. No label column. The checkbox
label is inside the input area, so we render a bare offset form-group. --}}
<div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
<div class="col-md-9 col-md-offset-3">
diff --git a/resources/views/blade/input/license-select.blade.php b/resources/views/blade/input/license-select.blade.php
index e86dd25e70..6802268023 100644
--- a/resources/views/blade/input/license-select.blade.php
+++ b/resources/views/blade/input/license-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\License', 'License')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -13,6 +17,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/location-select.blade.php b/resources/views/blade/input/location-select.blade.php
index 704595654c..549d68ab1c 100644
--- a/resources/views/blade/input/location-select.blade.php
+++ b/resources/views/blade/input/location-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\Location', 'Location')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -16,6 +20,7 @@
@php
$selectId = $id ?? $name.'_location_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/manufacturer-select.blade.php b/resources/views/blade/input/manufacturer-select.blade.php
index b999813886..b8331cbdf2 100644
--- a/resources/views/blade/input/manufacturer-select.blade.php
+++ b/resources/views/blade/input/manufacturer-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\Manufacturer', 'Manufacturer')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -13,6 +17,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/model-select.blade.php b/resources/views/blade/input/model-select.blade.php
index a107b8dda5..2582e311e1 100644
--- a/resources/views/blade/input/model-select.blade.php
+++ b/resources/views/blade/input/model-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\AssetModel', 'AssetModel')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -13,6 +17,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/password.blade.php b/resources/views/blade/input/password.blade.php
index 035c961829..a064423651 100644
--- a/resources/views/blade/input/password.blade.php
+++ b/resources/views/blade/input/password.blade.php
@@ -35,7 +35,7 @@
@required($required)
/>
<span class="input-group-addon" style="padding: 0;">
- {{-- Plain <button> without btn-link — btn-link inherits the
+ {{-- Plain <button> without btn-link. btn-link inherits the
theme link color (blue), which stands out wrong in an input
addon. Inline reset styles give the eye the addon's default
text color (dark gray) while keeping button semantics for
diff --git a/resources/views/blade/input/supplier-select.blade.php b/resources/views/blade/input/supplier-select.blade.php
index 860707470c..d6bde07af2 100644
--- a/resources/views/blade/input/supplier-select.blade.php
+++ b/resources/views/blade/input/supplier-select.blade.php
@@ -1,6 +1,10 @@
@use('App\Models\Supplier', 'Supplier')
@use('Illuminate\Support\Arr', 'Arr')
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -14,6 +18,7 @@
@php
$selectId = $id ?? $name.'_select';
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/input/user-select.blade.php b/resources/views/blade/input/user-select.blade.php
index a324db480c..4996f7e62a 100644
--- a/resources/views/blade/input/user-select.blade.php
+++ b/resources/views/blade/input/user-select.blade.php
@@ -8,6 +8,10 @@
values derived from the name prop, so a manager picker with
name="manager_id" gets id="manager_id_select" and
wrapperId="manager_id" automatically. --}}
+{{-- Auto-hides the "New" button when rendered inside an AJAX modal.
+ See x-input.company-select for the pattern. --}}
+@aware(['submitToSelect2' => false])
+
@props([
'label',
'name',
@@ -24,6 +28,7 @@
@php
$wrapperId = $wrapperId ?? $name;
$id = $id ?? ($name.'_select');
+ $hideNewButton = $hideNewButton || $submitToSelect2;
@endphp
<div
diff --git a/resources/views/blade/modals/company.blade.php b/resources/views/blade/modals/company.blade.php
index 4a679f46ed..3474c26f57 100644
--- a/resources/views/blade/modals/company.blade.php
+++ b/resources/views/blade/modals/company.blade.php
@@ -11,6 +11,5 @@
id="modal_parent_id_select"
:label="trans('admin/companies/table.parent')"
onlyTopLevel
- hideNewButton
/>
</x-modals>
diff --git a/resources/views/blade/modals/kit-accessory.blade.php b/resources/views/blade/modals/kit-accessory.blade.php
index a6f37af79b..8b6d23021e 100644
--- a/resources/views/blade/modals/kit-accessory.blade.php
+++ b/resources/views/blade/modals/kit-accessory.blade.php
@@ -9,7 +9,6 @@
id="modal_accessory_select"
:label="trans('general.accessory')"
required
- hideNewButton
/>
<x-form.row
diff --git a/resources/views/blade/modals/kit-consumable.blade.php b/resources/views/blade/modals/kit-consumable.blade.php
index 9fb92f4133..ac6830c60d 100644
--- a/resources/views/blade/modals/kit-consumable.blade.php
+++ b/resources/views/blade/modals/kit-consumable.blade.php
@@ -9,7 +9,6 @@
id="modal_consumable_select"
:label="trans('general.consumable')"
required
- hideNewButton
/>
<x-form.row
diff --git a/resources/views/blade/modals/kit-license.blade.php b/resources/views/blade/modals/kit-license.blade.php
index 4d2b545502..935f4a0009 100644
--- a/resources/views/blade/modals/kit-license.blade.php
+++ b/resources/views/blade/modals/kit-license.blade.php
@@ -9,7 +9,6 @@
id="modal_license_select"
:label="trans('general.license')"
required
- hideNewButton
/>
<x-form.row
diff --git a/resources/views/blade/modals/kit-model.blade.php b/resources/views/blade/modals/kit-model.blade.php
index a92775b847..60fed8a432 100644
--- a/resources/views/blade/modals/kit-model.blade.php
+++ b/resources/views/blade/modals/kit-model.blade.php
@@ -9,7 +9,6 @@
id="modal_model_select"
:label="trans('general.asset_model')"
required
- hideNewButton
/>
<x-form.row
diff --git a/resources/views/blade/modals/location.blade.php b/resources/views/blade/modals/location.blade.php
index 54a4f7f35e..dcbaaaedf1 100644
--- a/resources/views/blade/modals/location.blade.php
+++ b/resources/views/blade/modals/location.blade.php
@@ -21,7 +21,6 @@
name="company_id"
id="modal_company_id_select"
:label="trans('general.company')"
- hideNewButton
/>
@endif
diff --git a/resources/views/blade/modals/maintenance-complete.blade.php b/resources/views/blade/modals/maintenance-complete.blade.php
index 3c637794b8..f060ccf3f6 100644
--- a/resources/views/blade/modals/maintenance-complete.blade.php
+++ b/resources/views/blade/modals/maintenance-complete.blade.php
@@ -1,7 +1,7 @@
{{-- Confirmation modal for marking a maintenance complete. Rendered on any
page that lists maintenances via `x-table.maintenances`. The bootstrap-
table actions formatter that emits the green checkmark button lives in
- partials/bootstrap-table.blade.php; the click handler that populates the
+ partials/bootstrap-table.blade.php. The click handler that populates the
form action and shows this modal lives in resources/assets/js/snipeit.js
as a delegated `.complete-maintenance` handler. --}}
<x-modals
diff --git a/resources/views/blade/modals/model.blade.php b/resources/views/blade/modals/model.blade.php
index eabb6d0db3..1597438897 100644
--- a/resources/views/blade/modals/model.blade.php
+++ b/resources/views/blade/modals/model.blade.php
@@ -12,14 +12,12 @@
:label="trans('general.category')"
categoryType="asset"
required
- hideNewButton
/>
<x-input.manufacturer-select
name="manufacturer_id"
id="modal_manufacturer_id_select"
:label="trans('general.manufacturer')"
- hideNewButton
/>
<x-form.row name="model_number" :label="trans('general.model_no')" id="modal-model_number" />
diff --git a/resources/views/blade/modals/request-item.blade.php b/resources/views/blade/modals/request-item.blade.php
index 04da23858f..ad7d03cfb5 100644
--- a/resources/views/blade/modals/request-item.blade.php
+++ b/resources/views/blade/modals/request-item.blade.php
@@ -40,7 +40,7 @@
{{-- Start / end dates are optional. Requesters who just
want "whenever this becomes available" leave both
- blank; requesters reserving for a specific window
+ blank. Requesters reserving for a specific window
(offsite event, project sprint) fill them in.
end_date validates as after_or_equal:start_date in
the controller. --}}
diff --git a/resources/views/blade/modals/user.blade.php b/resources/views/blade/modals/user.blade.php
index c29e32ac04..8726b0faed 100644
--- a/resources/views/blade/modals/user.blade.php
+++ b/resources/views/blade/modals/user.blade.php
@@ -14,14 +14,12 @@
name="company_id"
id="modal_company_id_select"
:label="trans('general.company')"
- hideNewButton
/>
<x-input.location-select
name="location_id"
id="modal_location_id_select"
:label="trans('general.location')"
- hideNewButton
/>
<x-form.row name="first_name" :label="trans('general.first_name')" id="modal-first_name" required />