Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
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
9f53bda1
Commit
9f53bda1
authored
5 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Patches
Plain Diff
clean code
parent
41568916
Loading
Loading
1 merge request
!54
Meilleurs vues pour la gestion des boutons
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/note/tables.py
+17
-11
17 additions, 11 deletions
apps/note/tables.py
templates/note/transactiontemplate_list.html
+8
-10
8 additions, 10 deletions
templates/note/transactiontemplate_list.html
with
25 additions
and
21 deletions
apps/note/tables.py
+
17
−
11
View file @
9f53bda1
...
...
@@ -56,7 +56,11 @@ class HistoryTable(tables.Table):
def
render_valid
(
self
,
value
):
return
"
✔
"
if
value
else
"
✖
"
# function delete_button(id) provided in template file
delete_template
=
"""
<button id=
"
{{ record.pk }}
"
class=
"
btn btn-danger
"
onclick=
"
delete_button(this.id)
"
> {{ delete_trans }}</a>
"""
class
AliasTable
(
tables
.
Table
):
class
Meta
:
attrs
=
{
...
...
@@ -69,13 +73,9 @@ class AliasTable(tables.Table):
show_header
=
False
name
=
tables
.
Column
(
attrs
=
{
'
td
'
:
{
'
class
'
:
'
text-center
'
}})
delete
=
tables
.
LinkColumn
(
'
member:user_alias_delete
'
,
args
=
[
A
(
'
pk
'
)],
attrs
=
{
'
td
'
:
{
'
class
'
:
'
col-sm-2
'
},
'
a
'
:
{
'
class
'
:
'
btn btn-danger
'
}},
text
=
'
delete
'
,
accessor
=
'
pk
'
)
delete
=
tables
.
TemplateColumn
(
template_code
=
delete_template
,
extra_context
=
{
"
delete_trans
"
:
_
(
'
delete
'
)},
attrs
=
{
'
td
'
:{
'
class
'
:
'
col-sm-1
'
}})
class
ButtonTable
(
tables
.
Table
):
class
Meta
:
attrs
=
{
...
...
@@ -90,10 +90,16 @@ class ButtonTable(tables.Table):
model
=
TransactionTemplate
edit
=
tables
.
LinkColumn
(
'
note:template_update
'
,
args
=
[
A
(
'
pk
'
)],
attrs
=
{
'
td
'
:
{
'
class
'
:
'
col-sm-1
'
},
'
a
'
:
{
'
class
'
:
'
btn btn-primary
'
}},
text
=
_
(
'
edit
'
),
accessor
=
'
pk
'
)
delete
=
tables
.
TemplateColumn
(
template_code
=
"""
<button id=
"
{{ record.pk }}
"
class=
"
btn btn-danger
"
onclick=
"
delete_button(this.id)
"
>
delete
</a>
"""
)
delete
=
tables
.
TemplateColumn
(
template_code
=
delete_template
,
extra_context
=
{
"
delete_trans
"
:
_
(
'
delete
'
)},
attrs
=
{
'
td
'
:{
'
class
'
:
'
col-sm-1
'
}}
)
def
render_amount
(
self
,
value
):
return
pretty_money
(
value
)
This diff is collapsed.
Click to expand it.
templates/note/transactiontemplate_list.html
+
8
−
10
View file @
9f53bda1
...
...
@@ -63,15 +63,13 @@ function search_field_moved(secondfield) {
$
.
ajax
({
url
:
"
/api/note/transaction/template/
"
+
button_id
,
method
:
"
DELETE
"
,
headers
:
{
"
X-CSRFTOKEN
"
:
CSRF_TOKEN
},
success
:
function
(){
addMsg
(
'
{% trans "button successfully deleted "%}
'
,
'
success
'
);
$
(
"
#buttons_table
"
).
load
(
'
{% url "note:template_list" %} #buttons_tables
'
);
},
error
:
addMsg
(
'
{% trans "Unable to delete button "%} #
'
+
button_id
,
'
danger
'
)
});
}
headers
:
{
"
X-CSRFTOKEN
"
:
CSRF_TOKEN
}
})
.
done
(
function
(){
addMsg
(
'
{% trans "button successfully deleted "%}
'
,
'
success
'
);
$
(
"
#buttons_table
"
).
load
(
"
{% url 'note:template_list' %} #buttons_table
"
);
})
.
fail
(
addMsg
(
'
{% trans "Unable to delete button "%} #
'
+
button_id
,
'
danger
'
));
}
</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