Ignore:
Timestamp:
08/08/12 18:02:13 (12 years ago)
Author:
acoutinho
Message:

Ticket #2966 - Criado suporte a historico em atividades

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js

    r6955 r6968  
    727727        dueTime: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.due)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 
    728728        allDay: !!parseInt( objEvent.allDay ), 
    729             historic: [], 
     729            historic: !!objEvent.historic ? decodeHistotic(objEvent) : [] , 
    730730        attachments: $.map(objEvent.attachments || [], function( attachment, i ){ 
    731731            var attach = DataLayer.get('schedulableToAttachment', attachment, false); 
     
    802802    } 
    803803}); 
     804 
     805function decodeHistotic ( evt ) { 
     806    var historic = evt.historic; 
     807    var decoded = []; 
     808    var attributeDecoded = { 
     809        'startTime': 'Data de inicio', 
     810        'endTime' : 'Data de fim', 
     811        'summary' : 'Título', 
     812        'description': 'Descrição', 
     813        'status': 'Status', 
     814        'percentage': 'Porcentagem', 
     815        'priority': 'Priorudade', 
     816        'due' : 'Previsão de término' 
     817    } 
     818 
     819    var decodeDate = function(time){ 
     820        return new Date( parseInt( time) ).setTimezoneOffset( Timezone.timezone( evt.timezone ) ).toString( User.preferences.dateFormat+' - '+User.preferences.hourFormat ); 
     821    }; 
     822 
     823    var decodeItem = function(historic){ 
     824        switch(historic.attribute){ 
     825            case 'startTime': 
     826            case 'endTime' : 
     827            case 'due': 
     828                return { 
     829                    user : historic.user, 
     830                    attribute : attributeDecoded[historic.attribute], 
     831                    beforeValue : decodeDate(historic.beforeValue), 
     832                    afterValue : decodeDate(historic.afterValue), 
     833                    time: decodeDate(historic.time) 
     834                } 
     835            break; 
     836            case 'participant': 
     837                return{ 
     838                    user : historic.user, 
     839                    attribute : historic.beforeValue == '' ? ('Novo participante') : ('Rem. participante'), 
     840                    beforeValue : historic.beforeValue == '' ? '' : historic.beforeValue.mail, 
     841                    afterValue : historic.afterValue == '' ? '' : historic.afterValue.mail, 
     842                    time: decodeDate(historic.time) 
     843                } 
     844            break; 
     845            case 'attachment': 
     846                return{ 
     847                    user : historic.user, 
     848                    attribute : historic.beforeValue == '' ? ('Novo anexo') : ('Rem. anexo'), 
     849                    beforeValue : historic.beforeValue, 
     850                    afterValue : historic.afterValue, 
     851                    time: decodeDate(historic.time) 
     852                } 
     853            case 'percentage': 
     854                    return{ 
     855                    user : historic.user, 
     856                    attribute :attributeDecoded[historic.attribute], 
     857                    beforeValue : historic.beforeValue+' %', 
     858                    afterValue : historic.afterValue+' %', 
     859                    time: decodeDate(historic.time) 
     860                } 
     861            break; 
     862            default: 
     863                return { 
     864                    user : historic.user, 
     865                    attribute : attributeDecoded[historic.attribute], 
     866                    beforeValue : historic.beforeValue, 
     867                    afterValue : historic.afterValue, 
     868                    time: decodeDate(historic.time) 
     869                } 
     870            break; 
     871 
     872        } 
     873    } 
     874 
     875    for(var i = 0; i < historic.length; i++) 
     876        decoded.push(decodeItem(historic[i])); 
     877 
     878    return decoded; 
     879 
     880} 
    804881 
    805882DataLayer.codec( "schedulable", "taskSearch", { 
Note: See TracChangeset for help on using the changeset viewer.