Clean code
This commit is contained in:
parent
0c60c95b9f
commit
efe943361b
3 changed files with 44 additions and 38 deletions
|
@ -6,7 +6,6 @@ refresh_group_list=function() {
|
||||||
|
|
||||||
if (groups.count()==0) {
|
if (groups.count()==0) {
|
||||||
$(grouplist).prepend('<li><a class="group-choice">Aucune groupe</a></li>');
|
$(grouplist).prepend('<li><a class="group-choice">Aucune groupe</a></li>');
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
groups.each(function(idx,group) {
|
groups.each(function(idx,group) {
|
||||||
|
@ -167,7 +166,6 @@ on_valid_add_contributor_modal=function() {
|
||||||
$('#add_contributor_name')[0].value='';
|
$('#add_contributor_name')[0].value='';
|
||||||
$('#add_contributor_email')[0].value='';
|
$('#add_contributor_email')[0].value='';
|
||||||
groups.save();
|
groups.save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_close_add_contributor_modal=function () {
|
on_close_add_contributor_modal=function () {
|
||||||
|
@ -305,8 +303,6 @@ on_contribution_edit_btn_click=function(e) {
|
||||||
contribution_id=$($(e.target).parents('div')[0]).data('id');
|
contribution_id=$($(e.target).parents('div')[0]).data('id');
|
||||||
contribution=group.contributions[contribution_id];
|
contribution=group.contributions[contribution_id];
|
||||||
$('#add_contribution_modal #add_contribution_contributor_name')[0].value=contribution.contributor.name;
|
$('#add_contribution_modal #add_contribution_contributor_name')[0].value=contribution.contributor.name;
|
||||||
console.log($('#add_contribution_modal #add_contribution_contributor_name')[0]);
|
|
||||||
console.log(contribution.contributor.name);
|
|
||||||
$('#add_contribution_modal #add_contribution_title')[0].value=contribution.getTitle();
|
$('#add_contribution_modal #add_contribution_title')[0].value=contribution.getTitle();
|
||||||
$('#add_contribution_modal #add_contribution_cost')[0].value=contribution.cost;
|
$('#add_contribution_modal #add_contribution_cost')[0].value=contribution.cost;
|
||||||
$('#add_contribution_modal #add_contribution_date')[0].value=moment(contribution.date).format('DD/MM/YYYY');
|
$('#add_contribution_modal #add_contribution_date')[0].value=moment(contribution.date).format('DD/MM/YYYY');
|
||||||
|
@ -358,7 +354,6 @@ display_balance=function(group) {
|
||||||
on_remove_group_btn_click=function(e) {
|
on_remove_group_btn_click=function(e) {
|
||||||
group=groups[$('#view-group #group_name')[0].value];
|
group=groups[$('#view-group #group_name')[0].value];
|
||||||
myconfirm('Etes-vous sûre de vouloir supprimer le group '+group.name+' ?',on_confirm_remove_group,null,group);
|
myconfirm('Etes-vous sûre de vouloir supprimer le group '+group.name+' ?',on_confirm_remove_group,null,group);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_confirm_remove_group=function(group) {
|
on_confirm_remove_group=function(group) {
|
||||||
|
|
|
@ -79,6 +79,9 @@ function Group(name,data) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contributors
|
||||||
|
*/
|
||||||
this.removeContributor=function(c) {
|
this.removeContributor=function(c) {
|
||||||
this.contributors=this.contributors.filter(function(v){
|
this.contributors=this.contributors.filter(function(v){
|
||||||
return (v.name!=c);
|
return (v.name!=c);
|
||||||
|
@ -99,6 +102,19 @@ function Group(name,data) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.addContributor=function(c) {
|
||||||
|
c.id=this.contributors.length;
|
||||||
|
this.contributors.push(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.replaceContributor=function(idx,c) {
|
||||||
|
c.id=idx;
|
||||||
|
this.contributors[idx]=c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contributions
|
||||||
|
*/
|
||||||
this.contributionsByContributorName=function(name) {
|
this.contributionsByContributorName=function(name) {
|
||||||
var ret=[];
|
var ret=[];
|
||||||
for (idx in this.contributions) {
|
for (idx in this.contributions) {
|
||||||
|
@ -119,16 +135,9 @@ function Group(name,data) {
|
||||||
this.contributions[idx]=c;
|
this.contributions[idx]=c;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addContributor=function(c) {
|
/*
|
||||||
c.id=this.contributors.length;
|
* Balance
|
||||||
this.contributors.push(c);
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
this.replaceContributor=function(idx,c) {
|
|
||||||
c.id=idx;
|
|
||||||
this.contributors[idx]=c;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.balance=function() {
|
this.balance=function() {
|
||||||
ret={}
|
ret={}
|
||||||
for (idx in this.contributors) {
|
for (idx in this.contributors) {
|
||||||
|
@ -143,6 +152,9 @@ function Group(name,data) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contructor
|
||||||
|
*/
|
||||||
if (jQuery.type(data)=='object') {
|
if (jQuery.type(data)=='object') {
|
||||||
try {
|
try {
|
||||||
this.name=data.name;
|
this.name=data.name;
|
||||||
|
@ -167,6 +179,7 @@ function Group(name,data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
alert('Une erreur est survenue en chargeant le groupe '+this.name+' depuis le cache');
|
alert('Une erreur est survenue en chargeant le groupe '+this.name+' depuis le cache');
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,6 @@ body{
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Groupe <b class="caret"></b></a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Groupe <b class="caret"></b></a>
|
||||||
<ul id="group-choice" class="dropdown-menu">
|
<ul id="group-choice" class="dropdown-menu">
|
||||||
<li><a class='group-choice'>Quotidien</a></li>
|
|
||||||
<li><a class='group-choice'>Noël</a></li>
|
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="#" id='add_group_btn' data-toggle="modal" data-target="#add_group_modal">Nouveau</a></li>
|
<li><a href="#" id='add_group_btn' data-toggle="modal" data-target="#add_group_modal">Nouveau</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue