Add search contributions feature
This commit is contained in:
parent
384ead0025
commit
2272ff551b
3 changed files with 37 additions and 3 deletions
20
inc/myco.js
20
inc/myco.js
|
@ -172,12 +172,14 @@ on_contributor_change=function(e) {
|
||||||
show_contributions(groups[$('#view-group').data('uuid')],$('#view-group #contributor')[0].value);
|
show_contributions(groups[$('#view-group').data('uuid')],$('#view-group #contributor')[0].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_contributions=function(group,contributor_email) {
|
show_contributions=function(group,contributor_email,contributions) {
|
||||||
var tbody=$($('#view-group #contributions tbody')[0]);
|
var tbody=$($('#view-group #contributions tbody')[0]);
|
||||||
tbody.html('');
|
tbody.html('');
|
||||||
total=$($('#view-group #total-value')[0]);
|
total=$($('#view-group #total-value')[0]);
|
||||||
|
if (!contributions) {
|
||||||
contributions=group.contributionsByContributorEmail(contributor_email);
|
contributions=group.contributionsByContributorEmail(contributor_email);
|
||||||
contributions.reverse();
|
contributions.reverse();
|
||||||
|
}
|
||||||
if (contributions.length==0) {
|
if (contributions.length==0) {
|
||||||
tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
|
tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
|
||||||
total.html('0,00 €');
|
total.html('0,00 €');
|
||||||
|
@ -297,6 +299,20 @@ on_categories_group_add_btn_click=function(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
on_nav_search_form_submit=function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
on_nav_search_form_input=function(e) {
|
||||||
|
var ipt=$(e.target);
|
||||||
|
var pattern=ipt.val();
|
||||||
|
|
||||||
|
group=groups[$('#view-group').data('uuid')];
|
||||||
|
|
||||||
|
var found=group.searchContributions(pattern);
|
||||||
|
show_contributions(group,null,found);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
* Trash
|
* Trash
|
||||||
|
@ -953,6 +969,8 @@ $( document ).ready( function() {
|
||||||
$('#categories_group_btn').bind('click',on_categories_group_btn_click);
|
$('#categories_group_btn').bind('click',on_categories_group_btn_click);
|
||||||
$('#trash_group_btn').bind('click',on_trash_group_btn_click);
|
$('#trash_group_btn').bind('click',on_trash_group_btn_click);
|
||||||
$('#remove_group_btn').bind('click',on_remove_group_btn_click);
|
$('#remove_group_btn').bind('click',on_remove_group_btn_click);
|
||||||
|
$('#nav-search-form').bind('submit',on_nav_search_form_submit);
|
||||||
|
$('#nav-search-form input').bind('input',on_nav_search_form_input);
|
||||||
|
|
||||||
$('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click);
|
$('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click);
|
||||||
$("#view-group-categories button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
|
$("#view-group-categories button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
|
||||||
|
|
|
@ -337,6 +337,17 @@ function Group(uuid,name,data) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.searchContributions=function(pattern) {
|
||||||
|
var ret=[];
|
||||||
|
substrRegex = new RegExp(pattern, 'i');
|
||||||
|
for (uuid in this.contributions) {
|
||||||
|
if (substrRegex.test(this.contributions[uuid].title) || substrRegex.test(this.contributions[uuid].cost)) {
|
||||||
|
ret.push(this.contributions[uuid]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
this.getContributionsByCategory=function (category) {
|
this.getContributionsByCategory=function (category) {
|
||||||
var ret={};
|
var ret={};
|
||||||
for (uuid in this.contributions) {
|
for (uuid in this.contributions) {
|
||||||
|
|
|
@ -277,6 +277,11 @@ span.cat-color {
|
||||||
<button class="btn btn-default" id='display_balance_btn'><span class='glyphicon glyphicon-euro'></span> Balance</span></button>
|
<button class="btn btn-default" id='display_balance_btn'><span class='glyphicon glyphicon-euro'></span> Balance</span></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="bottom-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bottom-navbar-collapse-1">
|
||||||
|
<form class="navbar-form navbar-right" role="search" id='nav-search-form'>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" class="form-control" placeholder="Rechercher">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li><a id='categories_group_btn'><span class='glyphicon glyphicon-th-list'></span> Catégories</span></a></li>
|
<li><a id='categories_group_btn'><span class='glyphicon glyphicon-th-list'></span> Catégories</span></a></li>
|
||||||
<li><a id='trash_group_btn'><span class='glyphicon glyphicon-trash'></span> Corbeille</span></a></li>
|
<li><a id='trash_group_btn'><span class='glyphicon glyphicon-trash'></span> Corbeille</span></a></li>
|
||||||
|
|
Loading…
Reference in a new issue