Merge branch 'develop' into form-macros

# Conflicts:
#	resources/macros/macros.php
This commit is contained in:
Marcus Moore
2026-03-10 10:12:31 -07:00
26 changed files with 141 additions and 108 deletions

View File

@@ -46,13 +46,13 @@ jobs:
# https://github.com/docker/setup-buildx-action
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
# https://github.com/docker/login-action
- name: Login to DockerHub
# Only login if not a PR, as PRs only trigger a Docker build and not a push
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
@@ -64,7 +64,7 @@ jobs:
# Get Metadata for docker_build step below
- name: Sync metadata (tags, labels) from GitHub to Docker for 'snipe-it' image
id: meta_build
uses: docker/metadata-action@v5
uses: docker/metadata-action@v6
with:
images: snipe/snipe-it
tags: ${{ env.IMAGE_TAGS }}
@@ -73,7 +73,7 @@ jobs:
# https://github.com/docker/build-push-action
- name: Build and push 'snipe-it' image
id: docker_build
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile.alpine

View File

@@ -46,13 +46,13 @@ jobs:
# https://github.com/docker/setup-buildx-action
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
# https://github.com/docker/login-action
- name: Login to DockerHub
# Only login if not a PR, as PRs only trigger a Docker build and not a push
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
@@ -64,7 +64,7 @@ jobs:
# Get Metadata for docker_build step below
- name: Sync metadata (tags, labels) from GitHub to Docker for 'snipe-it' image
id: meta_build
uses: docker/metadata-action@v5
uses: docker/metadata-action@v6
with:
images: snipe/snipe-it
tags: ${{ env.IMAGE_TAGS }}
@@ -73,7 +73,7 @@ jobs:
# https://github.com/docker/build-push-action
- name: Build and push 'snipe-it' image
id: docker_build
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile

View File

@@ -1149,7 +1149,7 @@ class AssetsController extends Controller
'id' => $asset->id,
'asset_tag' => $asset->asset_tag,
'note' => e($request->input('note')),
'status_label' => e($asset->assetstatus->display_name),
'status_label' => e($asset->assetstatus?->display_name),
'status_type' => $asset->assetstatus->getStatuslabelType(),
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date),
];

View File

@@ -37,6 +37,9 @@ class LicenseSeatsController extends Controller
$seats->ByAssigned();
}
if ($request->filled('search')) {
$seats->TextSearch($request->input('search'));
}
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';

View File

@@ -93,7 +93,7 @@ class UploadedFilesController extends Controller
// Check the permissions to make sure the user can view the object
$object = self::$map_object_type[$object_type]::withTrashed()->find($id);
$this->authorize('view', $object);
$this->authorize('update', $object);
if (!$object) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_upload_status.invalid_object')));

View File

