Changeset 5376 for trunk/prototype/modules/calendar/js/calendar.codecs.js
- Timestamp:
- 01/13/12 09:10:28 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/js/calendar.codecs.js
r5365 r5376 109 109 for( var i = 0; i < this.signatures.length; i++ ) 110 110 { 111 this.signatureOf[ this.calendarIds[i] = this.signatures[i].calendar.id ] = this.signatures[i]; 112 //this.signatureOf[ this.calendarIds[i] = this.signatures[i].calendar ] = this.signatures[i]; 111 this.signatureOf[ this.calendarIds[i] = ( this.calendars[ this.calendars.length ] = this.signatures[i].calendar ).id ] = this.signatures[i]; 113 112 } 114 115 this.calendars = DataLayer.get( "calendar", {filter: ["IN", "id", this.calendarIds], criteria: {order: 'name'}} );116 117 113 delete Calendar.currentViewKey; 118 114 } … … 179 175 Calendar.load(); 180 176 181 DataLayer.poll( "schedulable" );177 //DataLayer.poll( "schedulable" ); 182 178 183 179 DataLayer.listen( "schedulable", function( status ){ … … 320 316 321 317 encoder: function (evtObjt){ 318 319 if(notArray = typeof(evtObjt) == 'array' ) 320 evtObjt = [evtObjt]; 321 322 322 var res = $.map(evtObjt, function( objEvent ){ 323 323 var timezone = User.timezones[objEvent.schedulable.timezone]; … … 377 377 378 378 var res = $.map(evtObj, function( form ){ 379 var event = {}; 380 event.id = form.idEvent; 381 event.calendar = form.calendar; 382 var isCurrentParticipant = function(user, event){ 383 var participant = DataLayer.get('participant', ['AND',['=', 'user', user],['=', 'schedulable', event]]); 384 if(participant != '') 385 return participant[0].id; 386 else 387 return false; 388 }; 389 390 event.participants = []; 391 var participant = {}; 392 participant.user = User.me.id, 393 participant.status = form.status; 394 if((form.idEvent) && (id = isCurrentParticipant(participant.user, form.idEvent))) 395 participant.id = id; 396 397 if(typeof(form.alarmTime) != 'undefined'){ 398 participant.alarms = $.map( form.alarmTime || [], function( alarmTime, i ){ 399 400 if( alarmTime === "" ) 401 return( null ); 402 403 if(form.alarmId[i] === "") 404 return { type: form.alarmType[i],unit: form.alarmUnit[i], time: form.alarmTime[i] }; 405 else 406 return { type: form.alarmType[i], unit: form.alarmUnit[i], time: form.alarmTime[i], id: form.alarmId[i] }; 407 }); 379 380 return { 381 id: form.idEvent, 382 calendar: form.calendar, 383 participants : [{ 384 user: User.me.id, 385 status: form.status, 386 id: form.attendee_organizer[0], 387 isOrganizer: 0, 388 alarms: typeof(form.alarmTime) != 'undefined' ? 389 $.map( form.alarmTime || [], function( alarmTime, i ){ 390 391 if( alarmTime === "" ) 392 return( null ); 393 394 if(form.alarmId[i] === "") 395 return { type: form.alarmType[i],unit: form.alarmUnit[i], time: form.alarmTime[i] }; 396 else 397 return { type: form.alarmType[i], unit: form.alarmUnit[i], time: form.alarmTime[i], id: form.alarmId[i] }; 398 }) : [] 399 }] 408 400 } 409 410 event.participants[0] = participant;411 412 return event;413 401 }); 414 return notArray ? res[0] : res; 402 403 return notArray ? res[0] : res; 415 404 }, 416 405 … … 460 449 data.setTime(time); 461 450 return dateFormat(setDateTimezone(data, timezone, existsTimezone, idCalendar), User.preferences.hourFormat.replace(/m/g,'M')) 462 } 463 var temp = []; 464 var tempAlarm = []; 465 466 var typeAlarm = function(obj){ 467 var alarm = []; 468 for(var i = 0; i < obj.length; i++){ 469 if(tempAlarm[obj[i].id]) 470 continue; 471 tempAlarm[obj[i].id] = true; 472 473 if(obj[i].type == "1"){ 474 obj[i].type = 'alert'; 475 }else if(obj[i].type == "2"){ 476 obj[i].type = 'mail'; 477 }else{ 478 obj[i].type = 'sms'; 479 } 480 alarm.push(obj[i]); 451 } 452 var alarmParticipant = function(obj){ 453 var alarms = []; 454 for(var i = 0; i < obj.length; i++){ 455 alarms.push(DataLayer.get('alarm', obj[i])); 481 456 } 482 return alarm ;457 return alarms; 483 458 } 484 459 return { … … 499 474 allDay: !!parseInt( objEvent.allDay ), 500 475 // attachments: this.decode( "attachment:detail", form ), 501 attendee: $.map(objEvent.participants || [], function( participant, i ){ 502 if(participant.indexOf('java') >= 0) 503 return (null); 504 if(temp[participant]) 505 return (null); 506 temp[participant] = true; 507 476 attendee: $.map(objEvent.participants || [], function( participant, i ){ 477 508 478 var attend = DataLayer.get('participant', participant); 509 479 attend.user = DataLayer.get('user', attend.user) … … 520 490 { 521 491 participantInfo.status = attend.status; 522 participantInfo.alarms = typeAlarm(objEvent.alarms); 492 participantInfo.alarms = alarmParticipant(attend.alarms); 493 me.uid = attend.id; 523 494 } 524 495 if( parseInt( attend.isOrganizer ) )
Note: See TracChangeset
for help on using the changeset viewer.