Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
e430d083
Commit
e430d083
authored
Feb 04, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linting
parent
79d992f1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
30 deletions
+62
-30
envelops.js
envelops/static/js/envelops.js
+26
-12
orders_helper.js
orders/static/js/orders_helper.js
+36
-18
No files found.
envelops/static/js/envelops.js
View file @
e430d083
...
@@ -14,7 +14,8 @@ function toggle_error_alert() {
...
@@ -14,7 +14,8 @@ function toggle_error_alert() {
}
}
function
toggle_success_alert
(
message
)
{
function
toggle_success_alert
(
message
)
{
$
(
'#envelop_cashing_success'
).
find
(
".success_alert_content"
).
text
(
message
);
$
(
'#envelop_cashing_success'
).
find
(
".success_alert_content"
)
.
text
(
message
);
$
(
'#envelop_cashing_success'
).
toggle
(
250
);
$
(
'#envelop_cashing_success'
).
toggle
(
250
);
}
}
...
@@ -107,25 +108,28 @@ function set_envelop_dom(envelop, envelop_name, envelop_content_id, envelop_inde
...
@@ -107,25 +108,28 @@ function set_envelop_dom(envelop, envelop_name, envelop_content_id, envelop_inde
}
}
let
envelop_panel
=
$
(
`.panel_
${
envelop_content_id
}
`
);
let
envelop_panel
=
$
(
`.panel_
${
envelop_content_id
}
`
);
envelop_panel
.
append
(
`<button class="btn--danger delete_envelop_button item-fluid" id="update_envelop_
${
envelop
.
type
}
_
${
envelop_index
}
">Supprimer l'enveloppe</button>`
);
envelop_panel
.
append
(
`<button class="btn--danger delete_envelop_button item-fluid" id="update_envelop_
${
envelop
.
type
}
_
${
envelop_index
}
">Supprimer l'enveloppe</button>`
);
envelop_panel
.
append
(
`<button class="btn--primary update_envelop_button item-fluid" id="update_envelop_
${
envelop
.
type
}
_
${
envelop_index
}
">Modifier</button>`
);
envelop_panel
.
append
(
`<button class="btn--primary update_envelop_button item-fluid" id="update_envelop_
${
envelop
.
type
}
_
${
envelop_index
}
">Modifier</button>`
);
$
(
".update_envelop_button"
).
off
(
"click"
);
$
(
".update_envelop_button"
).
off
(
"click"
);
$
(
".update_envelop_button"
).
on
(
"click"
,
function
()
{
$
(
".update_envelop_button"
).
on
(
"click"
,
function
()
{
let
el_id
=
$
(
this
).
attr
(
"id"
).
split
(
"_"
);
let
el_id
=
$
(
this
).
attr
(
"id"
)
.
split
(
"_"
);
envelop_to_update
=
{
envelop_to_update
=
{
type
:
el_id
[
2
],
type
:
el_id
[
2
],
index
:
el_id
[
3
],
index
:
el_id
[
3
],
lines_to_delete
:
[]
lines_to_delete
:
[]
}
}
;
set_update_envelop_modal
();
set_update_envelop_modal
();
});
});
$
(
".delete_envelop_button"
).
off
(
"click"
);
$
(
".delete_envelop_button"
).
off
(
"click"
);
$
(
".delete_envelop_button"
).
on
(
"click"
,
function
()
{
$
(
".delete_envelop_button"
).
on
(
"click"
,
function
()
{
let
el_id
=
$
(
this
).
attr
(
"id"
).
split
(
"_"
);
let
el_id
=
$
(
this
).
attr
(
"id"
)
.
split
(
"_"
);
let
type
=
el_id
[
2
];
let
type
=
el_id
[
2
];
let
index
=
el_id
[
3
];
let
index
=
el_id
[
3
];
let
envelop
=
get_envelop_from_type_index
(
type
,
index
);
let
envelop
=
get_envelop_from_type_index
(
type
,
index
);
...
@@ -208,12 +212,14 @@ function set_update_envelop_modal() {
...
@@ -208,12 +212,14 @@ function set_update_envelop_modal() {
let
envelop_name
=
get_envelop_name
(
envelop
,
'long'
);
let
envelop_name
=
get_envelop_name
(
envelop
,
'long'
);
let
modal_update_envelop
=
$
(
'#templates #modal_update_envelop'
);
let
modal_update_envelop
=
$
(
'#templates #modal_update_envelop'
);
modal_update_envelop
.
find
(
".envelop_name"
).
text
(
envelop_name
);
modal_update_envelop
.
find
(
".envelop_name"
).
text
(
envelop_name
);
modal_update_envelop
.
find
(
".envelop_lines"
).
empty
();
modal_update_envelop
.
find
(
".envelop_lines"
).
empty
();
let
update_line_template
=
$
(
'#templates #update_envelop_line_template'
);
let
update_line_template
=
$
(
'#templates #update_envelop_line_template'
);
let
cpt
=
1
;
let
cpt
=
1
;
for
(
let
partner_id
in
envelop
.
envelop_content
)
{
for
(
let
partner_id
in
envelop
.
envelop_content
)
{
let
line
=
envelop
.
envelop_content
[
partner_id
];
let
line
=
envelop
.
envelop_content
[
partner_id
];
...
@@ -243,21 +249,26 @@ function set_update_envelop_modal() {
...
@@ -243,21 +249,26 @@ function set_update_envelop_modal() {
for
(
let
partner_id
in
envelop
.
envelop_content
)
{
for
(
let
partner_id
in
envelop
.
envelop_content
)
{
let
line
=
envelop
.
envelop_content
[
partner_id
];
let
line
=
envelop
.
envelop_content
[
partner_id
];
$
(
`#update_line_
${
partner_id
}
`
).
find
(
'.line_partner_amount'
).
val
(
line
.
amount
);
$
(
`#update_line_
${
partner_id
}
`
).
find
(
'.line_partner_amount'
)
.
val
(
line
.
amount
);
}
}
modal
.
find
(
'.envelop_comments'
).
val
((
envelop
.
comments
!==
undefined
)
?
envelop
.
comments
:
''
);
modal
.
find
(
'.envelop_comments'
).
val
((
envelop
.
comments
!==
undefined
)
?
envelop
.
comments
:
''
);
$
(
".delete_envelop_line_icon"
).
off
(
"click"
);
$
(
".delete_envelop_line_icon"
).
off
(
"click"
);
$
(
".delete_envelop_line_icon"
).
on
(
"click"
,
function
()
{
$
(
".delete_envelop_line_icon"
).
on
(
"click"
,
function
()
{
let
line_id
=
$
(
this
).
closest
(
".update_envelop_line"
).
attr
(
"id"
).
split
(
"_"
);
let
line_id
=
$
(
this
).
closest
(
".update_envelop_line"
)
.
attr
(
"id"
)
.
split
(
"_"
);
let
partner_id
=
line_id
[
line_id
.
length
-
1
];
let
partner_id
=
line_id
[
line_id
.
length
-
1
];
envelop_to_update
.
lines_to_delete
.
push
(
partner_id
);
envelop_to_update
.
lines_to_delete
.
push
(
partner_id
);
$
(
this
).
hide
();
$
(
this
).
hide
();
$
(
this
).
closest
(
".update_envelop_line"
).
find
(
".deleted_line_through"
).
show
();
$
(
this
).
closest
(
".update_envelop_line"
)
})
.
find
(
".deleted_line_through"
)
.
show
();
});
}
}
/**
/**
...
@@ -269,8 +280,11 @@ function update_envelop() {
...
@@ -269,8 +280,11 @@ function update_envelop() {
// Update lines amounts
// Update lines amounts
let
amount_inputs
=
modal
.
find
(
'.line_partner_amount'
);
let
amount_inputs
=
modal
.
find
(
'.line_partner_amount'
);
amount_inputs
.
each
(
function
(
i
,
e
)
{
let
line_id
=
$
(
e
).
closest
(
".update_envelop_line"
).
attr
(
"id"
).
split
(
"_"
);
amount_inputs
.
each
(
function
(
i
,
e
)
{
let
line_id
=
$
(
e
).
closest
(
".update_envelop_line"
)
.
attr
(
"id"
)
.
split
(
"_"
);
let
partner_id
=
line_id
[
line_id
.
length
-
1
];
let
partner_id
=
line_id
[
line_id
.
length
-
1
];
envelop
.
envelop_content
[
partner_id
].
amount
=
parseInt
(
$
(
e
).
val
());
envelop
.
envelop_content
[
partner_id
].
amount
=
parseInt
(
$
(
e
).
val
());
...
@@ -278,7 +292,7 @@ function update_envelop() {
...
@@ -278,7 +292,7 @@ function update_envelop() {
// Delete lines
// Delete lines
for
(
let
partner_id
of
envelop_to_update
.
lines_to_delete
)
{
for
(
let
partner_id
of
envelop_to_update
.
lines_to_delete
)
{
delete
(
envelop
.
envelop_content
[
partner_id
])
delete
(
envelop
.
envelop_content
[
partner_id
])
;
}
}
// Envelop comments
// Envelop comments
...
@@ -383,7 +397,7 @@ function archive_envelop(type, index) {
...
@@ -383,7 +397,7 @@ function archive_envelop(type, index) {
}
}
});
});
}
else
{
}
else
{
alert
(
"Par sécurité, il faut attendre 5s entre l'encaissement de deux enveloppes."
)
alert
(
"Par sécurité, il faut attendre 5s entre l'encaissement de deux enveloppes."
)
;
}
}
}
}
...
...
orders/static/js/orders_helper.js
View file @
e430d083
...
@@ -29,7 +29,7 @@ var dbc = null,
...
@@ -29,7 +29,7 @@ var dbc = null,
var
clicked_order_pill
=
null
;
var
clicked_order_pill
=
null
;
var
timerId
var
timerId
;
/* - UTILS */
/* - UTILS */
/**
/**
...
@@ -117,9 +117,9 @@ function _compute_stats_date_from() {
...
@@ -117,9 +117,9 @@ function _compute_stats_date_from() {
}
}
function
debounceFunction
(
func
,
delay
=
1000
)
{
function
debounceFunction
(
func
,
delay
=
1000
)
{
clearTimeout
(
timerId
)
clearTimeout
(
timerId
);
timerId
=
setTimeout
(
func
,
delay
)
timerId
=
setTimeout
(
func
,
delay
);
}
}
/* - PRODUCTS */
/* - PRODUCTS */
...
@@ -196,6 +196,7 @@ function add_product() {
...
@@ -196,6 +196,7 @@ function add_product() {
function
compute_products_coverage_qties
()
{
function
compute_products_coverage_qties
()
{
const
pc_adjust
=
$
(
'#percent_adjust_input'
).
val
();
const
pc_adjust
=
$
(
'#percent_adjust_input'
).
val
();
let
coeff
=
1
;
let
coeff
=
1
;
if
(
!
isNaN
(
parseFloat
(
pc_adjust
)))
{
if
(
!
isNaN
(
parseFloat
(
pc_adjust
)))
{
coeff
=
(
1
+
parseFloat
(
pc_adjust
)
/
100
);
coeff
=
(
1
+
parseFloat
(
pc_adjust
)
/
100
);
}
}
...
@@ -295,6 +296,7 @@ function check_products_data() {
...
@@ -295,6 +296,7 @@ function check_products_data() {
// Remove fetched product id from loaded products list
// Remove fetched product id from loaded products list
const
loaded_p_index
=
loaded_products_ids
.
indexOf
(
p_id
);
const
loaded_p_index
=
loaded_products_ids
.
indexOf
(
p_id
);
if
(
loaded_p_index
>
-
1
)
{
if
(
loaded_p_index
>
-
1
)
{
loaded_products_ids
.
splice
(
loaded_p_index
,
1
);
loaded_products_ids
.
splice
(
loaded_p_index
,
1
);
}
}
...
@@ -311,6 +313,7 @@ function check_products_data() {
...
@@ -311,6 +313,7 @@ function check_products_data() {
for
(
pid
of
loaded_products_ids
)
{
for
(
pid
of
loaded_products_ids
)
{
const
p_index
=
products
.
findIndex
(
p
=>
p
.
id
==
pid
);
const
p_index
=
products
.
findIndex
(
p
=>
p
.
id
==
pid
);
const
p_name
=
products
[
p_index
].
name
;
const
p_name
=
products
[
p_index
].
name
;
products
.
splice
(
p_index
,
1
);
products
.
splice
(
p_index
,
1
);
$
.
notify
(
$
.
notify
(
...
@@ -735,8 +738,10 @@ function commit_actions_on_product(product, inputs) {
...
@@ -735,8 +738,10 @@ function commit_actions_on_product(product, inputs) {
id
:
product
.
id
,
id
:
product
.
id
,
name
:
product
.
name
name
:
product
.
name
};
};
inputs
.
each
(
function
(
i
,
e
)
{
const
input
=
$
(
e
)
inputs
.
each
(
function
(
i
,
e
)
{
const
input
=
$
(
e
);
if
(
input
.
attr
(
'name'
)
==
'npa-actions'
)
{
if
(
input
.
attr
(
'name'
)
==
'npa-actions'
)
{
if
(
input
.
prop
(
'checked'
)
==
true
)
{
if
(
input
.
prop
(
'checked'
)
==
true
)
{
actions
.
npa
.
push
(
input
.
val
());
actions
.
npa
.
push
(
input
.
val
());
...
@@ -800,7 +805,7 @@ function commit_actions_on_product(product, inputs) {
...
@@ -800,7 +805,7 @@ function commit_actions_on_product(product, inputs) {
try
{
try
{
if
(
data
.
responseJSON
.
code
===
"archiving_with_incoming_qty"
)
{
if
(
data
.
responseJSON
.
code
===
"archiving_with_incoming_qty"
)
{
alert
(
"Ce produit a des quantités entrantes, vous ne pouvez pas l'archiver."
)
alert
(
"Ce produit a des quantités entrantes, vous ne pouvez pas l'archiver."
)
;
}
else
if
(
data
.
responseJSON
.
code
===
"error_stock_update"
)
{
}
else
if
(
data
.
responseJSON
.
code
===
"error_stock_update"
)
{
alert
(
'Erreur lors de la mise à zéro du stock du produit archivé. Les actions ont bien été réalisées.'
);
alert
(
'Erreur lors de la mise à zéro du stock du produit archivé. Les actions ont bien été réalisées.'
);
}
else
{
}
else
{
...
@@ -1695,7 +1700,10 @@ function display_products(params) {
...
@@ -1695,7 +1700,10 @@ function display_products(params) {
e
.
preventDefault
();
e
.
preventDefault
();
// On arrow up pressed, focus next row input
// On arrow up pressed, focus next row input
let
next_input
=
$
(
this
).
closest
(
"tr"
).
prev
().
find
(
".product_qty_input"
);
let
next_input
=
$
(
this
).
closest
(
"tr"
)
.
prev
()
.
find
(
".product_qty_input"
);
next_input
.
focus
();
next_input
.
focus
();
// Scroll to a position where the target input is not hidden by the sticky suppliers container
// Scroll to a position where the target input is not hidden by the sticky suppliers container
...
@@ -1714,30 +1722,40 @@ function display_products(params) {
...
@@ -1714,30 +1722,40 @@ function display_products(params) {
e
.
preventDefault
();
e
.
preventDefault
();
// On arrow down pressed, focus previous row input
// On arrow down pressed, focus previous row input
$
(
this
).
closest
(
"tr"
).
next
().
find
(
".product_qty_input"
).
focus
();
$
(
this
).
closest
(
"tr"
)
.
next
()
.
find
(
".product_qty_input"
)
.
focus
();
}
else
if
(
e
.
which
==
13
)
{
}
else
if
(
e
.
which
==
13
)
{
e
.
preventDefault
();
e
.
preventDefault
();
// On enter pressed, focus previous row input
// On enter pressed, focus previous row input
$
(
this
).
closest
(
"tr"
).
next
().
find
(
".product_qty_input"
).
focus
();
$
(
this
).
closest
(
"tr"
)
.
next
()
.
find
(
".product_qty_input"
)
.
focus
();
}
}
})
})
.
on
(
'click'
,
'tbody td .product_actions'
,
function
(
e
){
.
on
(
'click'
,
'tbody td .product_actions'
,
function
(
e
)
{
// Save / unsave selected row
// Save / unsave selected row
const
p_id
=
products_table
.
row
(
$
(
this
).
closest
(
'tr'
)).
data
().
id
;
const
p_id
=
products_table
.
row
(
$
(
this
).
closest
(
'tr'
)).
data
().
id
;
const
product
=
products
.
find
(
p
=>
p
.
id
==
p_id
);
const
product
=
products
.
find
(
p
=>
p
.
id
==
p_id
);
let
modal_product_actions
=
$
(
'#templates #modal_product_actions'
);
let
modal_product_actions
=
$
(
'#templates #modal_product_actions'
);
modal_product_actions
.
find
(
".product_name"
).
text
(
product
.
name
);
modal_product_actions
.
find
(
".product_name"
).
text
(
product
.
name
);
const
product_can_be_archived
=
product
.
incoming_qty
===
0
;
const
product_can_be_archived
=
product
.
incoming_qty
===
0
;
if
(
product_can_be_archived
==
true
)
{
if
(
product_can_be_archived
==
true
)
{
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
false
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
false
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
).
removeClass
(
"checkbox_action_disabled"
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
)
.
removeClass
(
"checkbox_action_disabled"
);
}
else
{
}
else
{
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
true
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
prop
(
"disabled"
,
true
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
).
addClass
(
"checkbox_action_disabled"
);
modal_product_actions
.
find
(
'input[name="archive-action"]'
).
closest
(
"label"
)
.
addClass
(
"checkbox_action_disabled"
);
}
}
openModal
(
openModal
(
...
@@ -1750,7 +1768,7 @@ function display_products(params) {
...
@@ -1750,7 +1768,7 @@ function display_products(params) {
'Valider'
,
'Valider'
,
false
false
);
);
modal
.
find
(
'input[name="minimal_stock"]'
).
val
(
product
.
minimal_stock
)
modal
.
find
(
'input[name="minimal_stock"]'
).
val
(
product
.
minimal_stock
)
;
});
});
...
@@ -1981,7 +1999,7 @@ function update_main_screen(params) {
...
@@ -1981,7 +1999,7 @@ function update_main_screen(params) {
}
}
function
display_average_consumption_explanation
()
{
function
display_average_consumption_explanation
()
{
openModal
(
$
(
'#explanations'
).
html
())
openModal
(
$
(
'#explanations'
).
html
());
}
}
/**
/**
* Update DOM display on the order selection screen
* Update DOM display on the order selection screen
...
@@ -2355,7 +2373,7 @@ $(document).ready(function() {
...
@@ -2355,7 +2373,7 @@ $(document).ready(function() {
return
0
;
return
0
;
});
});
$
(
document
).
on
(
"click"
,
".average_consumption_explanation_icon"
,
display_average_consumption_explanation
)
$
(
document
).
on
(
"click"
,
".average_consumption_explanation_icon"
,
display_average_consumption_explanation
);
$
.
datepicker
.
regional
[
'fr'
]
=
{
$
.
datepicker
.
regional
[
'fr'
]
=
{
monthNames
:
[
monthNames
:
[
...
@@ -2493,7 +2511,7 @@ $(document).ready(function() {
...
@@ -2493,7 +2511,7 @@ $(document).ready(function() {
}
}
});
});
$
(
document
).
on
(
'click'
,
'.accordion'
,
function
(){
$
(
document
).
on
(
'click'
,
'.accordion'
,
function
()
{
/* Toggle between adding and removing the "active" class,
/* Toggle between adding and removing the "active" class,
to highlight the button that controls the panel */
to highlight the button that controls the panel */
this
.
classList
.
toggle
(
"active"
);
this
.
classList
.
toggle
(
"active"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment