Project

General

Profile

Proposal #1322 » 302-dynamic-time-sum.diff.patch

Olivier Houdas, 05/22/2014 03:25 PM

View differences:

app/views/work_time/_user_day_table.html.erb Tue Mar 04 12:41:29 2014 +0900 → app/views/work_time/_user_day_table.html.erb Mon May 05 13:11:08 2014 +0200
124 124
  </div>
125 125
  </td>
126 126
  <td>
127
    <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][hours]", "", :size=>5) %>
127
    <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][hours]", "", :size=>5, :onchange => "sumDayTimes()") %>
128 128
  </td>
129 129
  <% if @is_registerd_backlog then %>
130 130
  <td>
131 131
    <% if issue_pack[:cnt_childrens] != 0 || issue.closed? then %>
132 132
      <%= issue[:remaining_hours] %>
133 133
    <% else %>
134
      <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][remaining_hours]", issue[:remaining_hours], :size=>5) %>
134
      <%= text_field_tag("new_time_entry["+issue_id.to_s+"][0][remaining_hours]", issue[:remaining_hours], :size=>5, :onchange => "sumDayTimes()") %>
135 135
    <% end %>
136 136
  </td>
137 137
  <% end %>
......
223 223
  </div>
224 224
  </td>
225 225
  <td>
226
    <%= text_field_tag("time_entry["+hour_id.to_s+"][hours]", hour.hours, :size=>5) %>
226
    <%= text_field_tag("time_entry["+hour_id.to_s+"][hours]", hour.hours, :size=>5, :onchange => "sumDayTimes()") %>
227 227
  </td>
228 228
  <% if @is_registerd_backlog then %>
229 229
  <td>
230 230
    <% if issue_pack[:cnt_childrens] != 0 || hour.issue.closed? then %>
231 231
      <%= hour.issue[:remaining_hours] %>
232 232
    <% else %>
233
      <%= text_field_tag("time_entry["+hour_id.to_s+"][remaining_hours]", hour.issue[:remaining_hours], :size=>5) %>
233
      <%= text_field_tag("time_entry["+hour_id.to_s+"][remaining_hours]", hour.issue[:remaining_hours], :size=>5, :onchange => "sumDayTimes()") %>
234 234
    <% end %>
235 235
  </td>
236 236
  <% end %>
......
282 282
<% end %>
283 283
<tr align="center" id="time_input_table_bottom" style="background:#ddd;">
284 284
  <td>&nbsp;</td>
285
  <td><%=sprintf("%1.1f", @day_pack[:total])%></td>
285
  <td><span id='currentTotal' title='<%=l(:wt_saved_value)%> <%=sprintf("%1.1f", @day_pack[:total])%>'><%=sprintf("%1.1f", @day_pack[:total])%></span></td>
286 286
  <% if @is_registerd_backlog then %>
287 287
  <td>&nbsp;</td>
288 288
  <% end %>
......
294 294
  <% end %>
295 295
</tr>
296 296
</table>
297

  
app/views/work_time/ajax_insert_daily.html.erb Tue Mar 04 12:41:29 2014 +0900 → app/views/work_time/ajax_insert_daily.html.erb Mon May 05 13:11:08 2014 +0200
30 30
  </div>
31 31
  </td>
32 32
  <td>
33
    <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][hours]", "", :size=>5) %>
33
    <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][hours]", "", :size=>5, :onchange => "sumDayTimes()") %>
34 34
  </td>
35 35
  <% if @is_registerd_backlog then %>
36 36
  <td>
37 37
    <% if @add_issue_children_cnt != 0 || @add_issue.closed? then %>
38 38
      <%= @add_issue.remaining_hours %>
39 39
    <% else %>
40
        <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][remaining_hours]", @add_issue.remaining_hours, :size=>5) %>
40
        <%= text_field_tag("new_time_entry["+@add_issue_id+"]["+@add_count+"][remaining_hours]", @add_issue.remaining_hours, :size=>5, :onchange => "sumDayTimes()") %>
41 41
    <% end %>
42 42
  </td>
43 43
  <% end %>
assets/javascripts/work_time.js Tue Mar 04 12:41:29 2014 +0900 → assets/javascripts/work_time.js Mon May 05 13:11:08 2014 +0200
257 257
  v = obj.options[index].value;
258 258
  obj.options[index].value = 'M'+v;
