|
49 | 49 | autoOpen: false,
|
50 | 50 | buttons :
|
51 | 51 | [ {
|
52 |
| - id: 'confirm-button', |
| 52 | + id: 'confirm-button', |
53 | 53 | text: "Confirm",
|
54 | 54 | click: function() {
|
55 | 55 | var baseUrl = OC.generateUrl('/apps/timetracker/ajax/add-work-interval/'+$('#name-manual-entry').val());
|
|
58 | 58 | getWorkItems();
|
59 | 59 | $("#dialog-manual-entry").dialog("close");
|
60 | 60 | })
|
61 |
| - .done(function() { |
62 |
| - |
63 |
| - }) |
| 61 | + .done(function(data, status, jqXHR) { |
| 62 | + var response = data; |
| 63 | + if ('Error' in response){ |
| 64 | + alert(response.Error); |
| 65 | + } |
| 66 | + }) |
64 | 67 | .fail(function() {
|
65 | 68 | alert( "error" );
|
66 | 69 | })
|
|
90 | 93 | getWorkItems();
|
91 | 94 | $(dialogWorkItemEditForm).dialog("close");
|
92 | 95 | })
|
93 |
| - .done(function() { |
94 |
| - |
95 |
| - }) |
| 96 | + .done(function(data, status, jqXHR) { |
| 97 | + var response = data; |
| 98 | + if ('Error' in response){ |
| 99 | + alert(response.Error); |
| 100 | + } |
| 101 | + }) |
96 | 102 | .fail(function() {
|
97 | 103 | alert( "error" );
|
98 | 104 | })
|
|
101 | 107 | });
|
102 | 108 |
|
103 | 109 | }
|
104 |
| - |
| 110 | + function cutString(s, n){ |
| 111 | + if (s.length < n) { |
| 112 | + return s; |
| 113 | + } |
| 114 | + return s.substring(0, n - 4) + ' ...'; |
| 115 | + } |
105 | 116 | function secondsToTimer(s){
|
106 | 117 | function pad(num, size) {
|
107 | 118 | var s = num+"";
|
|
184 | 195 |
|
185 | 196 | $.each(workItem.children, function (ckey, child){
|
186 | 197 | //debugger;
|
187 |
| - children.push("<div class='wi-child'><li><div class='wi-child-element'><div class='wi-child-name clickable' data-myid="+child.id+" data-name='"+child.name+"'>"+child.name+"</div>"+ |
| 198 | + children.push("<div class='wi-child'><li><div class='wi-child-element'><div class='wi-child-name clickable' data-myid="+child.id+" data-name='"+child.name+"'>"+cutString(child.name,64)+"</div>"+ |
188 | 199 | "<span class='fas clickable fa-trash wi-trash' id="+child.id+"></span><span class='set-project' data-myid="+child.id+" data-projectid="+child.projectId+" data-projectname='"+child.projectName+"'></span>"+
|
189 | 200 | "<span class='set-tag' data-myid="+child.id+" data-tagids='"+child.tags.map(function(tag) {return tag.id}).join(',')+"' data-tagnames='"+child.tags.map(function(tag) {return tag.name}).join(',')+"'></span>"+
|
190 | 201 | "<div class='wi-child-hours' data-myid="+child.id+" data-start-date='"+child.start+"' data-end-date='"+(child.start+child.duration)+"'>"+tsToHour(child.start)+" - "+
|
|
198 | 209 | dayItems.push("<div class='work-item'>"+"<ul><li class=''><div class='work-item-element'>"+
|
199 | 210 | ((children.length == 1)?"<div class='wi-len-empty'> </div>":"<div class='wi-len'>"+children.length+"</div>")+
|
200 | 211 | "<div class='wi-name'>"+
|
201 |
| - dayItemName+"</div><div class='wi-duration'>"+secondsToTimer(workItem.totalTime)+ |
| 212 | + cutString(dayItemName,128)+"</div><div class='wi-duration'>"+secondsToTimer(workItem.totalTime)+ |
202 | 213 | "</div>"+
|
203 | 214 | "</div></li>"+children.join("")+"</ul>"+"</div>");
|
204 | 215 | });
|
|
227 | 238 | var id = $(this).data('myid');
|
228 | 239 | var jqxhr = $.post( "ajax/update-work-interval/"+id,{start:picker.startDate.format('DD/MM/YY HH:mm'), end:picker.endDate.format('DD/MM/YY HH:mm'), tzoffset: new Date().getTimezoneOffset()}, function() {
|
229 | 240 | })
|
230 |
| - .done(function() { |
231 |
| - getWorkItems(); |
232 |
| - }) |
| 241 | + .done(function(data, status, jqXHR) { |
| 242 | + var response = data; |
| 243 | + if ('Error' in response){ |
| 244 | + alert(response.Error); |
| 245 | + } |
| 246 | + getWorkItems(); |
| 247 | + }) |
233 | 248 | .fail(function() {
|
234 | 249 | alert( "error" );
|
235 | 250 | })
|
|
262 | 277 | getWorkItems();
|
263 | 278 | $("#dialog-confirm").dialog("close");
|
264 | 279 | })
|
265 |
| - .done(function() { |
266 |
| - |
| 280 | + .done(function(data, status, jqXHR) { |
| 281 | + var response = data; |
| 282 | + if ('Error' in response){ |
| 283 | + alert(response.Error); |
| 284 | + } |
267 | 285 | })
|
268 | 286 | .fail(function() {
|
269 | 287 | alert( "error" );
|
|
383 | 401 |
|
384 | 402 |
|
385 | 403 | })
|
386 |
| - .done(function() { |
| 404 | + .done(function(data, status, jqXHR) { |
| 405 | + var response = data; |
| 406 | + if ('Error' in response){ |
| 407 | + alert(response.Error); |
| 408 | + } |
387 | 409 | getWorkItems();
|
388 |
| - }) |
| 410 | + }) |
389 | 411 | .fail(function() {
|
390 | 412 | alert( "error" );
|
391 | 413 | })
|
|
398 | 420 | var selectedTag = $(e.target).val();
|
399 | 421 | var jqxhr = $.post( "ajax/update-work-interval/"+myid,{tagId:selectedTag}, function() {
|
400 | 422 | })
|
401 |
| - .done(function() { |
| 423 | + .done(function(data, status, jqXHR) { |
| 424 | + var response = data; |
| 425 | + if ('Error' in response){ |
| 426 | + alert(response.Error); |
| 427 | + } |
402 | 428 | getWorkItems();
|
403 | 429 | })
|
404 | 430 | .fail(function() {
|
|
426 | 452 | $('#start-tracking > span').addClass("stop-button").removeClass("play-button");
|
427 | 453 | getWorkItems();
|
428 | 454 | })
|
429 |
| - .done(function() { |
430 |
| - }) |
431 |
| - .fail(function() { |
| 455 | + .done(function(data, status, jqXHR) { |
| 456 | + var response = data; |
| 457 | + if ('Error' in response){ |
| 458 | + alert(response.Error); |
| 459 | + } |
| 460 | + }) |
| 461 | + .fail(function() { |
432 | 462 | alert( "error" );
|
433 |
| - }) |
| 463 | + }); |
434 | 464 |
|
435 | 465 | }
|
436 | 466 | function stopTimer(){
|
|
444 | 474 | $('#start-tracking > span').addClass("play-button").removeClass("stop-button");
|
445 | 475 | getWorkItems();
|
446 | 476 | })
|
447 |
| - .done(function() { |
448 |
| - }) |
| 477 | + .done(function(data, status, jqXHR) { |
| 478 | + var response = data; |
| 479 | + if ('Error' in response){ |
| 480 | + alert(response.Error); |
| 481 | + } |
| 482 | + }) |
449 | 483 | .fail(function() {
|
450 | 484 | alert( "error" );
|
451 | 485 | })
|
|
0 commit comments