-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added #14979: add checkout to location and assets functionality to accessories #15185
Added #14979: add checkout to location and assets functionality to accessories #15185
Conversation
Added snipe#14979: add checkout functionality to accessoires
PR Summary
|
We haven't built this functionality because we don't really want it. Our position has always been that you should be checking items out to users, since an asset or location cannot be held responsible for missing items. |
Let me spend some time looking at this and we'll consider whether we want to take this. As I mentioned, we didn't really want this functionality since it goes against the principles of what an asset system is supposed to do, but I'll consider it. |
As there is an option to define a manager for a location I see a good way to assign a responsiblity here. Our use case is also important to desk sharing topics where some of the accessories are part of a bookable working place for the employees. To give these items out on a daily basis is a lot of work. The idea is to assign locations via an additional workplace booking system on a time based ticket and handle the responsibility by it. |
Sure, but we don't have anything built in for them to be able to accept, etc. Right now it's just a field for reference, there are no controls there, and very few people use managers for locations anyway. |
I get that, but it opens the doors to people in other situations who don't use an external "responsible for" application. As I said, let me think about it. |
public function down(): void | ||
{ | ||
if (Schema::hasTable('accessories_checkout')) { | ||
Schema::rename('accessories_checkout', 'accessories_users'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to drop the column created in the up migration as well, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will adjust that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is some genuine good-looking code - I have a few small nits I've pointed out, but I feel like 80% of this is just handling that the table name has changed. This really does look pretty good to me. Wonderful, very well-written, tight, careful code. Thank you so much for your contribution!
@@ -316,19 +314,19 @@ public function checkout(AccessoryCheckoutRequest $request, Accessory $accessory | |||
*/ | |||
public function checkin(Request $request, $accessoryUserId = null) | |||
{ | |||
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) { | |||
if (is_null($accessory_checkout = DB::table('accessories_checkout')->find($accessoryUserId))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're already modifying this line, is there maybe a way for us to not say DB::table()
here? That always feels to me like a code smell. And the line's already being altered, is there a way to do this properly polymorphic and make it a little cleaner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted
@arne-kroeger I'm seeing some failing tests here - do you think you can take a look at this. I'm reluctantly inclined to take this (not because your code is bad - it's great - just from a product perspective), but we do need the tests to pass. |
Congrats on merging your first pull request! 🎉🎉🎉 |
I think you might have missed a bit in the seeder, but I think I fixed it
|
Something still seems off here. On develop.snipeitapp.com (the live dev branch) I just checked out an accessory to a location, and now the accessories page loads with an empty table, and the location does not show any accessories assigned. |
Thats a good point. Currently the location would show Accessories which are placed there (in terms of the field location inside the accessory). What would be you're recommendation? A mixed list of placed and checked out accessories? |
@snipe - Yeah, but I think in the end it will be a good enhancement. I will prepare an integration for it and prepare it. |
This also misses the "Print all assigned" views on locations, etc. We need to pull accessories into there as well. |
@@ -219,7 +219,7 @@ public function destroy(Request $request) | |||
|
|||
$users = User::whereIn('id', $user_raw_array)->get(); | |||
$assets = Asset::whereIn('assigned_to', $user_raw_array)->where('assigned_type', \App\Models\User::class)->get(); | |||
$accessories = DB::table('accessories_users')->whereIn('assigned_to', $user_raw_array)->get(); | |||
$accessories = DB::table('accessories_checkout')->whereIn('assigned_to', $user_raw_array)->get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this query will also not work, since it's not constraining to users. Location ID could get pulled from that list as well as User ID 4.
Added #14979: add checkout functionality to accessories
Description
Currently it is just possible to checkout accessories to a user and not to a location or asset like it is possible for assets. This would cover many use cases where a workplace definition can be done with a location or an assignment of accessories to a room. There are several uses case descriptions in the linked issues (see below).
Added #14665
Added #12381
Added #12452
Added #11820
Added #10956
Added #5140 (parts of it)
Added #14979 (parts of it)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: