Skip to content
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

[PUI/Feature] Integrate Part "Default Location" into UX #5972

Merged
merged 34 commits into from
Mar 15, 2024

Conversation

LavissaWoW
Copy link
Contributor

@LavissaWoW LavissaWoW commented Nov 22, 2023

Closes #5928
Closes #5938

  • Add Default Parts filter to API
  • [PUI] Add Default Parts panel to Stock Location View
  • Add "Transfer to default location" functionality [PUI] [CUI?]
  • Add Default location checkbox when splitting stock items
  • Propagate default location from parent category tree to parts

Copy link

netlify bot commented Nov 22, 2023

Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 9ef7454
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/65f3823e6741ce000821f30e

@LavissaWoW LavissaWoW changed the title [P-UI/Feature] Integrate Part "Default Location" into user [P-UI/Feature] Integrate Part "Default Location" into UX Nov 22, 2023
@LavissaWoW LavissaWoW marked this pull request as draft November 23, 2023 00:12
@LavissaWoW
Copy link
Contributor Author

@SchrodingersGat @matmair @wolflu05
Anyone currently implementing the following in PUI?
Stock Item Detail Panel
Stock Item Transfer Modal
Part Category Detail/List
Part Category Creation and Edit Modal

To do all the work I'm planning here, I'll have to add some elements to Stock Items, Part Categories, and additionally Purchase Orders. I don't want to overlap work others are doing :)
If these are TBD atm, I'll take a stab at implementing them, else I'll add the functionality to those when they are merged in.

@SchrodingersGat
Copy link
Member

@LavissaWoW I do not have any active progress on any of the items you list. We have not implemented any "detail" pages yet - I would be keen to see if we can develop a standard component or set of components for rendering a "detail" view - primarily for UI consistency.

If you want to tackle a detail page in the new UI that's great 👍

InvenTree/part/api.py Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Feb 4, 2024

This PR seems stale. Please react to show this is still important.

@github-actions github-actions bot added the inactive Indicates lack of activity label Feb 4, 2024
@SchrodingersGat
Copy link
Member

@LavissaWoW not stale, right?

@LavissaWoW
Copy link
Contributor Author

Not stale indeed. Need to sort out priorities here though. I got some backend shenanigans planned, and several frontend changes.
Depending on the frontend change, prio would be on PUI.

@github-actions github-actions bot removed the inactive Indicates lack of activity label Feb 5, 2024
@LavissaWoW
Copy link
Contributor Author

@SchrodingersGat I'm inclined to ignore CUI with this.
I'd rather not spend a lot of time digging into vanilla JS that we're phasing out soon.
I.e. #5938 would be more easily implemented in PUI rather than CUI. (Update location field when changing category)
This sentiment does however mean that this PR will rely on some PUI work.

@LavissaWoW
Copy link
Contributor Author

@wolflu05 @SchrodingersGat
I've implemented a form field type for rendering array-based values as tables.
Relevant changes are in
TableField.tsx
StockForms.tsx:stockTransferFields
StockForms.tsx:StockOperationsRow
ApiFormField.tsx (case: 'table')

The use for this is forms where we pass arrays of objects ot the API. For this PR, I'll use it for Stock operations.
Let me know what you think.

@wolflu05
Copy link
Contributor

Nice idea to implement this as a field type. After reading array field, I first was thinking something different, but after reading the implementation the name table makes sense. I'm only concerned about that this is actually not a real form, you're just using it to display a modal? But I'm fine with it.

@LavissaWoW
Copy link
Contributor Author

It is a proper form for the /stock/transfer POST endpoint.
Looks like this with only 1 item in the table :)
image

@SchrodingersGat
Copy link
Member

@LavissaWoW the table form UI looks really good :)

@LavissaWoW
Copy link
Contributor Author

I should probably handle the category defaults for CUI too. Feel free to review, though. I'll add one last commit asap

@LavissaWoW
Copy link
Contributor Author

@SchrodingersGat All good, this is ready now

@SchrodingersGat
Copy link
Member

@LavissaWoW this is great, such a lot of work here :)

Review below, there's a few points and suggestions but nothing major!

