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
74b71e5d
Commit
74b71e5d
authored
Nov 16, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add makeups from members admin
parent
6fdd55b7
Pipeline
#1437
failed with stage
in 1 minute 34 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
258 additions
and
16 deletions
+258
-16
admin.py
members/admin.py
+1
-1
members_admin.css
members/static/css/members_admin.css
+34
-1
members_admin.js
members/static/js/members_admin.js
+198
-5
index.html
templates/members/admin/index.html
+25
-9
No files found.
members/admin.py
View file @
74b71e5d
...
...
@@ -244,7 +244,7 @@ def get_makeups_members(request):
return
JsonResponse
({
'res'
:
res
})
def
update_members_makeups
(
request
):
"""
Décrémente
les rattrapages des membres passés dans la requête """
"""
Met à jour
les rattrapages des membres passés dans la requête """
res
=
{}
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
if
is_connected_user
is
True
:
...
...
members/static/css/members_admin.css
View file @
74b71e5d
...
...
@@ -70,10 +70,42 @@
}
.decrement_makeup
{
padding
:
0.4rem
1.25rem
;
margin-left
:
10px
;
}
.decrement_makeup
,
.increment_makeup
{
padding
:
0.4rem
1.25rem
;
}
.select_member_cb
{
cursor
:
pointer
;
}
/* Search membres area */
#add_members_area
{
margin-top
:
30px
;
}
#add_members_form_area
{
display
:
flex
;
align-items
:
center
;
}
#search_member_form
{
margin-left
:
10px
;
}
.search_member_results_area
{
margin-top
:
15px
;
display
:
flex
;
align-items
:
center
;
}
.search_member_results
{
display
:
flex
;
flex-wrap
:
wrap
;
}
.btn_possible_member
{
margin
:
0
1rem
;
}
\ No newline at end of file
members/static/js/members_admin.js
View file @
74b71e5d
var
makeups_members_table
=
null
,
makeups_members
=
null
,
members_search_results
=
[],
selected_rows
=
[];
// Contain members id
function
switch_active_tab
()
{
...
...
@@ -102,7 +103,10 @@ function display_makeups_members() {
render
:
function
(
data
,
type
,
full
)
{
return
`<b>
${
data
}
</b>
<button class="decrement_makeup btn--primary" id="decrement_member_
${
full
.
id
}
">
<i class="fas fa-arrow-down"></i>
<i class="fas fa-minus"></i>
</button>
<button class="increment_makeup btn--primary" id="increment_member_
${
full
.
id
}
">
<i class="fas fa-plus"></i>
</button>`
;
}
}
...
...
@@ -120,7 +124,35 @@ function display_makeups_members() {
]
],
iDisplayLength
:
-
1
,
language
:
{
url
:
'/static/js/datatables/french.json'
}
oLanguage
:
{
"sProcessing"
:
"Traitement en cours..."
,
"sSearch"
:
"Rechercher dans le tableau"
,
"sLengthMenu"
:
"Afficher _MENU_ éléments"
,
"sInfo"
:
"Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments"
,
"sInfoEmpty"
:
"Affichage de l'élément 0 à 0 sur 0 élément"
,
"sInfoFiltered"
:
"(filtré de _MAX_ éléments au total)"
,
"sInfoPostFix"
:
""
,
"sLoadingRecords"
:
"Chargement en cours..."
,
"sZeroRecords"
:
"Aucun élément à afficher"
,
"sEmptyTable"
:
"Aucune donnée disponible dans le tableau"
,
"oPaginate"
:
{
"sFirst"
:
"Premier"
,
"sPrevious"
:
"Précédent"
,
"sNext"
:
"Suivant"
,
"sLast"
:
"Dernier"
},
"oAria"
:
{
"sSortAscending"
:
": activer pour trier la colonne par ordre croissant"
,
"sSortDescending"
:
": activer pour trier la colonne par ordre décroissant"
},
"select"
:
{
"rows"
:
{
"_"
:
"%d lignes séléctionnées"
,
"0"
:
"Aucune ligne séléctionnée"
,
"1"
:
"1 ligne séléctionnée"
}
}
}
});
$
(
'#makeups_members_table'
).
on
(
'click'
,
'tbody td .decrement_makeup'
,
function
()
{
...
...
@@ -140,6 +172,23 @@ function display_makeups_members() {
);
});
$
(
'#makeups_members_table'
).
on
(
'click'
,
'tbody td .increment_makeup'
,
function
()
{
const
button_id
=
$
(
this
).
prop
(
'id'
)
.
split
(
'_'
);
const
member_id
=
button_id
[
button_id
.
length
-
1
];
const
member
=
makeups_members
.
find
(
m
=>
m
.
id
==
member_id
);
openModal
(
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
increment_makeups
([
member_id
]);
},
"Confirmer"
,
false
);
});
$
(
'#makeups_members_table'
).
on
(
'click'
,
'tbody td .select_member_cb'
,
function
()
{
$
(
this
).
closest
(
'tr'
)
.
toggleClass
(
'selected'
);
...
...
@@ -208,18 +257,129 @@ function decrement_makeups(member_ids) {
closeModal
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur pour décrémenter les rattrapages"
,
ctx
:
'
load_makeups_member
s'
};
err
=
{
msg
:
"erreur serveur pour décrémenter les rattrapages"
,
ctx
:
'
decrement_makeup
s'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'
orders
'
);
report_JS_error
(
err
,
'
members_admin
'
);
closeModal
();
alert
(
'Erreur serveur lors de la récupération des membres avec rattrapage. Ré-essayez plus tard.'
);
alert
(
'Erreur serveur pour décrémenter les rattrapages. Ré-essayez plus tard.'
);
}
});
}
/**
* Send request to update members nb of makeups to do
* @param {Array} member_ids
*/
function
increment_makeups
(
member_ids
)
{
openModal
();
data
=
[];
for
(
mid
of
member_ids
)
{
member_index
=
makeups_members
.
findIndex
(
m
=>
m
.
id
==
mid
);
makeups_members
[
member_index
].
makeups_to_do
+=
1
;
data
.
push
({
member_id
:
mid
,
target_makeups_nb
:
makeups_members
[
member_index
].
makeups_to_do
});
}
$
.
ajax
({
type
:
'POST'
,
url
:
"/members/update_members_makeups"
,
data
:
JSON
.
stringify
(
data
),
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
()
{
selected_rows
=
[];
display_makeups_members
();
closeModal
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur pour incrémenter les rattrapages"
,
ctx
:
'increment_makeups'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members_admin'
);
closeModal
();
alert
(
'Erreur serveur pour incrémenter les rattrapages. Ré-essayez plus tard.'
);
}
});
}
/**
* Display the members from the search result
*/
function
display_possible_members
()
{
$
(
'.search_member_results_area'
).
show
();
$
(
'.search_member_results'
).
empty
();
let
no_result
=
true
;
if
(
members_search_results
.
length
>
0
)
{
for
(
member
of
members_search_results
)
{
// Don't display members already in the table
if
(
makeups_members
.
find
(
m
=>
m
.
id
==
member
.
id
)
!=
null
)
{
continue
;
}
$
(
".search_results_text"
).
show
();
no_result
=
false
;
// Display results (possible members) as buttons
var
member_button
=
'<button class="btn--success btn_possible_member" member_id="'
+
member
.
id
+
'">'
+
member
.
barcode_base
+
' - '
+
member
.
name
+
'</button>'
;
$
(
'.search_member_results'
).
append
(
member_button
);
// Set action on member button click
$
(
'.btn_possible_member'
).
on
(
'click'
,
function
()
{
for
(
member
of
members_search_results
)
{
if
(
member
.
id
==
$
(
this
).
attr
(
'member_id'
))
{
if
(
makeups_members
===
null
)
{
makeups_members
=
[];
}
makeups_members
.
unshift
({
id
:
member
.
id
,
name
:
member
.
name
,
makeups_to_do
:
0
})
openModal
(
`Ajouter un rattrapage à
${
member
.
name
}
?`
,
()
=>
{
increment_makeups
([
member
.
id
]);
members_search_results
=
[];
$
(
'#search_member_input'
).
val
(
''
);
$
(
'.search_member_results_area'
).
hide
();
$
(
'.search_member_results'
).
empty
();
},
"Confirmer"
,
false
);
break
;
}
}
});
}
}
if
(
no_result
===
true
)
{
$
(
".search_results_text"
).
hide
();
$
(
'.search_member_results'
).
html
(
`<p>
<i>Aucun résultat ! Vérifiez votre recherche, ou si le.la membre n\'est pas déjà dans le tableau...</i>
</p>`
);
}
}
$
(
document
).
ready
(
function
()
{
if
(
coop_is_connected
())
{
$
.
ajaxSetup
({
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)
}
});
...
...
@@ -231,4 +391,37 @@ $(document).ready(function() {
}
else
{
$
(
".page_content"
).
hide
();
}
// Set action to search for the member
$
(
'#search_member_form'
).
submit
(
function
()
{
let
search_str
=
$
(
'#search_member_input'
).
val
();
$
.
ajax
({
url
:
'/members/search/'
+
search_str
,
dataType
:
'json'
,
success
:
function
(
data
)
{
members_search_results
=
[];
for
(
member
of
data
.
res
)
{
if
(
member
.
is_member
||
member
.
is_associated_people
)
{
members_search_results
.
push
(
member
);
}
}
display_possible_members
();
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur lors de la recherche de membres"
,
ctx
:
'confirm_movement.search_members'
};
report_JS_error
(
err
,
'stock'
);
$
.
notify
(
"Erreur lors de la recherche de membre, il faut ré-essayer plus tard..."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
}
});
});
});
templates/members/admin/index.html
View file @
74b71e5d
...
...
@@ -28,17 +28,33 @@
</section>
<div
id=
"tab_makeups_content"
class=
"tab_content"
>
<div
id=
"table_top_area"
>
<h3>
Liste des membres devant effectuer un rattrapage
</h3>
<div
class=
"table_grouped_action"
>
<button
type=
"button"
class=
"btn--primary"
id=
"decrement_selected_members_makeups"
>
-1 rattrapage pour les membres sélectionnés
</button>
</div>
<div
id=
"table_top_area"
>
<h3>
Liste des membres devant effectuer un rattrapage
</h3>
<div
class=
"table_grouped_action"
>
<button
type=
"button"
class=
"btn--primary"
id=
"decrement_selected_members_makeups"
>
-1 rattrapage pour les membres sélectionnés
</button>
</div>
</div>
<div
class=
"table_area"
>
<table
id=
"makeups_members_table"
class=
"display"
cellspacing=
"0"
width=
"100%"
></table>
</div>
<div
id=
"add_members_area"
>
<div
id=
"add_members_form_area"
>
<h4>
Ou, ajouter un rattrapage à un.e membre
</h4>
<form
id=
"search_member_form"
action=
"javascript:;"
method=
"post"
>
<input
type=
"text"
id=
"search_member_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
<button
type=
"submit"
class=
"btn--primary"
id=
"search_member_button"
>
Recherche
</button>
</form>
</div>
<div
class=
"table_area"
>
<table
id=
"makeups_members_table"
class=
"display"
cellspacing=
"0"
width=
"100%"
></table>
<div
class=
"search_member_results_area"
style=
"display:none;"
>
<div
class=
"search_results_text"
>
<p><i>
Choisissez parmi les membres trouvés :
</i></p>
</div>
<div
class=
"search_member_results"
></div>
</div>
</div>
</div>
</div>
...
...
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