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
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
bb0fc8c2
Commit
bb0fc8c2
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Consumptions with item selected before
parent
e81450e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!57
Page de consommations
Pipeline
#7936
passed with warnings with stages
in 4 minutes and 1 second
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
static/js/base.js
+10
-1
10 additions, 1 deletion
static/js/base.js
static/js/consos.js
+26
-4
26 additions, 4 deletions
static/js/consos.js
templates/note/conso_form.html
+3
-1
3 additions, 1 deletion
templates/note/conso_form.html
with
39 additions
and
6 deletions
static/js/base.js
+
10
−
1
View file @
bb0fc8c2
...
...
@@ -134,9 +134,12 @@ function removeNote(d, note_prefix="note", notes_display, note_list_id, user_not
* consumptions, put null if not used)
* @param profile_pic_field The identifier of the field that display the profile picture of the hovered note
* (useful in consumptions, put null if not used)
* @param alias_click Function that is called when an alias is clicked. If this method exists and doesn't return true,
* the associated note is not displayed.
* Useful for a consumption if the item is selected before.
*/
function
autoCompleteNote
(
field_id
,
alias_matched_id
,
note_list_id
,
notes
,
notes_display
,
alias_prefix
=
"
alias
"
,
note_prefix
=
"
note
"
,
user_note_field
=
null
,
profile_pic_field
=
null
)
{
note_prefix
=
"
note
"
,
user_note_field
=
null
,
profile_pic_field
=
null
,
alias_click
=
null
)
{
let
field
=
$
(
"
#
"
+
field_id
);
// When the user clicks on the search field, it is immediately cleared
field
.
click
(
function
()
{
...
...
@@ -192,6 +195,12 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
// In the other case, we add a new emitter
if
(
disp
==
null
)
notes_display
.
push
([
alias
.
name
,
note
.
id
,
note
,
1
]);
// If the function alias_click exists, it is called. If it doesn't return true, then the notes are
// note displayed. Useful for a consumption when a button is already clicked
if
(
alias_click
&&
!
alias_click
())
return
;
let
note_list
=
$
(
"
#
"
+
note_list_id
);
let
html
=
""
;
notes_display
.
forEach
(
function
(
disp
)
{
...
...
This diff is collapsed.
Click to expand it.
static/js/consos.js
+
26
−
4
View file @
bb0fc8c2
...
...
@@ -29,7 +29,13 @@ let buttons = [];
// When the user searches an alias, we update the auto-completion
autoCompleteNote
(
"
note
"
,
"
alias_matched
"
,
"
note_list
"
,
notes
,
notes_display
,
"
alias
"
,
"
note
"
,
"
user_note
"
,
"
profile_pic
"
);
"
alias
"
,
"
note
"
,
"
user_note
"
,
"
profile_pic
"
,
function
()
{
if
(
buttons
.
length
>
0
)
{
consumeAll
();
return
false
;
}
return
true
;
});
/**
* Add a transaction from a button.
...
...
@@ -44,7 +50,7 @@ autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display,
function
addConso
(
dest
,
amount
,
type
,
category_id
,
category_name
,
template_id
,
template_name
)
{
var
button
=
null
;
buttons
.
forEach
(
function
(
b
)
{
if
(
b
[
5
]
===
template_id
)
{
if
(
b
[
6
]
===
template_id
)
{
b
[
1
]
+=
1
;
button
=
b
;
}
...
...
@@ -52,9 +58,24 @@ function addConso(dest, amount, type, category_id, category_name, template_id, t
if
(
button
==
null
)
buttons
.
push
([
dest
,
1
,
amount
,
type
,
category_id
,
category_name
,
template_id
,
template_name
]);
// TODO Only in simple consumption mode
if
(
notes
.
length
>
0
)
if
(
$
(
"
#double_conso:checked
"
).
length
>
0
)
{
let
html
=
""
;
buttons
.
forEach
(
function
(
button
)
{
html
+=
li
(
"
conso_button_
"
+
button
[
6
],
button
[
7
]
+
"
<span class=
\"
badge badge-dark badge-pill
\"
>
"
+
button
[
1
]
+
"
</span>
"
);
});
$
(
"
#consos_list
"
).
html
(
html
);
}
else
if
(
notes_display
.
length
>
0
)
consumeAll
();
else
{
let
html
=
""
;
buttons
.
forEach
(
function
(
button
)
{
html
+=
li
(
"
conso_button_
"
+
button
[
6
],
button
[
7
]
+
"
<span class=
\"
badge badge-dark badge-pill
\"
>
"
+
button
[
1
]
+
"
</span>
"
);
});
$
(
"
#note_list
"
).
html
(
html
);
}
}
/**
...
...
@@ -100,6 +121,7 @@ function consume(source, dest, quantity, amount, reason, type, category, templat
buttons
.
length
=
0
;
$
(
"
#note_list
"
).
html
(
""
);
$
(
"
#alias_matched
"
).
html
(
""
);
$
(
"
#consos_list
"
).
html
(
""
);
displayNote
(
null
,
""
);
refreshHistory
();
refreshBalance
();
...
...
This diff is collapsed.
Click to expand it.
templates/note/conso_form.html
+
3
−
1
View file @
bb0fc8c2
...
...
@@ -47,7 +47,7 @@
</div>
<ul
class=
"list-group list-group-flush"
id=
"consos_list"
>
</ul>
<button
id=
"consume"
class=
"form-control btn btn-primary"
>
Consommer !
</button>
<button
id=
"consume
_all
"
class=
"form-control btn btn-primary"
>
Consommer !
</button>
</div>
</div>
</div>
...
...
@@ -163,6 +163,8 @@
$
(
"
#consos_list_div
"
).
hide
();
$
(
"
#consume_all
"
).
click
(
consumeAll
);
{
%
for
button
in
transaction_templates
%
}
{
%
if
button
.
display
%
}
$
(
"
#button{{ button.id }}
"
).
click
(
function
()
{
...
...
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