Commit 50878b74 by Thibault Grandjean

lint

parent 1a90ffeb
Pipeline #1906 passed with stage
in 1 minute 28 seconds
...@@ -23,11 +23,11 @@ function load_member_infos(divId, memberId) { ...@@ -23,11 +23,11 @@ function load_member_infos(divId, memberId) {
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
success: function(data) { success: function(data) {
if (divId === 'parentInfo') { if (divId === 'parentInfo') {
parentId = data.member.id parentId = data.member.id;
} else if (divId === 'childInfo') { } else if (divId === 'childInfo') {
childId = data.member.id childId = data.member.id;
} }
display_member_infos(divId, data.member) display_member_infos(divId, data.member);
}, },
error: function(data) { error: function(data) {
err = {msg: "erreur serveur lors de la récupération des infos du membre", ctx: 'load_member_infos'}; err = {msg: "erreur serveur lors de la récupération des infos du membre", ctx: 'load_member_infos'};
...@@ -44,8 +44,9 @@ function load_member_infos(divId, memberId) { ...@@ -44,8 +44,9 @@ function load_member_infos(divId, memberId) {
function ready_for_submission() { function ready_for_submission() {
if (parentId != null && childId != null) { if (parentId != null && childId != null) {
console.log("ready") console.log("ready");
return true
return true;
} }
} }
...@@ -53,26 +54,31 @@ function ready_for_submission() { ...@@ -53,26 +54,31 @@ function ready_for_submission() {
* Display member info * Display member info
*/ */
function display_member_infos(divId, memberData) { function display_member_infos(divId, memberData) {
console.log(memberData) console.log(memberData);
$("#" + divId).show() $("#" + divId).show();
$("#" + divId).find(".member_name").text(memberData.name) $("#" + divId).find(".member_name")
$("#" + divId).find(".member_status").text(possible_cooperative_state[memberData.cooperative_state]) .text(memberData.name);
$("#" + divId).find(".member_shift_name").text(memberData.current_template_name); $("#" + divId).find(".member_status")
$("#" + divId).find(".member_makeups_to_do").text(memberData.makeups_to_do); .text(possible_cooperative_state[memberData.cooperative_state]);
$("#" + divId).find(".member_shift_name")
.text(memberData.current_template_name);
$("#" + divId).find(".member_makeups_to_do")
.text(memberData.makeups_to_do);
if (memberData.is_associated_people === false) { if (memberData.is_associated_people === false) {
$("#" + divId).find(".member_associated_partner_area").hide(); $("#" + divId).find(".member_associated_partner_area")
.hide();
} }
if (parentId != null && childId != null) { if (parentId != null && childId != null) {
$("#createPair").prop("disabled", false) $("#createPair").prop("disabled", false);
} }
} }
/** /**
* Load attached members * Load attached members
*/ */
function load_attached_members() { function load_attached_members() {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: "/members/get_attached_members", url: "/members/get_attached_members",
...@@ -93,13 +99,13 @@ function display_member_infos(divId, memberData) { ...@@ -93,13 +99,13 @@ function display_member_infos(divId, memberData) {
closeModal(); closeModal();
alert('Erreur serveur lors de la récupération des membres avec rattrapage. Ré-essayez plus tard.'); alert('Erreur serveur lors de la récupération des membres avec rattrapage. Ré-essayez plus tard.');
} }
}); });
} }
/** /**
* Display table of attached members * Display table of attached members
*/ */
function display_attached_members() { function display_attached_members() {
// load_attached_members() // load_attached_members()
// var attached_members_table = $('#attached_members_table') // var attached_members_table = $('#attached_members_table')
...@@ -128,7 +134,7 @@ function display_member_infos(divId, memberData) { ...@@ -128,7 +134,7 @@ function display_member_infos(divId, memberData) {
}, },
{ {
data: "name", data: "name",
title: "en binôme avec", title: "en binôme avec"
}, },
{ {
data: "action", data: "action",
...@@ -183,7 +189,7 @@ function display_member_infos(divId, memberData) { ...@@ -183,7 +189,7 @@ function display_member_infos(divId, memberData) {
"1": "1 ligne séléctionnée" "1": "1 ligne séléctionnée"
} }
} }
}, }
}); });
...@@ -191,7 +197,7 @@ function display_member_infos(divId, memberData) { ...@@ -191,7 +197,7 @@ function display_member_infos(divId, memberData) {
function delete_pair(childId) { function delete_pair(childId) {
var payload = {"child": {"id": childId}} var payload = {"child": {"id": childId}};
$.ajax({ $.ajax({
type: "POST", type: "POST",
...@@ -213,7 +219,7 @@ function delete_pair(childId) { ...@@ -213,7 +219,7 @@ function delete_pair(childId) {
closeModal(); closeModal();
alert('Erreur serveur lors de la désolidarisation du binôme. Ré-essayez plus tard.'); alert('Erreur serveur lors de la désolidarisation du binôme. Ré-essayez plus tard.');
} }
}) });
} }
$(document).ready(function() { $(document).ready(function() {
...@@ -247,8 +253,8 @@ $(document).ready(function() { ...@@ -247,8 +253,8 @@ $(document).ready(function() {
return { return {
label: item.barcode_base + ' ' + item.name, label: item.barcode_base + ' ' + item.name,
value: item.id value: item.id
} };
})) }));
}, },
error: function() { error: function() {
err = { err = {
...@@ -261,9 +267,8 @@ $(document).ready(function() { ...@@ -261,9 +267,8 @@ $(document).ready(function() {
globalPosition:"top right", globalPosition:"top right",
className: "error" className: "error"
}); });
},
} }
) });
}, },
minLength: 1, minLength: 1,
search: function(event, ui) { search: function(event, ui) {
...@@ -272,15 +277,16 @@ $(document).ready(function() { ...@@ -272,15 +277,16 @@ $(document).ready(function() {
response: function(event, ui) { response: function(event, ui) {
$('#spinner1').hide(); $('#spinner1').hide();
}, },
select: function( event, ui ) { select: function(event, ui) {
event.preventDefault(); event.preventDefault();
if (ui.item) { if (ui.item) {
load_member_infos("parentInfo", ui.item.value) load_member_infos("parentInfo", ui.item.value);
$('#search_member_input').val(ui.item.label) $('#search_member_input').val(ui.item.label);
return false
return false;
} }
} }
}) });
$("#search_child_input").autocomplete({source: function(request, response) { $("#search_child_input").autocomplete({source: function(request, response) {
$.ajax({ $.ajax({
...@@ -293,13 +299,13 @@ $(document).ready(function() { ...@@ -293,13 +299,13 @@ $(document).ready(function() {
members_search_results.push(member); members_search_results.push(member);
} }
} }
console.log(members_search_results) console.log(members_search_results);
response($.map(data.res, function(item) { response($.map(data.res, function(item) {
return { return {
label: item.barcode_base + ' ' + item.name, label: item.barcode_base + ' ' + item.name,
value: item.id value: item.id
} };
})) }));
}, },
error: function() { error: function() {
err = { err = {
...@@ -312,9 +318,8 @@ $(document).ready(function() { ...@@ -312,9 +318,8 @@ $(document).ready(function() {
globalPosition:"top right", globalPosition:"top right",
className: "error" className: "error"
}); });
},
} }
) });
}, },
minLength: 1, minLength: 1,
search: function(event, ui) { search: function(event, ui) {
...@@ -323,20 +328,21 @@ $(document).ready(function() { ...@@ -323,20 +328,21 @@ $(document).ready(function() {
response: function(event, ui) { response: function(event, ui) {
$('#spinner2').hide(); $('#spinner2').hide();
}, },
select: function( event, ui ) { select: function(event, ui) {
if (ui.item) { if (ui.item) {
load_member_infos("childInfo", ui.item.value) load_member_infos("childInfo", ui.item.value);
$('#search_child_input').val(ui.item.label) $('#search_child_input').val(ui.item.label);
return false
return false;
} }
}, }
}) });
$("#createPair").on('click', function() { $("#createPair").on('click', function() {
var payload = { var payload = {
"parent": {"id": parentId}, "parent": {"id": parentId},
"child": {"id": childId} "child": {"id": childId}
} };
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
...@@ -345,7 +351,7 @@ $(document).ready(function() { ...@@ -345,7 +351,7 @@ $(document).ready(function() {
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
data: JSON.stringify(payload), data: JSON.stringify(payload),
success: function(data) { success: function(data) {
alert("binôme créé") alert("binôme créé");
}, },
error: function(data) { error: function(data) {
err = {msg: "erreur serveur", ctx: 'create pair'}; err = {msg: "erreur serveur", ctx: 'create pair'};
...@@ -355,19 +361,23 @@ $(document).ready(function() { ...@@ -355,19 +361,23 @@ $(document).ready(function() {
report_JS_error(err, 'members.admin'); report_JS_error(err, 'members.admin');
closeModal(); closeModal();
var message = 'Erreur lors de création du binôme.' var message = 'Erreur lors de création du binôme.';
data.responseJSON.errors.map(function(error){ message += ('\n' + error)})
data.responseJSON.errors.map(function(error) {
message += ('\n' + error);
});
alert(message); alert(message);
} }
}) });
}); });
if ($("#attached_members_table") != "undefined") { if ($("#attached_members_table") != "undefined") {
load_attached_members() load_attached_members();
} }
$(document).on('click', '.delete_pair', function (event) { $(document).on('click', '.delete_pair', function (event) {
var childId = event.target.id.split('_').slice(-1)[0] var childId = event.target.id.split('_').slice(-1)[0];
delete_pair(childId)
}) delete_pair(childId);
}) });
});
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