Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
f68523cd
Commit
f68523cd
authored
5 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Plain Diff
Merge branch 'page_conso' into 'master'
Dynamic tabs on conso view See merge request
!17
parents
12d7ddfa
a39bbea2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!17
Dynamic tabs on conso view
Pipeline
#7768
passed with stages
in 3 minutes and 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/note/urls.py
+0
-1
0 additions, 1 deletion
apps/note/urls.py
apps/note/views.py
+8
-14
8 additions, 14 deletions
apps/note/views.py
templates/note/conso_form.html
+87
-31
87 additions, 31 deletions
templates/note/conso_form.html
with
95 additions
and
46 deletions
apps/note/urls.py
+
0
−
1
View file @
f68523cd
...
...
@@ -12,7 +12,6 @@ urlpatterns = [
path
(
'
buttons/create/
'
,
views
.
TransactionTemplateCreateView
.
as_view
(),
name
=
'
template_create
'
),
path
(
'
buttons/update/<int:pk>/
'
,
views
.
TransactionTemplateUpdateView
.
as_view
(),
name
=
'
template_update
'
),
path
(
'
buttons/
'
,
views
.
TransactionTemplateListView
.
as_view
(),
name
=
'
template_list
'
),
path
(
'
consos/<str:template_type>/
'
,
views
.
ConsoView
.
as_view
(),
name
=
'
consos
'
),
path
(
'
consos/
'
,
views
.
ConsoView
.
as_view
(),
name
=
'
consos
'
),
# API for the note autocompleter
...
...
This diff is collapsed.
Click to expand it.
apps/note/views.py
+
8
−
14
View file @
f68523cd
...
...
@@ -8,7 +8,7 @@ from django.urls import reverse
from
django.utils.translation
import
gettext_lazy
as
_
from
django.views.generic
import
CreateView
,
ListView
,
UpdateView
from
.models
import
Transaction
,
TransactionCategory
,
TransactionTemplate
,
Alias
from
.models
import
Transaction
,
TransactionTemplate
,
Alias
from
.forms
import
TransactionForm
,
TransactionTemplateForm
,
ConsoForm
...
...
@@ -135,19 +135,13 @@ class ConsoView(LoginRequiredMixin, CreateView):
Add some context variables in template such as page title
"""
context
=
super
().
get_context_data
(
**
kwargs
)
context
[
'
template_types
'
]
=
TransactionCategory
.
objects
.
all
()
if
'
template_type
'
not
in
self
.
kwargs
.
keys
():
return
context
template_type
=
TransactionCategory
.
objects
.
filter
(
name
=
self
.
kwargs
.
get
(
'
template_type
'
)).
get
()
context
[
'
buttons
'
]
=
TransactionTemplate
.
objects
.
filter
(
template_type
=
template_type
)
context
[
'
title
'
]
=
template_type
context
[
'
transaction_templates
'
]
=
TransactionTemplate
.
objects
.
all
()
\
.
order_by
(
'
template_type
'
)
context
[
'
title
'
]
=
_
(
"
Consommations
"
)
return
context
def
get_success_url
(
self
):
return
reverse
(
'
note:consos
'
,
args
=
(
self
.
kwargs
.
get
(
'
template_type
'
),
))
"""
When clicking a button, reload the same page
"""
return
reverse
(
'
note:consos
'
)
This diff is collapsed.
Click to expand it.
templates/note/conso_form.html
+
87
−
31
View file @
f68523cd
...
...
@@ -2,40 +2,96 @@
{% load i18n static pretty_money %}
{# Remove page title #}
{% block contenttitle %}{% endblock %}
{% block content %}
<fieldset
class=
"module aligned"
>
{% for type in template_types %}
<a
href=
"{% url 'note:consos' template_type=type %}"
><button>
{{ type }}
</button></a>
{% endfor %}
</fieldset>
<form
method=
"post"
onsubmit=
"window.onbeforeunload=null"
>
{% csrf_token %}
{% if form.non_field_errors %}
<p
class=
"errornote"
>
{% for error in form.non_field_errors %}
{{ error }}
{# Regroup buttons under categories #}
{% regroup transaction_templates by template_type as template_types %}
<form
method=
"post"
onsubmit=
"window.onbeforeunload=null"
>
{% csrf_token %}
<div
class=
"row"
>
<div
class=
"col-sm-5 mb-4"
>
{% if form.non_field_errors %}
<p
class=
"errornote"
>
{% for error in form.non_field_errors %}
{{ error }}
{% endfor %}
</p>
{% endif %}
{% for field in form %}
<div
class=
"form-row{% if field.errors %} errors{% endif %}"
>
{{ field.errors }}
<div>
{{ field.label_tag }}
{% if field.is_readonly %}
<div
class=
"readonly"
>
{{ field.contents }}
</div>
{% else %}
{{ field }}
{% endif %}
{% if field.field.help_text %}
<div
class=
"help"
>
{{ field.field.help_text|safe }}
</div>
{% endif %}
</div>
</div>
{% endfor %}
</p>
{% endif %}
<fieldset
class=
"module aligned"
>
{% for field in form %}
<div
class=
"form-row{% if field.errors %} errors{% endif %}"
>
{{ field.errors }}
<div>
{{ field.label_tag }}
{% if field.is_readonly %}
<div
class=
"readonly"
>
{{ field.contents }}
</div>
{% else %}
{{ field }}
{% endif %}
{% if field.field.help_text %}
<div
class=
"help"
>
{{ field.field.help_text|safe }}
</div>
{% endif %}
</div>
<div
class=
"col-sm-7"
>
<div
class=
"card text-center shadow"
>
{# Tabs for button categories #}
<div
class=
"card-header"
>
<ul
class=
"nav nav-tabs nav-fill card-header-tabs"
>
{% for template_type in template_types %}
<li
class=
"nav-item"
>
<a
class=
"nav-link"
data-toggle=
"tab"
href=
"#{{ template_type.grouper|slugify }}"
>
{{ template_type.grouper }}
</a>
</li>
{% endfor %}
</ul>
</div>
{# Tabs content #}
<div
class=
"card-body"
>
<div
class=
"tab-content"
>
{% for template_type in template_types %}
<div
class=
"tab-pane"
id=
"{{ template_type.grouper|slugify }}"
>
<div
class=
"d-inline-flex flex-wrap justify-content-center"
>
{% for button in template_type.list %}
<button
class=
"btn btn-outline-dark rounded-0 flex-fill"
name=
"button"
value=
"{{ button.name }}"
>
{{ button.name }} ({{ button.amount | pretty_money }})
</button>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
{% for button in buttons %}
<button
name=
"button"
value=
"{{ button.name }}"
>
{{ button.name }} ({{ button.amount | pretty_money }})
</button>
{% endfor %}
</fieldset>
</div>
</div>
</form>
{% endblock %}
{% block extrajavascript %}
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
// If hash of a category in the URL, then select this category
// else select the first one
if
(
location
.
hash
)
{
$
(
"
a[href='
"
+
location
.
hash
+
"
']
"
).
tab
(
"
show
"
);
}
else
{
$
(
"
a[data-toggle='tab']
"
).
first
().
tab
(
"
show
"
);
}
// When selecting a category, change URL
$
(
document
.
body
).
on
(
"
click
"
,
"
a[data-toggle='tab']
"
,
function
(
event
)
{
location
.
hash
=
this
.
getAttribute
(
"
href
"
);
});
});
</script>
{% 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