Commit b6673825 by Damien Moulard

display member in shift template management

parent 52bf5444
Pipeline #1926 passed with stage
in 1 minute 27 seconds
......@@ -26,8 +26,7 @@ class CagetteMember(models.Model):
'display_ftop_points', 'display_std_points',
'is_exempted', 'cooperative_state', 'date_alert_stop']
m_shoft_default_fields = ['name', 'barcode_base', 'total_partner_owned_share',
'amount_subscription']
m_short_default_fields = ['name', 'barcode_base']
def __init__(self, id):
"""Init with odoo id."""
......@@ -96,7 +95,6 @@ class CagetteMember(models.Model):
# # # BDM
def save_partner_info(self, partner_id, fieldsDatas):
print(fieldsDatas)
return self.o_api.update('res.partner', partner_id, fieldsDatas)
......@@ -775,8 +773,26 @@ class CagetteMember(models.Model):
members.append(m)
return CagetteMember.add_next_shifts_to_members(members)
elif search_type == "shift_template_data":
fields = CagetteMember.m_short_default_fields
fields = fields + ['id', 'makeups_to_do', 'cooperative_state']
res = api.search_read('res.partner', cond, fields)
if res:
c = [['partner_id', '=', int(res[0]['id'])]]
f = ['shift_template_id']
shift_template_reg = api.search_read('shift.template.registration', c, f)
if shift_template_reg:
res[0]['shift_template_name'] = shift_template_reg[0]['shift_template_id'][1]
else:
res[0]['shift_template_name'] = None
return res
else:
fields = CagetteMember.m_shoft_default_fields
# TODO differentiate short & subscription_data searches
fields = CagetteMember.m_short_default_fields
fields = fields + ['total_partner_owned_share','amount_subscription']
res = api.search_read('res.partner', cond, fields)
return res
......
......@@ -50,3 +50,26 @@
.btn_possible_member {
margin: 0.5rem 1rem;
}
/* Member info area */
#partner_data_area {
width: 80%;
display: none;
flex-direction: column;
align-items: center;
border-radius: 30px;
margin: 30px auto;
padding: 15px;
box-shadow: 2px 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1);
}
.member_name_container {
margin: 1rem 0 2rem 0;
}
.member_name_icon {
color: #00a573;
margin-right: 5px;
}
.member_info {
font-weight: bold;
}
var selected_member = null,
possible_cooperative_state = {
suspended: "Rattrapage",
exempted: "Exempté.e",
alert: "En alerte",
up_to_date: "À jour",
unsubscribed: "Désinscrit.e des créneaux",
delay: "En délai",
gone: "Parti.e"
};
/**
* When a member is selected, display the selected member relevant info
*/
function display_member_info() {
$('.member_name').text(`${selected_member.barcode_base} - ${selected_member.name}`);
$('.member_shift').text(selected_member.shift_template_name);
$('.member_status').text(possible_cooperative_state[selected_member.cooperative_state]);
$('.member_makeups').text(selected_member.makeups_to_do);
$('#search_member_input').val();
$('#partner_data_area').css('display', 'flex');
}
/**
* Display the members from the search result
*/
......@@ -27,8 +51,7 @@
for (member of members_search_results) {
if (member.id == $(this).attr('member_id')) {
selected_member = member;
// TODO display member
display_member_info();
$('.search_member_results').empty();
$('.search_member_results_area').hide();
......@@ -51,7 +74,6 @@
$(document).ready(function() {
if (coop_is_connected()) {
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
$(".page_content").show();
} else {
$(".page_content").hide();
......@@ -67,18 +89,16 @@ $(document).ready(function() {
let search_str = $('#search_member_input').val();
$.ajax({
url: '/members/search/' + search_str,
url: `/members/search/${search_str}?search_type=shift_template_data`,
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);
}
}
if (data.res.length === 1) {
selected_member = data.res[0];
display_member_info();
} else {
members_search_results = data.res;
display_possible_members();
}
},
error: function() {
err = {
......
......@@ -34,15 +34,15 @@
<span class="management_type_button_icons"><i class="fas fa-wrench"></i></span>
{# <span class="management_type_button_icons"><i class="fas fa-arrow-right"></i></span> #}
</button><br>
<button type="button" class="btn--primary management_type_button" id="manage_regular_shifts_button">
Gestion des créneaux
<span class="management_type_button_icons"><i class="fas fa-arrow-right"></i></span>
</button><br>
<button type="button" class="btn--primary management_type_button" id="manage_leaves_button" disabled>
Gestion des congés
<span class="management_type_button_icons"><i class="fas fa-wrench"></i></span>
{# <span class="management_type_button_icons"><i class="fas fa-arrow-right"></i></span> #}
</button><br>
<button type="button" class="btn--primary management_type_button" id="manage_regular_shifts_button">
Gestion des créneaux
<span class="management_type_button_icons"><i class="fas fa-arrow-right"></i></span>
</button><br>
</div>
</div>
</div>
......
......@@ -42,7 +42,15 @@
<div class="search_member_results"></div>
</div>
</div>
<div id="partner_data_area">
<h4 class="member_name_container">
<i class="fas fa-user member_name_icon"></i>
<span class="member_info member_name"></span>
</h4>
<p class="shift_name_container">Créneau : <span class="member_info member_shift"></span></p>
<p class="status_container">Statut : <span class="member_info member_status"></span></p>
<p class="makeups_container">Nb rattrapage(s) : <span class="member_info member_makeups"></span></p>
</div>
</div>
<div id="templates" style="display:none;"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment