Updated controllers and presenters

This commit is contained in:
snipe
2025-11-14 17:58:27 +00:00
parent 09575e5312
commit 590f77bdb4
43 changed files with 326 additions and 54 deletions
@@ -43,6 +43,7 @@ class CategoriesController extends Controller
'created_at',
'updated_at',
'image',
'tag_color',
'notes',
];
@@ -57,6 +58,7 @@ class CategoriesController extends Controller
'require_acceptance',
'checkin_email',
'image',
'tag_color',
'notes',
])
->with('adminuser')
@@ -24,7 +24,7 @@ class DepartmentsController extends Controller
public function index(Request $request) : JsonResponse | array
{
$this->authorize('view', Department::class);
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes'];
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes', 'tag_color'];
$departments = Department::select(
[
@@ -38,6 +38,7 @@ class DepartmentsController extends Controller
'departments.created_at',
'departments.updated_at',
'departments.image',
'departments.tag_color',
'departments.notes'
])->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count');
@@ -61,6 +62,10 @@ class DepartmentsController extends Controller
$departments->where('location_id', '=', $request->input('location_id'));
}
if ($request->filled('tag_color')) {
$departments->where('tag_color', '=', $request->input('departments.tag_color'));
}
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $departments->count()) ? $departments->count() : app('api_offset_value');
$limit = app('api_limit_value');
@@ -59,6 +59,7 @@ class LocationsController extends Controller
'state',
'updated_at',
'zip',
'tag_color',
'notes',
];
@@ -81,6 +82,8 @@ class LocationsController extends Controller
'locations.ldap_ou',
'locations.currency',
'locations.company_id',
'locations.tag_color',
'locations.tag_color',
'locations.notes',
'locations.created_by',
'locations.deleted_at',
@@ -145,6 +148,10 @@ class LocationsController extends Controller
$locations->onlyTrashed();
}
if ($request->filled('tag_color')) {
$locations->where('tag_color', '=', $request->input('locations.tag_color'));
}
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value');
$limit = app('api_limit_value');
@@ -47,6 +47,7 @@ class ManufacturersController extends Controller
'consumables_count',
'components_count',
'licenses_count',
'tag_color',
'notes',
];
@@ -63,6 +64,7 @@ class ManufacturersController extends Controller
'updated_at',
'image',
'deleted_at',
'tag_color',
'notes',
])
->with('adminuser')
@@ -104,6 +106,10 @@ class ManufacturersController extends Controller
$manufacturers->where('support_email', '=', $request->input('support_email'));
}
if ($request->filled('tag_color')) {
$manufacturers->where('tag_color', '=', $request->input('manufacturers.tag_color'));
}
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $manufacturers->count()) ? $manufacturers->count() : app('api_offset_value');
$limit = app('api_limit_value');
@@ -50,12 +50,13 @@ class SuppliersController extends Controller
'accessories_count',
'components_count',
'consumables_count',
'tag_color',
'url',
'notes',
];
$suppliers = Supplier::select(
['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip'])
['id', 'name', 'address', 'address2', 'city', 'state', 'country', 'fax', 'phone', 'email', 'contact', 'created_at', 'created_by', 'updated_at', 'deleted_at', 'image', 'notes', 'url', 'zip', 'tag_color'])
->withCount('assets as assets_count')
->withCount('licenses as licenses_count')
->withCount('accessories as accessories_count')
@@ -78,6 +78,7 @@ class CategoriesController extends Controller
$category->require_acceptance = $request->input('require_acceptance', '0');
$category->alert_on_response = $request->input('alert_on_response', '0');
$category->checkin_email = $request->input('checkin_email', '0');
$category->tag_color = $request->input('tag_color');
$category->notes = $request->input('notes');
$category->created_by = auth()->id();
@@ -132,6 +133,7 @@ class CategoriesController extends Controller
$category->require_acceptance = $request->input('require_acceptance', '0');
$category->alert_on_response = $request->input('alert_on_response', '0');
$category->checkin_email = $request->input('checkin_email', '0');
$category->tag_color = $request->input('tag_color');
$category->notes = $request->input('notes');
$category = $request->handleImages($category);
@@ -55,6 +55,7 @@ class DepartmentsController extends Controller
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
$department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null);
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
$department->tag_color = $request->input('tag_color');
$department->notes = $request->input('notes');
$department = $request->handleImages($department);
@@ -157,6 +158,7 @@ class DepartmentsController extends Controller
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
$department->phone = $request->input('phone');
$department->fax = $request->input('fax');
$department->tag_color = $request->input('tag_color');
$department->notes = $request->input('notes');
$department = $request->handleImages($department);
@@ -82,6 +82,7 @@ class LocationsController extends Controller
$location->created_by = auth()->id();
$location->phone = request('phone');
$location->fax = request('fax');
$location->tag_color = $request->input('tag_color');
$location->notes = $request->input('notes');
$location->company_id = Company::getIdForCurrentUser($request->input('company_id'));
@@ -156,6 +157,7 @@ class LocationsController extends Controller
$location->fax = request('fax');
$location->ldap_ou = $request->input('ldap_ou');
$location->manager_id = $request->input('manager_id');
$location->tag_color = $request->input('tag_color');
$location->notes = $request->input('notes');
// Only scope the location if the setting is enabled
@@ -101,6 +101,7 @@ class ManufacturersController extends Controller
$manufacturer->support_email = $request->input('support_email');
$manufacturer->notes = $request->input('notes');
$manufacturer = $request->handleImages($manufacturer);
$manufacturer->tag_color = $request->input('tag_color');
if ($manufacturer->save()) {
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.create.success'));
@@ -142,6 +143,7 @@ class ManufacturersController extends Controller
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
$manufacturer->support_phone = $request->input('support_phone');
$manufacturer->support_email = $request->input('support_email');
$manufacturer->tag_color = $request->input('tag_color');
$manufacturer->notes = $request->input('notes');
// Set the model's image property to null if the image is being deleted
@@ -67,6 +67,7 @@ class SuppliersController extends Controller
$supplier->phone = request('phone');
$supplier->fax = request('fax');
$supplier->email = request('email');
$supplier->tag_color = $request->input('tag_color');
$supplier->notes = request('notes');
$supplier->url = $supplier->addhttp(request('url'));
$supplier->created_by = auth()->id();
@@ -111,6 +112,7 @@ class SuppliersController extends Controller
$supplier->fax = request('fax');
$supplier->email = request('email');
$supplier->url = $supplier->addhttp(request('url'));
$supplier->tag_color = $request->input('tag_color');
$supplier->notes = request('notes');
$supplier = $request->handleImages($supplier);
@@ -26,12 +26,32 @@ class AccessoriesTransformer
'id' => $accessory->id,
'name' => e($accessory->name),
'image' => ($accessory->image) ? Storage::disk('public')->url('accessories/'.e($accessory->image)) : null,
'company' => ($accessory->company) ? ['id' => $accessory->company->id, 'name'=> e($accessory->company->name)] : null,
'manufacturer' => ($accessory->manufacturer) ? ['id' => $accessory->manufacturer->id, 'name'=> e($accessory->manufacturer->name)] : null,
'supplier' => ($accessory->supplier) ? ['id' => $accessory->supplier->id, 'name'=> e($accessory->supplier->name)] : null,
'company' => ($accessory->company) ? [
'id' => $accessory->company->id,
'name'=> e($accessory->company->name),
'tag_color'=> ($accessory->company->tag_color) ? e($accessory->company->tag_color) : null,
] : null,
'manufacturer' => ($accessory->manufacturer) ? [
'id' => $accessory->manufacturer->id,
'name'=> e($accessory->manufacturer->name),
'tag_color'=> ($accessory->manufacturer->tag_color) ? e($accessory->manufacturer->tag_color) : null,
] : null,
'supplier' => ($accessory->supplier) ? [
'id' => $accessory->supplier->id,
'name'=> e($accessory->supplier->name),
'tag_color'=> ($accessory->supplier->tag_color) ? e($accessory->supplier->tag_color) : null,
] : null,
'model_number' => ($accessory->model_number) ? e($accessory->model_number) : null,
'category' => ($accessory->category) ? ['id' => $accessory->category->id, 'name'=> e($accessory->category->name)] : null,
'location' => ($accessory->location) ? ['id' => $accessory->location->id, 'name'=> e($accessory->location->name)] : null,
'category' => ($accessory->category) ? [
'id' => $accessory->category->id,
'name'=> e($accessory->category->name),
'tag_color'=> ($accessory->category->tag_color) ? e($accessory->category->tag_color) : null,
] : null,
'location' => ($accessory->location) ? [
'id' => $accessory->location->id,
'name'=> e($accessory->location->name),
'tag_color'=> ($accessory->location->tag_color) ? e($accessory->location->tag_color) : null,
] : null,
'notes' => ($accessory->notes) ? Helper::parseEscapedMarkedownInline($accessory->notes) : null,
'qty' => ($accessory->qty) ? (int) $accessory->qty : null,
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
@@ -161,6 +161,7 @@ class ActionlogsTransformer
'location' => ($actionlog->location) ? [
'id' => (int) $actionlog->location->id,
'name' => e($actionlog->location->name),
'tag_color'=> ($actionlog->location->tag_color) ? e($actionlog->location->tag_color) : null,
] : null,
'created_at' => Helper::getFormattedDateObject($actionlog->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($actionlog->updated_at, 'datetime'),
@@ -44,6 +44,7 @@ class AssetModelsTransformer
'manufacturer' => ($assetmodel->manufacturer) ? [
'id' => (int) $assetmodel->manufacturer->id,
'name'=> e($assetmodel->manufacturer->name),
'tag_color'=> ($assetmodel->manufacturer->tag_color) ? e($assetmodel->manufacturer->tag_color) : null,
] : null,
'image' => ($assetmodel->image != '') ? Storage::disk('public')->url('models/'.e($assetmodel->image)) : null,
'model_number' => ($assetmodel->model_number ? e($assetmodel->model_number): null),
@@ -60,6 +61,7 @@ class AssetModelsTransformer
'category' => ($assetmodel->category) ? [
'id' => (int) $assetmodel->category->id,
'name'=> e($assetmodel->category->name),
'tag_color'=> ($assetmodel->category->tag_color) ? e($assetmodel->category->tag_color) : null,
] : null,
'fieldset' => ($assetmodel->fieldset) ? [
'id' => (int) $assetmodel->fieldset->id,
+6 -1
View File
@@ -40,7 +40,6 @@ class AssetsTransformer
] : null,
'byod' => ($asset->byod ? true : false),
'requestable' => ($asset->requestable ? true : false),
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
'eol' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? (int) Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date, true) . ' months' : null,
'asset_eol_date' => ($asset->asset_eol_date != '') ? Helper::getFormattedDateObject($asset->asset_eol_date, 'date') : null,
@@ -53,10 +52,12 @@ class AssetsTransformer
'category' => (($asset->model) && ($asset->model->category)) ? [
'id' => (int) $asset->model->category->id,
'name'=> e($asset->model->category->name),
'tag_color'=> ($asset->model->category->tag_color) ? e($asset->model->category->tag_color) : null,
] : null,
'manufacturer' => (($asset->model) && ($asset->model->manufacturer)) ? [
'id' => (int) $asset->model->manufacturer->id,
'name'=> e($asset->model->manufacturer->name),
'tag_color'=> ($asset->model->manufacturer->tag_color) ? e($asset->model->manufacturer->tag_color) : null,
] : null,
'depreciation' => (($asset->model) && ($asset->model->depreciation)) ? [
'id' => (int) $asset->model->depreciation->id,
@@ -68,20 +69,24 @@ class AssetsTransformer
'supplier' => ($asset->supplier) ? [
'id' => (int) $asset->supplier->id,
'name'=> e($asset->supplier->name),
'tag_color'=> ($asset->supplier->tag_color) ? e($asset->supplier->tag_color) : null,
] : null,
'notes' => ($asset->notes) ? Helper::parseEscapedMarkedownInline($asset->notes) : null,
'order_number' => ($asset->order_number) ? e($asset->order_number) : null,
'company' => ($asset->company) ? [
'id' => (int) $asset->company->id,
'name'=> e($asset->company->name),
'tag_color'=> ($asset->company->tag_color) ? e($asset->company->tag_color) : null,
] : null,
'location' => ($asset->location) ? [
'id' => (int) $asset->location->id,
'name'=> e($asset->location->name),
'tag_color'=> ($asset->location->tag_color) ? e($asset->location->tag_color) : null,
] : null,
'rtd_location' => ($asset->defaultLoc) ? [
'id' => (int) $asset->defaultLoc->id,
'name'=> e($asset->defaultLoc->name),
'tag_color'=> ($asset->defaultLoc->tag_color) ? e($asset->defaultLoc->tag_color) : null,
] : null,
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
'qr' => ($setting->qr_code=='1') ? config('app.url').'/uploads/barcodes/qr-'.str_slug($asset->asset_tag).'-'.str_slug($asset->id).'.png' : null,
@@ -66,6 +66,7 @@ class CategoriesTransformer
'id' => (int) $category->adminuser->id,
'name'=> e($category->adminuser->display_name),
] : null,
'tag_color' => $category->tag_color ? e($category->tag_color) : null,
'notes' => Helper::parseEscapedMarkedownInline($category->notes),
'created_at' => Helper::getFormattedDateObject($category->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($category->updated_at, 'datetime'),
@@ -44,6 +44,7 @@ class DepartmentsTransformer
'name' => e($department->location->name),
] : null,
'users_count' => (int) ($department->users_count),
'tag_color' => $department->tag_color ? e($department->tag_color) : null,
'notes' => Helper::parseEscapedMarkedownInline($department->notes),
'created_at' => Helper::getFormattedDateObject($department->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($department->updated_at, 'datetime'),
+15 -3
View File
@@ -25,7 +25,11 @@ class LicensesTransformer
'id' => (int) $license->id,
'name' => e($license->name),
'company' => ($license->company) ? ['id' => (int) $license->company->id, 'name'=> e($license->company->name)] : null,
'manufacturer' => ($license->manufacturer) ? ['id' => (int) $license->manufacturer->id, 'name'=> e($license->manufacturer->name)] : null,
'manufacturer' => ($license->manufacturer) ? [
'id' => (int) $license->manufacturer->id,
'name'=> e($license->manufacturer->name),
'tag_color'=> ($license->manufacturer->tag_color) ? e($license->manufacturer->tag_color) : null,
] : null,
'product_key' => (Gate::allows('viewKeys', License::class)) ? e($license->serial) : '------------',
'order_number' => ($license->order_number) ? e($license->order_number) : null,
'purchase_order' => ($license->purchase_order) ? e($license->purchase_order) : null,
@@ -44,8 +48,16 @@ class LicensesTransformer
'license_email' => ($license->license_email) ? e($license->license_email) : null,
'reassignable' => ($license->reassignable == 1) ? true : false,
'maintained' => ($license->maintained == 1) ? true : false,
'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id, 'name'=> e($license->supplier->name)] : null,
'category' => ($license->category) ? ['id' => (int) $license->category->id, 'name'=> e($license->category->name)] : null,
'supplier' => ($license->supplier) ? [
'id' => (int) $license->supplier->id,
'name'=> e($license->supplier->name),
'tag_color'=> ($license->supplier->tag_color) ? e($license->supplier->tag_color) : null,
] : null,
'category' => ($license->category) ? [
'id' => (int) $license->category->id,
'name'=> e($license->category->name),
'tag_color'=> ($license->category->tag_color) ? e($license->category->tag_color) : null,
] : null,
'created_by' => ($license->adminuser) ? [
'id' => (int) $license->adminuser->id,
'name'=> e($license->adminuser->display_name),
@@ -58,6 +58,7 @@ class LocationsTransformer
'children_count' => (int) $location->children_count,
'currency' => ($location->currency) ? e($location->currency) : null,
'ldap_ou' => ($location->ldap_ou) ? e($location->ldap_ou) : null,
'tag_color' => $location->tag_color ? e($location->tag_color) : null,
'notes' => Helper::parseEscapedMarkedownInline($location->notes),
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
'created_by' => $location->adminuser ? [
@@ -68,11 +69,13 @@ class LocationsTransformer
'parent' => ($location->parent) ? [
'id' => (int) $location->parent->id,
'name'=> e($location->parent->name),
'tag_color' => $location->parent->tag_color ? e($location->parent->tag_color) : null,
] : null,
'manager' => ($location->manager) ? (new UsersTransformer)->transformUser($location->manager) : null,
'company' => ($location->company) ? [
'id' => (int) $location->company->id,
'name'=> e($location->company->name)
'name'=> e($location->company->name),
'tag_color' => $location->company->tag_color ? e($location->company->tag_color) : null,
] : null,
'children' => $children_arr,
@@ -37,6 +37,7 @@ class ManufacturersTransformer
'consumables_count' => (int) $manufacturer->consumables_count,
'accessories_count' => (int) $manufacturer->accessories_count,
'components_count' => (int) $manufacturer->components_count,
'tag_color' => $manufacturer->tag_color ? e($manufacturer->tag_color) : null,
'notes' => Helper::parseEscapedMarkedownInline($manufacturer->notes),
'created_by' => ($manufacturer->adminuser) ? [
'id' => (int) $manufacturer->adminuser->id,
@@ -43,6 +43,7 @@ class SuppliersTransformer
'licenses_count' => (int) $supplier->licenses_count,
'consumables_count' => (int) $supplier->consumables_count,
'components_count' => (int) $supplier->components_count,
'tag_color' => $supplier->tag_color ? e($supplier->tag_color) : null,
'notes' => ($supplier->notes) ? Helper::parseEscapedMarkedownInline($supplier->notes) : null,
'created_at' => Helper::getFormattedDateObject($supplier->created_at, 'datetime'),
'created_by' => $supplier->adminuser ? [
+6 -1
View File
@@ -65,6 +65,7 @@ class UsersTransformer
'location' => ($user->userloc) ? [
'id' => (int) $user->userloc->id,
'name'=> e($user->userloc->name),
'tag_color'=> ($user->userloc->tag_color) ? e($user->userloc->tag_color) : null,
] : null,
'notes'=> Helper::parseEscapedMarkedownInline($user->notes),
'role' => $role,
@@ -80,7 +81,11 @@ class UsersTransformer
'consumables_count' => (int) $user->consumables_count,
'manages_users_count' => (int) $user->manages_users_count,
'manages_locations_count' => (int) $user->manages_locations_count,
'company' => ($user->company) ? ['id' => (int) $user->company->id, 'name'=> e($user->company->name)] : null,
'company' => ($user->company) ? [
'id' => (int) $user->company->id,
'name'=> e($user->company->name),
'tag_color'=> ($user->company->tag_color) ? e($user->company->tag_color) : null,
] : null,
'created_by' => ($user->createdBy) ? [
'id' => (int) $user->createdBy->id,
'name'=> e($user->createdBy->display_name),
+1
View File
@@ -73,6 +73,7 @@ class Category extends SnipeModel
'alert_on_response',
'use_default_eula',
'created_by',
'tag_color',
'notes',
];
+1
View File
@@ -53,6 +53,7 @@ class Department extends SnipeModel
'location_id',
'company_id',
'manager_id',
'tag_color',
'notes',
];
+1
View File
@@ -77,6 +77,7 @@ class Location extends SnipeModel
'manager_id',
'image',
'company_id',
'tag_color',
'notes',
];
protected $hidden = ['user_id'];
+1
View File
@@ -53,6 +53,7 @@ class Manufacturer extends SnipeModel
'support_url',
'url',
'warranty_lookup_url',
'tag_color',
'notes',
];
+1 -1
View File
@@ -66,7 +66,7 @@ class Supplier extends SnipeModel
*
* @var array
*/
protected $fillable = ['name', 'address', 'address2', 'city', 'state', 'country', 'zip', 'phone', 'fax', 'email', 'contact', 'url', 'notes'];
protected $fillable = ['name', 'address', 'address2', 'city', 'state', 'country', 'zip', 'phone', 'fax', 'email', 'contact', 'url', 'tag_color', 'notes'];
/**
* Eager load counts
+1 -1
View File
@@ -49,7 +49,7 @@ class AccessoryPresenter extends Presenter
'field' => 'category',
'searchable' => true,
'sortable' => true,
'title' => trans('admin/accessories/general.accessory_category'),
'title' => trans('general.category'),
'formatter' => 'categoriesLinkObjFormatter',
], [
'field' => 'model_number',
+17
View File
@@ -82,6 +82,14 @@ class CategoryPresenter extends Presenter
"title" => trans('admin/categories/general.use_default_eula_column'),
'visible' => true,
"formatter" => 'trueFalseFormatter',
], [
'field' => 'tag_color',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.tag_color'),
'visible' => false,
'formatter' => 'colorTagFormatter',
], [
'field' => 'notes',
'searchable' => true,
@@ -142,4 +150,13 @@ class CategoryPresenter extends Presenter
{
return route('categories.show', $this->id);
}
public function formattedNameLink() {
if (auth()->user()->can('category.view', $this)) {
return ($this->tag_color ? "<i class='fa-solid fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').' <a href="'.route('categories.show', e($this->id)).'">'.e($this->name).'</a>';
}
return ($this->tag_color ? "<i class='fa-solid fa-square' style='color: ".e($this->tag_color)."' aria-hidden='true'></i> " : '').$this->name;
}
}
+9 -1
View File
@@ -227,7 +227,15 @@ class LocationPresenter extends Presenter
'title' => trans('admin/users/table.manager'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
], [
'field' => 'tag_color',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.tag_color'),
'visible' => false,
'formatter' => 'colorTagFormatter',
], [
'field' => 'notes',
'searchable' => true,
'sortable' => true,
+8
View File
@@ -156,6 +156,14 @@ class SupplierPresenter extends Presenter
'visible' => false,
'formatter' => 'phoneFormatter',
], [
'field' => 'tag_color',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.tag_color'),
'visible' => false,
'formatter' => 'colorTagFormatter',
],[
'field' => 'notes',
'searchable' => true,
'sortable' => true,
@@ -14,6 +14,26 @@ return new class extends Migration
Schema::table('companies', function (Blueprint $table) {
$table->string('tag_color', )->after('name')->nullable()->default(null);
});
Schema::table('categories', function (Blueprint $table) {
$table->string('tag_color', )->after('name')->nullable()->default(null);
});
Schema::table('manufacturers', function (Blueprint $table) {
$table->string('tag_color', )->after('name')->nullable()->default(null);
});
Schema::table('suppliers', function (Blueprint $table) {
$table->string('tag_color', )->after('name')->nullable()->default(null);
});
Schema::table('locations', function (Blueprint $table) {
$table->string('tag_color', )->after('name')->nullable()->default(null);
});
Schema::table('departments', function (Blueprint $table) {
$table->string('tag_color', )->after('name')->nullable()->default(null);
});
}
/**
@@ -24,5 +44,25 @@ return new class extends Migration
Schema::table('companies', function ($table) {
$table->dropColumn('tag_color');
});
Schema::table('categories', function ($table) {
$table->dropColumn('tag_color');
});
Schema::table('manufacturers', function ($table) {
$table->dropColumn('tag_color');
});
Schema::table('suppliers', function ($table) {
$table->dropColumn('tag_color');
});
Schema::table('locations', function ($table) {
$table->dropColumn('tag_color');
});
Schema::table('departments', function ($table) {
$table->dropColumn('tag_color');
});
}
};
+1 -1
View File
@@ -188,7 +188,7 @@
<strong>{{ trans('general.category')}}</strong>
</div>
<div class="col-md-9">
<a href="{{ route('categories.show', $accessory->category->id) }}">{{ $accessory->category->name }} </a>
{!! $accessory->category->present()->formattedNameLink !!}
</div>
</div>
@endif
@@ -0,0 +1,13 @@
@props([
'item' => null,
'name' => 'color',
'id' => 'color',
])
<!-- Colorpicker -->
<div id="color" class="input-group colorpicker-component row col-md-5">
<input class="form-control" placeholder="#FF0000" aria-label="{{ $name }}" name="{{ $name }}" type="text" id="{{ $id }}" value="{{ old($name, ($item->{$name} ?? '')) }}">
<span class="input-group-addon"><i></i></span>
</div>
<!-- /.input group -->
+15 -5
View File
@@ -63,11 +63,6 @@
</div>
@stop
@section('content')
@parent
@if ($snipeSettings->default_eula_text!='')
<!-- Modal -->
@@ -89,6 +84,21 @@
</div>
@endif
<fieldset name="color-preferences">
<x-form-legend help_text="{{ trans('general.tag_color_help') }}">
{{ trans('general.tag_color') }}
</x-form-legend>
<!-- color -->
<div class="form-group {{ $errors->has('tag_color') ? 'error' : '' }}">
<label for="tag_color" class="col-md-3 control-label">
{{ trans('general.tag_color') }}
</label>
<div class="col-md-9">
<x-input.colorpicker :item="$item" id="color" :value="old('color', ($item->color ?? '#f4f4f4'))" name="tag_color" id="tag_color" />
{!! $errors->first('tag_color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
</fieldset>
@stop
+17
View File
@@ -30,4 +30,21 @@
</div>
</div>
<fieldset name="color-preferences">
<x-form-legend help_text="{{ trans('general.tag_color_help') }}">
{{ trans('general.tag_color') }}
</x-form-legend>
<!-- color -->
<div class="form-group {{ $errors->has('tag_color') ? 'error' : '' }}">
<label for="tag_color" class="col-md-3 control-label">
{{ trans('general.tag_color') }}
</label>
<div class="col-md-9">
<x-input.colorpicker :item="$item" id="tag_color" :value="old('tag_color', ($item->tag_color ?? '#f4f4f4'))" name="tag_color" id="tag_color" />
{!! $errors->first('tag_color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
</fieldset>
@stop
@@ -1086,6 +1086,10 @@ dir="{{ Helper::determineLanguageDirection() }}">
<script nonce="{{ csrf_token() }}">
//color picker with addon
$("#color").colorpicker();
$.fn.datepicker.dates['{{ app()->getLocale() }}'] = {
days: [
"{{ trans('datepicker.days.sunday') }}",
+15
View File
@@ -78,5 +78,20 @@
</div>
</div>
<fieldset name="color-preferences">
<x-form-legend help_text="{{ trans('general.tag_color_help') }}">
{{ trans('general.tag_color') }}
</x-form-legend>
<!-- color -->
<div class="form-group {{ $errors->has('tag_color') ? 'error' : '' }}">
<label for="tag_color" class="col-md-3 control-label">
{{ trans('general.tag_color') }}
</label>
<div class="col-md-9">
<x-input.colorpicker :item="$item" id="color" :value="old('color', ($item->color ?? '#f4f4f4'))" name="tag_color" id="tag_color" />
{!! $errors->first('tag_color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
</fieldset>
@stop
@@ -93,5 +93,20 @@
placeholder="{{ trans('general.placeholders.notes') }}"
/>
<fieldset name="color-preferences">
<x-form-legend help_text="{{ trans('general.tag_color_help') }}">
{{ trans('general.tag_color') }}
</x-form-legend>
<!-- color -->
<div class="form-group {{ $errors->has('tag_color') ? 'error' : '' }}">
<label for="tag_color" class="col-md-3 control-label">
{{ trans('general.tag_color') }}
</label>
<div class="col-md-9">
<x-input.colorpicker :item="$item" id="color" :value="old('color', ($item->color ?? '#f4f4f4'))" name="tag_color" id="tag_color" />
{!! $errors->first('tag_color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
</fieldset>
@stop
@@ -972,16 +972,41 @@
// Add some overrides for any funny urls we have
var dest = destination;
var tag_color;
var polymorphicItemFormatterDest = '';
if (destination == 'fieldsets') {
var polymorphicItemFormatterDest = 'fields/';
}
}
return '<nobr><a href="{{ config('app.url') }}/' + polymorphicItemFormatterDest + dest + '/' + value.id + '">' + value.name + '</a></span>';
// Handle the preceding icon if a tag_color is given in the API response
if ((value.tag_color) && (value.tag_color!='')) {
var tag_icon = '<i class="fa-solid fa-square" style="color: ' + value.tag_color + ';" aria-hidden="true"></i>';
} else {
var tag_icon = '';
}
return '<nobr>'+ tag_icon + ' <a href="{{ config('app.url') }}/' + polymorphicItemFormatterDest + dest + '/' + value.id + '">' + value.name + '</a></span>';
}
};
}
function colorSqFormatter(value, row) {
if (value) {
return '<span class="label" style="background-color: ' + value + ';">&nbsp;</span> ' + value;
}
}
function colorTagFormatter(value, row) {
if (value) {
return '<i class="fa-solid fa-square" style="color: ' + value + ';" aria-hidden="true"></i> ' + value;
}
}
function licenseKeyFormatter(value, row) {
if (value) {
@@ -1414,7 +1439,14 @@
function deployedLocationFormatter(row, value) {
if ((row) && (row!=undefined)) {
return '<a href="{{ config('app.url') }}/locations/' + row.id + '">' + row.name + '</a>';
// Handle the preceding icon if a tag_color is given in the API response
if ((row.tag_color) && (row.tag_color!='')) {
var tag_icon = '<i class="fa-solid fa-square" style="color: ' + row.tag_color + ';" aria-hidden="true"></i> ';
} else {
var tag_icon = '';
}
return '<nobr>' + tag_icon +'<a href="{{ config('app.url') }}/locations/' + row.id + '">' + row.name + '</a></nobr>';
} else if (value.rtd_location) {
return '<a href="{{ config('app.url') }}/locations/' + value.rtd_location.id + '">' + value.rtd_location.name + '</a>';
}
+17 -10
View File
@@ -228,16 +228,15 @@
<!-- Header color -->
<div class="form-group {{ $errors->has('header_color') ? 'error' : '' }}">
<label for="header_color" class="col-md-3 control-label">{{ trans('admin/settings/general.header_color') }}</label>
<div class="col-md-9">
<div id="header-color" class="input-group colorpicker-component row col-md-5">
<input type="text" class="form-control" placeholder="#FF0000" aria-label="header_color" name="header_color" id="header_color" value="{{ old('header_color', ($setting->header_color ?? '#3c8dbc')) }}" />
<span class="input-group-addon"><i></i></span>
</div>
<p class="help-block">{{ trans('admin/settings/general.header_color_help') }}</p>
<div class="col-md-5 col-xs-5 col-sm-3 col-md-4 col-lg-3 col-xl-3">
<div class="input-group header-color">
<input class="form-control" placeholder="#FF0000" aria-label="header_color" name="header_color" type="text" id="header_color" value="{{ old('header_color', ($setting->header_color ?? '#3c8dbc')) }}">
<div class="input-group-addon">
<i class="fa-solid fa-square" style="color: {{ old('header_color', ($setting->header_color ?? '#3c8dbc')) }}"></i>
</div>
</div><!-- /.input group -->
{!! $errors->first('header_color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@@ -423,9 +422,17 @@
@section('moar_scripts')
<!-- bootstrap color picker -->
<script nonce="{{ csrf_token() }}">
//color picker with addon
$(".header-color").colorpicker();
$(function() {
$('#header-color').colorpicker().on('changeColor', function(e) {
$('.main-header .navbar')[0].style.backgroundColor = e.color
.toString('rgba');
});
});
// toggle the disabled state of asset id prefix
$('#auto_increment_assets').on('ifChecked', function(){
$('#auto_increment_prefix').prop('disabled', false).focus();
+1 -18
View File
@@ -42,10 +42,7 @@
<div class="form-group{{ $errors->has('color') ? ' has-error' : '' }}">
<label for="color" class="col-md-3 control-label">{{ trans('admin/statuslabels/table.color') }}</label>
<div class="col-md-9">
<div class="input-group color">
<input class="form-control col-md-10" maxlength="20" name="color" type="text" id="color" value="{{ old('color', $item->color) }}">
<div class="input-group-addon"><i></i></div>
</div><!-- /.input group -->
<x-input.colorpicker :item="$item" id="color" :value="old('color', ($item->color ?? '#f4f4f4'))" name="color" id="color" />
{!! $errors->first('color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@@ -75,17 +72,3 @@
@stop
@section('moar_scripts')
<!-- bootstrap color picker -->
<script nonce="{{ csrf_token() }}">
$(function() {
$('.color').colorpicker({
color: `{{ old('color', $item->color) ?: '#AA3399' }}`,
format: 'hex'
});
});
</script>
@stop
+1 -1
View File
@@ -79,7 +79,7 @@
<script nonce="{{ csrf_token() }}">
function colorSqFormatter(value, row) {
if (value) {
return '<span class="label" style="background-color: ' + value + ';">&nbsp;</span> ' + value;
return '<i class="fa-solid fa-square" style="color: ' + value + ';" aria-hidden="true"></i> ' + value;
}
}
+16
View File
@@ -36,4 +36,20 @@
@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.image-upload', ['image_path' => app('suppliers_upload_path')])
<fieldset name="color-preferences">
<x-form-legend help_text="{{ trans('general.tag_color_help') }}">
{{ trans('general.tag_color') }}
</x-form-legend>
<!-- color -->
<div class="form-group {{ $errors->has('tag_color') ? 'error' : '' }}">
<label for="tag_color" class="col-md-3 control-label">
{{ trans('general.tag_color') }}
</label>
<div class="col-md-9">
<x-input.colorpicker :item="$item" id="color" :value="old('color', ($item->color ?? '#f4f4f4'))" name="tag_color" id="tag_color" />
{!! $errors->first('tag_color', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
</fieldset>
@stop