Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
warehouse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian
warehouse
Commits
99a26435
Commit
99a26435
authored
Mar 11, 2023
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Location selection UI
parent
47de8bcf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
warehouse/__init__.py
+13
-1
13 additions, 1 deletion
warehouse/__init__.py
warehouse/templates/item/locate.html
+40
-6
40 additions, 6 deletions
warehouse/templates/item/locate.html
with
53 additions
and
7 deletions
warehouse/__init__.py
+
13
−
1
View file @
99a26435
...
@@ -174,7 +174,19 @@ def item_upload_photo(item_id):
...
@@ -174,7 +174,19 @@ def item_upload_photo(item_id):
def
item_locate
(
item_id
):
def
item_locate
(
item_id
):
item
=
Item
.
query
.
get_or_404
(
item_id
)
item
=
Item
.
query
.
get_or_404
(
item_id
)
if
request
.
method
==
'
GET
'
:
if
request
.
method
==
'
GET
'
:
return
render_template
(
'
item/locate.html
'
,
item
=
item
,
all_locations
=
Location
.
query
.
all
())
query
=
Location
.
query
if
'
search
'
in
request
.
values
:
keywords
=
request
.
values
[
'
search
'
].
strip
().
split
()
for
keyword
in
keywords
:
query
=
query
.
filter
(
db
.
or_
(
Location
.
name
.
contains
(
keyword
),
Location
.
description
.
contains
(
keyword
)))
locations
=
query
.
all
()
def
include_parents_r
(
location
):
if
location
.
parent
and
location
.
parent
not
in
locations
:
locations
.
append
(
location
.
parent
)
include_parents_r
(
location
.
parent
)
for
location
in
list
(
locations
):
include_parents_r
(
location
)
return
render_template
(
'
item/locate.html
'
,
item
=
item
,
locations
=
locations
)
item
.
location
=
Location
.
query
.
get
(
request
.
form
[
'
location_id
'
])
item
.
location
=
Location
.
query
.
get
(
request
.
form
[
'
location_id
'
])
db
.
session
.
commit
()
db
.
session
.
commit
()
return
redirect
(
url_for
(
'
item_view
'
,
item_id
=
item_id
))
return
redirect
(
url_for
(
'
item_view
'
,
item_id
=
item_id
))
...
...
This diff is collapsed.
Click to expand it.
warehouse/templates/item/locate.html
+
40
−
6
View file @
99a26435
{% extends 'layout.html' %}
{% extends 'layout.html' %}
{% macro location_recursive(location, indent=0) %}
<tr>
<td>
{{ ('
 
'*indent)|safe }}{{ location.name }}
</td>
<td>
{% if not location.children %}
<button
type=
"submit"
name=
"location_id"
value=
"{{ location.id }}"
class=
"float-end btn btn-sm btn-primary"
>
Select
</button>
{% else %}
<button
type=
"submit"
name=
"location_id"
value=
"{{ location.id }}"
class=
"float-end btn btn-sm btn-secondary"
>
Select
</button>
{% endif %}
</td>
</tr>
{% for item in locations if item in location.children %}
{{ location_recursive(item, indent+1) }}
{% endfor %}
{% endmacro %}
{% block body %}
{% block body %}
<h1>
Set location for {{ item.name }}
</h1>
<div
class=
"d-flex justify-content-end gap-1"
>
<form
class=
"form-inline"
>
<div
class=
"input-group"
>
<input
type=
"text"
class=
"form-control"
name=
"search"
value=
"{{ request.args.search }}"
placeholder=
"Search"
autofocus
>
<button
class=
"btn btn-outline-secondary"
type=
"submit"
>
Search
</button>
</div>
</form>
</div>
<form
method=
"POST"
>
<form
method=
"POST"
>
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{ request.csrf_token }}"
>
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{ request.csrf_token }}"
>
{% for location in all_locations %}
<table
class=
"table table-hover"
>
<div
class=
"clearfix w-100 my-2"
>
<thead>
{{ location.name }}
<tr>
<button
type=
"submit"
name=
"location_id"
value=
"{{ location.id }}"
class=
"float-end btn btn-primary"
>
Select
</button>
<th
scope=
"col"
>
Location
</th>
</div>
<th
scope=
"col"
></th>
</tr>
</thead>
<tbody>
{% for location in locations if not location.parent %}
{{ location_recursive(location) }}
{% endfor %}
{% endfor %}
</tbody>
</table>
</form>
</form>
{% endblock %}
{% endblock %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment