Project

General

Profile

Defect #1345 » wt-1345.patch

Olivier Houdas, 09/12/2014 09:36 PM

View differences:

plugins/redmine_work_time/app/controllers/work_time_controller.rb Tue Aug 26 12:12:11 2014 +0200 → plugins/redmine_work_time/app/controllers/work_time_controller.rb Fri Sep 12 14:04:52 2014 +0200
284 284
            UserIssueMonth.create(:uid=>uid, :issue=>@add_issue_id,
285 285
              :odr=>UserIssueMonth.count(:conditions=>["uid=:u",{:u=>uid}])+1)
286 286
          end
287
        else
288
          Rails.logger.info("WorkTime plugin warning: not enough rights for adding issue #" + @add_issue_id + " for user '" + User.current.name + "'")
287 289
        end
288 290
      end
289 291
    end
plugins/redmine_work_time/app/views/work_time/ajax_select_ticket.html.erb Tue Aug 26 12:12:11 2014 +0200 → plugins/redmine_work_time/app/views/work_time/ajax_select_ticket.html.erb Fri Sep 12 14:04:52 2014 +0200
43 43
<%=issueHtml.html_safe%>
44 44
<a href="#"
45 45
  onclick="JavaScript:
46
    showModalDialog(
46
    window.open(
47 47
      '<%=url_for(:controller=>"issues", :action=>"show", :id=>issue.id)%>',
48
      window,
48
      "",
49 49
      '');
50 50
    return false;">
51 51
  &#63;
plugins/redmine_work_time/app/views/work_time/ajax_select_tickets.html.erb Tue Aug 26 12:12:11 2014 +0200 → plugins/redmine_work_time/app/views/work_time/ajax_select_tickets.html.erb Fri Sep 12 14:04:52 2014 +0200
57 57
<%=issueHtml.html_safe%>
58 58
<a href="#"
59 59
  onclick="JavaScript:
60
    showModalDialog(
60
    windo.open(
61 61
      '<%=url_for(:controller=>"issues", :action=>"show", :id=>issue.id)%>',
62
      window,
62
      "",
63 63
      '');
64 64
    return false;">
65 65
  &#63;
plugins/redmine_work_time/app/views/work_time/popup_update_done_ratio.html.erb Tue Aug 26 12:12:11 2014 +0200 → plugins/redmine_work_time/app/views/work_time/popup_update_done_ratio.html.erb Fri Sep 12 14:04:52 2014 +0200
10 10
    <h2><%=l(:label_update_issue_done_ratios)%></h2>
11 11
    <a href="#"
12 12
      onclick="JavaScript:
13
        showModalDialog(
13
        window.open(
14 14
          '<%=url_for(:controller=>"issues", :action=>"show", :id=>@issue.id)%>',
15
          window,
15
          "",
16 16
          '');
17 17
        return false;">
18 18
      <%= @issueHtml.html_safe %>
plugins/redmine_work_time/assets/javascripts/work_time.js Tue Aug 26 12:12:11 2014 +0200 → plugins/redmine_work_time/assets/javascripts/work_time.js Fri Sep 12 14:04:52 2014 +0200
1
// global variables for funtions called after closing a popup
2
var g_ajax_url; 
3
var g_req_url;
4
var g_child_url;
5
var g_rep_url;
6
var g_issue_id;
7

  
1 8
function ticket_pos(url, issue, pos, max)
2 9
{
3 10
  var new_pos = prompt("Destination No.", pos);
......
49 56

  
50 57
function set_ticket_relay(pop_url, req_url, child_id)
51 58
{
52
  var parent_id = showModalDialog(pop_url, window, "dialogWidth:600px;dialogHeight:480px");
59
  g_req_url = req_url;
60
  g_child_url = child_url;
61
  var parent_id = window.open(pop_url,"", "width=600,height=480");
62
}
63
function set_ticket_relay_post(parent_id){
53 64
  if (parent_id != null) {
54
    set_ticket_relay_core(req_url, child_id, parent_id);
65
    set_ticket_relay_core(g_req_url, g_child_id, parent_id);
55 66
  }
56 67
}
57 68

  
69

  
58 70
function set_ticket_relay_by_issue_relation(req_url) {
59 71
  if (typeof jQuery == "function") {
60 72
    $('[data-has-parent="false"]').each(function(i, v) {
......
70 82

  
71 83
function update_done_ratio(pop_url, rep_url, issue_id)
72 84
{
73
  var done_ratio = showModalDialog(pop_url+"&issue_id="+issue_id,
74
        window, "dialogWidth:500px;dialogHeight:150px");
75
  if(done_ratio!=null){
85
  g_rep_url = rep_url;
86
  g_issue_id = issue_id;
87
  var done_ratio = window.open(pop_url+"&issue_id="+issue_id,
88
        "", "width:500,height=150");
89
}
90
function update_done_ratio_post(done_ratio){
91
  if(done_ratio != null){
76 92
    if( typeof jQuery == "function" ) {
77 93
      jQuery.ajax({
78
        url:rep_url+"&issue_id="+issue_id+"&done_ratio="+done_ratio,
94
        url:g_rep_url+"&issue_id="+g_issue_id+"&done_ratio="+done_ratio,
79 95
        data:{asynchronous:true, method:'get'},
80 96
        success:function(response){
81
          jQuery('#done_ratio'+issue_id).html(response);
97
          jQuery('#done_ratio'+g_issue_id).html(response);
82 98
        }
83 99
      });
84 100
    }
85 101
    else {
86
      new Ajax.Updater('done_ratio'+issue_id,
87
        rep_url+"&issue_id="+issue_id+"&done_ratio="+done_ratio,
102
      new Ajax.Updater('done_ratio'+g_issue_id,
103
        g_rep_url+"&issue_id="+g_issue_id+"&done_ratio="+done_ratio,
88 104
        {asynchronous:true, method:'get'});
89 105
    }
90 106

  
91
    var drs = document.getElementsByName("done_ratio"+issue_id);
107
    var drs = document.getElementsByName("done_ratio"+g_issue_id);
92 108
    for(var i = 0; i < drs.length; i++) {
93
      drs[i].innerHTML = "["+done_ratio+"&#37;]";
109
      drs[i].innerHTML = "["+window['done_ratio']+"&#37;]";
94 110
    }
95 111
  }
96 112
}
......
147 163
var add_ticket_count = 1;
148 164
function add_ticket(pop_url, ajax_url)
149 165
{
150
    var tickets = showModalDialog(pop_url, window, "dialogWidth:600px;dialogHeight:480px");
166
    g_ajax_url = ajax_url;
167
    var tickets = window.open(pop_url, "tickets", "width=600,height=480");
168
}
169
function add_ticket_post(tickets){
151 170
    for(i=0; i<tickets.length;i++) {
152 171
      if( typeof jQuery == "function" ) {
153 172
        jQuery.ajax({
154
          url:ajax_url+"&add_issue="+tickets[i]+"&count="+add_ticket_count,
173
          url:g_ajax_url+"&add_issue="+tickets[i]+"&count="+add_ticket_count,
155 174
          data:{asynchronous:true, method:'get'},
156 175
          success:function(response){
157 176
            jQuery('#time_input_table_bottom').before(response);
......
160 179
      }
161 180
      else {
162 181
        new Ajax.Updater('time_input_table_bottom',
163
          ajax_url+"&add_issue="+tickets[i]+"&count="+add_ticket_count,
182
          g_ajax_url+"&add_issue="+tickets[i]+"&count="+add_ticket_count,
164 183
          {insertion:Insertion.Before, method:'get'});
165 184
      }
166 185
      add_ticket_count ++;
167 186
    }
168 187
}
169 188

  
189

  
170 190
function dup_ticket(ajax_url, insert_pos, id)
171 191
{
172 192
  if( typeof jQuery == "function" ) {
......
207 227
//---------------------------------------- for popup_update_done_ratio.html.erb
208 228
function ratio_inputed()
209 229
{
210
  returnValue = document.getElementById("input_ratio").value;
230
  window.opener.update_done_ratio_post(document.getElementById("input_ratio").value);
231
//  returnValue = document.getElementById("input_ratio").value;
211 232
  close();
212 233
}
213 234

  
214 235
//--------------- for popup_select_ticket.html.erb, ajax_select_ticket.html.erb
215 236
function ticket_inputed()
216 237
{
217
  returnValue = document.getElementById("input_id").value;
238
  window.opener.set_ticket_relay_post(document.getElementById("input_id").value);
239
//  returnValue = document.getElementById("input_id").value;
218 240
  close();
219 241
}
220 242

  
......
229 251
{
230 252
  var vals = document.getElementById("input_ids").value;
231 253
  var tickets = vals.split(',');
232
  returnValue=tickets;
254
  window.opener.add_ticket_post(tickets);
255
//  returnValue=tickets;
233 256
  close();
234 257
}
235 258

  
(2-2/2)