@@ -111,11 +111,11 @@ class AssetModelsTransformer
$array = [
'id' => (int) $file->id,
'filename' => e($file->filename),
'note' => $file->note,
'note' => $file->note ? e($file->note) : null,
'url' => route('show/modelfile', [$assetmodel->id, $file->id]),
'created_by' => ($file->adminuser) ? [
'id' => (int) $file->adminuser->id,
'name'=> e($file->adminuser->present()->fullName),
'name'=> e($file->adminuser->display_name),
] : null,
'created_at' => Helper::getFormattedDateObject($file->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($file->updated_at, 'datetime'),

View File

@@ -322,14 +322,14 @@ class AssetsTransformer
'id' => $accessory_checkout->id,
'accessory' => [
'id' => $accessory_checkout->accessory->id,
'name' => $accessory_checkout->accessory->name,
'name' => e($accessory_checkout->accessory->display_name),
],
'assigned_to' => $accessory_checkout->assigned_to,
'image' => ($accessory_checkout->accessory->image) ? Storage::disk('public')->url('accessories/' . e($accessory_checkout->accessory->image)) : null,
'note' => $accessory_checkout->note ? e($accessory_checkout->note) : null,
'created_by' => $accessory_checkout->adminuser ? [
'id' => (int)$accessory_checkout->adminuser->id,
'name' => e($accessory_checkout->adminuser->present()->fullName),
'name' => e($accessory_checkout->display_name),
] : null,
'created_at' => Helper::getFormattedDateObject($accessory_checkout->created_at, 'datetime'),
'deleted_at' => Helper::getFormattedDateObject($accessory_checkout->deleted_at, 'datetime'),

View File

@@ -91,7 +91,7 @@ class ComponentsTransformer
'id' => (int) $asset->id,
'name' => e($asset->model->display_name).' '.e($asset->display_name),
'qty' => $asset->pivot->assigned_qty,
'note' => $asset->pivot->note,
'note' => e($asset->pivot->note),
'type' => 'asset',
'created_at' => Helper::getFormattedDateObject($asset->pivot->created_at, 'datetime'),
'available_actions' => ['checkin' => true],

View File

@@ -44,7 +44,7 @@ class CustomFieldsTransformer
'db_column_name' => e($field->db_column_name()),
'format' => e($field->format),
'field_values' => ($field->field_values) ? e($field->field_values) : null,
'field_encrypted' => $field->field_encrypted,
'field_encrypted' => ($field->field_encrypted =='1') ? true : false,
'field_values_array' => ($field->field_values) ? explode("\r\n", e($field->field_values)) : null,
'type' => e($field->element),
'required' => (($field->pivot) && ($field->pivot->required=='1')) ? true : false,

View File

@@ -30,7 +30,7 @@ class LocationsTransformer
foreach ($location->children as $child) {
$children_arr[] = [
'id' => (int) $child->id,
'name' => $child->name,
'name' => e($child->display_name),
];
}
}
@@ -157,7 +157,7 @@ class LocationsTransformer
'name' => e($location->name),
'created_by' => $location->adminuser ? [
'id' => (int) $location->adminuser->id,
'name'=> e($location->adminuser->present()->fullName),
'name'=> e($location->adminuser->display_name),
]: null,
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
];
@@ -171,7 +171,7 @@ class LocationsTransformer
if ($accessory) {
return [
'id' => $accessory->id,
'name' => $accessory->name,
'name' => e($accessory->display_name),
];
}

View File

@@ -41,7 +41,7 @@ class UploadedFilesTransformer
'note' => ($file->note) ? e($file->note) : null,
'created_by' => ($file->adminuser) ? [
'id' => (int) $file->adminuser->id,
'name'=> e($file->adminuser->present()->fullName),
'name'=> e($file->adminuser->display_name),
] : null,
'created_at' => Helper::getFormattedDateObject($file->created_at, 'datetime'),
'deleted_at' => Helper::getFormattedDateObject($file->deleted_at, 'datetime'),

View File

