# HG changeset patch # User olivier # Date 1399288268 -7200 # Mon May 05 13:11:08 2014 +0200 # Node ID 148993d45ade86a60c845a0cc182e713b1f841be # Parent 116583b3859f919ce38a121f527ca8c8cad60d03 Changes to add dynamic time updates for day time form diff -r 116583b3859f -r 148993d45ade app/views/work_time/_user_day_table.html.erb --- a/app/views/work_time/_user_day_table.html.erb Tue Mar 04 12:41:29 2014 +0900 +++ b/app/views/work_time/_user_day_table.html.erb Mon May 05 13:11:08 2014 +0200 @@ -124,14 +124,14 @@ - <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][hours]", "", :size=>5) %> + <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][hours]", "", :size=>5, :onchange => "sumDayTimes()") %> <% if @is_registerd_backlog then %> <% if issue_pack[:cnt_childrens] != 0 || issue.closed? then %> <%= issue[:remaining_hours] %> <% else %> - <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][remaining_hours]", issue[:remaining_hours], :size=>5) %> + <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][remaining_hours]", issue[:remaining_hours], :size=>5, :onchange => "sumDayTimes()") %> <% end %> <% end %> @@ -223,14 +223,14 @@ - <%= text_field_tag("time_entry["+hour_id.to_s+"][hours]", hour.hours, :size=>5) %> + <%= text_field_tag("time_entry["+hour_id.to_s+"][hours]", hour.hours, :size=>5, :onchange => "sumDayTimes()") %> <% if @is_registerd_backlog then %> <% if issue_pack[:cnt_childrens] != 0 || hour.issue.closed? then %> <%= hour.issue[:remaining_hours] %> <% else %> - <%= text_field_tag("time_entry["+hour_id.to_s+"][remaining_hours]", hour.issue[:remaining_hours], :size=>5) %> + <%= text_field_tag("time_entry["+hour_id.to_s+"][remaining_hours]", hour.issue[:remaining_hours], :size=>5, :onchange => "sumDayTimes()") %> <% end %> <% end %> @@ -282,7 +282,7 @@ <% end %>   - <%=sprintf("%1.1f", @day_pack[:total])%> + <%=sprintf("%1.1f", @day_pack[:total])%> <% if @is_registerd_backlog then %>   <% end %> @@ -294,3 +294,4 @@ <% end %> + diff -r 116583b3859f -r 148993d45ade app/views/work_time/ajax_insert_daily.html.erb --- a/app/views/work_time/ajax_insert_daily.html.erb Tue Mar 04 12:41:29 2014 +0900 +++ b/app/views/work_time/ajax_insert_daily.html.erb Mon May 05 13:11:08 2014 +0200 @@ -30,14 +30,14 @@ - <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][hours]", "", :size=>5) %> + <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][hours]", "", :size=>5, :onchange => "sumDayTimes()") %> <% if @is_registerd_backlog then %> <% if @add_issue_children_cnt != 0 || @add_issue.closed? then %> <%= @add_issue.remaining_hours %> <% else %> - <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][remaining_hours]", @add_issue.remaining_hours, :size=>5) %> + <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][remaining_hours]", @add_issue.remaining_hours, :size=>5, :onchange => "sumDayTimes()") %> <% end %> <% end %> diff -r 116583b3859f -r 148993d45ade assets/javascripts/work_time.js --- a/assets/javascripts/work_time.js Tue Mar 04 12:41:29 2014 +0900 +++ b/assets/javascripts/work_time.js Mon May 05 13:11:08 2014 +0200 @@ -257,3 +257,27 @@ v = obj.options[index].value; obj.options[index].value = 'M'+v; } + +//------------- for user_day_table.html.erb +function sumDayTimes() { + var total=0; + var dayInputs; + + // List all Input elemnets of the page + dayInputs = document.getElementsByTagName("input"); + for (var i=0; i= 0) && (dayInputs[i].id.indexOf("hours") >= 0)) { + if (dayInputs[i].value && !isNaN(parseFloat(dayInputs[i].value))) { + // add the number to the total if it is a valid number + total = total + parseFloat(dayInputs[i].value); + } + } + } + // Set the total value to the new number, changing the style to indicate + // it is not saved, and adding the saved value as a flyover indication + var originalValue; + document.getElementById("currentTotal").innerHTML = total; + document.getElementById("currentTotal").style = 'color:#FF0000;'; +return true; +} diff -r 116583b3859f -r 148993d45ade config/locales/en.yml --- a/config/locales/en.yml Tue Mar 04 12:41:29 2014 +0900 +++ b/config/locales/en.yml Mon May 05 13:11:08 2014 +0200 @@ -30,3 +30,8 @@ wt_opt_disp_ticket_with_other_member: "[display other members ticket]" wt_opt_disp_ticket_mine_only: "[display my ticket only]" wt_bulkupdate_relations: "bulkupdate to parent" + permission_edit_work_time_total: "Edit work time totals" + permission_view_work_time_tab: "View Work time tab" + permission_view_work_time_other_member: "View other members' work time" + permission_edit_work_time_other_member: "Edit other members' work time " + wt_saved_value: "Saved timed: " diff -r 116583b3859f -r 148993d45ade config/locales/fr.yml --- a/config/locales/fr.yml Tue Mar 04 12:41:29 2014 +0900 +++ b/config/locales/fr.yml Mon May 05 13:11:08 2014 +0200 @@ -1,32 +1,37 @@ fr: work_time: "Temps de travail" - wt_update: "Mise à jour" - wt_month_names: "Jan,Fev,Mar,Avr,Mai,Juin,Juil,Aout,Sep,Oct,Nov,Dec" + wt_update: "Mettre à jour" + wt_month_names: "Jan,Fév,Mar,Avr,Mai,Juin,Juil,Août,Sep,Oct,Nov,Déc" wt_week_day_names: "Dim,Lun,Mar,Mer,Jeu,Ven,Sam" wt_monthly_report: "Rapport mensuel" wt_daily_report: "Rapport journalier" wt_each_member_report: "Rapport utilisateur" - wt_raw_total: "Rapport mensuel(not relayed)" - wt_relay_total: "Rapport mensuel (relayed)" + wt_raw_total: "Rapport mensuel(non relayé)" + wt_relay_total: "Rapport mensuel (relayé)" wt_edit_relay: "Ticket Relay Editor" wt_ticket: "Demande" wt_add_ticket: "Ajouter une demande" wt_no_permission: "Vous n'avez pas les droits" - wt_loop_relay: "Ticket relation looped" - wt_set_holiday: "Placer cette date en vacances" - wt_del_holiday: "Retirer cette date de vacances" + wt_loop_relay: "Boucle infinie sur une demande" + wt_set_holiday: "Placer cette date en jour férié" + wt_del_holiday: "Retirer cette date des jours fériés" wt_apply_checked: "Appliquer pour toutes les cases cochées" - wt_select_project: "Restreint un projet" + wt_select_project: "Restreindre à un projet" wt_select_user: "Choisir un utilisateur" - wt_edit_memo: "Editer la note" + wt_edit_memo: "Éditer la note" wt_pre_memo: "Note précédente" wt_next_memo: "Note suivante" wt_data_list: "Liste brute" wt_input_ticket_numbers: "ou entrez le numéro de la demande" wt_delete_closed_tickets: "Supprimer les demandes fermées" - wt_data_download: "les données téléchargent" - wt_opt_disp_ticket_with_closed: "[display closed ticket]" - wt_opt_disp_ticket_opened_only: "[display opened ticket only]" - wt_opt_disp_ticket_with_other_member: "[display other members ticket]" - wt_opt_disp_ticket_mine_only: "[display my ticket only]" - wt_bulkupdate_relations: "bulkupdate to parent" + wt_data_download: "Téléchargement des données" + wt_opt_disp_ticket_with_closed: "[afficher les demandes fermés]" + wt_opt_disp_ticket_opened_only: "[n'afficher que les demandes ouvertes]" + wt_opt_disp_ticket_with_other_member: "[afficher les demandes des autres membres]" + wt_opt_disp_ticket_mine_only: "[n'afficher que mes demandes]" + wt_bulkupdate_relations: "mise à jour en bloc du parent" + permission_edit_work_time_total: "Modifier les totaux de temps de travail" + permission_view_work_time_tab: "Afficher l'onglet Temps de travail" + permission_view_work_time_other_member: "Afficher les temps des autres membres" + permission_edit_work_time_other_member: "Modifier les temps des autres membres" + wt_saved_value: "Temps sauvegardé : "