Changeset 4498 for sandbox/2.2.0.2/contactcenter/js
- Timestamp:
- 05/24/11 17:58:15 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.2.0.2/contactcenter/js/cc.js
r4305 r4498 74 74 /* Connections Variables */ 75 75 var CC_conn_last_selected = 0; 76 77 /* Grupos inicialmente selecionados */ 78 var CC_initial_selected_grps = new Array(); 76 79 77 80 /***********************************************\ … … 344 347 345 348 /* Populate Connection Types */ 346 i = 1; 349 /* 350 * Código não funcional com o expresso. 351 */ 352 /*i = 1; 347 353 for (j in data[4]) 348 354 { 349 355 Element('cc_conn_type').options[i] = new Option(data[4][j], j); 350 356 i++; 351 } 352 357 }*/ 358 353 359 /* Populate Relations Types */ 360 /* 361 * Código conflitante com a modificação de seleção de grupos durante 362 * a criação de um novo contato. Também foi verificado que este código não 363 * é funcional. 364 */ 365 /* 354 366 i = 0; 355 367 for (j in data[5]) … … 357 369 Element('cc_rels_type').options[i] = new Option(data[5][j], j); 358 370 i++; 371 }*/ 372 373 /* Populate available groups */ 374 i = 0; 375 var grupos = data[5]; 376 for (var grupo in grupos) 377 { 378 Element('id_grps_available').options[i] = new Option(grupos[grupo]['title'], grupos[grupo]['id_group']); 379 i++; 359 380 } 360 381 … … 364 385 365 386 Connector.newRequest('populateFullAddConst', CC_url+'get_contact_full_add_const', 'GET', handler); 387 } 388 389 /* 390 * Função que faz a seleção do grupo. 391 * Autor: Luiz Carlos Viana Melo - Prognus 392 */ 393 function selectGroup() 394 { 395 grps_avail = Element('id_grps_available'); 396 grps_selec = Element('id_grps_selected'); 397 398 for (i = 0; i < grps_avail.length; i++) 399 { 400 if (grps_avail.options[i].selected) { 401 isSelected = false; 402 403 for(var j = 0;j < grps_selec.options.length; j++) { 404 if(grps_selec.options[j].value === grps_avail.options[i].value){ 405 isSelected = true; 406 break; 407 } 408 } 409 410 if(!isSelected){ 411 412 option = document.createElement('option'); 413 option.value = grps_avail.options[i].value; 414 option.text = grps_avail.options[i].text; 415 option.selected = false; 416 grps_selec.options[grps_selec.options.length] = option; 417 418 } 419 420 } 421 } 422 423 for (j =0; j < grps_avail.options.length; j++) 424 grps_avail.options[j].selected = false; 425 } 426 427 /* 428 * Função que remove um grupo selecionado. 429 * Autor: Luiz Carlos Viana Melo - Prognus 430 */ 431 function deselectGroup() 432 { 433 grps_selec = Element('id_grps_selected'); 434 435 for(var i = 0;i < grps_selec.options.length; i++) 436 if(grps_selec.options[i].selected) 437 grps_selec.options[i--] = null; 366 438 } 367 439 … … 384 456 Element('cc_full_add_contact_id').value = data['cc_full_add_contact_id']; 385 457 populatePersonalData(data['personal']); 458 populateContactGroups(data['groups']); 386 459 //populateRelations(data['relations']); 387 460 }; 388 461 Connector.newRequest('populateFullEdit', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_full_data&id=' + id + "&catalog="+catalog, 'GET', handler); 462 } 463 464 /* 465 * Função que preenche a lista de grupos a qual o contato pertence. 466 * Autor: Luiz Carlos Viana Melo - Prognus 467 */ 468 function populateContactGroups(groupsData) 469 { 470 groups_selected = Element('id_grps_selected'); 471 var i = 0; 472 CC_initial_selected_grps = new Array(); 473 for (var group in groupsData) 474 { 475 var id_group = groupsData[group]['id_group']; 476 option = document.createElement('option'); 477 option.value = id_group; 478 option.text = groupsData[group]['title']; 479 option.selected = false; 480 groups_selected.options[i++] = option; 481 CC_initial_selected_grps[id_group] = new Array(); 482 CC_initial_selected_grps[id_group]['id_group'] = id_group; 483 CC_initial_selected_grps[id_group]['title'] = groupsData[group]['title']; 484 CC_initial_selected_grps[id_group]['short_name'] = groupsData[group]['short_name']; 485 } 389 486 } 390 487 … … 441 538 function resetFullAdd() 442 539 { 540 /* Groups */ 541 gprs_selected = Element('id_grps_selected'); 542 for (j =0; j < gprs_selected.options.length; j++) { 543 gprs_selected.options[j].selected = false; 544 gprs_selected.options[j--] = null; 545 } 443 546 /* Clear information container */ 444 547 CC_contact_full_info = new Array(); … … 706 809 } 707 810 811 data['groups'] = getAddedRemovedGroups(); 812 708 813 var serial = serialize(data); 709 814 return 'data=' + escape(serialize(data)); 815 } 816 817 /* 818 * Função que retorna os grupos que foram anteriormente selecionados, adicionados ou removidos pelo 819 * usuário. O formato retornado é um array contendo: 820 * ['added'] { 821 * [id_group] { 822 * 'id_group' => o ID do grupo 823 * 'title' => o título do grupo 824 * } 825 * }, 826 * ['removed'] { 827 * [id_group] { 828 * 'id_group' => o ID do grupo 829 * 'title' => o título do grupo 830 * } 831 * } 832 * Autor: Luiz Carlos Viana Melo - Prognus 833 */ 834 function getAddedRemovedGroups() 835 { 836 var selected_groups = getSelectedGroups(); 837 var added_groups = diffContactIDArray(selected_groups, CC_initial_selected_grps); 838 var removed_groups = diffContactIDArray(CC_initial_selected_grps, selected_groups); 839 var groups = new Array(); 840 groups['added'] = added_groups; 841 groups['removed'] = removed_groups; 842 return groups; 843 } 844 845 /* 846 * Função que retorna os grupos que foram selecionados pelo usuário. O formato retornado é: 847 * [id_group] { 848 * 'id_group' => o ID do grupo 849 * 'title' => o título do grupo 850 * } 851 * Autor: Luiz Carlos Viana Melo - Prognus 852 */ 853 function getSelectedGroups() 854 { 855 var gprs_selected = Element('id_grps_selected'); 856 var data = new Array(); 857 for(i = 0; i < gprs_selected.options.length; i++) 858 { 859 var id_group = gprs_selected.options[i].value; 860 data[id_group] = new Array(); 861 data[id_group]['id_group'] = id_group; 862 data[id_group]['title'] = gprs_selected.options[i].text; 863 } 864 return data; 865 } 866 867 /* 868 * Função que retorna a diferença entre 2 arrays com ID dos contatos. 869 * Autor: Luiz Carlos Viana Melo - Prognus 870 */ 871 function diffContactIDArray(array1, array2) 872 { 873 var diff = new Array(); 874 for (var group in array1) 875 { 876 if (!array2[group]) 877 diff.push(array1[group]); 878 } 879 return diff; 710 880 } 711 881
Note: See TracChangeset
for help on using the changeset viewer.