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
45b3fc2a
Commit
45b3fc2a
authored
Jul 07, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REC: unmerge orders
parent
53f28cc4
Pipeline
#2304
passed with stage
in 1 minute 25 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
16 deletions
+128
-16
reception_style.css
reception/static/css/reception_style.css
+23
-0
reception_index.js
reception/static/js/reception_index.js
+92
-15
reception_produits.js
reception/static/js/reception_produits.js
+0
-0
index.html
templates/reception/index.html
+13
-1
No files found.
reception/static/css/reception_style.css
View file @
45b3fc2a
...
...
@@ -15,6 +15,11 @@ input[type="number"] {
margin-bottom
:
5px
;
}
.group_line_content
{
display
:
flex
;
align-items
:
center
;
}
#orders
tbody
tr
{
cursor
:
pointer
;
}
...
...
@@ -44,6 +49,24 @@ input[type="number"] {
color
:
#e62720
;
}
.group_partner_name
{
margin
:
0
3px
;
}
.goto_group_button
{
margin-left
:
10px
;
}
.ungroup_orders_icon
{
margin-left
:
15px
;
color
:
#d9534f
;
cursor
:
pointer
;
}
.ungroup_precisions
{
font-style
:
italic
;
}
/* PRODUITS */
.page_body
{
height
:
100%
;
...
...
reception/static/js/reception_index.js
View file @
45b3fc2a
...
...
@@ -289,6 +289,59 @@ function group_action() {
}
}
/**
* Remove an orders group.
* Correctly set orders data so ungrouping goes smoothly.
*
* @param {int} group_index index in the groups array
*/
function
ungroup
(
group_index
)
{
let
group
=
order_groups
.
groups
[
group_index
];
for
(
let
order_id
of
group
)
{
let
order_doc_id
=
'order_'
+
order_id
;
// Delete group data in each order
dbc
.
get
(
order_doc_id
).
then
((
doc
)
=>
{
if
(
"updated_products"
in
doc
)
{
for
(
let
i
=
0
;
i
<
doc
.
updated_products
.
length
;
i
++
)
{
delete
(
doc
.
updated_products
[
i
].
other_orders_data
);
}
doc
.
last_update
=
{
timestamp
:
Date
.
now
(),
fingerprint
:
fingerprint
};
dbc
.
put
(
doc
).
then
(()
=>
{})
.
catch
((
err
)
=>
{
error
=
{
msg
:
'Erreur dans la creation de la commande dans couchdb'
,
ctx
:
'create_order_doc'
,
details
:
err
};
report_JS_error
(
error
,
'reception'
);
console
.
log
(
error
);
});
}
})
.
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
order_groups
.
groups
.
splice
(
group_index
,
1
);
dbc
.
put
(
order_groups
,
(
err
,
result
)
=>
{
if
(
!
err
)
{
order_groups
.
_rev
=
result
.
rev
;
display_orders_table
();
display_grouped_orders
();
}
else
{
console
.
log
(
err
);
}
});
}
/* DISPLAY */
/**
...
...
@@ -296,7 +349,6 @@ function group_action() {
* Remove the grouped orders from the order table to prevent grouping in multiple groups.
*/
function
display_grouped_orders
()
{
if
(
table_orders
!==
null
)
{
var
display_something
=
false
;
...
...
@@ -326,33 +378,57 @@ function display_grouped_orders() {
// Display group
display_something
=
true
;
document
.
getElementById
(
"container_groups"
).
hidden
=
false
;
let
group_row
=
`<li class="group_line"> Commandes de `
;
let
group_row
=
`<li class="group_line"
group_index="
${
group_index
}
"><span class="group_line_content"
> Commandes de `
;
for
(
let
i
in
group_orders
)
{
if
(
i
==
group_orders
.
length
-
1
)
{
// last element of list
group_row
+=
"<b>"
+
group_orders
[
i
].
partner
+
"</b> du "
+
group_orders
[
i
].
date_order
+
" : "
;
}
else
{
group_row
+=
"<b>"
+
group_orders
[
i
].
partner
+
"</b> du "
+
group_orders
[
i
].
date_order
+
", "
;
group_row
+=
`<b class="group_partner_name">
${
group_orders
[
i
].
partner
}
</b> du
${
group_orders
[
i
].
date_order
}
`
;
if
(
i
!=
group_orders
.
length
-
1
)
{
// for other elements than last of list
group_row
+=
", "
;
}
}
if
(
group_orders
[
0
].
reception_status
==
'False'
)
{
group_row
+=
"<button class='btn--primary' onClick='group_goto("
+
group_index
+
")'>Compter les produits</button>"
;
group_row
+=
`
<button class='btn--primary goto_group_button' onClick='group_goto(
${
group_index
}
)'>
Compter les produits
</button>`
;
}
else
{
group_row
+=
"<button class='btn--success' onClick='group_goto("
+
group_index
+
")'>Mettre à jour les prix</button>"
;
group_row
+=
`
<button class='btn--success goto_group_button' onClick='group_goto(
${
group_index
}
)'>
Mettre à jour les prix
</button>`
;
}
group_row
+=
"</li>"
;
group_row
+=
`<i class="fas fa-times fa-lg ungroup_orders_icon"></i>`
;
group_row
+=
"</span></li>"
;
groups_display_content
+=
group_row
;
}
}
if
(
display_something
===
true
)
{
$
(
'#container_groups'
).
show
();
$
(
'#groups_items'
).
append
(
groups_display_content
);
setTimeout
(()
=>
{
$
(
".ungroup_orders_icon"
).
off
(
"click"
);
$
(
".ungroup_orders_icon"
).
on
(
"click"
,
function
()
{
let
modal_template
=
$
(
"#modal_delete_group"
);
let
group_to_delete_index
=
$
(
this
).
closest
(
".group_line"
)
.
attr
(
"group_index"
);
openModal
(
modal_template
.
html
(),
()
=>
{
ungroup
(
group_to_delete_index
);
},
"Confirmer"
);
});
},
100
);
}
else
{
$
(
'#container_groups'
).
hide
();
}
}
}
...
...
@@ -593,9 +669,8 @@ $(document).ready(function() {
order_groups
=
doc
;
})
.
catch
(
function
(
err
)
{
console
.
log
(
err
);
if
(
err
.
status
===
404
)
{
// Create if doesn't exist
// Create if doesn't exist
dbc
.
put
(
order_groups
,
(
err
,
result
)
=>
{
if
(
!
err
)
{
order_groups
.
_rev
=
result
.
rev
;
...
...
@@ -604,6 +679,8 @@ $(document).ready(function() {
console
.
log
(
err
);
}
});
}
else
{
console
.
log
(
err
);
}
});
...
...
reception/static/js/reception_produits.js
View file @
45b3fc2a
This diff is collapsed.
Click to expand it.
templates/reception/index.html
View file @
45b3fc2a
...
...
@@ -59,7 +59,19 @@
</p><br/>
<p>
Voulez-vous quand même y accéder ?
</p>
<hr/>
</div>
</div>
<div
id=
"modal_delete_group"
>
<h3>
Attention !
</h3>
<p>
Vous vous apprêtez à défusionner un groupe de commandes.
</p>
<p>
Il est conseillé de conserver les groupes jusqu'au bout de la réception autant que possible,
par soucis de cohérence du rapport de réception.
</p>
<p>
Si vous souhaitez tout de même défusionner les commandes, cliquez sur Confirmer.
<br/>
<span
class=
"ungroup_precisions"
>
Les données de réception des différentes commandes seront concervées.
</span>
</p>
</div>
</div>
<br/>
...
...
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