Stock Table Actions

When no items are selected, either:

a) Disable the "actions" column, or
b) Select all stock items in the table by default

Otherwise, you get this "no entries available" message

image

In fact, this goes for other table forms too. If there are no available lines when opening the form, we need a "default selection" here.

Receive Line Items

image

Really good! Perhaps the modal should be wider by default?

Receive Line Items - Default Location

Looks like the "default location" does not propagate here?

image

This part does have a "default location" set:

image

Although it should also work if there is a "default category location"

Category Detail Page

Should display the "default location" for the category (or upstream parent category as required). Currently not displayed:

image

@LavissaWoW
Copy link
Contributor Author

@SchrodingersGat Aside from the propagating default to PO line, and the category detail panel, (I'll fix those) I looked at most of this myself.

The APIForm modals have a default width defined deeply nested within the framework we've created to display them. I wanted the PO Receive to be wider, and the lack of width is why I hid the Status field within a toggleable extra row. I can look into if it's possible to add some props to allow for oversizing the modals?

Table actions I concluded it's not possible to get all records from a given table as things are now.
Out custom useTable hook holds data for any given table, but it doesn't hold "all records" afaik. Records are fetched in the InvenTreeTable component, so the modals can't access the raw records from StockItemTable/POLineTable/etc.
Solution: Either see if an allRecords/pageRecords can be added to useTable, or disable actions when selectedRecords is empty? This includes PO receive too.

@SchrodingersGat
Copy link
Member

or disable actions when selectedRecords is empty? This includes PO receive too.

This is probably the best approach for now, until (if) we can work out a different approach. At least visually the user should be aware that they have no records selected and thus cannot perform actions

@LavissaWoW
Copy link
Contributor Author

@SchrodingersGat I was initially struggling to reproduce the PO line location, but it turns out I made a couple of mistakes, and it was even more broken than you experienced. The PO lines have a destination and a destination_detail. The latter can be set without the former being set. If the latter is set, and the former not, one of the following is true:

  1. The part has a default location
  2. Some stock has already been received for this line

My logic was off in my assumptions here, and I found myself with test data where previously received stock had been placed at the default location. So some of my logic indicated default, while it was actually previously received that triggered it. Additionally, the queryset annotation I added to StockItem ofc. didn't magically carry over to POLineItems, so category_default_location never even existed on line.part_detail

Fix incoming shortly

@SchrodingersGat
Copy link
Member

@LavissaWoW I realize that part of the issue was that I was viewing the netlify preview - which talks to the demo server, which in turn does not have the latest API. So, this will explain the discrepencies.

@SchrodingersGat SchrodingersGat merged commit 0196dd2 into inventree:master Mar 15, 2024
22 checks passed
@SchrodingersGat
Copy link
Member

@LavissaWoW thanks again for the great work here!

@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature api Relates to the API Platform UI Related to the React based User Interface labels Mar 15, 2024
@SchrodingersGat SchrodingersGat added this to the 0.15.0 milestone Mar 15, 2024
XanderLuciano added a commit to XanderLuciano/InvenTree that referenced this pull request Mar 16, 2024
commit 06c7ebf
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Sat Mar 16 09:11:57 2024 +1100

    Update docker_install.md (inventree#6723)

    * Update docker_install.md

    Add note about external access

    * Update docker_install.md

commit a00d5ab
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 17:53:58 2024 +1100

    Disable BOM requirement (inventree#6719)

    * Add new setting STOCK_ENFORCE_BOM_INSTALLATION

    - Defaults to True (legacy)

    * Add logic to bypass BOM check

    * Update CUI to reflect new logic

    * Render InstalledItemsTable in PUI

commit 160d014
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 17:12:53 2024 +1100

    [PUI] Details Pages (inventree#6718)

    * Add "details" view to SupplierPart page

    * Fix PartActions

    * Add placeholder for actions

    * Add "title" option to DetailsTable

    * Add edit form to supplier part page

    * Fix link to manufacturer part

    * Add "details" view to ManufacturerPartDetail page

    * Add edit for ManufacturerPart

    * Create new manufacturer part from company table

    * Tweak ActionIcon

commit 57a1a81
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 12:24:17 2024 +1100

    Reporting: Build line label fix (inventree#6717)

    * Fix "BuildLine" label in PUI

    - Point to "buildline" not "build"

    * Prevent escape closing template ediror

    * Update report docs

    * Fix for format_number

    - Prevent number from being represented as scientific notation

commit 0196dd2
Author: Lavissa <lavissawow@gmail.com>
Date:   Fri Mar 15 02:06:18 2024 +0100

    [PUI/Feature] Integrate Part "Default Location" into UX (inventree#5972)

    * Add default parts to location page

    * Fix name strings

    * Add Stock Transfer modal

    * Add ApiForm Table field

    * temp

    * Add stock transfer form to part, stock item and location

    * All stock operations for Item, Part, and Location added (except order new)

    * Add default_location category traversal, and initial PO Line Item Receive form

    * .

    * Remove debug values

    * Added PO line receive form

    * Add functionality to PO receive extra fields

    * .

    * Forgot to bump API version

    * Add Category Default to details panel

    * Fix stockItem query count

    * Fix reviewed issues

    * .

    * .

    * .

    * Prevent root category from checking parent for default location

commit 6abd33f
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 00:24:48 2024 +1100

    Report enhancements (inventree#6714)

    * Add "enabled" filter to template table

    * Cleanup

    * API endpoints

    - Add API endpoints for report snippet
    - List endpoint
    - Details endpoint

    * Update serializers

    - Add asset serializer
    - Update

    * Check for duplicate asset files

    - Prevent upload of duplicate asset files
    - Allow re-upload for same PK

    * Duplicate checks for ReportSnippet

    * Bump API version

commit cbd94fc
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Thu Mar 14 23:06:11 2024 +1100

    Fix for caddyfile (inventree#6712)

    - Add "authorization" to Access-Control-Allow-Headers
    - CORS requests actually *work* now

commit ec5ff64
Author: Lukas <76838159+wolflu05@users.noreply.github.com>
Date:   Thu Mar 14 13:03:30 2024 +0100

    handle report previewing errors (inventree#6709)

commit 267ff67
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Thu Mar 14 15:11:27 2024 +1100

    [PUI] Updates (inventree#6707)

    * Add button to edit part category

    * Fix useMemo()

    * Edit stock location

commit 610ea7b
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Thu Mar 14 12:09:14 2024 +1100

    Report: Add date rendering (inventree#6706)

    * Validate timezone in settings.py

    * Add helper functions for timezone information

    - Extract server timezone
    - Convert provided time to specified timezone

    * Add more unit tests

    * Remove debug print

    * Test fix

    * Add report helper tags

    - format_date
    - format_datetime
    - Update report templates
    - Unit tests

    * Add setting to control report errors

    - Only log errors to DB if setting is enabled

    * Update example report

    * Fixes for to_local_time

    * Update type hinting

    * Fix unit test typo

commit 7de8738
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Wed Mar 13 21:37:56 2024 +1100

    Update .env (inventree#6700)

    Fix comment - no need to change Caddyfile in most cases

commit 2fef348
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Wed Mar 13 20:37:05 2024 +1100

    Unit tests for HOST settings (inventree#6698)

    - CORS
    - ALLOWED_HOSTS
@LavissaWoW LavissaWoW deleted the def-locs branch March 17, 2024 21:22
SchrodingersGat pushed a commit that referenced this pull request Mar 20, 2024
* Quick attempt at fixed form footer

* slightly improve on lower res devices

* Squashed commit of the following:

commit 06c7ebf
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Sat Mar 16 09:11:57 2024 +1100

    Update docker_install.md (#6723)

    * Update docker_install.md

    Add note about external access

    * Update docker_install.md

commit a00d5ab
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 17:53:58 2024 +1100

    Disable BOM requirement (#6719)

    * Add new setting STOCK_ENFORCE_BOM_INSTALLATION

    - Defaults to True (legacy)

    * Add logic to bypass BOM check

    * Update CUI to reflect new logic

    * Render InstalledItemsTable in PUI

commit 160d014
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 17:12:53 2024 +1100

    [PUI] Details Pages (#6718)

    * Add "details" view to SupplierPart page

    * Fix PartActions

    * Add placeholder for actions

    * Add "title" option to DetailsTable

    * Add edit form to supplier part page

    * Fix link to manufacturer part

    * Add "details" view to ManufacturerPartDetail page

    * Add edit for ManufacturerPart

    * Create new manufacturer part from company table

    * Tweak ActionIcon

commit 57a1a81
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 12:24:17 2024 +1100

    Reporting: Build line label fix (#6717)

    * Fix "BuildLine" label in PUI

    - Point to "buildline" not "build"

    * Prevent escape closing template ediror

    * Update report docs

    * Fix for format_number

    - Prevent number from being represented as scientific notation

commit 0196dd2
Author: Lavissa <lavissawow@gmail.com>
Date:   Fri Mar 15 02:06:18 2024 +0100

    [PUI/Feature] Integrate Part "Default Location" into UX (#5972)

    * Add default parts to location page

    * Fix name strings

    * Add Stock Transfer modal

    * Add ApiForm Table field

    * temp

    * Add stock transfer form to part, stock item and location

    * All stock operations for Item, Part, and Location added (except order new)

    * Add default_location category traversal, and initial PO Line Item Receive form

    * .

    * Remove debug values

    * Added PO line receive form

    * Add functionality to PO receive extra fields

    * .

    * Forgot to bump API version

    * Add Category Default to details panel

    * Fix stockItem query count

    * Fix reviewed issues

    * .

    * .

    * .

    * Prevent root category from checking parent for default location

commit 6abd33f
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Fri Mar 15 00:24:48 2024 +1100

    Report enhancements (#6714)

    * Add "enabled" filter to template table

    * Cleanup

    * API endpoints

    - Add API endpoints for report snippet
    - List endpoint
    - Details endpoint

    * Update serializers

    - Add asset serializer
    - Update

    * Check for duplicate asset files

    - Prevent upload of duplicate asset files
    - Allow re-upload for same PK

    * Duplicate checks for ReportSnippet

    * Bump API version

commit cbd94fc
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Thu Mar 14 23:06:11 2024 +1100

    Fix for caddyfile (#6712)

    - Add "authorization" to Access-Control-Allow-Headers
    - CORS requests actually *work* now

commit ec5ff64
Author: Lukas <76838159+wolflu05@users.noreply.github.com>
Date:   Thu Mar 14 13:03:30 2024 +0100

    handle report previewing errors (#6709)

commit 267ff67
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Thu Mar 14 15:11:27 2024 +1100

    [PUI] Updates (#6707)

    * Add button to edit part category

    * Fix useMemo()

    * Edit stock location

commit 610ea7b
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Thu Mar 14 12:09:14 2024 +1100

    Report: Add date rendering (#6706)

    * Validate timezone in settings.py

    * Add helper functions for timezone information

    - Extract server timezone
    - Convert provided time to specified timezone

    * Add more unit tests

    * Remove debug print

    * Test fix

    * Add report helper tags

    - format_date
    - format_datetime
    - Update report templates
    - Unit tests

    * Add setting to control report errors

    - Only log errors to DB if setting is enabled

    * Update example report

    * Fixes for to_local_time

    * Update type hinting

    * Fix unit test typo

commit 7de8738
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Wed Mar 13 21:37:56 2024 +1100

    Update .env (#6700)

    Fix comment - no need to change Caddyfile in most cases

commit 2fef348
Author: Oliver <oliver.henry.walters@gmail.com>
Date:   Wed Mar 13 20:37:05 2024 +1100

    Unit tests for HOST settings (#6698)

    - CORS
    - ALLOWED_HOSTS

* Make ApiForms shrinkable, spoiler long group list

* Improve API Form Scroll Behavior

* Fix incorrect modal component

* Force load all modal fields to trigger loading animation

* Show loading overlay while fetching fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Relates to the API enhancement This is an suggested enhancement or new feature Platform UI Related to the React based User Interface
Projects
None yet
4 participants