Skip to content

Commit

Permalink
Merge pull request #16226 from snipe/add_notes_to_locations_companies…
Browse files Browse the repository at this point in the history
…_etc

Fixed #16184 - added notes to locations, companies, categories, manufacturers and groups
  • Loading branch information
snipe authored Feb 11, 2025
2 parents aa14cfe + 6159163 commit c08cfb9
Show file tree
Hide file tree
Showing 63 changed files with 466 additions and 32 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/Api/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function index(Request $request) : array
'components_count',
'licenses_count',
'image',
'notes',
];

$categories = Category::select([
Expand All @@ -52,6 +53,7 @@ public function index(Request $request) : array
'require_acceptance',
'checkin_email',
'image',
'notes',
])
->with('adminuser')
->withCount('accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count');
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Api/CompaniesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function index(Request $request) : JsonResponse | array
'accessories_count',
'consumables_count',
'components_count',
'notes',
];

$companies = Company::withCount(['assets as assets_count' => function ($query) {
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Api/DepartmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DepartmentsController extends Controller
public function index(Request $request) : JsonResponse | array
{
$this->authorize('view', Department::class);
$allowed_columns = ['id', 'name', 'image', 'users_count'];
$allowed_columns = ['id', 'name', 'image', 'users_count', 'notes'];

$departments = Department::select(
'departments.id',
Expand All @@ -35,7 +35,8 @@ public function index(Request $request) : JsonResponse | array
'departments.manager_id',
'departments.created_at',
'departments.updated_at',
'departments.image'
'departments.image',
'departments.notes',
)->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count');

if ($request->filled('search')) {
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Api/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function index(Request $request) : JsonResponse | array

$this->authorize('view', Group::class);

$groups = Group::select('id', 'name', 'permissions', 'created_at', 'updated_at', 'created_by')->with('adminuser')->withCount('users as users_count');
$groups = Group::select('id', 'name', 'permissions', 'notes', 'created_at', 'updated_at', 'created_by')->with('adminuser')->withCount('users as users_count');

if ($request->filled('search')) {
$groups = $groups->TextSearch($request->input('search'));
Expand Down Expand Up @@ -81,6 +81,7 @@ public function store(Request $request) : JsonResponse

$group->name = $request->input('name');
$group->created_by = auth()->id();
$group->notes = $request->input('notes');
$group->permissions = json_encode($request->input('permissions', $groupPermissions));

if ($group->save()) {
Expand Down Expand Up @@ -118,6 +119,7 @@ public function update(Request $request, $id) : JsonResponse
$group = Group::findOrFail($id);

$group->name = $request->input('name');
$group->notes = $request->input('notes');
$group->permissions = $request->input('permissions'); // Todo - some JSON validation stuff here

if ($group->save()) {
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Api/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function index(Request $request) : JsonResponse | array
'updated_at',
'users_count',
'zip',
'notes',
];

$locations = Location::with('parent', 'manager', 'children')->select([
Expand All @@ -73,6 +74,7 @@ public function index(Request $request) : JsonResponse | array
'locations.image',
'locations.ldap_ou',
'locations.currency',
'locations.notes',
])
->withCount('assignedAssets as assigned_assets_count')
->withCount('assets as assets_count')
Expand Down Expand Up @@ -190,6 +192,7 @@ public function show($id) : JsonResponse | array
'locations.updated_at',
'locations.image',
'locations.currency',
'locations.notes',
])
->withCount('assignedAssets as assigned_assets_count')
->withCount('assets as assets_count')
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Api/ManufacturersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public function index(Request $request) : JsonResponse | array
'assets_count',
'consumables_count',
'components_count',
'licenses_count'
'licenses_count',
'notes',
];

$manufacturers = Manufacturer::select([
Expand All @@ -55,6 +56,7 @@ public function index(Request $request) : JsonResponse | array
'updated_at',
'image',
'deleted_at',
'notes',
])
->with('adminuser')
->withCount('assets as assets_count')
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
$category->use_default_eula = $request->input('use_default_eula', '0');
$category->require_acceptance = $request->input('require_acceptance', '0');
$category->checkin_email = $request->input('checkin_email', '0');
$category->notes = $request->input('notes');
$category->created_by = auth()->id();

$category = $request->handleImages($category);
Expand Down Expand Up @@ -134,6 +135,7 @@ public function update(ImageUploadRequest $request, $categoryId = null) : Redire
$category->use_default_eula = $request->input('use_default_eula', '0');
$category->require_acceptance = $request->input('require_acceptance', '0');
$category->checkin_email = $request->input('checkin_email', '0');
$category->notes = $request->input('notes');

$category = $request->handleImages($category);

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/CompaniesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
$company->phone = $request->input('phone');
$company->fax = $request->input('fax');
$company->email = $request->input('email');
$company->notes = $request->input('notes');
$company->created_by = auth()->id();

$company = $request->handleImages($company);
Expand Down Expand Up @@ -111,6 +112,7 @@ public function update(ImageUploadRequest $request, $companyId) : RedirectRespon
$company->phone = $request->input('phone');
$company->fax = $request->input('fax');
$company->email = $request->input('email');
$company->notes = $request->input('notes');

$company = $request->handleImages($company);

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/DepartmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
$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->notes = $request->input('notes');
$department = $request->handleImages($department);

if ($department->save()) {
Expand Down Expand Up @@ -171,7 +172,7 @@ public function update(ImageUploadRequest $request, $id) : RedirectResponse
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);
$department->phone = $request->input('phone');
$department->fax = $request->input('fax');

$department->notes = $request->input('notes');
$department = $request->handleImages($department);

if ($department->save()) {
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function store(Request $request) : RedirectResponse
$group->name = $request->input('name');
$group->permissions = json_encode($request->input('permission'));
$group->created_by = auth()->id();
$group->notes = $request->input('notes');

if ($group->save()) {
return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.create'));
Expand Down Expand Up @@ -108,6 +109,7 @@ public function update(Request $request, $id = null) : RedirectResponse
}
$group->name = $request->input('name');
$group->permissions = json_encode($request->input('permission'));
$group->notes = $request->input('notes');

if (! config('app.lock_passwords')) {
if ($group->save()) {
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
$location->created_by = auth()->id();
$location->phone = request('phone');
$location->fax = request('fax');
$location->notes = $request->input('notes');

$location = $request->handleImages($location);

Expand Down Expand Up @@ -138,6 +139,7 @@ public function update(ImageUploadRequest $request, $locationId = null) : Redire
$location->fax = request('fax');
$location->ldap_ou = $request->input('ldap_ou');
$location->manager_id = $request->input('manager_id');
$location->notes = $request->input('notes');

$location = $request->handleImages($location);

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/ManufacturersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
$manufacturer->support_phone = $request->input('support_phone');
$manufacturer->support_email = $request->input('support_email');
$manufacturer->notes = $request->input('notes');
$manufacturer = $request->handleImages($manufacturer);

if ($manufacturer->save()) {
Expand Down Expand Up @@ -123,6 +124,7 @@ public function update(ImageUploadRequest $request, $manufacturerId = null) : Re
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
$manufacturer->support_phone = $request->input('support_phone');
$manufacturer->support_email = $request->input('support_email');
$manufacturer->notes = $request->input('notes');

// Set the model's image property to null if the image is being deleted
if ($request->input('image_delete') == 1) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/CategoriesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function transformCategory(Category $category = null)
'id' => (int) $category->adminuser->id,
'name'=> e($category->adminuser->present()->fullName()),
] : null,
'notes' => Helper::parseEscapedMarkedownInline($category->notes),
'created_at' => Helper::getFormattedDateObject($category->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($category->updated_at, 'datetime'),
];
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/CompaniesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function transformCompany(Company $company = null)
'id' => (int) $company->adminuser->id,
'name'=> e($company->adminuser->present()->fullName()),
] : null,
'notes' => Helper::parseEscapedMarkedownInline($company->notes),
'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
];
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/DepartmentsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function transformDepartment(Department $department = null)
'name' => e($department->location->name),
] : null,
'users_count' => e($department->users_count),
'notes' => Helper::parseEscapedMarkedownInline($department->notes),
'created_at' => Helper::getFormattedDateObject($department->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($department->updated_at, 'datetime'),
];
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/GroupsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function transformGroup(Group $group)
'name' => e($group->name),
'permissions' => json_decode($group->permissions),
'users_count' => (int) $group->users_count,
'notes' => Helper::parseEscapedMarkedownInline($group->notes),
'created_by' => ($group->adminuser) ? [
'id' => (int) $group->adminuser->id,
'name'=> e($group->adminuser->present()->fullName()),
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/LocationsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function transformLocation(Location $location = null)
'users_count' => (int) $location->users_count,
'currency' => ($location->currency) ? e($location->currency) : null,
'ldap_ou' => ($location->ldap_ou) ? e($location->ldap_ou) : null,
'notes' => Helper::parseEscapedMarkedownInline($location->notes),
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($location->updated_at, 'datetime'),
'parent' => ($location->parent) ? [
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/ManufacturersTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function transformManufacturer(Manufacturer $manufacturer = null)
'consumables_count' => (int) $manufacturer->consumables_count,
'accessories_count' => (int) $manufacturer->accessories_count,
'components_count' => (int) $manufacturer->components_count,
'notes' => Helper::parseEscapedMarkedownInline($manufacturer->notes),
'created_by' => ($manufacturer->adminuser) ? [
'id' => (int) $manufacturer->adminuser->id,
'name'=> e($manufacturer->adminuser->present()->fullName()),
Expand Down
2 changes: 2 additions & 0 deletions app/Importer/LocationImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public function createLocationIfNotExists(array $row)
$this->item['ldap_ou'] = trim($this->findCsvMatch($row, 'ldap_ou'));
$this->item['manager'] = trim($this->findCsvMatch($row, 'manager'));
$this->item['manager_username'] = trim($this->findCsvMatch($row, 'manager_username'));
$this->item['notes'] = trim($this->findCsvMatch($row, 'notes'));


if ($this->findCsvMatch($row, 'parent_location')) {
$this->item['parent_id'] = $this->createOrFetchLocation(trim($this->findCsvMatch($row, 'parent_location')));
Expand Down
1 change: 1 addition & 0 deletions app/Livewire/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ public function mount()
'manager_username' => trans('general.importer.manager_username'),
'manager' => trans('general.importer.manager_full_name'),
'parent_location' => trans('admin/locations/table.parent'),
'notes' => trans('general.notes'),
];

$this->assetmodels_fields = [
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Category extends SnipeModel
'require_acceptance',
'use_default_eula',
'created_by',
'notes',
];

use Searchable;
Expand All @@ -80,7 +81,7 @@ class Category extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'category_type'];
protected $searchableAttributes = ['name', 'category_type', 'notes'];

/**
* The relations and their attributes that should be included when searching the model.
Expand Down
5 changes: 3 additions & 2 deletions app/Models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Group extends SnipeModel

protected $fillable = [
'name',
'permissions'
'permissions',
'notes',
];

/**
Expand All @@ -37,7 +38,7 @@ class Group extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'created_at'];
protected $searchableAttributes = ['name', 'created_at', 'notes'];

/**
* The relations and their attributes that should be included when searching the model.
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Location extends SnipeModel
'currency',
'manager_id',
'image',
'notes',
];
protected $hidden = ['user_id'];

Expand All @@ -82,7 +83,7 @@ class Location extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou', 'phone', 'fax'];
protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou', 'phone', 'fax', 'notes'];

/**
* The relations and their attributes that should be included when searching the model.
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Manufacturer extends SnipeModel
'support_url',
'url',
'warranty_lookup_url',
'notes',
];

use Searchable;
Expand All @@ -62,7 +63,7 @@ class Manufacturer extends SnipeModel
*
* @var array
*/
protected $searchableAttributes = ['name', 'created_at'];
protected $searchableAttributes = ['name', 'created_at', 'notes'];

/**
* The relations and their attributes that should be included when searching the model.
Expand Down
8 changes: 7 additions & 1 deletion app/Presenters/CategoryPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ public static function dataTableLayout()
"title" => trans('admin/categories/general.use_default_eula_column'),
'visible' => true,
"formatter" => 'trueFalseFormatter',
],[
], [
'field' => 'notes',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.notes'),
], [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
Expand Down
8 changes: 7 additions & 1 deletion app/Presenters/CompanyPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public static function dataTableLayout()
'title' => trans('general.components'),
'visible' => true,
'class' => 'css-component',
],[
], [
'field' => 'notes',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.notes'),
], [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
Expand Down
6 changes: 6 additions & 0 deletions app/Presenters/LocationPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public static function dataTableLayout()
'title' => trans('admin/users/table.manager'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'notes',
'searchable' => true,
'sortable' => true,
'visible' => false,
'title' => trans('general.notes'),
], [
'field' => 'created_at',
'searchable' => true,
Expand Down
2 changes: 1 addition & 1 deletion config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
'prerelease_version' => '',
'hash_version' => 'gfb857ccf5',
'full_hash' => 'v7.1.16-510-gfb857ccf5',
'branch' => 'master',
'branch' => 'develop',
);
Loading

0 comments on commit c08cfb9

Please sign in to comment.