[5592] | 1 | function show_modal_shared(calendarId){ |
---|
| 2 | var html = DataLayer.render('templates/shared_calendar.ejs', {calendar: Calendar.calendars}); |
---|
| 3 | |
---|
| 4 | //Variaval global para manipulação dos usuários |
---|
| 5 | //melhor perforface |
---|
[5617] | 6 | currentUsers = {}; |
---|
[5592] | 7 | currentUsers[User.me.id] = true; |
---|
| 8 | changePublic = false; |
---|
| 9 | |
---|
| 10 | if (!UI.dialogs.sharedCalendar) { |
---|
| 11 | UI.dialogs.sharedCalendar = jQuery('#calendarShared').append('<div title="Compatilhamento de Agenda" class="shared-calendar active"> <div>').find('.shared-calendar.active').html(html).dialog({ |
---|
| 12 | resizable: false, |
---|
| 13 | modal:true, |
---|
| 14 | autoOpen: false, |
---|
| 15 | width:620, |
---|
| 16 | position: 'center', |
---|
| 17 | close: function(event, ui) { |
---|
| 18 | //Implementações de cancelar |
---|
[5617] | 19 | currentUsers = {}; |
---|
[5592] | 20 | } |
---|
| 21 | }); |
---|
| 22 | } else { |
---|
| 23 | UI.dialogs.sharedCalendar.html(html); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | /*Seleciona a agenda selecionada para compartilhamento*/ |
---|
| 27 | UI.dialogs.sharedCalendar.find('option[value="'+calendarId+'"]').attr('selected','selected').trigger('change'); |
---|
| 28 | |
---|
| 29 | UI.dialogs.sharedCalendar.find('input[name="isPublic"]').change(function(event){ |
---|
| 30 | $(this).parent().find('.free-busy').toggleClass('hidden'); |
---|
| 31 | changePublic = changePublic ? false: true; |
---|
| 32 | }); |
---|
| 33 | |
---|
| 34 | UI.dialogs.sharedCalendar.find('.button').button() |
---|
| 35 | .filter('.cancel').click(function(evt){ |
---|
| 36 | UI.dialogs.sharedCalendar.dialog("close"); |
---|
| 37 | }).end() |
---|
| 38 | .filter('.save').click(function(evt){ |
---|
| 39 | //TODO - API ainda não suporta |
---|
| 40 | //UI.dialogs.sharedCalendar.find('form').submit(); |
---|
| 41 | var calendarSelected = UI.dialogs.sharedCalendar.find('option:selected').val(); |
---|
| 42 | var save = function(){ |
---|
| 43 | if($('li.not-user').length == 0) |
---|
| 44 | $.each(UI.dialogs.sharedCalendar.find('.user-list li'), function( i , element ){ |
---|
| 45 | var user = $(element).find('input[name="user[]"]').val(); |
---|
| 46 | var acl = $(element).find('input[name="attendeeAcl[]"]').val(); |
---|
| 47 | if(acl == "") |
---|
| 48 | return true; |
---|
| 49 | DataLayer.put('calendarToPermission', {calendar: calendarSelected, type: 0, user: user, acl: acl}); |
---|
| 50 | }); |
---|
| 51 | DataLayer.commit(false, false, function(data){ |
---|
| 52 | UI.dialogs.sharedCalendar.dialog("close"); |
---|
| 53 | }); |
---|
| 54 | }; |
---|
| 55 | |
---|
| 56 | //Trata a criação de um acesso público a agenda |
---|
| 57 | if(changePublic){ |
---|
| 58 | if(UI.dialogs.sharedCalendar.find('input[name="isPublic"]').is(':checked')){ |
---|
| 59 | var acl = UI.dialogs.sharedCalendar.find('input[name="busy"]').is(':checked') ? 'b' : 'w'; |
---|
| 60 | DataLayer.put('calendarToPermission', {calendar: calendarSelected, type: '1', user: '0', acl: acl}); |
---|
| 61 | }else{ |
---|
| 62 | //TODO - remover quando for implementado remove com criteria |
---|
| 63 | var permission = DataLayer.get('calendarPermission', {filter: [AND, ['=', 'calendar', calendarId], ['=', 'user', '0']]}, true); |
---|
| 64 | DataLayer.remove('calendarToPermission', permission.id); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | if(!!UI.dialogs.sharedCalendar.find('.user-list li input[name="attendeeAcl[]"][value=""]').length){ |
---|
| 68 | $.Zebra_Dialog('Alguns usuários estão sem permissões e serão automáticamente removidos, deseja continuar ?', { |
---|
| 69 | 'type': 'question', |
---|
| 70 | 'overlay_opacity': '0.5', |
---|
| 71 | 'buttons': ['Continuar', 'Cancelar'], |
---|
| 72 | 'onClose': function(clicked) { |
---|
| 73 | if(clicked == 'Continuar') { |
---|
| 74 | save(); |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | }); |
---|
| 78 | }else |
---|
| 79 | save(); |
---|
| 80 | }); |
---|
| 81 | |
---|
| 82 | UI.dialogs.sharedCalendar.find('.add-user-search .ui-icon-search').click(function(event) { |
---|
| 83 | UI.dialogs.sharedCalendar.find('.add-user-search input').keydown(); |
---|
| 84 | }); |
---|
| 85 | |
---|
| 86 | var incompatibleAcl = function (obj, acls, buttons){ |
---|
| 87 | for (var i = 0; i < acls.length; i++){ |
---|
| 88 | var objremove = obj.parent().find('.'+buttons[i]+''); |
---|
| 89 | if(objremove.hasClass('attendee-permissions-change-button')) |
---|
| 90 | changeAcl(objremove, acls[i]); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | var removeAcl = function(current, acl){ |
---|
| 95 | var acls = ''; |
---|
| 96 | for(var i = 0; i < current.length; i++) |
---|
| 97 | if(current.charAt(i) != acl) |
---|
| 98 | acls += current.charAt(i) ; |
---|
| 99 | return acls; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | var dependsAcl = function(obj, acls, buttons){ |
---|
| 103 | for (var i = 0; i < acls.length; i++){ |
---|
| 104 | var objremove = obj.parent().find('.'+buttons[i]+''); |
---|
| 105 | if(!objremove.hasClass('attendee-permissions-change-button')) |
---|
| 106 | changeAcl(objremove, acls[i]); |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | var changeAcl = function(obj, acl){ |
---|
| 111 | if(obj.hasClass('attendee-permissions-change-button')){ |
---|
| 112 | obj.parent().siblings('input[name="attendeeAcl[]"]').val(removeAcl( obj.parent().siblings('input[name="attendeeAcl[]"]').val(), acl)) ; |
---|
| 113 | }else{ |
---|
| 114 | var acls = obj.parent().siblings('input[name="attendeeAcl[]"]').val(); |
---|
| 115 | obj.parent().siblings('input[name="attendeeAcl[]"]').val(acls + acl); |
---|
| 116 | } |
---|
| 117 | obj.toggleClass('attendee-permissions-change-button') |
---|
| 118 | .find('span:first').toggleClass('attendee-permissions-change').end(); |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | UI.dialogs.sharedCalendar.find('.add-user-search input').keydown(function(event) { |
---|
| 123 | if(event.keyCode == '13' || typeof(event.keyCode) == 'undefined') { |
---|
| 124 | var result = DataLayer.get('user', ["*", "name", $(this).val()], true); |
---|
| 125 | /** |
---|
| 126 | * TODO: trocar por template |
---|
| 127 | */ |
---|
| 128 | UI.dialogs.sharedCalendar.find('ul.search-result-list').empty().css('overflow', 'hidden'); |
---|
| 129 | if (!result) { |
---|
| 130 | UI.dialogs.sharedCalendar.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>'); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | for(i=0; i<result.length; i++) |
---|
| 134 | result[i].enabled = currentUsers[result[i].id] ? false : true; |
---|
| 135 | |
---|
| 136 | UI.dialogs.sharedCalendar.find('ul.search-result-list').append(DataLayer.render( 'templates/participants_search_itemlist.ejs', result)); |
---|
| 137 | |
---|
| 138 | UI.dialogs.sharedCalendar.find('ul.search-result-list li').click(function(event, ui){ |
---|
| 139 | if ($(event.target).is('input')) { |
---|
| 140 | old_item = $(event.target).parents('li'); |
---|
| 141 | var id = old_item.find('.id').html(); |
---|
| 142 | |
---|
| 143 | currentUsers [id] = { |
---|
| 144 | id: id, |
---|
| 145 | name: old_item.find('.name').html(), |
---|
| 146 | mail: old_item.find('.mail').html() |
---|
| 147 | }; |
---|
| 148 | |
---|
| 149 | UI.dialogs.sharedCalendar.find('dd.user-list ul.user-list') |
---|
| 150 | .append(DataLayer.render('templates/user_shared_add_itemlist.ejs', [{id: id, name: currentUsers [id] .name, mail: currentUsers [id] .mail}])) |
---|
| 151 | .scrollTo('max'); |
---|
| 152 | |
---|
| 153 | $('li.not-user').remove(); |
---|
| 154 | callbackSharedCotactsAdd(); |
---|
| 155 | old_item.remove(); |
---|
| 156 | } |
---|
| 157 | }); |
---|
| 158 | event.preventDefault(); |
---|
| 159 | } |
---|
| 160 | }); |
---|
| 161 | |
---|
| 162 | var callbackSharedCotactsAdd = function(event){ |
---|
| 163 | UI.dialogs.sharedCalendar.find('.button').filter(".read.new").button({ |
---|
| 164 | icons: { |
---|
| 165 | primary: "ui-icon-circle-zoomin" |
---|
| 166 | }, |
---|
| 167 | text: false |
---|
| 168 | }).click(function () { |
---|
| 169 | incompatibleAcl($(this), ['b'], ['busy']); |
---|
| 170 | changeAcl($(this), 'r'); |
---|
| 171 | }) |
---|
| 172 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 173 | .removeClass('new').end() |
---|
| 174 | |
---|
| 175 | .filter(".write.new").button({ |
---|
| 176 | icons: { |
---|
| 177 | primary: "ui-icon-key" |
---|
| 178 | }, |
---|
| 179 | text: false |
---|
| 180 | }).click(function () { |
---|
| 181 | incompatibleAcl($(this), ['b'], ['busy']); |
---|
| 182 | dependsAcl($(this), ['r'], ['read']); |
---|
| 183 | changeAcl($(this), 'w'); |
---|
| 184 | }) |
---|
| 185 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 186 | .removeClass('new').end() |
---|
| 187 | |
---|
| 188 | .filter(".remove.new").button({ |
---|
| 189 | icons: { |
---|
| 190 | primary: "ui-icon-trash" |
---|
| 191 | }, |
---|
| 192 | text: false |
---|
| 193 | }).click(function () { |
---|
| 194 | incompatibleAcl($(this), ['b'], ['busy']); |
---|
| 195 | dependsAcl($(this), ['r'], ['read']); |
---|
| 196 | changeAcl($(this), 'd'); |
---|
| 197 | }) |
---|
| 198 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 199 | .removeClass('new').end() |
---|
| 200 | |
---|
| 201 | .filter(".busy.new").button({ |
---|
| 202 | icons: { |
---|
| 203 | primary: "ui-icon-clock" |
---|
| 204 | }, |
---|
| 205 | text: false |
---|
| 206 | }).click(function () { |
---|
| 207 | //Remove incompativbilidade de acls |
---|
| 208 | incompatibleAcl($(this), ['r', 'w', 'd', 's' ], ['read', 'write', 'remove', 'shared']); |
---|
| 209 | changeAcl($(this), 'b'); |
---|
| 210 | }) |
---|
| 211 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 212 | .removeClass('new').end() |
---|
| 213 | |
---|
| 214 | .filter(".shared.new").button({ |
---|
| 215 | icons: { |
---|
| 216 | primary: "ui-icon-transferthick-e-w" |
---|
| 217 | }, |
---|
| 218 | text: false |
---|
| 219 | }).click(function () { |
---|
| 220 | incompatibleAcl($(this), ['b',], ['busy']); |
---|
| 221 | dependsAcl($(this), ['r'], ['read']); |
---|
| 222 | changeAcl($(this), 's'); |
---|
| 223 | }) |
---|
| 224 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 225 | .removeClass('new').end() |
---|
| 226 | |
---|
| 227 | .filter(".close.new").button({ |
---|
| 228 | icons: { |
---|
| 229 | primary: "ui-icon-close" |
---|
| 230 | }, |
---|
| 231 | text: false |
---|
| 232 | }).click(function () { |
---|
| 233 | currentUsers[$(this).parents().find('input[name="user[]"]').val()] = false; |
---|
| 234 | $(this).parents('li').remove(); |
---|
| 235 | }) |
---|
| 236 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 237 | .removeClass('new').end(); |
---|
| 238 | |
---|
| 239 | UI.dialogs.sharedCalendar.find('.user-list li').hover( |
---|
| 240 | function () { |
---|
| 241 | $(this).addClass("hover-user"); |
---|
| 242 | $(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 243 | .find('.user-acls-shared-calendar').addClass('hover-user'); |
---|
| 244 | }, |
---|
| 245 | function () { |
---|
| 246 | $(this).removeClass("hover-user"); |
---|
| 247 | $(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 248 | .find('.user-acls-shared-calendar').removeClass('hover-user');; |
---|
| 249 | } |
---|
| 250 | ); |
---|
| 251 | } |
---|
[5617] | 252 | |
---|
[5592] | 253 | //Carrega os dados já cadastrados |
---|
| 254 | var dataCurrent = DataLayer.get('calendarToPermission:detail', {filter: ['=','calendar', calendarId] , criteria: {deepness: 2}}, true); |
---|
| 255 | if(dataCurrent){ |
---|
| 256 | for(var i = 0; i < dataCurrent.length; i++){ |
---|
| 257 | if(dataCurrent[i].user == "0"){ |
---|
| 258 | UI.dialogs.sharedCalendar.find('input[name="isPublic"]').attr('checked', 'checked') |
---|
| 259 | .parent().find('.free-busy').toggleClass('hidden'); |
---|
| 260 | if(dataCurrent[i].acl['busy']) |
---|
| 261 | UI.dialogs.sharedCalendar.find('input[name="isPublic"]').attr('checked', 'checked'); |
---|
| 262 | }else{ |
---|
| 263 | currentUsers[dataCurrent[i].user.id] = true; |
---|
| 264 | |
---|
| 265 | UI.dialogs.sharedCalendar.find('dd.user-list ul.user-list') |
---|
| 266 | .append(DataLayer.render('templates/user_shared_add_itemlist.ejs', [{id: dataCurrent[i].user.id, name: dataCurrent[i].user.name, mail: dataCurrent[i].user.mail, acl:dataCurrent[i].acl, aclValue: dataCurrent[i].aclValues}])) |
---|
| 267 | .scrollTo('max'); |
---|
| 268 | $('li.not-user').remove(); |
---|
| 269 | callbackSharedCotactsAdd(); |
---|
| 270 | |
---|
| 271 | for (var f in dataCurrent[i].acl){ |
---|
| 272 | if(dataCurrent[i].acl[f]){ |
---|
| 273 | UI.dialogs.sharedCalendar.find('.'+f+':last').toggleClass('attendee-permissions-change-button') |
---|
| 274 | .find('span:first').toggleClass('attendee-permissions-change').end(); |
---|
| 275 | } |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | UI.dialogs.sharedCalendar.dialog('open'); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | function show_modal_search_shared(){ |
---|
| 284 | |
---|
| 285 | var html = DataLayer.render('templates/shared_calendar.ejs', {}); |
---|
| 286 | |
---|
| 287 | //Variaval global para manipulação dos usuários |
---|
| 288 | //melhor perforface |
---|
[5617] | 289 | currentCalendars = {}; |
---|
[5592] | 290 | |
---|
| 291 | if (!UI.dialogs.sharedCalendar) { |
---|
| 292 | UI.dialogs.sharedCalendar = jQuery('#calendarShared').append('<div title="Pesquisar Agendas" class="shared-calendar active"> <div>').find('.shared-calendar.active').html(html).dialog({ |
---|
| 293 | resizable: false, |
---|
| 294 | modal:true, |
---|
| 295 | autoOpen: false, |
---|
| 296 | width:620, |
---|
| 297 | position: 'center', |
---|
| 298 | close: function(event, ui) { |
---|
| 299 | //Implementações de cancelar :D |
---|
[5617] | 300 | currentCalendars = {}; |
---|
[5592] | 301 | $('.signed-calendars').find('.calendar-shared-search input').val('').Watermark('Pesquisar agendas...'); |
---|
| 302 | } |
---|
| 303 | }); |
---|
| 304 | } else { |
---|
| 305 | UI.dialogs.sharedCalendar.html(html); |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | UI.dialogs.sharedCalendar.find('.button').button() |
---|
| 309 | .filter('.cancel').click(function(evt){ |
---|
| 310 | UI.dialogs.sharedCalendar.dialog("close"); |
---|
| 311 | }).end() |
---|
| 312 | .filter('.save').click(function(evt){ |
---|
| 313 | $.each(UI.dialogs.sharedCalendar.find('.user-list li'), function( i , element ){ |
---|
| 314 | var idPermission = $(element).find('input[name="idpermission[]"]').val(); |
---|
| 315 | var calendarId = $(element).find('input[name="calendar[]"]').val(); |
---|
| 316 | var type = parseInt($(element).find('input[name="type[]"]').val()); |
---|
| 317 | DataLayer.put('calendarSignature', DataLayer.merge({calendar: calendarId, isOwner: 0, user: User.me.id, fontColor: '120d0d', backgroundColor: (!!type ? 'fbec88' : '8c8c8c'), borderColor: (!!type ? 'fad24e' : '120d0d')}, !!idPermission ? {id: idPermission} : {} )); |
---|
| 318 | }); |
---|
[5615] | 319 | |
---|
| 320 | DataLayer.commit( false, false, function( received ){ |
---|
| 321 | delete Calendar.currentViewKey; |
---|
| 322 | Calendar.load(); |
---|
| 323 | refresh_calendars(); |
---|
| 324 | }); |
---|
| 325 | |
---|
[5592] | 326 | UI.dialogs.sharedCalendar.dialog("close"); |
---|
| 327 | |
---|
| 328 | }); |
---|
| 329 | |
---|
| 330 | UI.dialogs.sharedCalendar.find('.add-user-search .ui-icon-search').click(function(event) { |
---|
| 331 | UI.dialogs.sharedCalendar.find('.add-user-search input').keydown(); |
---|
| 332 | }); |
---|
| 333 | |
---|
| 334 | UI.dialogs.sharedCalendar.find('.add-user-search input').keydown(function(event) { |
---|
| 335 | if(event.keyCode == '13' || typeof(event.keyCode) == 'undefined') { |
---|
| 336 | var result = DataLayer.get('calendarToPermission', {filter: ['AND', ['=','user',User.me.id], ['OR', ['i*','name',$(this).val()], ["i*", "description", $(this).val()]]] , criteria: {deepness: 2}}, true); |
---|
| 337 | var resultPublic = DataLayer.get('calendarToPermission', {filter: ['AND', ['=','type',1], ['OR', ['i*','name',$(this).val()], ["i*", "description", $(this).val()]]] , criteria: {deepness: 2}}, true); |
---|
| 338 | |
---|
| 339 | /** |
---|
| 340 | * TODO: trocar por template |
---|
| 341 | */ |
---|
| 342 | UI.dialogs.sharedCalendar.find('ul.search-result-list').empty().css('overflow', 'hidden'); |
---|
| 343 | if (!result && !resultPublic) { |
---|
| 344 | UI.dialogs.sharedCalendar.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>'); |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | if(resultPublic){ |
---|
| 348 | var notConflict = []; |
---|
| 349 | var conflit = false; |
---|
| 350 | for(var i = 0; i < resultPublic.length; i++){ |
---|
| 351 | for(var j = 0; j < result.length; j++){ |
---|
| 352 | if(resultPublic[i].id == result[j].calendar.id) |
---|
| 353 | conflit = true; |
---|
| 354 | }if(!conflit){ |
---|
| 355 | notConflict.push(resultPublic[i]); |
---|
| 356 | conflit = false; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | resultPublic = notConflict; |
---|
| 361 | |
---|
| 362 | var resultNormalize = []; |
---|
| 363 | for(i=0; i<result.length; i++){ |
---|
| 364 | resultNormalize.push({id: result[i].calendar.id, name:result[i].calendar.name, mail: result[i].calendar.description, type: 0 }) |
---|
| 365 | resultNormalize[i].enabled = currentCalendars[result[i].id] ? false : true; |
---|
| 366 | } |
---|
| 367 | if(resultPublic) |
---|
| 368 | for(i=0; i<resultPublic.length; i++){ |
---|
| 369 | resultNormalize.push({id: resultPublic[i].calendar.id, name:resultPublic[i].calendar.name, mail: resultPublic[i].calendar.description,type: 1 }) |
---|
| 370 | resultNormalize[i].enabled = currentCalendars[resultPublic[i].id] ? false : true; |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | UI.dialogs.sharedCalendar.find('ul.search-result-list').append(DataLayer.render( 'templates/participants_search_itemlist.ejs', resultNormalize)); |
---|
| 374 | |
---|
| 375 | UI.dialogs.sharedCalendar.find('ul.search-result-list li').click(function(event, ui){ |
---|
| 376 | if ($(event.target).is('input')) { |
---|
| 377 | old_item = $(event.target).parents('li'); |
---|
| 378 | var id = old_item.find('.id').html(); |
---|
| 379 | |
---|
| 380 | for(var i = 0; i<resultNormalize.length; i++){ |
---|
| 381 | if(resultNormalize[i].id == id) |
---|
| 382 | currentCalendars[id] = { id: id, name: resultNormalize[i].name, description: resultNormalize[i].description, type: resultNormalize[i].type, isCalendar: true}; |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | UI.dialogs.sharedCalendar.find('dd.calendar-list ul.user-list') |
---|
| 386 | .append(DataLayer.render('templates/user_shared_add_itemlist.ejs', [currentCalendars[id]])) |
---|
| 387 | .scrollTo('max'); |
---|
| 388 | |
---|
| 389 | $('li.not-user').remove(); |
---|
| 390 | callbackSharedCalendarAdd(); |
---|
| 391 | old_item.remove(); |
---|
| 392 | } |
---|
| 393 | }); |
---|
| 394 | event.preventDefault(); |
---|
| 395 | } |
---|
| 396 | }); |
---|
| 397 | |
---|
| 398 | var callbackSharedCalendarAdd = function(event){ |
---|
| 399 | |
---|
| 400 | UI.dialogs.sharedCalendar.find('.button').filter(".close.new").button({ |
---|
| 401 | icons: { |
---|
| 402 | primary: "ui-icon-close" |
---|
| 403 | }, |
---|
| 404 | text: false |
---|
| 405 | }).click(function () { |
---|
| 406 | currentCalendars[$(this).parents().find('input[name="calendar[]"]').val()] = false; |
---|
| 407 | $(this).parents('li').remove(); |
---|
| 408 | }) |
---|
| 409 | .addClass('tiny disable ui-button-disabled ui-state-disabled') |
---|
| 410 | .removeClass('new').end(); |
---|
| 411 | |
---|
| 412 | UI.dialogs.sharedCalendar.find('.user-list li').hover( |
---|
| 413 | function () { |
---|
| 414 | $(this).addClass("hover-user"); |
---|
| 415 | $(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 416 | .find('.user-acls-shared-calendar').addClass('hover-user'); |
---|
| 417 | }, |
---|
| 418 | function () { |
---|
| 419 | $(this).removeClass("hover-user"); |
---|
| 420 | $(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end() |
---|
| 421 | .find('.user-acls-shared-calendar').removeClass('hover-user');; |
---|
| 422 | } |
---|
| 423 | ); |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | //Carrega os dados já cadastrados |
---|
| 427 | for (var i = 0; i < Calendar.signatures.length; i++) |
---|
| 428 | if(Calendar.signatures[i].isOwner == "0"){ |
---|
| 429 | var dataCurrent = Calendar.signatures[i].calendar; |
---|
| 430 | currentCalendars[Calendar.signatures[i].permission.id] = { id: dataCurrent.id, idPermission:Calendar.signatures[i].id ,name: dataCurrent.name, description: dataCurrent.description, type: Calendar.signatures[i].permission.type, isCalendar: true}; |
---|
| 431 | |
---|
| 432 | UI.dialogs.sharedCalendar.find('dd.calendar-list ul.user-list') |
---|
| 433 | .append(DataLayer.render('templates/user_shared_add_itemlist.ejs', [currentCalendars[Calendar.signatures[i].permission.id]])) |
---|
| 434 | .scrollTo('max'); |
---|
| 435 | |
---|
| 436 | $('li.not-user').remove(); |
---|
| 437 | callbackSharedCalendarAdd(); |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | UI.dialogs.sharedCalendar.dialog('open'); |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | function cancel_signature(signatureId){ |
---|
| 444 | $.Zebra_Dialog('Confirma a remoção desta assinatura ?', { |
---|
| 445 | 'type': 'question', |
---|
| 446 | 'overlay_opacity': '0.5', |
---|
| 447 | 'buttons': ['Sim', 'Não'], |
---|
| 448 | 'onClose': function(clicked) { |
---|
| 449 | if(clicked == 'Sim'){ |
---|
| 450 | DataLayer.remove('calendarSignature', ''+signatureId); |
---|
[5617] | 451 | DataLayer.commit( false, false, function( received ){ |
---|
| 452 | delete Calendar.currentViewKey; |
---|
| 453 | Calendar.load(); |
---|
| 454 | refresh_calendars(); |
---|
| 455 | }); |
---|
[5592] | 456 | } |
---|
| 457 | } |
---|
| 458 | }); |
---|
| 459 | } |
---|