Replace usage of view-group h1 HTML content as group name reference by an input[type=hidden]

This commit is contained in:
Benjamin Renard 2014-01-06 03:03:17 +01:00
parent 1db9f37d04
commit 0da244586b
2 changed files with 13 additions and 11 deletions

View file

@ -59,7 +59,8 @@ on_group_choice_click=function(e) {
* View group * View group
****************/ ****************/
view_group=function(group) { view_group=function(group) {
$('#view-group h1').html(group.name); $('#view-group h1 span:first').html(group.name);
$('#view-group #group_name')[0].value=group.name;
set_contributors(group); set_contributors(group);
on_contributor_change(); on_contributor_change();
$('#view-group').css('display','block'); $('#view-group').css('display','block');
@ -78,7 +79,7 @@ set_contributors=function(group) {
} }
on_contributor_change=function(e) { on_contributor_change=function(e) {
show_contributions(groups[$('#view-group h1').html()],$('#view-group #contributor')[0].value); show_contributions(groups[$('#view-group #group_name')[0].value],$('#view-group #contributor')[0].value);
} }
show_contributions=function(group,contributor_name) { show_contributions=function(group,contributor_name) {
@ -108,7 +109,7 @@ show_contributions=function(group,contributor_name) {
* Add contributor * Add contributor
*********************/ *********************/
on_click_add_contributor_btn=function() { on_click_add_contributor_btn=function() {
$('#add_contributor_modal #group_name')[0].value=$($('#view-group h1')[0]).html(); $('#add_contributor_modal #group_name')[0].value=$('#view-group #group_name')[0].value;
$('#add_contributor_modal').modal('show'); $('#add_contributor_modal').modal('show');
} }
@ -157,7 +158,7 @@ on_click_del_contributor_btn=function() {
} }
on_confirm_del_contributor=function(contributor) { on_confirm_del_contributor=function(contributor) {
var group=groups[$($('#view-group h1')[0]).html()]; var group=groups[$('#view-group #group_name')[0].value];
group.removeContributor(contributor); group.removeContributor(contributor);
set_contributors(group); set_contributors(group);
groups.save(); groups.save();
@ -177,7 +178,7 @@ on_show_add_contribution_modal=function(e) {
} }
on_click_add_contribution_btn=function() { on_click_add_contribution_btn=function() {
$('#add_contribution_modal #group_name')[0].value=$($('#view-group h1')[0]).html(); $('#add_contribution_modal #group_name')[0].value=$('#view-group #group_name')[0].value;
$('#add_contribution_modal #edit_id')[0].value='-1'; $('#add_contribution_modal #edit_id')[0].value='-1';
$('#add_contribution_modal').modal('show'); $('#add_contribution_modal').modal('show');
} }
@ -245,7 +246,7 @@ on_close_add_contribution_modal=function () {
} }
on_contribution_delete_btn_click=function(e) { on_contribution_delete_btn_click=function(e) {
var group=groups[$($('#view-group h1')[0]).html()]; var group=groups[$('#view-group #group_name')[0].value];
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];
myconfirm('Etes-vous sûre de vouloir supprimer la participation '+contribution.getTitle()+' de '+contribution.contributor.name+' ?',on_confirm_contribution_delete,null,{'group':group,'contribution_id':contribution_id, 'contribution': contribution} ); myconfirm('Etes-vous sûre de vouloir supprimer la participation '+contribution.getTitle()+' de '+contribution.contributor.name+' ?',on_confirm_contribution_delete,null,{'group':group,'contribution_id':contribution_id, 'contribution': contribution} );
@ -258,8 +259,8 @@ on_confirm_contribution_delete=function(data) {
} }
on_contribution_edit_btn_click=function(e) { on_contribution_edit_btn_click=function(e) {
var group=groups[$($('#view-group h1')[0]).html()]; var group=groups[$('#view-group #group_name')[0].value];
$('#add_contribution_modal #group_name')[0].value=$($('#view-group h1')[0]).html(); $('#add_contribution_modal #group_name')[0].value=$('#view-group #group_name')[0].value;
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;
@ -291,7 +292,7 @@ on_confirm_clear_local_data=function(data) {
*********************/ *********************/
on_display_balance_btn_click=function(e) { on_display_balance_btn_click=function(e) {
group=groups[$($('#view-group h1')[0]).html()]; group=groups[$('#view-group #group_name')[0].value];
display_balance(group); display_balance(group);
} }
@ -313,7 +314,7 @@ display_balance=function(group) {
*********************/ *********************/
on_remove_group_btn_click=function(e) { on_remove_group_btn_click=function(e) {
group=groups[$($('#view-group h1')[0]).html()]; 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);
} }

View file

@ -74,8 +74,9 @@ body{
<div class="container"> <div class="container">
<div id='view-group' class='part hidden-part'> <div id='view-group' class='part hidden-part'>
<h1>Noël</h1> <h1><span>Noël</span><small><span id='edit_group_btn' class='glyphicon glyphicon-edit btn btn-sm'></span></small></h1>
<form class="form-horizontal" role="form"> <form class="form-horizontal" role="form">
<input type='hidden' id='group_name' value='Noël'/>
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon">Participant</span> <span class="input-group-addon">Participant</span>