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
3b618502
Commit
3b618502
authored
Jun 23, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REC] various minor improvements + linting
parent
cad2882a
Pipeline
#2262
passed with stage
in 1 minute 53 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
38 deletions
+59
-38
reception_style.css
reception/static/css/reception_style.css
+7
-0
reception_produits.js
reception/static/js/reception_produits.js
+47
-37
reception_produits.html
templates/reception/reception_produits.html
+5
-1
No files found.
reception/static/css/reception_style.css
View file @
3b618502
...
@@ -217,6 +217,9 @@ tr.odd td.row_product_no_qty {
...
@@ -217,6 +217,9 @@ tr.odd td.row_product_no_qty {
.search_products_to_add_area
{
.search_products_to_add_area
{
margin
:
2rem
0
;
margin
:
2rem
0
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
}
.search_product_input
{
.search_product_input
{
...
@@ -227,6 +230,10 @@ tr.odd td.row_product_no_qty {
...
@@ -227,6 +230,10 @@ tr.odd td.row_product_no_qty {
z-index
:
10000001
!important
;
z-index
:
10000001
!important
;
}
}
.search_product_help
{
margin-left
:
10px
;
}
.products_lines
{
.products_lines
{
display
:
none
;
display
:
none
;
}
}
...
...
reception/static/js/reception_produits.js
View file @
3b618502
...
@@ -58,11 +58,13 @@ function is_grouped_order() {
...
@@ -58,11 +58,13 @@ function is_grouped_order() {
*/
*/
function
get_suppliers_id
()
{
function
get_suppliers_id
()
{
let
suppliers_id
=
[];
let
suppliers_id
=
[];
for
(
var
order_id
in
orders
)
{
for
(
var
order_id
in
orders
)
{
if
(
'partner_id'
in
orders
[
order_id
])
{
//
for versions transition
if
(
'partner_id'
in
orders
[
order_id
])
{
// check
for versions transition
suppliers_id
.
push
(
orders
[
order_id
].
partner_id
);
suppliers_id
.
push
(
orders
[
order_id
].
partner_id
);
}
}
}
}
return
suppliers_id
;
return
suppliers_id
;
}
}
...
@@ -1803,10 +1805,12 @@ function add_products_action() {
...
@@ -1803,10 +1805,12 @@ function add_products_action() {
for
(
let
qty_input
of
qty_inputs
)
{
for
(
let
qty_input
of
qty_inputs
)
{
if
(
$
(
qty_input
).
val
()
===
""
)
{
if
(
$
(
qty_input
).
val
()
===
""
)
{
has_empty_qty_input
=
true
has_empty_qty_input
=
true
;
$
(
qty_input
).
siblings
(
".product_qty_input_alert"
).
show
();
$
(
qty_input
).
siblings
(
".product_qty_input_alert"
)
.
show
();
}
else
{
}
else
{
$
(
qty_input
).
siblings
(
".product_qty_input_alert"
).
hide
();
$
(
qty_input
).
siblings
(
".product_qty_input_alert"
)
.
hide
();
}
}
}
}
...
@@ -1825,6 +1829,7 @@ function create_orders() {
...
@@ -1825,6 +1829,7 @@ function create_orders() {
// Mock order date_planned : today
// Mock order date_planned : today
let
date_object
=
new
Date
();
let
date_object
=
new
Date
();
formatted_date
=
date_object
.
toISOString
().
replace
(
'T'
,
' '
)
formatted_date
=
date_object
.
toISOString
().
replace
(
'T'
,
' '
)
.
split
(
'.'
)[
0
];
// Get ISO format bare string
.
split
(
'.'
)[
0
];
// Get ISO format bare string
...
@@ -1840,11 +1845,15 @@ function create_orders() {
...
@@ -1840,11 +1845,15 @@ function create_orders() {
// Get product qty from input
// Get product qty from input
let
product_qty
=
0
;
let
product_qty
=
0
;
let
add_products_lines
=
$
(
"#modal .add_product_line"
)
let
add_products_lines
=
$
(
"#modal .add_product_line"
);
for
(
let
i
=
0
;
i
<
add_products_lines
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
add_products_lines
.
length
;
i
++
)
{
let
line
=
add_products_lines
[
i
];
let
line
=
add_products_lines
[
i
];
if
(
$
(
line
).
find
(
".product_name"
).
text
()
===
p
.
name
)
{
product_qty
=
parseFloat
(
$
(
line
).
find
(
".product_qty_input"
).
val
());
if
(
$
(
line
).
find
(
".product_name"
)
.
text
()
===
p
.
name
)
{
product_qty
=
parseFloat
(
$
(
line
).
find
(
".product_qty_input"
)
.
val
());
break
;
break
;
}
}
}
}
...
@@ -1874,6 +1883,7 @@ function create_orders() {
...
@@ -1874,6 +1883,7 @@ function create_orders() {
}
}
openModal
();
openModal
();
$
(
"#modal em:contains('Chargement en cours...')"
).
append
(
"<br/>L'opération peut prendre un certain temps..."
);
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
...
@@ -1883,7 +1893,7 @@ function create_orders() {
...
@@ -1883,7 +1893,7 @@ function create_orders() {
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
orders_data
),
data
:
JSON
.
stringify
(
orders_data
),
success
:
(
result
)
=>
{
success
:
(
result
)
=>
{
po_ids
=
[]
po_ids
=
[]
;
for
(
let
po
of
result
.
res
.
created
)
{
for
(
let
po
of
result
.
res
.
created
)
{
po_ids
.
push
(
po
.
id_po
);
po_ids
.
push
(
po
.
id_po
);
}
}
...
@@ -1909,7 +1919,7 @@ function create_orders() {
...
@@ -1909,7 +1919,7 @@ function create_orders() {
// Consider new order lines as updated products
// Consider new order lines as updated products
new_order
.
updated_products
=
new_order
.
po
;
new_order
.
updated_products
=
new_order
.
po
;
delete
(
new_order
.
po
)
delete
(
new_order
.
po
)
;
// Add necessary data to order updated products
// Add necessary data to order updated products
for
(
let
noup
of
new_order
.
updated_products
)
{
for
(
let
noup
of
new_order
.
updated_products
)
{
...
@@ -1939,21 +1949,11 @@ function create_orders() {
...
@@ -1939,21 +1949,11 @@ function create_orders() {
}
}
dbc
.
put
(
doc
,
()
=>
{
dbc
.
put
(
doc
,
()
=>
{
// Update screen
// The easy way: reload page now all data is correctly set.
window
.
location
.
reload
();
window
.
location
.
reload
();
});
});
});
})
// now we have order_lines in result2 orders
// TODO
// reload ! (should be fine) (or more complex : initList & set title)
// TODO aussi, ne permettre d'ajouter des produits que dans étape 1 (jcrois c'est déjà fait)
// TODO aussi, enlever de la liste des produits à ajouter, les produits déjà récupérés
// TODO bug : peut pas sélectionner produit à ajouter si déjà une recherche dans page principale
// TODO aussi : press enter sur item du dropdown
// TODO aussi sur page d'accueil action quand groups doc est maj (surement reload)
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la récupération des commandes"
,
ctx
:
'get_list_orders'
};
err
=
{
msg
:
"erreur serveur lors de la récupération des commandes"
,
ctx
:
'get_list_orders'
};
...
@@ -1966,8 +1966,6 @@ function create_orders() {
...
@@ -1966,8 +1966,6 @@ function create_orders() {
alert
(
'Erreur lors de la récupération des commandes, rechargez la page plus tard.'
);
alert
(
'Erreur lors de la récupération des commandes, rechargez la page plus tard.'
);
}
}
});
});
// closeModal();
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
let
msg
=
"erreur serveur lors de la création des product orders"
;
let
msg
=
"erreur serveur lors de la création des product orders"
;
...
@@ -1989,7 +1987,7 @@ function create_orders() {
...
@@ -1989,7 +1987,7 @@ function create_orders() {
*
*
* @param {Object} order_data
* @param {Object} order_data
*/
*/
function
create_order_doc
(
order_data
)
{
function
create_order_doc
(
order_data
)
{
const
order_doc_id
=
'order_'
+
order_data
.
id
;
const
order_doc_id
=
'order_'
+
order_data
.
id
;
order_data
.
_id
=
order_doc_id
;
order_data
.
_id
=
order_doc_id
;
...
@@ -2042,7 +2040,14 @@ function openErrorReport() {
...
@@ -2042,7 +2040,14 @@ function openErrorReport() {
* Filter autocomplete data by removing products already selected.
* Filter autocomplete data by removing products already selected.
*/
*/
function
set_products_autocomplete
()
{
function
set_products_autocomplete
()
{
let
autocomplete_products
=
suppliers_products
.
filter
(
p
=>
products_to_add
.
findIndex
(
pta
=>
pta
.
name
===
p
.
name
)
===
-
1
);
// Filter autocomplete products on products already in orders
let
autocomplete_products
=
suppliers_products
.
filter
(
p
=>
list_to_process
.
findIndex
(
ptp
=>
ptp
.
product_id
[
1
]
===
p
.
name
)
===
-
1
);
autocomplete_products
=
autocomplete_products
.
filter
(
p
=>
list_processed
.
findIndex
(
pp
=>
pp
.
product_id
[
1
]
===
p
.
name
)
===
-
1
);
console
.
log
(
products_to_add
);
// Filter autocomplete products on products already selected
autocomplete_products
=
autocomplete_products
.
filter
(
p
=>
products_to_add
.
findIndex
(
pta
=>
pta
.
name
===
p
.
name
)
===
-
1
);
try
{
try
{
$
(
"#modal .search_product_input"
).
autocomplete
(
"destroy"
);
$
(
"#modal .search_product_input"
).
autocomplete
(
"destroy"
);
...
@@ -2055,25 +2060,21 @@ function set_products_autocomplete() {
...
@@ -2055,25 +2060,21 @@ function set_products_autocomplete() {
classes
:
{
classes
:
{
"ui-autocomplete"
:
"autocomplete_dropdown"
"ui-autocomplete"
:
"autocomplete_dropdown"
},
},
delay
:
0
delay
:
0
,
});
select
:
function
(
event
,
ui
)
{
// Action called when an item is selected
$
(
".autocomplete_dropdown"
).
off
(
"click"
);
// todo + enter
event
.
preventDefault
();
$
(
".autocomplete_dropdown"
).
on
(
"click"
,
(
e
)
=>
{
let
product_name
=
ui
.
item
.
label
;
let
product_name
=
e
.
target
.
textContent
;
// extra secutiry but shouldn't happen
// extra secutiry but shouldn't happen
if
(
products_to_add
.
findIndex
(
p
=>
p
.
name
===
product_name
)
===
-
1
)
{
if
(
products_to_add
.
findIndex
(
p
=>
p
.
name
===
product_name
)
===
-
1
)
{
let
product
=
suppliers_products
.
find
(
p
=>
p
.
name
===
product_name
);
let
product
=
suppliers_products
.
find
(
p
=>
p
.
name
===
product_name
);
products_to_add
.
push
(
product
);
// Reset search elements
products_to_add
.
push
(
product
);
$
(
".autocomplete_dropdown"
).
hide
();
$
(
"#modal .search_product_input"
).
val
(
''
);
set_products_autocomplete
();
// Display
// Display
let
add_product_template
=
$
(
"#add_product_line_template"
);
let
add_product_template
=
$
(
"#add_product_line_template"
);
add_product_template
.
find
(
".product_name"
).
text
(
product_name
);
add_product_template
.
find
(
".product_name"
).
text
(
product_name
);
$
(
"#modal .products_lines"
).
append
(
add_product_template
.
html
());
$
(
"#modal .products_lines"
).
append
(
add_product_template
.
html
());
...
@@ -2083,6 +2084,11 @@ function set_products_autocomplete() {
...
@@ -2083,6 +2084,11 @@ function set_products_autocomplete() {
$
(
".remove_line_icon"
).
off
(
"click"
);
$
(
".remove_line_icon"
).
off
(
"click"
);
$
(
".remove_line_icon"
).
on
(
"click"
,
remove_product_line
);
$
(
".remove_line_icon"
).
on
(
"click"
,
remove_product_line
);
// Reset search elements
$
(
"#modal .search_product_input"
).
val
(
''
);
set_products_autocomplete
();
}
}
}
});
});
}
}
...
@@ -2095,6 +2101,7 @@ function remove_product_line(e) {
...
@@ -2095,6 +2101,7 @@ function remove_product_line(e) {
let
product_line
=
$
(
e
.
target
).
closest
(
".add_product_line"
);
let
product_line
=
$
(
e
.
target
).
closest
(
".add_product_line"
);
let
product_name
=
product_line
.
find
(
".product_name"
).
text
();
let
product_name
=
product_line
.
find
(
".product_name"
).
text
();
let
product_to_add_index
=
products_to_add
.
findIndex
(
p
=>
p
.
name
===
product_name
);
let
product_to_add_index
=
products_to_add
.
findIndex
(
p
=>
p
.
name
===
product_name
);
products_to_add
.
splice
(
product_to_add_index
,
1
);
products_to_add
.
splice
(
product_to_add_index
,
1
);
product_line
.
remove
();
product_line
.
remove
();
set_products_autocomplete
();
set_products_autocomplete
();
...
@@ -2105,6 +2112,7 @@ function remove_product_line(e) {
...
@@ -2105,6 +2112,7 @@ function remove_product_line(e) {
*/
*/
function
set_add_products_modal
()
{
function
set_add_products_modal
()
{
let
add_products_modal
=
$
(
"#modal_add_products"
);
let
add_products_modal
=
$
(
"#modal_add_products"
);
openModal
(
openModal
(
add_products_modal
.
html
(),
add_products_modal
.
html
(),
add_products_action
,
add_products_action
,
...
@@ -2289,6 +2297,7 @@ function init_dom(partners_display_data) {
...
@@ -2289,6 +2297,7 @@ function init_dom(partners_display_data) {
});
});
$
(
"#add_products_button"
).
on
(
'click'
,
()
=>
{
$
(
"#add_products_button"
).
on
(
'click'
,
()
=>
{
if
(
reception_status
==
"False"
)
{
let
pswd
=
prompt
(
'Merci de demander à un.e salarié.e le mot de passe pour ajouter des produits à la commande'
);
let
pswd
=
prompt
(
'Merci de demander à un.e salarié.e le mot de passe pour ajouter des produits à la commande'
);
// Minimum security level
// Minimum security level
...
@@ -2299,6 +2308,7 @@ function init_dom(partners_display_data) {
...
@@ -2299,6 +2308,7 @@ function init_dom(partners_display_data) {
}
else
{
}
else
{
alert
(
'Mauvais mot de passe !'
);
alert
(
'Mauvais mot de passe !'
);
}
}
}
});
});
// Barcode reader
// Barcode reader
...
...
templates/reception/reception_produits.html
View file @
3b618502
...
@@ -194,6 +194,11 @@
...
@@ -194,6 +194,11 @@
<h3>
Ajouter des produits à la commande
</h3>
<h3>
Ajouter des produits à la commande
</h3>
<div
class=
"search_products_to_add_area"
>
<div
class=
"search_products_to_add_area"
>
<input
type=
"text"
class=
"search_product_input"
name=
"search_product_input"
placeholder=
"Rechercher un produit..."
>
<input
type=
"text"
class=
"search_product_input"
name=
"search_product_input"
placeholder=
"Rechercher un produit..."
>
<i
class=
'fa fa-info-circle search_product_help'
title=
'Vous ne trouvez pas un produit ? Les produits déjà dans la commande ou déjà sélectionnés ont été retirés de la liste.'
>
</i>
</div>
</div>
<div
class=
"products_lines"
>
<div
class=
"products_lines"
>
<p
class=
"products_lines_title"
>
<p
class=
"products_lines_title"
>
...
@@ -202,7 +207,6 @@
...
@@ -202,7 +207,6 @@
</p>
</p>
</div>
</div>
<hr
/>
<hr
/>
<i>
Attention : le processus peut prendre un certain temps.
</i>
</div>
</div>
<div
id=
"add_product_line_template"
>
<div
id=
"add_product_line_template"
>
<div
class=
"add_product_line"
>
<div
class=
"add_product_line"
>
...
...
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