@@ -5,6 +5,7 @@ namespace App\Models;
use App\Models\Traits\Acceptable;
use App\Models\Traits\CompanyableChildTrait;
use App\Models\Traits\Loggable;
use App\Models\Traits\Searchable;
use App\Notifications\CheckinLicenseNotification;
use App\Notifications\CheckoutLicenseNotification;
use App\Presenters\Presentable;
@@ -14,13 +15,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class LicenseSeat extends SnipeModel implements ICompanyableChild
{
use Acceptable;
use CompanyableChildTrait;
use HasFactory;
use Loggable;
use Presentable;
use Searchable;
use SoftDeletes;
protected $presenter = \App\Presenters\LicenseSeatPresenter::class;
use Presentable;
protected $guarded = 'id';
protected $table = 'license_seats';
@@ -39,7 +42,25 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
'notes',
];
use Acceptable;
/**
* The attributes that should be included when searching the model.
*
* @var array
*/
protected $searchableAttributes = [
'notes',
];
/**
* The relations and their attributes that should be included when searching the model.
*
* @var array
*/
protected $searchableRelations = [
'user' => ['first_name', 'last_name', 'display_name', 'username', 'email'],
'asset' => ['name', 'asset_tag'],
];
public function getCompanyableParents()
{

View File

@@ -2,65 +2,3 @@
/**
* Macro helpers
*/
/**
* Country macro
* Generates the dropdown menu of countries for the profile form
*/
Form::macro('countries', function ($name = 'country', $selected = null, $class = null, $id = null) {
$idclause = (!is_null($id)) ? $id : '';
// Pull the autoglossonym array from the localizations translation file
$countries_array = trans('localizations.countries');
$select = '<select name="'.$name.'" class="'.$class.'" style="width:100%" '.$idclause.' aria-label="'.$name.'" data-placeholder="'.trans('localizations.select_country').'" data-allow-clear="true" data-tags="true">';
$select .= '<option value="" role="option">'.trans('localizations.select_country').'</option>';
foreach ($countries_array as $abbr => $country) {
// We have to handle it this way to handle deprecation warnings since you can't strtoupper on null
if ($abbr!='') {
$abbr = strtoupper($abbr);
}
// Loop through the countries configured in the localization file
$select .= '<option value="' . $abbr . '" role="option" ' . (($selected == $abbr) ? ' selected="selected" aria-selected="true"' : ' aria-selected="false"') . '>' . $country . '</option> ';
}
// If the country value doesn't exist in the array, add it as a new option and select it so we don't drop that data
if (!array_key_exists($selected, $countries_array)) {
$select .= '<option value="' . e($selected) . '" selected="selected" role="option" aria-selected="true">' . e($selected) .' *</option> ';
}
$select .= '</select>';
return $select;
});
Form::macro('username_format', function ($name = 'username_format', $selected = null, $class = null) {
$formats = [
'firstname.lastname' => trans('admin/settings/general.username_formats.firstname_lastname_format'),
'firstname' => trans('admin/settings/general.username_formats.first_name_format'),
'lastname' => trans('admin/settings/general.username_formats.last_name_format'),
'filastname' => trans('admin/settings/general.username_formats.filastname_format'),
'lastnamefirstinitial' => trans('admin/settings/general.username_formats.lastnamefirstinitial_format'),
'firstname_lastname' => trans('admin/settings/general.username_formats.firstname_lastname_underscore_format'),
'firstinitial.lastname' => trans('admin/settings/general.username_formats.firstinitial_lastname'),
'lastname_firstinitial' => trans('admin/settings/general.username_formats.lastname_firstinitial'),
'lastname.firstinitial' => trans('admin/settings/general.username_formats.lastname_dot_firstinitial_format'),
'firstnamelastname' => trans('admin/settings/general.username_formats.firstnamelastname'),
'firstnamelastinitial' => trans('admin/settings/general.username_formats.firstnamelastinitial'),
'lastname.firstname' => trans('admin/settings/general.username_formats.lastnamefirstname'),
];
$select = '<select name="'.$name.'" class="'.$class.'" style="width: 100%" aria-label="'.$name.'">';
foreach ($formats as $format => $label) {
$select .= '<option value="'.$format.'"'.($selected == $format ? ' selected="selected" role="option" aria-selected="true"' : ' aria-selected="false"').'>'.$label.'</option> '."\n";
}
$select .= '</select>';
return $select;
});

View File

@@ -288,9 +288,9 @@
@if ((isset($infoPanelObj->parent)) && $infoPanelObj->parent))
@if ((isset($infoPanelObj->parent)) && ($infoPanelObj->parent))
<x-info-element icon_type="parent" title="{{ trans('admin/locations/table.parent') }}">
{{ $infoPanelObj->parent->display_name }}
<a href="{{ route('locations.show', $infoPanelObj->parent->id) }}">{{ $infoPanelObj->parent->display_name }}</a>
</x-info-element>
@endif

View File

@@ -6,7 +6,7 @@
])
@if (!$slot->isEmpty())
<li {{ $attributes->merge(['class' => 'list-group-item']) }}>
<li {{ $attributes->merge(['class' => 'list-group-item']) }} id="{{ strtolower(str_slug($title)) }}">
@if ($icon_type)
<x-icon type="{{ $icon_type }}" :title="$title" class="fa-fw" style="{{ 'color: '.$icon_color.' !important' ?? '' }}" />