259 259
}
260

  
261
//------------- for user_day_table.html.erb
262
function sumDayTimes() {
263
  var total=0;
264
  var dayInputs;
265
  
266
  // List all Input elemnets of the page
267
  dayInputs = document.getElementsByTagName("input");
268
  for (var i=0; i<dayInputs.length; i++) {
269
    // Consider only those with an id containing the strings 'time_entry' and 'hours'
270
    if ((dayInputs[i].id.indexOf("time_entry") >= 0) && (dayInputs[i].id.indexOf("hours") >= 0)) {
271
      if (dayInputs[i].value && !isNaN(parseFloat(dayInputs[i].value))) {
272
      // add the number to the total if it is a valid number
273
        total = total + parseFloat(dayInputs[i].value);
274
     }
275
    }
276
  }
277
  // Set the total value to the new number, changing the style to indicate 
278
  // it is not saved, and adding the saved value as a flyover indication
279
  var originalValue;
280
  document.getElementById("currentTotal").innerHTML = total;
281
  document.getElementById("currentTotal").style = 'color:#FF0000;';
282
return true;
283
}
config/locales/en.yml Tue Mar 04 12:41:29 2014 +0900 → config/locales/en.yml Mon May 05 13:11:08 2014 +0200
30 30
  wt_opt_disp_ticket_with_other_member: "[display other members ticket]"
31 31
  wt_opt_disp_ticket_mine_only: "[display my ticket only]"
32 32
  wt_bulkupdate_relations: "bulkupdate to parent"
33
  permission_edit_work_time_total: "Edit work time totals"
34
  permission_view_work_time_tab: "View Work time tab"
35
  permission_view_work_time_other_member: "View other members' work time"
36
  permission_edit_work_time_other_member: "Edit other members' work time "
37
  wt_saved_value: "Saved timed: "
config/locales/fr.yml Tue Mar 04 12:41:29 2014 +0900 → config/locales/fr.yml Mon May 05 13:11:08 2014 +0200
1 1
fr:
2 2
  work_time: "Temps de travail"
3
  wt_update: "Mise à jour"
4
  wt_month_names: "Jan,Fev,Mar,Avr,Mai,Juin,Juil,Aout,Sep,Oct,Nov,Dec"
3
  wt_update: "Mettre à jour"
4
  wt_month_names: "Jan,Fév,Mar,Avr,Mai,Juin,Juil,Août,Sep,Oct,Nov,Déc"
5 5
  wt_week_day_names: "Dim,Lun,Mar,Mer,Jeu,Ven,Sam"
6 6
  wt_monthly_report: "Rapport mensuel"
7 7
  wt_daily_report: "Rapport journalier"
8 8
  wt_each_member_report: "Rapport utilisateur"
9
  wt_raw_total: "Rapport mensuel(not relayed)"
10
  wt_relay_total: "Rapport mensuel (relayed)"
9
  wt_raw_total: "Rapport mensuel(non relayé)"
10
  wt_relay_total: "Rapport mensuel (relayé)"
11 11
  wt_edit_relay: "Ticket Relay Editor"
12 12
  wt_ticket: "Demande"
13 13
  wt_add_ticket: "Ajouter une demande"
14 14
  wt_no_permission: "Vous n'avez pas les droits"
15
  wt_loop_relay: "Ticket relation looped"
16
  wt_set_holiday: "Placer cette date en vacances"
17
  wt_del_holiday: "Retirer cette date de vacances"
15
  wt_loop_relay: "Boucle infinie sur une demande"
16
  wt_set_holiday: "Placer cette date en jour férié"
17
  wt_del_holiday: "Retirer cette date des jours fériés"
18 18
  wt_apply_checked: "Appliquer pour toutes les cases cochées"
19
  wt_select_project: "Restreint un projet"
19
  wt_select_project: "Restreindre à un projet"
20 20
  wt_select_user: "Choisir un utilisateur"
21
  wt_edit_memo: "Editer la note"
21
  wt_edit_memo: "Éditer la note"
22 22
  wt_pre_memo: "Note précédente"
23 23
  wt_next_memo: "Note suivante"
24 24
  wt_data_list: "Liste brute"
25 25
  wt_input_ticket_numbers: "ou entrez le numéro de la demande"
26 26
  wt_delete_closed_tickets: "Supprimer les demandes fermées"
27
  wt_data_download: "les données téléchargent"
28
  wt_opt_disp_ticket_with_closed: "[display closed ticket]"
29
  wt_opt_disp_ticket_opened_only: "[display opened ticket only]"
30
  wt_opt_disp_ticket_with_other_member: "[display other members ticket]"
31
  wt_opt_disp_ticket_mine_only: "[display my ticket only]"
32
  wt_bulkupdate_relations: "bulkupdate to parent"
27
  wt_data_download: "Téléchargement des données"
28
  wt_opt_disp_ticket_with_closed: "[afficher les demandes fermés]"
29
  wt_opt_disp_ticket_opened_only: "[n'afficher que les demandes ouvertes]"
30
  wt_opt_disp_ticket_with_other_member: "[afficher les demandes des autres membres]"
31
  wt_opt_disp_ticket_mine_only: "[n'afficher que mes demandes]"
32
  wt_bulkupdate_relations: "mise à jour en bloc du parent"
33
  permission_edit_work_time_total: "Modifier les totaux de temps de travail"
34
  permission_view_work_time_tab: "Afficher l'onglet Temps de travail"
35
  permission_view_work_time_other_member: "Afficher les temps des autres membres"
36
  permission_edit_work_time_other_member: "Modifier les temps des autres membres"
37
  wt_saved_value: "Temps sauvegardé : "
(2-2/2)