diff --git a/inc/myco.js b/inc/myco.js
index 2bc3371..da00268 100644
--- a/inc/myco.js
+++ b/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=function(group,contributor_email) {
+show_contributions=function(group,contributor_email,contributions) {
var tbody=$($('#view-group #contributions tbody')[0]);
tbody.html('');
total=$($('#view-group #total-value')[0]);
- contributions=group.contributionsByContributorEmail(contributor_email);
- contributions.reverse();
+ if (!contributions) {
+ contributions=group.contributionsByContributorEmail(contributor_email);
+ contributions.reverse();
+ }
if (contributions.length==0) {
tbody.append('
Aucune contributions |
');
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
@@ -953,6 +969,8 @@ $( document ).ready( function() {
$('#categories_group_btn').bind('click',on_categories_group_btn_click);
$('#trash_group_btn').bind('click',on_trash_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 button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
diff --git a/inc/myco_objects.js b/inc/myco_objects.js
index f23d72b..5bac102 100644
--- a/inc/myco_objects.js
+++ b/inc/myco_objects.js
@@ -336,6 +336,17 @@ function Group(uuid,name,data) {
cb(matches);
};
}
+
+ 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) {
var ret={};
diff --git a/index.html b/index.html
index 139ec09..7c5ad9a 100644
--- a/index.html
+++ b/index.html
@@ -277,6 +277,11 @@ span.cat-color {