Benjamin Renard commited on 2014-10-12 22:20:28
Showing 3 changed files, with 35 additions and 1 deletions.
... | ... |
@@ -172,12 +172,14 @@ on_contributor_change=function(e) { |
172 | 172 |
show_contributions(groups[$('#view-group').data('uuid')],$('#view-group #contributor')[0].value); |
173 | 173 |
} |
174 | 174 |
|
175 |
-show_contributions=function(group,contributor_email) { |
|
175 |
+show_contributions=function(group,contributor_email,contributions) { |
|
176 | 176 |
var tbody=$($('#view-group #contributions tbody')[0]); |
177 | 177 |
tbody.html(''); |
178 | 178 |
total=$($('#view-group #total-value')[0]); |
179 |
+ if (!contributions) { |
|
179 | 180 |
contributions=group.contributionsByContributorEmail(contributor_email); |
180 | 181 |
contributions.reverse(); |
182 |
+ } |
|
181 | 183 |
if (contributions.length==0) { |
182 | 184 |
tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>'); |
183 | 185 |
total.html('0,00 €'); |
... | ... |
@@ -297,6 +299,20 @@ on_categories_group_add_btn_click=function(e) { |
297 | 299 |
} |
298 | 300 |
} |
299 | 301 |
|
302 |
+on_nav_search_form_submit=function(e) { |
|
303 |
+ e.preventDefault(); |
|
304 |
+} |
|
305 |
+ |
|
306 |
+on_nav_search_form_input=function(e) { |
|
307 |
+ var ipt=$(e.target); |
|
308 |
+ var pattern=ipt.val(); |
|
309 |
+ |
|
310 |
+ group=groups[$('#view-group').data('uuid')]; |
|
311 |
+ |
|
312 |
+ var found=group.searchContributions(pattern); |
|
313 |
+ show_contributions(group,null,found); |
|
314 |
+} |
|
315 |
+ |
|
300 | 316 |
|
301 | 317 |
/***************************** |
302 | 318 |
* Trash |
... | ... |
@@ -953,6 +969,8 @@ $( document ).ready( function() { |
953 | 969 |
$('#categories_group_btn').bind('click',on_categories_group_btn_click); |
954 | 970 |
$('#trash_group_btn').bind('click',on_trash_group_btn_click); |
955 | 971 |
$('#remove_group_btn').bind('click',on_remove_group_btn_click); |
972 |
+ $('#nav-search-form').bind('submit',on_nav_search_form_submit); |
|
973 |
+ $('#nav-search-form input').bind('input',on_nav_search_form_input); |
|
956 | 974 |
|
957 | 975 |
$('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click); |
958 | 976 |
$("#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) { |
337 | 337 |
}; |
338 | 338 |
} |
339 | 339 |
|
340 |
+ this.searchContributions=function(pattern) { |
|
341 |
+ var ret=[]; |
|
342 |
+ substrRegex = new RegExp(pattern, 'i'); |
|
343 |
+ for (uuid in this.contributions) { |
|
344 |
+ if (substrRegex.test(this.contributions[uuid].title) || substrRegex.test(this.contributions[uuid].cost)) { |
|
345 |
+ ret.push(this.contributions[uuid]); |
|
346 |
+ } |
|
347 |
+ } |
|
348 |
+ return ret; |
|
349 |
+ } |
|
350 |
+ |
|
340 | 351 |
this.getContributionsByCategory=function (category) { |
341 | 352 |
var ret={}; |
342 | 353 |
for (uuid in this.contributions) { |
... | ... |
@@ -277,6 +277,11 @@ span.cat-color { |
277 | 277 |
<button class="btn btn-default" id='display_balance_btn'><span class='glyphicon glyphicon-euro'></span> Balance</span></button> |
278 | 278 |
</div> |
279 | 279 |
<div class="collapse navbar-collapse" id="bottom-navbar-collapse-1"> |
280 |
+ <form class="navbar-form navbar-right" role="search" id='nav-search-form'> |
|
281 |
+ <div class="form-group"> |
|
282 |
+ <input type="text" class="form-control" placeholder="Rechercher"> |
|
283 |
+ </div> |
|
284 |
+ </form> |
|
280 | 285 |
<ul class="nav navbar-nav navbar-right"> |
281 | 286 |
<li><a id='categories_group_btn'><span class='glyphicon glyphicon-th-list'></span> Catégories</span></a></li> |
282 | 287 |
<li><a id='trash_group_btn'><span class='glyphicon glyphicon-trash'></span> Corbeille</span></a></li> |
283 | 288 |