View File

@@ -0,0 +1,35 @@
@props([
'name' => 'country',
'selected' => null,
])
@php
$countries_array = trans('localizations.countries');
@endphp
<select
name="{{ $name }}"
{{ $attributes->merge(['class' => 'select2']) }}
aria-label="{{ $name }}"
data-placeholder="{{ trans('localizations.select_country') }}"
data-allow-clear="true"
>
@foreach($countries_array as $abbreviation => $country)
@php
// We have to handle it this way to handle deprecation warnings since you can't strtoupper on null
if ($abbreviation!='') {
$abbreviation = strtoupper($abbreviation);
}
@endphp
<option value="{{ $abbreviation }}" {{ $selected === $abbreviation ? 'selected' : '' }}>
{{ $country }}
</option>
@endforeach
{{-- If the country value doesn't exist in the array, add it as a new option and select it so we don't drop that data --}}
@if (!array_key_exists($selected, $countries_array)) {
<option value="{{ e($selected) }}" selected="selected" role="option" aria-selected="true"> {{ e($selected) }} *</option> ';
@endif
</select>

View File

@@ -0,0 +1,27 @@
@php
$formats = [
'firstname.lastname' => trans('admin/settings/general.username_formats.firstname_lastname_format'),
'firstname' => trans('admin/settings/general.username_formats.first_name_format'),
'lastname' => trans('admin/settings/general.username_formats.last_name_format'),
'filastname' => trans('admin/settings/general.username_formats.filastname_format'),
'lastnamefirstinitial' => trans('admin/settings/general.username_formats.lastnamefirstinitial_format'),
'firstname_lastname' => trans('admin/settings/general.username_formats.firstname_lastname_underscore_format'),
'firstinitial.lastname' => trans('admin/settings/general.username_formats.firstinitial_lastname'),
'lastname_firstinitial' => trans('admin/settings/general.username_formats.lastname_firstinitial'),
'lastname.firstinitial' => trans('admin/settings/general.username_formats.lastname_dot_firstinitial_format'),
'firstnamelastname' => trans('admin/settings/general.username_formats.firstnamelastname'),
'firstnamelastinitial' => trans('admin/settings/general.username_formats.firstnamelastinitial'),
'lastname.firstname' => trans('admin/settings/general.username_formats.lastnamefirstname'),
];
@endphp
<x-input.select {{ $attributes }}>
@foreach($formats as $format => $label)
<option
value="{{ $format }}"
@selected($selected == $format)
>
{{ $label }}
</option>
@endforeach
</x-input.select>

View File

@@ -5,6 +5,7 @@
'api_url' => null,
'show_column_search' => false,
'show_advanced_search' => false,
'show_search' => true,
'fixed_number' => false,
'fixed_right_number' => false,
'sort_order' => 'asc',
@@ -26,6 +27,7 @@
id="{{ $name }}ListingTable"
data-show-columns-search="{{ $show_column_search }}"
data-show-advanced-search="{{ $show_advanced_search }}"
data-search="{{ $show_search }}"
data-footer-style="footerStyle"
data-show-footer="true"

View File

@@ -158,7 +158,7 @@
if (data.status == 'success') {
$('#audited tbody').prepend("<tr class='success'><td>" + data.payload.asset_tag + "</td><td>" + data.messages + "</td><td>" + data.payload.status_label + " (" + data.payload.status_type + ")</td><td>" + data.payload.note + "</td><td><i class='fas fa-check text-success' style='font-size:18px;'></i></td></tr>");
@if ($user->enable_sounds)
@if ($user?->enable_sounds)
var audio = new Audio('{{ config('app.url') }}/sounds/success.mp3');
audio.play()
@endif
@@ -182,7 +182,7 @@
});
function handleAuditFail (data, asset_tag) {
@if ($user->enable_sounds)
@if ($user?->enable_sounds)
var audio = new Audio('{{ config('app.url') }}/sounds/error.mp3');
audio.play()
@endif

View File

@@ -79,6 +79,7 @@
<x-slot:content>
<x-table
show_search="false"
api_url="{{ route('api.licenses.seats.index', [$license->id, 'status' => 'available']) }}"
:presenter="\App\Presenters\LicensePresenter::dataTableLayoutSeats()"
export_filename="export-{{ str_slug($license->name) }}-available-{{ date('Y-m-d') }}"
@@ -128,7 +129,7 @@
<x-slot:buttons>
<x-button.checkout permission="checkout" :item="$license" :route="route('licenses.freecheckout', $license->id)" />
<x-button.checkout permission="checkout" :item="$license" :route="route('licenses.checkout', $license->id)" />
<x-button.edit :item="$license" :route="route('licenses.edit', $license->id)" />
<x-button.clone :item="$license" :route="route('clone/license', $license->id)" />
<x-button.delete :item="$license" />

View File

@@ -32,7 +32,13 @@
<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12 country"><label for="modal-country">{{ trans('general.country') }}:</label></div>
<div class="col-md-9 col-xs-12">{!! Form::countries('country', old('country'), 'select2 country',"modal-country") !!}</div>
<div class="col-md-9 col-xs-12">
<x-input.country-select
name="country"
:selected="old('country')"
id="modal-country"
/>
</div>
</div>
</form>
</div>

View File

@@ -46,7 +46,7 @@
</div> <!-- /.modal-body-->
<div class="modal-footer">
<a href="#" class="pull-left" data-dismiss="modal">{{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-theme">{{ trans('button.upload') }}</button>
<button type="button" class="btn btn-theme" formnovalidate>{{ trans('button.upload') }}</button>
</div>
</form>
</div>

View File

@@ -34,7 +34,10 @@
<div class="form-group {{ $errors->has('country') ? ' has-error' : '' }}">
<label for="country" class="col-md-3 control-label">{{ trans('general.country') }}</label>
<div class="col-md-7">
{!! Form::countries('country', old('country', $item->country), 'select2') !!}
<x-input.country-select
name="country"
:selected="old('country', $item->country)"
/>
<p class="help-block">{{ trans('general.countries_manually_entered_help') }}</p>
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>

View File

@@ -102,7 +102,12 @@
<label for="username_format" class="col-md-3 control-label">{{ trans('admin/settings/general.username_formats.username_format') }}</label>
<div class="col-md-8">
{!! Form::username_format('username_format', old('username_format', $setting->username_format), 'select2') !!}
<x-input.username-select
name="username_format"
:selected="old('username_format', $setting->username_format)"
style="width: 100%"
aria-label="username_format"
/>
{!! $errors->first('username_format', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
<p class="help-block">

View File

@@ -80,19 +80,7 @@
<!-- start components tab pane -->
@can('view', \App\Models\Component::class)
<x-tabs.pane name="components" class="{{ $supplier->components->count() == 0 ? 'hidden-print' : '' }}">
<x-slot:header>
{{ trans('general.components') }}
</x-slot:header>
<x-table
show_advanced_search="true"
buttons="componentButtons"
api_url="{{ route('api.components.index', ['supplier_id' => $supplier->id]) }}"
:presenter="\App\Presenters\ComponentPresenter::dataTableLayout()"
export_filename="export-{{ str_slug($supplier->name) }}-components-{{ date('Y-m-d') }}"
/>
<x-table.components name="components" :route="route('api.components.index', ['supplier_id' => $supplier->id])" />
</x-tabs.pane>
@endcan
<!-- end components tab pane -->

View File

@@ -502,7 +502,11 @@
<div class="form-group{{ $errors->has('country') ? ' has-error' : '' }}">
<label class="col-md-3 control-label" for="country">{{ trans('general.country') }}</label>
<div class="col-md-6">
{!! Form::countries('country', old('country', $user->country), 'col-md-12 select2') !!}
<x-input.country-select
name="country"
:selected="old('country', $user->country)"
class="col-md-12"
/>
<p class="help-block">{{ trans('general.countries_manually_entered_help') }}</p>
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}