Ignore:
Timestamp:
01/13/12 09:10:28 (12 years ago)
Author:
acoutinho
Message:

Ticket #2434 - Estabilizacao da nova api, correcoes de bug e melhorias na nova agenda

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/calendar/js/calendar.codecs.js

    r5365 r5376  
    109109          for( var i = 0; i < this.signatures.length; i++ ) 
    110110          { 
    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]; 
    113112          } 
    114  
    115           this.calendars = DataLayer.get( "calendar", {filter: ["IN", "id", this.calendarIds], criteria: {order: 'name'}} ); 
    116  
    117113          delete Calendar.currentViewKey; 
    118114      } 
     
    179175Calendar.load(); 
    180176 
    181 DataLayer.poll( "schedulable" ); 
     177//DataLayer.poll( "schedulable" ); 
    182178 
    183179DataLayer.listen( "schedulable", function( status ){ 
     
    320316         
    321317        encoder: function (evtObjt){ 
     318         
     319                        if(notArray = typeof(evtObjt) == 'array' ) 
     320                                evtObjt = [evtObjt]; 
     321                         
    322322                        var res = $.map(evtObjt, function( objEvent ){   
    323323                                var timezone = User.timezones[objEvent.schedulable.timezone]; 
     
    377377 
    378378                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                                        }] 
    408400                        } 
    409                          
    410                         event.participants[0] = participant; 
    411                          
    412                         return event; 
    413401                }); 
    414         return notArray ? res[0] : res; 
     402                 
     403                return notArray ? res[0] : res; 
    415404    }, 
    416405 
     
    460449                                data.setTime(time); 
    461450                                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])); 
    481456                                } 
    482                                 return alarm; 
     457                                return alarms; 
    483458                        } 
    484459                    return { 
     
    499474                              allDay: !!parseInt( objEvent.allDay ), 
    500475          //                            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                                         
    508478                                        var attend = DataLayer.get('participant', participant); 
    509479                                        attend.user = DataLayer.get('user', attend.user) 
     
    520490                                          { 
    521491                                              participantInfo.status = attend.status; 
    522                                               participantInfo.alarms = typeAlarm(objEvent.alarms); 
     492                                              participantInfo.alarms = alarmParticipant(attend.alarms); 
     493                                                  me.uid = attend.id; 
    523494                                          } 
    524495                                          if( parseInt( attend.isOrganizer ) ) 
Note: See TracChangeset for help on using the changeset viewer.