| @@ -1,4 +1,32 @@ | ||
| 1 | +function getMentionDropdown(editor) { | |
| 2 | + let body = jQuery(editor.getBody()); | |
| 3 | + let dropdown = body.find('#wppm_mention_list'); | |
| 4 | + | |
| 5 | + if (!dropdown.length) { | |
| 6 | + dropdown = jQuery('<div id="wppm_mention_list"></div>'); | |
| 7 | + body.append(dropdown); | |
| 8 | + } | |
| 9 | + if (!editor.mentionDropdown) { | |
| 10 | + return editor.mentionDropdown; | |
| 11 | + }else{ | |
| 12 | + return dropdown; | |
| 13 | + } | |
| 14 | +} | |
| 15 | + | |
| 16 | +function updateActiveItem(items,mentionIndex) { | |
| 17 | + items.removeClass('active').css({ | |
| 18 | + background: '#fff', | |
| 19 | + color: '#333' | |
| 20 | + }); | |
| 21 | + items.eq(mentionIndex) | |
| 22 | + .addClass('active') | |
| 23 | + .css({ | |
| 24 | + background: '#0073aa', | |
| 25 | + color: '#fff' | |
| 26 | + }); | |
| 27 | +} | |
| 28 | + | |
| 1 | 29 | function wppm_add_new_project(){ |
| 2 | 30 | jQuery('#wppm_project_container').show(); |
| 3 | 31 | jQuery('#wppm_project_container').html(wppm_admin.loading_html); |
| 4 | 32 | var data = { |
| @@ -157,9 +185,9 @@ | ||
| 157 | 185 | wppm_open_project(proj_id); |
| 158 | 186 | }); |
| 159 | 187 | } |
| 160 | 188 | |
| 161 | -function wppm_set_task_users(proj_id){ | |
| 189 | +function wppm_set_task_users(proj_id,project_id){ | |
| 162 | 190 | var dataform = new FormData(jQuery('#frm_get_task_users')[0]); |
| 163 | 191 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 164 | 192 | var task_id = jQuery('#wppm_task_id').val(); |
| 165 | 193 | jQuery.ajax({ |
| @@ -174,9 +202,9 @@ | ||
| 174 | 202 | wppm_task_modal_close(); |
| 175 | 203 | wppm_open_project_tasks(task_id,proj_id); |
| 176 | 204 | }else if((proj_id==0)||(proj_id=="")){ |
| 177 | 205 | wppm_task_modal_close(); |
| 178 | - wppm_open_task(task_id); | |
| 206 | + wppm_open_task(task_id,project_id); | |
| 179 | 207 | } |
| 180 | 208 | }); |
| 181 | 209 | } |
| 182 | 210 | |
| @@ -185,8 +213,10 @@ | ||
| 185 | 213 | jQuery('#wppm_project_container').html(wppm_admin.loading_html); |
| 186 | 214 | var dataform=new FormData(jQuery('#wppm_project_list_frm')[0]); |
| 187 | 215 | dataform.append("page_no", page_no); |
| 188 | 216 | dataform.append("action", 'wppm_get_project_list'); |
| 217 | + dataform.append("page", wppm_admin.page); | |
| 218 | + dataform.append("wppm_project_filter", wppm_project_filter); | |
| 189 | 219 | jQuery.ajax( { |
| 190 | 220 | url: wppm_admin.ajax_url, |
| 191 | 221 | type: 'POST', |
| 192 | 222 | data: dataform, |
| @@ -197,14 +227,15 @@ | ||
| 197 | 227 | jQuery('#wppm_project_container').html(response); |
| 198 | 228 | }); |
| 199 | 229 | } |
| 200 | 230 | |
| 201 | -function wppm_add_new_task(proj_id){ | |
| 231 | +function wppm_add_new_task(proj_id,project_id){ | |
| 202 | 232 | jQuery('#wppm_task_container').show(); |
| 203 | 233 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 204 | 234 | var data = { |
| 205 | 235 | action: 'wppm_add_new_task', |
| 206 | - proj_id:proj_id | |
| 236 | + proj_id:proj_id, | |
| 237 | + project_id:project_id | |
| 207 | 238 | }; |
| 208 | 239 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 209 | 240 | jQuery('#wppm_task_container').html(response); |
| 210 | 241 | }); |
| @@ -209,15 +240,18 @@ | ||
| 209 | 240 | jQuery('#wppm_task_container').html(response); |
| 210 | 241 | }); |
| 211 | 242 | } |
| 212 | 243 | |
| 213 | -function wppm_get_task_list(page_no){ | |
| 244 | +function wppm_get_task_list(page_no,id){ | |
| 214 | 245 | jQuery('#wppm_task_container').show(); |
| 215 | - window.history.replaceState( {}, null, 'admin.php?page=wppm-tasks§ion=task-list' ); | |
| 246 | + // window.history.replaceState( {}, null, 'admin.php?page=wppm-tasks§ion=task-list' ); | |
| 216 | 247 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 217 | 248 | var data = { |
| 218 | 249 | action: 'wppm_get_task_list', |
| 219 | - page_no:page_no | |
| 250 | + page_no:page_no, | |
| 251 | + page:wppm_admin.page, | |
| 252 | + project_id:id, | |
| 253 | + wppm_task_filter:wppm_task_filter | |
| 220 | 254 | }; |
| 221 | 255 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 222 | 256 | jQuery('#wppm_task_container').html(response); |
| 223 | 257 | }); |
| @@ -295,15 +329,16 @@ | ||
| 295 | 329 | wppm_get_task_status_settings(); |
| 296 | 330 | }); |
| 297 | 331 | } |
| 298 | 332 | |
| 299 | -function wppm_task_search_filter(){ | |
| 333 | +function wppm_task_search_filter(page){ | |
| 300 | 334 | var task_search = jQuery("#wppm_task_search_filter").val(); |
| 301 | 335 | jQuery('#wppm_task_container').show(); |
| 302 | 336 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 303 | 337 | var data = { |
| 304 | 338 | action: 'wppm_get_task_list', |
| 305 | - task_search:task_search | |
| 339 | + task_search:task_search, | |
| 340 | + page:page | |
| 306 | 341 | }; |
| 307 | 342 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 308 | 343 | jQuery('#wppm_task_container').html(response); |
| 309 | 344 | }); |
| @@ -308,10 +343,10 @@ | ||
| 308 | 343 | jQuery('#wppm_task_container').html(response); |
| 309 | 344 | }); |
| 310 | 345 | } |
| 311 | 346 | |
| 312 | -function wppm_view_task_search_filter(page_no){ | |
| 313 | - var task_search = jQuery("#wppm_view_task_search_filter").val(); | |
| 347 | +function wppm_view_task_search_filter(page_no,page,proj_id){ | |
| 348 | + var task_search = jQuery("#wppm_view_task_search_filter").val() || ''; | |
| 314 | 349 | jQuery('#wppm_task_container').show(); |
| 315 | 350 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 316 | 351 | |
| 317 | 352 | var data = { |
| @@ -316,9 +351,11 @@ | ||
| 316 | 351 | |
| 317 | 352 | var data = { |
| 318 | 353 | action: 'wppm_get_task_list_card_view', |
| 319 | 354 | task_search:task_search, |
| 320 | - page_no:page_no | |
| 355 | + page_no:page_no, | |
| 356 | + page:page, | |
| 357 | + project_id:proj_id | |
| 321 | 358 | }; |
| 322 | 359 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 323 | 360 | jQuery('#wppm_task_container').html(response); |
| 324 | 361 | }); |
| @@ -323,15 +360,17 @@ | ||
| 323 | 360 | jQuery('#wppm_task_container').html(response); |
| 324 | 361 | }); |
| 325 | 362 | } |
| 326 | 363 | |
| 327 | -function wppm_open_task(id){ | |
| 364 | +function wppm_open_task(id,proj_id){ | |
| 328 | 365 | jQuery('#wppm_task_container').show(); |
| 329 | 366 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 330 | 367 | var data = { |
| 331 | 368 | action: 'wppm_open_task', |
| 332 | 369 | id:id, |
| 333 | - auth_code: wppm_admin.auth_code | |
| 370 | + auth_code: wppm_admin.auth_code, | |
| 371 | + page:wppm_admin.page, | |
| 372 | + project_id:proj_id | |
| 334 | 373 | }; |
| 335 | 374 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 336 | 375 | jQuery('#wppm_task_container').html(response); |
| 337 | 376 | }); |
| @@ -336,8 +375,20 @@ | ||
| 336 | 375 | jQuery('#wppm_task_container').html(response); |
| 337 | 376 | }); |
| 338 | 377 | } |
| 339 | 378 | |
| 379 | +function wppm_open_dashboard_task(id){ | |
| 380 | + window.location.href = 'admin.php?page=wppm-tasks&task_id=' + id; | |
| 381 | +} | |
| 382 | + | |
| 383 | +function wppm_open_subtask(id,proj_id){ | |
| 384 | + if((proj_id!=0)&&(proj_id!="")){ | |
| 385 | + wppm_open_project_tasks(id,proj_id); | |
| 386 | + }else{ | |
| 387 | + wppm_open_task(id); | |
| 388 | + } | |
| 389 | +} | |
| 390 | + | |
| 340 | 391 | function wppm_open_project_tasks(id,proj_id){ |
| 341 | 392 | wppm_modal_open('Open Tasks'); |
| 342 | 393 | jQuery('#wppm_task_container').show(); |
| 343 | 394 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| @@ -460,8 +511,101 @@ | ||
| 460 | 511 | wppm_open_task(task_id); |
| 461 | 512 | }); |
| 462 | 513 | } |
| 463 | 514 | |
| 515 | +function wppm_show_add_subtask(){ | |
| 516 | + jQuery('#wppm_add_subtask_label_container').show(); | |
| 517 | + jQuery('#wppm_subtask_label').val('').focus(); | |
| 518 | +} | |
| 519 | + | |
| 520 | +function wppm_hide_add_subtask(){ | |
| 521 | + jQuery('#wppm_add_subtask_label_container').hide(); | |
| 522 | + jQuery('#wppm_subtask_label').val(''); | |
| 523 | +} | |
| 524 | + | |
| 525 | +function wppm_remove_subtask_user(e){ | |
| 526 | + jQuery(e).closest('li').remove(); | |
| 527 | +} | |
| 528 | + | |
| 529 | +function wppm_add_new_subtask(task_id,proj_id){ | |
| 530 | + if(jQuery('#wppm_subtask_label').val()==''){ | |
| 531 | + jQuery('#wppm_subtask_label').focus(); | |
| 532 | + return false; | |
| 533 | + } | |
| 534 | + var user_ids = []; | |
| 535 | + jQuery('.wppm_subtask_filter_display_users_container input[name="wppm_subtask_user_names[]"]').each(function(){ | |
| 536 | + user_ids.push(jQuery(this).val()); | |
| 537 | + }); | |
| 538 | + var data = { | |
| 539 | + action: 'wppm_add_new_subtask', | |
| 540 | + task_id: task_id, | |
| 541 | + label: jQuery('#wppm_subtask_label').val(), | |
| 542 | + wppm_subtask_status: jQuery('#wppm_subtask_status').val(), | |
| 543 | + wppm_subtask_due_date: jQuery('#wppm_subtask_due_date').val(), | |
| 544 | + wppm_subtask_description: jQuery('#wppm_subtask_description').val(), | |
| 545 | + wppm_subtask_user_names: user_ids, | |
| 546 | + _ajax_nonce: jQuery('#wppm_add_new_subtask_ajax_nonce').val() | |
| 547 | + }; | |
| 548 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 549 | + if((proj_id!=0)&&(proj_id!="")){ | |
| 550 | + wppm_open_project_tasks(task_id,proj_id); | |
| 551 | + }else{ | |
| 552 | + wppm_open_task(task_id); | |
| 553 | + } | |
| 554 | + }); | |
| 555 | +} | |
| 556 | + | |
| 557 | +function wppm_delete_subtask(subtask_id,task_id,proj_id){ | |
| 558 | + const flag = confirm(wppm_admin.confirm); | |
| 559 | + if (!flag) return; | |
| 560 | + var data = { | |
| 561 | + action: 'wppm_remove_subtask', | |
| 562 | + subtask_id: subtask_id, | |
| 563 | + _ajax_nonce: jQuery('#wppm_remove_subtask_ajax_nonce').val() | |
| 564 | + }; | |
| 565 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 566 | + if((proj_id!=0)&&(proj_id!="")){ | |
| 567 | + wppm_open_project_tasks(task_id,proj_id); | |
| 568 | + }else{ | |
| 569 | + wppm_open_task(task_id); | |
| 570 | + } | |
| 571 | + }); | |
| 572 | +} | |
| 573 | + | |
| 574 | +function wppm_convert_subtask_to_task(subtask_id,reload_task_id,proj_id){ | |
| 575 | + const flag = confirm(wppm_admin.confirm); | |
| 576 | + if (!flag) return; | |
| 577 | + var data = { | |
| 578 | + action: 'wppm_convert_subtask_to_task', | |
| 579 | + subtask_id: subtask_id, | |
| 580 | + _ajax_nonce: jQuery('#wppm_convert_subtask_to_task_ajax_nonce').val() | |
| 581 | + }; | |
| 582 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 583 | + if((proj_id!=0)&&(proj_id!="")){ | |
| 584 | + wppm_open_project_tasks(reload_task_id,proj_id); | |
| 585 | + }else{ | |
| 586 | + wppm_open_task(reload_task_id); | |
| 587 | + } | |
| 588 | + }); | |
| 589 | +} | |
| 590 | + | |
| 591 | +function wppm_toggle_subtask_status(subtask_id,task_id,proj_id,default_status_id,is_checked){ | |
| 592 | + var status_id = is_checked ? 4 : default_status_id; | |
| 593 | + var data = { | |
| 594 | + action: 'wppm_set_change_task_status', | |
| 595 | + task_id: subtask_id, | |
| 596 | + wppm_status: status_id, | |
| 597 | + _ajax_nonce: jQuery('#wppm_subtask_status_ajax_nonce').val() | |
| 598 | + }; | |
| 599 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 600 | + if((proj_id!=0)&&(proj_id!="")){ | |
| 601 | + wppm_open_project_tasks(task_id,proj_id); | |
| 602 | + }else{ | |
| 603 | + wppm_open_task(task_id); | |
| 604 | + } | |
| 605 | + }); | |
| 606 | +} | |
| 607 | + | |
| 464 | 608 | function wppm_open_individual_task(id){ |
| 465 | 609 | jQuery('#wppm_project_container').show(); |
| 466 | 610 | jQuery('#wppm_project_container').html(wppm_admin.loading_html); |
| 467 | 611 | var data = { |
| @@ -472,15 +616,19 @@ | ||
| 472 | 616 | jQuery('#wppm_project_container').html(response); |
| 473 | 617 | }); |
| 474 | 618 | } |
| 475 | 619 | |
| 476 | -function wppm_display_grid_view(){ | |
| 477 | - var task_search = jQuery("#wppm_view_task_search_filter").val(); | |
| 620 | + | |
| 621 | +function wppm_display_grid_view(page,id){ | |
| 622 | + var task_search = jQuery("#wppm_view_task_search_filter").val() || ''; | |
| 478 | 623 | jQuery('#wppm_task_container').show(); |
| 479 | 624 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 480 | 625 | var data = { |
| 481 | 626 | action: 'wppm_get_task_list_card_view', |
| 482 | - task_search: task_search | |
| 627 | + task_search: task_search, | |
| 628 | + wppm_task_filter: wppm_task_filter, | |
| 629 | + page:page, | |
| 630 | + id:id | |
| 483 | 631 | }; |
| 484 | 632 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 485 | 633 | jQuery('#wppm_task_container').html(response); |
| 486 | 634 | }); |
| @@ -551,9 +699,9 @@ | ||
| 551 | 699 | jQuery('.wppm_setting_col2').html(response); |
| 552 | 700 | }); |
| 553 | 701 | } |
| 554 | 702 | |
| 555 | -function wppm_edit_task_status(id,proj_id){ | |
| 703 | +function wppm_edit_task_status(id,proj_id,project_id){ | |
| 556 | 704 | if(proj_id==0){ |
| 557 | 705 | wppm_task_modal_open('Edit'); |
| 558 | 706 | }else{ |
| 559 | 707 | wppm_modal_open('Edit'); |
| @@ -560,9 +708,10 @@ | ||
| 560 | 708 | } |
| 561 | 709 | var data = { |
| 562 | 710 | action: 'wppm_edit_task_status', |
| 563 | 711 | task_id: id, |
| 564 | - proj_id:proj_id | |
| 712 | + proj_id:proj_id, | |
| 713 | + project_id:project_id | |
| 565 | 714 | } |
| 566 | 715 | jQuery.post(wppm_admin.ajax_url, data, function(response_str) { |
| 567 | 716 | var response = JSON.parse(response_str); |
| 568 | 717 | if(proj_id==0){ |
| @@ -574,9 +723,9 @@ | ||
| 574 | 723 | } |
| 575 | 724 | }); |
| 576 | 725 | } |
| 577 | 726 | |
| 578 | -function wppm_edit_task_users(task_id,proj_id){ | |
| 727 | +function wppm_edit_task_users(task_id,proj_id,project_id){ | |
| 579 | 728 | if(proj_id==0){ |
| 580 | 729 | wppm_task_modal_open('Add Users'); |
| 581 | 730 | }else{ |
| 582 | 731 | wppm_modal_open('Add Users'); |
| @@ -583,9 +732,10 @@ | ||
| 583 | 732 | } |
| 584 | 733 | var data = { |
| 585 | 734 | action: 'wppm_get_task_users', |
| 586 | 735 | task_id: task_id, |
| 587 | - proj_id:proj_id | |
| 736 | + proj_id:proj_id, | |
| 737 | + project_id:project_id | |
| 588 | 738 | } |
| 589 | 739 | jQuery.post(wppm_admin.ajax_url, data, function(response_str) { |
| 590 | 740 | var response = JSON.parse(response_str); |
| 591 | 741 | if(proj_id==0){ |
| @@ -597,9 +747,9 @@ | ||
| 597 | 747 | } |
| 598 | 748 | }); |
| 599 | 749 | } |
| 600 | 750 | |
| 601 | -function wppm_edit_task_details(id,proj_id){ | |
| 751 | +function wppm_edit_task_details(id,proj_id,project_id){ | |
| 602 | 752 | if(proj_id==0){ |
| 603 | 753 | wppm_task_modal_open('Edit Task Details'); |
| 604 | 754 | }else{ |
| 605 | 755 | wppm_modal_open('Edit Task Details'); |
| @@ -606,9 +756,10 @@ | ||
| 606 | 756 | } |
| 607 | 757 | var data = { |
| 608 | 758 | action: 'wppm_edit_task_details', |
| 609 | 759 | task_id: id, |
| 610 | - proj_id:proj_id | |
| 760 | + proj_id:proj_id, | |
| 761 | + project_id:project_id | |
| 611 | 762 | } |
| 612 | 763 | jQuery.post(wppm_admin.ajax_url, data, function(response_str) { |
| 613 | 764 | var response = JSON.parse(response_str); |
| 614 | 765 | if(proj_id==0){ |
| @@ -620,9 +771,9 @@ | ||
| 620 | 771 | } |
| 621 | 772 | }); |
| 622 | 773 | } |
| 623 | 774 | |
| 624 | -function wppm_set_change_task_status(task_id,proj_id){ | |
| 775 | +function wppm_set_change_task_status(task_id,proj_id,project_id){ | |
| 625 | 776 | var dataform = new FormData(jQuery('#frm_get_task_change_status')[0]); |
| 626 | 777 | if(proj_id == 0){ |
| 627 | 778 | wppm_task_modal_close(); |
| 628 | 779 | }else{ |
| @@ -639,15 +790,15 @@ | ||
| 639 | 790 | .done(function (response_str) { |
| 640 | 791 | if((proj_id!=0)||(proj_id!="")){ |
| 641 | 792 | wppm_open_project_tasks(task_id,proj_id); |
| 642 | 793 | }else if((proj_id==0)||(proj_id=="")){ |
| 643 | - wppm_open_task(task_id); | |
| 794 | + wppm_open_task(task_id,project_id); | |
| 644 | 795 | } |
| 645 | 796 | |
| 646 | 797 | }); |
| 647 | 798 | } |
| 648 | 799 | |
| 649 | -function wppm_edit_task_creator(task_id,proj_id){ | |
| 800 | +function wppm_edit_task_creator(task_id,proj_id,project_id){ | |
| 650 | 801 | if(proj_id==0){ |
| 651 | 802 | wppm_task_modal_open('Edit Task Creator'); |
| 652 | 803 | }else{ |
| 653 | 804 | wppm_modal_open('Edit Task Creator'); |
| @@ -654,9 +805,10 @@ | ||
| 654 | 805 | } |
| 655 | 806 | var data = { |
| 656 | 807 | action: 'wppm_edit_task_creator', |
| 657 | 808 | task_id: task_id, |
| 658 | - proj_id: proj_id | |
| 809 | + proj_id: proj_id, | |
| 810 | + project_id: project_id | |
| 659 | 811 | } |
| 660 | 812 | jQuery.post(wppm_admin.ajax_url, data, function(response_str) { |
| 661 | 813 | var response = JSON.parse(response_str); |
| 662 | 814 | if(proj_id==0){ |
| @@ -668,9 +820,9 @@ | ||
| 668 | 820 | } |
| 669 | 821 | }); |
| 670 | 822 | } |
| 671 | 823 | |
| 672 | -function wppm_set_change_raised_by(task_id,proj_id){ | |
| 824 | +function wppm_set_change_raised_by(task_id,proj_id,project_id){ | |
| 673 | 825 | var dataform = new FormData(jQuery('#frm_get_task_creator')[0]); |
| 674 | 826 | if(proj_id==0){ |
| 675 | 827 | wppm_task_modal_close(); |
| 676 | 828 | }else{ |
| @@ -687,37 +839,42 @@ | ||
| 687 | 839 | .done(function (response_str) { |
| 688 | 840 | if((proj_id!=0)||(proj_id!="")){ |
| 689 | 841 | wppm_open_project_tasks(task_id,proj_id); |
| 690 | 842 | }else if((proj_id==0)||(proj_id=="")){ |
| 691 | - wppm_open_task(task_id); | |
| 843 | + wppm_open_task(task_id,project_id); | |
| 692 | 844 | } |
| 693 | 845 | }); |
| 694 | 846 | } |
| 695 | 847 | |
| 696 | -function wppm_set_change_task_details(task_id,proj_id){ | |
| 697 | - var dataform = new FormData(jQuery('#frm_get_edit_task_deatils')[0]); | |
| 698 | - var description = tinyMCE.get('wppm_edit_task_description').getContent().trim(); | |
| 699 | - dataform.append('wppm_edit_task_description', description); | |
| 700 | - if(proj_id==0){ | |
| 701 | - wppm_task_modal_close(); | |
| 702 | - }else{ | |
| 703 | - wppm_modal_close(); | |
| 704 | - } | |
| 705 | - jQuery('#wppm_task_container').html(wppm_admin.loading_html); | |
| 706 | - jQuery.ajax({ | |
| 707 | - url: wppm_admin.ajax_url, | |
| 708 | - type: 'POST', | |
| 709 | - data: dataform, | |
| 710 | - processData: false, | |
| 711 | - contentType: false | |
| 712 | - }) | |
| 713 | - .done(function (response_str) { | |
| 714 | - if((proj_id!=0)||(proj_id!="")){ | |
| 715 | - wppm_open_project_tasks(task_id,proj_id); | |
| 716 | - }else if((proj_id==0)||(proj_id=="")){ | |
| 717 | - wppm_open_task(task_id); | |
| 848 | +function wppm_set_change_task_details(task_id, proj_id, project_id) { | |
| 849 | + var dataform = new FormData(jQuery('#frm_get_edit_task_deatils')[0]); | |
| 850 | + var editor = tinyMCE.get('wppm_edit_task_description'); | |
| 851 | + var description = ''; | |
| 852 | + if (editor) { | |
| 853 | + description = editor.getContent().trim(); | |
| 854 | + } else { | |
| 855 | + description = jQuery('#wppm_edit_task_description').val().trim(); | |
| 718 | 856 | } |
| 719 | - }); | |
| 857 | + dataform.append('wppm_edit_task_description', description); | |
| 858 | + if (proj_id == 0) { | |
| 859 | + wppm_task_modal_close(); | |
| 860 | + } else { | |
| 861 | + wppm_modal_close(); | |
| 862 | + } | |
| 863 | + jQuery('#wppm_task_container').html(wppm_admin.loading_html); | |
| 864 | + jQuery.ajax({ | |
| 865 | + url: wppm_admin.ajax_url, | |
| 866 | + type: 'POST', | |
| 867 | + data: dataform, | |
| 868 | + processData: false, | |
| 869 | + contentType: false | |
| 870 | + }).done(function(response_str) { | |
| 871 | + if (proj_id != 0 && proj_id != "") { | |
| 872 | + wppm_open_project_tasks(task_id, proj_id); | |
| 873 | + } else { | |
| 874 | + wppm_open_task(task_id, project_id); | |
| 875 | + } | |
| 876 | + }); | |
| 720 | 877 | } |
| 721 | 878 | |
| 722 | 879 | function wppm_edit_thread(comment_id,task_id,proj_id){ |
| 723 | 880 | if(proj_id==0){ |
| @@ -758,9 +915,13 @@ | ||
| 758 | 915 | } |
| 759 | 916 | |
| 760 | 917 | function wppm_set_edit_task_thread(task_id,proj_id){ |
| 761 | 918 | var dataform = new FormData(jQuery('#frm_edit_task_thread')[0]); |
| 762 | - var comment_body = tinyMCE.get('wppm_edit_task_thread_editor').getContent().trim(); | |
| 919 | + if(wppm_admin.rich_text_editor == 1){ | |
| 920 | + var comment_body = tinyMCE.get('wppm_edit_task_thread_editor').getContent().trim(); | |
| 921 | + }else{ | |
| 922 | + var comment_body = jQuery('#wppm_edit_task_thread_editor').val().trim(); | |
| 923 | + } | |
| 763 | 924 | dataform.append('wppm_edit_task_thread', comment_body); |
| 764 | 925 | if(proj_id==0){ |
| 765 | 926 | wppm_task_modal_close(); |
| 766 | 927 | }else{ |
| @@ -784,9 +945,13 @@ | ||
| 784 | 945 | } |
| 785 | 946 | |
| 786 | 947 | function wppm_set_edit_proj_thread(proj_id){ |
| 787 | 948 | var dataform = new FormData(jQuery('#frm_edit_proj_thread')[0]); |
| 788 | - var comment_body = tinyMCE.get('wppm_edit_proj_thread_editor').getContent().trim(); | |
| 949 | + if(wppm_admin.rich_text_editor == 1){ | |
| 950 | + var comment_body = tinyMCE.get('wppm_edit_proj_thread_editor').getContent().trim(); | |
| 951 | + }else{ | |
| 952 | + var comment_body = jQuery('#wppm_edit_proj_thread_editor').val().trim(); | |
| 953 | + } | |
| 789 | 954 | dataform.append('wppm_edit_proj_thread', comment_body); |
| 790 | 955 | wppm_modal_close(); |
| 791 | 956 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 792 | 957 | jQuery.ajax({ |
| @@ -1009,9 +1174,9 @@ | ||
| 1009 | 1174 | wppm_get_project_list(); |
| 1010 | 1175 | }); |
| 1011 | 1176 | } |
| 1012 | 1177 | |
| 1013 | -function wppm_get_delete_task(id,proj_id){ | |
| 1178 | +function wppm_get_delete_task(id,proj_id,project_id){ | |
| 1014 | 1179 | if(proj_id==0){ |
| 1015 | 1180 | wppm_task_modal_open('Delete Task'); |
| 1016 | 1181 | }else{ |
| 1017 | 1182 | wppm_modal_open('Delete Task'); |
| @@ -1018,9 +1183,10 @@ | ||
| 1018 | 1183 | } |
| 1019 | 1184 | var data = { |
| 1020 | 1185 | action: 'wppm_get_delete_task', |
| 1021 | 1186 | id: id, |
| 1022 | - proj_id:proj_id | |
| 1187 | + proj_id:proj_id, | |
| 1188 | + project_id:project_id | |
| 1023 | 1189 | } |
| 1024 | 1190 | jQuery.post(wppm_admin.ajax_url, data, function(response_str) { |
| 1025 | 1191 | var response = JSON.parse(response_str); |
| 1026 | 1192 | if(proj_id==0){ |
| @@ -1032,9 +1198,9 @@ | ||
| 1032 | 1198 | } |
| 1033 | 1199 | }); |
| 1034 | 1200 | } |
| 1035 | 1201 | |
| 1036 | -function wppm_set_delete_task(proj_id){ | |
| 1202 | +function wppm_set_delete_task(proj_id,project_id){ | |
| 1037 | 1203 | var dataform = new FormData(jQuery('#frm_delete_task')[0]); |
| 1038 | 1204 | if(proj_id==0){ |
| 1039 | 1205 | wppm_task_modal_close(); |
| 1040 | 1206 | }else{ |
| @@ -1047,12 +1213,16 @@ | ||
| 1047 | 1213 | processData: false, |
| 1048 | 1214 | contentType: false |
| 1049 | 1215 | }) |
| 1050 | 1216 | .done(function (response_str) { |
| 1051 | - if(proj_id==0){ | |
| 1052 | - wppm_get_task_list(); | |
| 1217 | + if(project_id!=0){ | |
| 1218 | + wppm_get_project_tasks_kanban_view(project_id); | |
| 1053 | 1219 | }else{ |
| 1054 | - wppm_get_project_tasks(proj_id); | |
| 1220 | + if(proj_id==0){ | |
| 1221 | + wppm_get_task_list(); | |
| 1222 | + }else{ | |
| 1223 | + wppm_get_project_tasks(proj_id); | |
| 1224 | + } | |
| 1055 | 1225 | } |
| 1056 | 1226 | }); |
| 1057 | 1227 | } |
| 1058 | 1228 | |
| @@ -1178,20 +1348,49 @@ | ||
| 1178 | 1348 | jQuery('#wppm_popup_body').html(response_str); |
| 1179 | 1349 | }); |
| 1180 | 1350 | } |
| 1181 | 1351 | |
| 1182 | -function wppm_load_prev_page(prev_page_no,page_no,sort_by, order){ | |
| 1183 | - if(prev_page_no!=0){ | |
| 1184 | - page_no=prev_page_no-1; | |
| 1185 | - wppm_get_project_list(page_no,sort_by,order); | |
| 1186 | - } | |
| 1352 | +function wppm_load_prev_page(prev_page_no, page_no, sort_by, order, is_archieved) { | |
| 1353 | + if (prev_page_no != 0) { | |
| 1354 | + page_no = prev_page_no - 1; | |
| 1355 | + if (parseInt(is_archieved) === 1) { | |
| 1356 | + wppm_get_archieve_project_list( | |
| 1357 | + page_no, | |
| 1358 | + sort_by, | |
| 1359 | + order, | |
| 1360 | + 1 | |
| 1361 | + ); | |
| 1362 | + } else { | |
| 1363 | + wppm_get_project_list( | |
| 1364 | + page_no, | |
| 1365 | + sort_by, | |
| 1366 | + order | |
| 1367 | + ); | |
| 1368 | + } | |
| 1369 | + } | |
| 1370 | + return false; | |
| 1187 | 1371 | } |
| 1188 | 1372 | |
| 1189 | -function wppm_load_next_page(next_page_no,page_no,sort_by,order){ | |
| 1190 | - if(next_page_no!=page_no){ | |
| 1191 | - page_no = next_page_no; | |
| 1192 | - wppm_get_project_list(page_no,sort_by,order); | |
| 1193 | - } | |
| 1373 | +function wppm_load_next_page(next_page_no, page_no, sort_by, order, is_archieved) { | |
| 1374 | + if (next_page_no != page_no) { | |
| 1375 | + page_no = next_page_no; | |
| 1376 | + if (parseInt(is_archieved) === 1) { | |
| 1377 | + wppm_get_archieve_project_list( | |
| 1378 | + page_no, | |
| 1379 | + sort_by, | |
| 1380 | + order, | |
| 1381 | + 1 | |
| 1382 | + ); | |
| 1383 | + } else { | |
| 1384 | + wppm_get_project_list( | |
| 1385 | + page_no, | |
| 1386 | + sort_by, | |
| 1387 | + order | |
| 1388 | + ); | |
| 1389 | + } | |
| 1390 | + } | |
| 1391 | + | |
| 1392 | + return false; | |
| 1194 | 1393 | } |
| 1195 | 1394 | |
| 1196 | 1395 | function wppm_load_prev_task_page(prev_page_no,page_no, sort_by, order){ |
| 1197 | 1396 | if(prev_page_no!=0){ |
| @@ -1270,15 +1469,17 @@ | ||
| 1270 | 1469 | jQuery('#wppm_project_container').html(response); |
| 1271 | 1470 | }); |
| 1272 | 1471 | } |
| 1273 | 1472 | |
| 1274 | -function wppm_project_search_filter(){ | |
| 1473 | +function wppm_project_search_filter(is_archieved){ | |
| 1275 | 1474 | var project_search = jQuery("#wppm_project_search_filter").val(); |
| 1276 | 1475 | jQuery('#wppm_project_container').show(); |
| 1277 | 1476 | jQuery('#wppm_project_container').html(wppm_admin.loading_html); |
| 1278 | 1477 | var data = { |
| 1279 | 1478 | action: 'wppm_get_project_list', |
| 1280 | - project_search:project_search | |
| 1479 | + project_search:project_search, | |
| 1480 | + page: wppm_admin.page, | |
| 1481 | + is_archieved:is_archieved | |
| 1281 | 1482 | }; |
| 1282 | 1483 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1283 | 1484 | jQuery('#wppm_project_container').html(response); |
| 1284 | 1485 | }); |
| @@ -1283,9 +1484,9 @@ | ||
| 1283 | 1484 | jQuery('#wppm_project_container').html(response); |
| 1284 | 1485 | }); |
| 1285 | 1486 | } |
| 1286 | 1487 | |
| 1287 | -function wppm_clone_task(id,proj_id){ | |
| 1488 | +function wppm_clone_task(id,proj_id,project_id){ | |
| 1288 | 1489 | if(proj_id==0){ |
| 1289 | 1490 | wppm_task_modal_open('Clone Task'); |
| 1290 | 1491 | }else{ |
| 1291 | 1492 | wppm_modal_open('Clone Task'); |
| @@ -1292,9 +1493,10 @@ | ||
| 1292 | 1493 | } |
| 1293 | 1494 | var data = { |
| 1294 | 1495 | action: 'wppm_clone_task', |
| 1295 | 1496 | id: id, |
| 1296 | - proj_id: proj_id | |
| 1497 | + proj_id: proj_id, | |
| 1498 | + project_id: project_id | |
| 1297 | 1499 | } |
| 1298 | 1500 | jQuery.post(wppm_admin.ajax_url, data, function(response_str) { |
| 1299 | 1501 | var response = JSON.parse(response_str); |
| 1300 | 1502 | if(proj_id==0){ |
| @@ -1306,9 +1508,9 @@ | ||
| 1306 | 1508 | } |
| 1307 | 1509 | }); |
| 1308 | 1510 | } |
| 1309 | 1511 | |
| 1310 | -function wppm_set_clone_task(proj_id){ | |
| 1512 | +function wppm_set_clone_task(proj_id,project_id){ | |
| 1311 | 1513 | var dataform = new FormData(jQuery('#frm_edit_clone_task_name')[0]); |
| 1312 | 1514 | if(proj_id==0){ |
| 1313 | 1515 | wppm_task_modal_close(); |
| 1314 | 1516 | }else{ |
| @@ -1321,23 +1523,28 @@ | ||
| 1321 | 1523 | processData: false, |
| 1322 | 1524 | contentType: false |
| 1323 | 1525 | }) |
| 1324 | 1526 | .done(function (response_str) { |
| 1325 | - if(proj_id==0){ | |
| 1326 | - wppm_get_task_list(); | |
| 1527 | + if(project_id!=0){ | |
| 1528 | + wppm_get_project_tasks_kanban_view(project_id); | |
| 1327 | 1529 | }else{ |
| 1328 | - wppm_get_project_tasks(proj_id); | |
| 1530 | + if(proj_id==0){ | |
| 1531 | + wppm_get_task_list(); | |
| 1532 | + }else{ | |
| 1533 | + wppm_get_project_tasks(proj_id); | |
| 1534 | + } | |
| 1329 | 1535 | } |
| 1330 | 1536 | }); |
| 1331 | 1537 | } |
| 1332 | 1538 | |
| 1333 | -function wppm_sort_up_task_list(sort_by,order){ | |
| 1539 | +function wppm_sort_up_task_list(sort_by,order,page){ | |
| 1334 | 1540 | jQuery('#wppm_task_container').show(); |
| 1335 | 1541 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1336 | 1542 | var data = { |
| 1337 | 1543 | action: 'wppm_get_task_list', |
| 1338 | 1544 | sort_by:sort_by, |
| 1339 | - order:order | |
| 1545 | + order:order, | |
| 1546 | + page:page | |
| 1340 | 1547 | }; |
| 1341 | 1548 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1342 | 1549 | jQuery('#wppm_task_container').html(response); |
| 1343 | 1550 | }); |
| @@ -1348,9 +1555,10 @@ | ||
| 1348 | 1555 | jQuery('#wppm_project_container').html(wppm_admin.loading_html); |
| 1349 | 1556 | var data = { |
| 1350 | 1557 | action: 'wppm_get_project_list', |
| 1351 | 1558 | sort_by:sort_by, |
| 1352 | - order:order | |
| 1559 | + order:order, | |
| 1560 | + page: wppm_admin.page | |
| 1353 | 1561 | }; |
| 1354 | 1562 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1355 | 1563 | jQuery('#wppm_project_container').html(response); |
| 1356 | 1564 | }); |
| @@ -1780,14 +1988,16 @@ | ||
| 1780 | 1988 | jQuery.post(wppm_admin.ajax_url, data, function() { |
| 1781 | 1989 | }); |
| 1782 | 1990 | } |
| 1783 | 1991 | |
| 1784 | -function wppm_apply_project_filter(){ | |
| 1992 | +function wppm_apply_project_filter(is_archieved){ | |
| 1785 | 1993 | wppm_project_filter = jQuery('#wppm_project_filter').find(":selected").val(); |
| 1786 | 1994 | jQuery('#wppm_project_container').html(wppm_admin.loading_html); |
| 1787 | 1995 | var data = { |
| 1788 | 1996 | action: 'wppm_get_project_list', |
| 1789 | - wppm_project_filter:wppm_project_filter | |
| 1997 | + wppm_project_filter:wppm_project_filter, | |
| 1998 | + page:wppm_admin.page, | |
| 1999 | + is_archieved:is_archieved | |
| 1790 | 2000 | }; |
| 1791 | 2001 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1792 | 2002 | jQuery('#wppm_project_container').html(response); |
| 1793 | 2003 | }); |
| @@ -1792,21 +2002,70 @@ | ||
| 1792 | 2002 | jQuery('#wppm_project_container').html(response); |
| 1793 | 2003 | }); |
| 1794 | 2004 | } |
| 1795 | 2005 | |
| 1796 | -function wppm_apply_task_filter(){ | |
| 1797 | - wppm_task_filter = jQuery('#wppm_task_filter').find(":selected").val(); | |
| 2006 | +function getWppmCookie(name) { | |
| 2007 | + const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); | |
| 2008 | + if (match) return decodeURIComponent(match[2]); | |
| 2009 | + return null; | |
| 2010 | +} | |
| 2011 | + | |
| 2012 | +function wppm_apply_task_filter(page = 1, listFilters = null) { | |
| 2013 | + // 🔥 use passed filters OR read from UI | |
| 2014 | + if (!listFilters) { | |
| 2015 | + listFilters = { | |
| 2016 | + created_by: jQuery("#tb-created-by").val() || [], | |
| 2017 | + assigned: jQuery("#tb-assigned").val() || [], | |
| 2018 | + priority: jQuery("#tb-priority").val() || [], | |
| 2019 | + start_date: jQuery("#tb-start-date").val() || "", | |
| 2020 | + end_date: jQuery("#tb-end-date").val() || "" | |
| 2021 | + }; | |
| 2022 | + } | |
| 2023 | + // 🔥 get main filter | |
| 2024 | + let wppm_task_filter = jQuery('#wppm_task_filter').val(); | |
| 1798 | 2025 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1799 | - var data = { | |
| 2026 | + jQuery.post(wppm_admin.ajax_url, { | |
| 1800 | 2027 | action: 'wppm_get_task_list', |
| 1801 | - wppm_task_filter:wppm_task_filter | |
| 1802 | - }; | |
| 1803 | - jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 2028 | + wppm_task_filter: wppm_task_filter, | |
| 2029 | + page: wppm_admin.page, | |
| 2030 | + page_no: page - 1, | |
| 2031 | + listFilters: JSON.stringify(listFilters) // ✅ ALWAYS stringify | |
| 2032 | + }, function (response) { | |
| 1804 | 2033 | jQuery('#wppm_task_container').html(response); |
| 1805 | - }); | |
| 2034 | + // 🔥 save cookie | |
| 2035 | + setListFilterCookie(listFilters); | |
| 2036 | + // 🔥 sync UI | |
| 2037 | + setTimeout(function () { | |
| 2038 | + syncUIWithFilters(listFilters); | |
| 2039 | + renderActiveFilters(listFilters); | |
| 2040 | + }, 100); | |
| 2041 | + | |
| 2042 | + }); | |
| 1806 | 2043 | } |
| 1807 | 2044 | |
| 1808 | -function wppm_tl_reset_filter(){ | |
| 2045 | +function wppm_tl_reset_filter(page){ | |
| 2046 | + var url = new URL(window.location.href); | |
| 2047 | + if (url.searchParams.has('wppm_task_filter')) { | |
| 2048 | + url.searchParams.delete('wppm_task_filter'); | |
| 2049 | + window.location.href = url.toString(); | |
| 2050 | + return false; | |
| 2051 | + } | |
| 2052 | + // ✅ close popup | |
| 2053 | + jQuery("#tb-advanced-panel").removeClass("tb-open"); | |
| 2054 | + jQuery("#tb-backdrop").removeClass("active"); | |
| 2055 | + | |
| 2056 | + // ✅ clear inputs | |
| 2057 | + jQuery('#tb-advanced-panel input').val(''); | |
| 2058 | + jQuery('#tb-advanced-panel select').val([]); | |
| 2059 | + | |
| 2060 | + // ✅ clear chips | |
| 2061 | + jQuery("#tb-active-filters").html(''); | |
| 2062 | + | |
| 2063 | + // ✅ clear advanced filters + cookie BEFORE requesting the list, otherwise | |
| 2064 | + // this request still sends the stale tb_list_filters cookie and the | |
| 2065 | + // reset only takes effect on the next click | |
| 2066 | + resetFilters('list'); | |
| 2067 | + | |
| 1809 | 2068 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1810 | 2069 | var data = { |
| 1811 | 2070 | action: 'wppm_get_task_list', |
| 1812 | 2071 | wppm_task_filter:'all', |
| @@ -1812,28 +2071,77 @@ | ||
| 1812 | 2071 | wppm_task_filter:'all', |
| 1813 | 2072 | task_search:"", |
| 1814 | 2073 | sort_by:"task_name", |
| 1815 | 2074 | order:"ASC", |
| 1816 | - wppm_proj_filter:0 | |
| 2075 | + wppm_proj_filter:0, | |
| 2076 | + page:page | |
| 1817 | 2077 | }; |
| 1818 | 2078 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1819 | 2079 | jQuery('#wppm_task_container').html(response); |
| 1820 | - }); | |
| 2080 | + }); | |
| 1821 | 2081 | } |
| 1822 | 2082 | |
| 1823 | -function wppm_apply_task_filter_grid_view(){ | |
| 2083 | +function wppm_apply_task_filter_grid_view(page,id,filters){ | |
| 1824 | 2084 | wppm_task_filter = jQuery('#wppm_task_filter').find(":selected").val(); |
| 2085 | + if (!filters) { | |
| 2086 | + filters = { | |
| 2087 | + created_by: jQuery("#tb-created-by").val() || [], | |
| 2088 | + assigned: jQuery("#tb-assigned").val() || [], | |
| 2089 | + priority: jQuery("#tb-priority").val() || [], | |
| 2090 | + start_date: jQuery("#tb-start-date").val() || "", | |
| 2091 | + end_date: jQuery("#tb-end-date").val() || "" | |
| 2092 | + }; | |
| 2093 | + } | |
| 1825 | 2094 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1826 | 2095 | var data = { |
| 1827 | 2096 | action: 'wppm_view_project_tasks', |
| 1828 | - wppm_task_filter:wppm_task_filter | |
| 2097 | + wppm_task_filter:wppm_task_filter, | |
| 2098 | + page: wppm_admin.page, | |
| 2099 | + page_no: (typeof page === 'number' ? page - 1 : 0), | |
| 2100 | + id:id, | |
| 2101 | + filters: JSON.stringify(filters) | |
| 1829 | 2102 | }; |
| 1830 | 2103 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1831 | - jQuery('#wppm_task_container').html(response); | |
| 2104 | + jQuery('#wppm_task_container').html(response); | |
| 2105 | + // 🔥 save cookie | |
| 2106 | + setFilterCookie(filters); | |
| 2107 | + | |
| 2108 | + // 🔥 sync UI | |
| 2109 | + setTimeout(function () { | |
| 2110 | + syncUIWithFilters(filters); | |
| 2111 | + renderActiveFilters(filters); | |
| 2112 | + }, 100); | |
| 1832 | 2113 | }); |
| 1833 | 2114 | } |
| 1834 | 2115 | |
| 1835 | -function wppm_tl_reset_grid_view_filter(){ | |
| 2116 | +function wppm_tl_reset_grid_view_filter(page,id){ | |
| 2117 | + var url = new URL(window.location.href); | |
| 2118 | + if (url.searchParams.has('wppm_task_filter')) { | |
| 2119 | + url.searchParams.delete('wppm_task_filter'); | |
| 2120 | + window.location.href = url.toString(); | |
| 2121 | + return false; | |
| 2122 | + } | |
| 2123 | + // ✅ close popup | |
| 2124 | + jQuery("#tb-advanced-panel").removeClass("tb-open"); | |
| 2125 | + jQuery("#tb-backdrop").removeClass("active"); | |
| 2126 | + | |
| 2127 | + // ✅ clear inputs | |
| 2128 | + jQuery('#tb-advanced-panel input').val(''); | |
| 2129 | + jQuery('#tb-advanced-panel select').val([]); | |
| 2130 | + | |
| 2131 | + // ✅ clear chips | |
| 2132 | + jQuery("#tb-active-filters").html(''); | |
| 2133 | + window.localStorage.removeItem('wppm_task_filter'); | |
| 2134 | + | |
| 2135 | + // ✅ clear advanced filters + cookie BEFORE requesting the list, otherwise | |
| 2136 | + // this request still sends the stale filters cookie and the reset only | |
| 2137 | + // takes effect on the next click | |
| 2138 | + if(id!=0){ | |
| 2139 | + resetFilters('kanban'); | |
| 2140 | + }else{ | |
| 2141 | + resetFilters('grid'); | |
| 2142 | + } | |
| 2143 | + | |
| 1836 | 2144 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1837 | 2145 | var data = { |
| 1838 | 2146 | action: 'wppm_view_project_tasks', |
| 1839 | 2147 | wppm_task_filter:'all', |
| @@ -1839,35 +2147,62 @@ | ||
| 1839 | 2147 | wppm_task_filter:'all', |
| 1840 | 2148 | task_search:"", |
| 1841 | 2149 | sort_by:"task_name", |
| 1842 | 2150 | order:"ASC", |
| 1843 | - wppm_proj_filter:"0" | |
| 2151 | + wppm_proj_filter:"0", | |
| 2152 | + page:page, | |
| 2153 | + id:id | |
| 1844 | 2154 | }; |
| 1845 | 2155 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1846 | 2156 | jQuery('#wppm_task_container').html(response); |
| 1847 | - }); | |
| 2157 | + }); | |
| 1848 | 2158 | } |
| 2159 | +function wppm_pl_reset_filter(is_archieved) { | |
| 2160 | + var url = new URL(window.location.href); | |
| 2161 | + if (url.searchParams.has('wppm_project_filter')) { | |
| 2162 | + url.searchParams.delete('wppm_project_filter'); | |
| 2163 | + window.location.href = url.toString(); | |
| 2164 | + return false; | |
| 2165 | + } | |
| 2166 | + // close popup | |
| 2167 | + jQuery("#tb-advanced-panel").removeClass("tb-open"); | |
| 2168 | + jQuery("#tb-backdrop").removeClass("active"); | |
| 2169 | + // clear inputs | |
| 2170 | + jQuery('#tb-advanced-panel input').val(''); | |
| 2171 | + jQuery('#tb-advanced-panel select').val([]); | |
| 2172 | + // clear chips | |
| 2173 | + jQuery("#tb-active-filters").html(''); | |
| 1849 | 2174 | |
| 1850 | -function wppm_pl_reset_filter(){ | |
| 1851 | - jQuery('#wppm_project_container').html(wppm_admin.loading_html); | |
| 1852 | - var data = { | |
| 1853 | - action: 'wppm_get_project_list', | |
| 1854 | - wppm_project_filter:'all', | |
| 1855 | - project_search:"", | |
| 1856 | - sort_by:"project_name", | |
| 1857 | - order:"ASC" | |
| 1858 | - }; | |
| 1859 | - jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 1860 | - jQuery('#wppm_project_container').html(response); | |
| 1861 | - }); | |
| 2175 | + // clear advanced filters + cookie BEFORE requesting the list, otherwise | |
| 2176 | + // this request still sends the stale tb_proj_list_filters cookie and the | |
| 2177 | + // reset only takes effect on the next click | |
| 2178 | + resetProjectFilters(is_archieved); | |
| 2179 | + | |
| 2180 | + jQuery('#wppm_project_container').html(wppm_admin.loading_html); | |
| 2181 | + var data = { | |
| 2182 | + action: 'wppm_get_project_list', | |
| 2183 | + wppm_project_filter: 'all', | |
| 2184 | + project_search: '', | |
| 2185 | + sort_by: 'project_name', | |
| 2186 | + order: 'ASC', | |
| 2187 | + page: wppm_admin.page, | |
| 2188 | + is_archieved: is_archieved, | |
| 2189 | + // send explicit empty filters so the server doesn't fall back to | |
| 2190 | + // the (possibly not-yet-expired) tb_proj_list_filters cookie | |
| 2191 | + filters: JSON.stringify({}) | |
| 2192 | + }; | |
| 2193 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 2194 | + jQuery('#wppm_project_container').html(response); | |
| 2195 | + }); | |
| 1862 | 2196 | } |
| 1863 | 2197 | |
| 1864 | -function wppm_tasks_by_select_project(){ | |
| 2198 | +function wppm_tasks_by_select_project(page){ | |
| 1865 | 2199 | wppm_proj_filter = jQuery('#wppm_task_list_proj_filter').find(":selected").val(); |
| 1866 | 2200 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1867 | 2201 | var data = { |
| 1868 | 2202 | action: 'wppm_get_task_list', |
| 1869 | - wppm_proj_filter:wppm_proj_filter | |
| 2203 | + wppm_proj_filter:wppm_proj_filter, | |
| 2204 | + page:page | |
| 1870 | 2205 | }; |
| 1871 | 2206 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1872 | 2207 | jQuery('#wppm_task_container').html(response); |
| 1873 | 2208 | }); |
| @@ -1872,14 +2207,15 @@ | ||
| 1872 | 2207 | jQuery('#wppm_task_container').html(response); |
| 1873 | 2208 | }); |
| 1874 | 2209 | } |
| 1875 | 2210 | |
| 1876 | -function wppm_tasks_by_select_project_grid_view(){ | |
| 2211 | +function wppm_tasks_by_select_project_grid_view(page){ | |
| 1877 | 2212 | wppm_proj_filter = jQuery('#wppm_task_list_proj_filter').find(":selected").val(); |
| 1878 | 2213 | jQuery('#wppm_task_container').html(wppm_admin.loading_html); |
| 1879 | 2214 | var data = { |
| 1880 | 2215 | action: 'wppm_view_project_tasks', |
| 1881 | - wppm_proj_filter:wppm_proj_filter | |
| 2216 | + wppm_proj_filter:wppm_proj_filter, | |
| 2217 | + page:page | |
| 1882 | 2218 | }; |
| 1883 | 2219 | jQuery.post(wppm_admin.ajax_url, data, function(response) { |
| 1884 | 2220 | jQuery('#wppm_task_container').html(response); |
| 1885 | 2221 | }); |
| @@ -2273,5 +2609,492 @@ | ||
| 2273 | 2609 | }) |
| 2274 | 2610 | .done(function (response_str) { |
| 2275 | 2611 | wppm_get_task_list(); |
| 2276 | 2612 | }); |
| 2277 | -} | |
| 2613 | +} | |
| 2614 | + | |
| 2615 | +function wppm_print_task(id){ | |
| 2616 | + jQuery('#wppmprint_menu').css('display', 'flex'); | |
| 2617 | +} | |
| 2618 | + | |
| 2619 | +function wppm_open_pdf(id){ | |
| 2620 | + window.open(wppm_admin.ajax_url + "?action=wppm_get_task_pdf&id=" + id, "_blank"); | |
| 2621 | +} | |
| 2622 | + | |
| 2623 | +function wppm_download_pdf(id){ | |
| 2624 | + window.open(wppm_admin.ajax_url + "?action=wppm_download_pdf&id=" + id, "_blank"); | |
| 2625 | +} | |
| 2626 | + | |
| 2627 | +function wppm_archive_task(id,is_archived,project_id){ | |
| 2628 | + if (!confirm(wppm_admin.confirm)) { | |
| 2629 | + return; | |
| 2630 | + } else { | |
| 2631 | + var data = { | |
| 2632 | + action: 'wppm_archive_task', | |
| 2633 | + id: id, | |
| 2634 | + is_archived: is_archived, | |
| 2635 | + project_id: project_id, | |
| 2636 | + }; | |
| 2637 | + jQuery.post(wppm_admin.ajax_url, data, function() { | |
| 2638 | + wppm_open_task(id,project_id); | |
| 2639 | + }); | |
| 2640 | + } | |
| 2641 | +} | |
| 2642 | + | |
| 2643 | +function wppm_archive_project(project_id,is_archived){ | |
| 2644 | + if (!confirm(wppm_admin.confirm)) { | |
| 2645 | + return; | |
| 2646 | + } else { | |
| 2647 | + var data = { | |
| 2648 | + action: 'wppm_archive_project', | |
| 2649 | + project_id: project_id, | |
| 2650 | + is_archived: is_archived, | |
| 2651 | + }; | |
| 2652 | + jQuery.post(wppm_admin.ajax_url, data, function() { | |
| 2653 | + wppm_open_project(project_id); | |
| 2654 | + }); | |
| 2655 | + } | |
| 2656 | +} | |
| 2657 | + | |
| 2658 | +function wppm_get_print_task_settings(){ | |
| 2659 | + jQuery('.wppm_setting_pills li').removeClass('active'); | |
| 2660 | + jQuery('#wppm_settings_print_task').addClass('active'); | |
| 2661 | + jQuery('.wppm_setting_col2').html(wppm_admin.loading_html); | |
| 2662 | + var data = { | |
| 2663 | + action: 'wppm_get_print_task_settings' | |
| 2664 | + }; | |
| 2665 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 2666 | + jQuery('.wppm_setting_col2').html(response); | |
| 2667 | + }); | |
| 2668 | +} | |
| 2669 | + | |
| 2670 | +function wppm_set_print_task_settings(){ | |
| 2671 | + jQuery('.wppm_submit_wait').show(); | |
| 2672 | + var dataform = new FormData(jQuery('#wppm_print_task_settings')[0]); | |
| 2673 | + jQuery.ajax({ | |
| 2674 | + url: wppm_admin.ajax_url, | |
| 2675 | + type: 'POST', | |
| 2676 | + data: dataform, | |
| 2677 | + processData: false, | |
| 2678 | + contentType: false | |
| 2679 | + }) | |
| 2680 | + .done(function (response_str) { | |
| 2681 | + var response = JSON.parse(response_str); | |
| 2682 | + jQuery('.wppm_submit_wait').hide(); | |
| 2683 | + if (response.sucess_status=='1') { | |
| 2684 | + jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege); | |
| 2685 | + } | |
| 2686 | + jQuery('#wppm_alert_success').slideDown('fast',function(){}); | |
| 2687 | + setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 2688 | + }); | |
| 2689 | +} | |
| 2690 | + | |
| 2691 | +function wppm_edit_checklist_item(item_id,checklist_id,proj_id,task_id){ | |
| 2692 | + wppm_task_modal_open('Edit Checklist Item') ; | |
| 2693 | + var data = { | |
| 2694 | + action: 'wppm_edit_checklist_item', | |
| 2695 | + item_id:item_id, | |
| 2696 | + checklist_id: checklist_id, | |
| 2697 | + task_id: task_id, | |
| 2698 | + proj_id: proj_id, | |
| 2699 | + _ajax_nonce:jQuery('#wppm_edit_checklist_item_ajax_nonce').val() | |
| 2700 | + }; | |
| 2701 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 2702 | + var response = JSON.parse(response); | |
| 2703 | + if(proj_id==0){ | |
| 2704 | + jQuery('#wppm_task_popup_body').html(response.body); | |
| 2705 | + jQuery('#wppm_task_popup_footer').html(response.footer); | |
| 2706 | + }else{ | |
| 2707 | + jQuery('#wppm_popup_body').html(response.body); | |
| 2708 | + jQuery('#wppm_popup_footer').html(response.footer); | |
| 2709 | + } | |
| 2710 | + }); | |
| 2711 | +} | |
| 2712 | + | |
| 2713 | +function wppm_set_checklist_item_name(item_id,checklist_id,task_id){ | |
| 2714 | + var dataform = new FormData(jQuery('#frm_get_edit_checklist_item')[0]); | |
| 2715 | + wppm_task_modal_close(); | |
| 2716 | + jQuery('#wppm_task_container').html(wppm_admin.loading_html); | |
| 2717 | + jQuery.ajax({ | |
| 2718 | + url: wppm_admin.ajax_url, | |
| 2719 | + type: 'POST', | |
| 2720 | + data: dataform, | |
| 2721 | + processData: false, | |
| 2722 | + contentType: false | |
| 2723 | + }) | |
| 2724 | + .done(function (response_str) { | |
| 2725 | + wppm_open_task(task_id); | |
| 2726 | + }); | |
| 2727 | +} | |
| 2728 | + | |
| 2729 | +function wppm_get_project_tasks_kanban_view(proj_id, KanbanFilters = {}) { | |
| 2730 | + jQuery('#wppm_project_container').html(wppm_admin.loading_html); | |
| 2731 | + var data = { | |
| 2732 | + action: 'wppm_get_project_tasks_kanban_view', | |
| 2733 | + id: proj_id, | |
| 2734 | + filters: JSON.stringify(KanbanFilters) | |
| 2735 | + }; | |
| 2736 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 2737 | + jQuery('#wppm_project_container').html(response); | |
| 2738 | + }); | |
| 2739 | +} | |
| 2740 | + | |
| 2741 | +function renderActiveFilters(filters) { | |
| 2742 | + let box = document.getElementById("tb-active-filters"); | |
| 2743 | + if (!box) { | |
| 2744 | + return; | |
| 2745 | + } | |
| 2746 | + // CLEAR OLD CHIPS | |
| 2747 | + box.innerHTML = ""; | |
| 2748 | + if (!filters || typeof filters !== "object") { | |
| 2749 | + return; | |
| 2750 | + } | |
| 2751 | + // CREATED BY | |
| 2752 | + if (Array.isArray(filters.created_by)) { | |
| 2753 | + filters.created_by.forEach(function(id) { | |
| 2754 | + let text = jQuery('#tb-created-by option[value="' + id + '"]').text(); | |
| 2755 | + if (text) { | |
| 2756 | + createChip(text, "created_by", id); | |
| 2757 | + } | |
| 2758 | + }); | |
| 2759 | + } | |
| 2760 | + // ASSIGNED | |
| 2761 | + if (Array.isArray(filters.assigned)) { | |
| 2762 | + filters.assigned.forEach(function(id) { | |
| 2763 | + let text = jQuery('#tb-assigned option[value="' + id + '"]').text(); | |
| 2764 | + if (text) { | |
| 2765 | + createChip(text, "assigned", id); | |
| 2766 | + } | |
| 2767 | + }); | |
| 2768 | + } | |
| 2769 | + | |
| 2770 | + // PRIORITY | |
| 2771 | + if (Array.isArray(filters.priority)) { | |
| 2772 | + filters.priority.forEach(function(id) { | |
| 2773 | + let text = jQuery('#tb-priority option[value="' + id + '"]').text(); | |
| 2774 | + if (text) { | |
| 2775 | + createChip(text, "priority", id); | |
| 2776 | + } | |
| 2777 | + }); | |
| 2778 | + } | |
| 2779 | + | |
| 2780 | + // CATEGORY (Project List) | |
| 2781 | + if (Array.isArray(filters.category)) { | |
| 2782 | + filters.category.forEach(function(id) { | |
| 2783 | + let text = jQuery('#tb-category option[value="' + id + '"]').text(); | |
| 2784 | + if (text) { | |
| 2785 | + createChip(text, "category", id); | |
| 2786 | + } | |
| 2787 | + }); | |
| 2788 | + } | |
| 2789 | + | |
| 2790 | + // DATE CHIP | |
| 2791 | + if (filters.start_date || filters.end_date) { | |
| 2792 | + let dateText = | |
| 2793 | + (filters.start_date || "") + | |
| 2794 | + " → " + | |
| 2795 | + (filters.end_date || ""); | |
| 2796 | + createChip(dateText, "date", ""); | |
| 2797 | + } | |
| 2798 | +} | |
| 2799 | + | |
| 2800 | +function renderMulti(filters, key, selector, label) { | |
| 2801 | + if (!filters || !filters[key]) { | |
| 2802 | + return; | |
| 2803 | + } | |
| 2804 | + let values = filters[key] || []; | |
| 2805 | + if (!Array.isArray(values) || values.length === 0) { | |
| 2806 | + return; | |
| 2807 | + } | |
| 2808 | + jQuery(selector + " option").each(function () { | |
| 2809 | + let val = String(jQuery(this).val()); | |
| 2810 | + let text = jQuery(this).text(); | |
| 2811 | + if (values.map(String).includes(val)) { | |
| 2812 | + createChip(`${label}: ${text}`, key, val); | |
| 2813 | + } | |
| 2814 | + }); | |
| 2815 | +} | |
| 2816 | + | |
| 2817 | +function createChip(text, key, value) { | |
| 2818 | + let container = document.getElementById("tb-active-filters"); | |
| 2819 | + if (!container) { | |
| 2820 | + return; | |
| 2821 | + } | |
| 2822 | + let chip = document.createElement("span"); | |
| 2823 | + chip.className = "tb-chip"; | |
| 2824 | + chip.innerHTML = ` | |
| 2825 | + ${key.charAt(0).toUpperCase() + key.slice(1)}: ${text} | |
| 2826 | + <span | |
| 2827 | + class="tb-remove" | |
| 2828 | + data-key="${key}" | |
| 2829 | + data-value="${value || ''}" | |
| 2830 | + > | |
| 2831 | + ✕ | |
| 2832 | + </span> | |
| 2833 | + `; | |
| 2834 | + container.appendChild(chip); | |
| 2835 | +} | |
| 2836 | + | |
| 2837 | +function syncUIWithFilters(filters) { | |
| 2838 | + jQuery("#tb-created-by") | |
| 2839 | + .val(filters.created_by || []) | |
| 2840 | + .trigger("change"); | |
| 2841 | + | |
| 2842 | + jQuery("#tb-assigned") | |
| 2843 | + .val(filters.assigned || []) | |
| 2844 | + .trigger("change"); | |
| 2845 | + | |
| 2846 | + jQuery("#tb-priority") | |
| 2847 | + .val(filters.priority || []) | |
| 2848 | + .trigger("change"); | |
| 2849 | + | |
| 2850 | + jQuery("#tb-category") | |
| 2851 | + .val(filters.category || []) | |
| 2852 | + .trigger("change"); | |
| 2853 | + | |
| 2854 | + jQuery("#tb-start-date") | |
| 2855 | + .val(filters.start_date || ""); | |
| 2856 | + | |
| 2857 | + jQuery("#tb-end-date") | |
| 2858 | + .val(filters.end_date || ""); | |
| 2859 | +} | |
| 2860 | + | |
| 2861 | +function resetFilters(view_type) { | |
| 2862 | + let emptyFilters = { | |
| 2863 | + created_by: [], | |
| 2864 | + assigned: [], | |
| 2865 | + priority: [], | |
| 2866 | + start_date: "", | |
| 2867 | + end_date: "", | |
| 2868 | + id: jQuery('#wppm_proj_id').val() || 0 | |
| 2869 | + }; | |
| 2870 | + // Reset UI fields | |
| 2871 | + jQuery("#tb-created-by").val(null).trigger("change"); | |
| 2872 | + jQuery("#tb-assigned").val(null).trigger("change"); | |
| 2873 | + jQuery("#tb-priority").val(null).trigger("change"); | |
| 2874 | + jQuery("#tb-start-date").val(""); | |
| 2875 | + jQuery("#tb-end-date").val(""); | |
| 2876 | + if (view_type === 'grid') { | |
| 2877 | + window.filters = { ...emptyFilters }; | |
| 2878 | + // Delete cookie | |
| 2879 | + document.cookie = | |
| 2880 | + "tb_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | |
| 2881 | + // Apply fresh filters | |
| 2882 | + wppm_apply_task_filter_grid_view('0',emptyFilters.id,window.filters); | |
| 2883 | + } | |
| 2884 | + if (view_type === 'list') { | |
| 2885 | + window.listFilters = { ...emptyFilters }; | |
| 2886 | + // Delete cookie | |
| 2887 | + document.cookie = | |
| 2888 | + "tb_list_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | |
| 2889 | + // Apply fresh filters | |
| 2890 | + wppm_apply_task_filter(1, window.listFilters); | |
| 2891 | + } | |
| 2892 | + if (view_type === 'kanban') { | |
| 2893 | + window.KanbanFilters = { ...emptyFilters }; | |
| 2894 | + // Delete cookie | |
| 2895 | + document.cookie = | |
| 2896 | + "tb_kanban_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | |
| 2897 | + // Apply fresh filters | |
| 2898 | + wppm_get_project_tasks_kanban_view( | |
| 2899 | + window.KanbanFilters.id, | |
| 2900 | + window.KanbanFilters | |
| 2901 | + ); | |
| 2902 | + } | |
| 2903 | +} | |
| 2904 | + | |
| 2905 | +function getFilterCookie() { | |
| 2906 | + let name = "tb_filters="; | |
| 2907 | + let arr = document.cookie.split(';'); | |
| 2908 | + for (let i = 0; i < arr.length; i++) { | |
| 2909 | + let c = arr[i].trim(); | |
| 2910 | + if (c.indexOf(name) === 0) { | |
| 2911 | + try { | |
| 2912 | + return JSON.parse(decodeURIComponent(c.substring(name.length))); | |
| 2913 | + } catch (e) { | |
| 2914 | + return null; | |
| 2915 | + } | |
| 2916 | + } | |
| 2917 | + } | |
| 2918 | + return null; | |
| 2919 | +} | |
| 2920 | + | |
| 2921 | +function getListFilterCookie() { | |
| 2922 | + let name = "tb_list_filters="; | |
| 2923 | + let arr = document.cookie.split(';'); | |
| 2924 | + for (let i = 0; i < arr.length; i++) { | |
| 2925 | + let c = arr[i].trim(); | |
| 2926 | + if (c.indexOf(name) === 0) { | |
| 2927 | + try { | |
| 2928 | + return JSON.parse(decodeURIComponent(c.substring(name.length))); | |
| 2929 | + } catch (e) { | |
| 2930 | + return null; | |
| 2931 | + } | |
| 2932 | + } | |
| 2933 | + } | |
| 2934 | + return null; | |
| 2935 | +} | |
| 2936 | + | |
| 2937 | +function getKanbanFilterCookie() { | |
| 2938 | + let name = "tb_kanban_filters="; | |
| 2939 | + let arr = document.cookie.split(';'); | |
| 2940 | + for (let i = 0; i < arr.length; i++) { | |
| 2941 | + let c = arr[i].trim(); | |
| 2942 | + if (c.indexOf(name) === 0) { | |
| 2943 | + try { | |
| 2944 | + return JSON.parse(decodeURIComponent(c.substring(name.length))); | |
| 2945 | + } catch (e) { | |
| 2946 | + return null; | |
| 2947 | + } | |
| 2948 | + } | |
| 2949 | + } | |
| 2950 | + return null; | |
| 2951 | +} | |
| 2952 | + | |
| 2953 | +function setFilterCookie(filters) { | |
| 2954 | + document.cookie = | |
| 2955 | + "tb_filters=" + encodeURIComponent(JSON.stringify(filters)) + | |
| 2956 | + ";path=/;max-age=" + (60 * 60 * 24); | |
| 2957 | +} | |
| 2958 | + | |
| 2959 | +function setListFilterCookie(listFilters) { | |
| 2960 | + document.cookie = | |
| 2961 | + "tb_list_filters=" + encodeURIComponent(JSON.stringify(listFilters)) + | |
| 2962 | + ";path=/;max-age=" + (60 * 60 * 24); | |
| 2963 | +} | |
| 2964 | + | |
| 2965 | +function setKanbanFilterCookie(KanbanFilters) { | |
| 2966 | + document.cookie = | |
| 2967 | + "tb_kanban_filters=" + encodeURIComponent(JSON.stringify(KanbanFilters)) + | |
| 2968 | + ";path=/;max-age=" + (60 * 60 * 24); | |
| 2969 | +} | |
| 2970 | + | |
| 2971 | +let filterTimeout; | |
| 2972 | +function triggerFilter(page = 1, filters = {}, view_type = 'list', proj_id = 0) { | |
| 2973 | + clearTimeout(filterTimeout); | |
| 2974 | + filterTimeout = setTimeout(function () { | |
| 2975 | + if (view_type === 'grid') { | |
| 2976 | + wppm_apply_task_filter_grid_view( | |
| 2977 | + page, | |
| 2978 | + proj_id, | |
| 2979 | + filters | |
| 2980 | + ); | |
| 2981 | + } | |
| 2982 | + if (view_type === 'list') { | |
| 2983 | + wppm_apply_task_filter( | |
| 2984 | + page, | |
| 2985 | + filters | |
| 2986 | + ); | |
| 2987 | + } | |
| 2988 | + if (view_type === 'kanban') { | |
| 2989 | + wppm_get_project_tasks_kanban_view( | |
| 2990 | + proj_id, | |
| 2991 | + filters | |
| 2992 | + ); | |
| 2993 | + } | |
| 2994 | + }, 300); | |
| 2995 | +} | |
| 2996 | + | |
| 2997 | +// ================= PROJECT LIST ADVANCED FILTER ================= | |
| 2998 | +function getProjectListFilterCookie() { | |
| 2999 | + let name = "tb_proj_list_filters="; | |
| 3000 | + let arr = document.cookie.split(';'); | |
| 3001 | + for (let i = 0; i < arr.length; i++) { | |
| 3002 | + let c = arr[i].trim(); | |
| 3003 | + if (c.indexOf(name) === 0) { | |
| 3004 | + try { | |
| 3005 | + return JSON.parse(decodeURIComponent(c.substring(name.length))); | |
| 3006 | + } catch (e) { | |
| 3007 | + return null; | |
| 3008 | + } | |
| 3009 | + } | |
| 3010 | + } | |
| 3011 | + return null; | |
| 3012 | +} | |
| 3013 | + | |
| 3014 | +function setProjectListFilterCookie(projectFilters) { | |
| 3015 | + document.cookie = | |
| 3016 | + "tb_proj_list_filters=" + encodeURIComponent(JSON.stringify(projectFilters)) + | |
| 3017 | + ";path=/;max-age=" + (60 * 60 * 24); | |
| 3018 | +} | |
| 3019 | + | |
| 3020 | +function resetProjectFilters(is_archieved) { | |
| 3021 | + let emptyFilters = { | |
| 3022 | + created_by: [], | |
| 3023 | + assigned: [], | |
| 3024 | + category: [], | |
| 3025 | + start_date: "", | |
| 3026 | + end_date: "" | |
| 3027 | + }; | |
| 3028 | + jQuery("#tb-created-by").val(null).trigger("change"); | |
| 3029 | + jQuery("#tb-assigned").val(null).trigger("change"); | |
| 3030 | + jQuery("#tb-category").val(null).trigger("change"); | |
| 3031 | + jQuery("#tb-start-date").val(""); | |
| 3032 | + jQuery("#tb-end-date").val(""); | |
| 3033 | + window.projectFilters = { ...emptyFilters }; | |
| 3034 | + document.cookie = "tb_proj_list_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | |
| 3035 | + jQuery("#tb-advanced-panel").removeClass("tb-open"); | |
| 3036 | + jQuery("#tb-backdrop").removeClass("active"); | |
| 3037 | + jQuery("#tb-active-filters").html(''); | |
| 3038 | + wppm_apply_project_filter_advanced(1, window.projectFilters, is_archieved); | |
| 3039 | +} | |
| 3040 | + | |
| 3041 | +let projectFilterTimeout; | |
| 3042 | +function triggerProjectFilter(page, filters, is_archieved) { | |
| 3043 | + clearTimeout(projectFilterTimeout); | |
| 3044 | + projectFilterTimeout = setTimeout(function () { | |
| 3045 | + wppm_apply_project_filter_advanced(page, filters, is_archieved); | |
| 3046 | + }, 300); | |
| 3047 | +} | |
| 3048 | + | |
| 3049 | +function wppm_apply_project_filter_advanced(page, projectFilters, is_archieved) { | |
| 3050 | + page = page || 1; | |
| 3051 | + is_archieved = is_archieved || 0; | |
| 3052 | + if (!projectFilters) { | |
| 3053 | + projectFilters = { | |
| 3054 | + created_by: jQuery("#tb-created-by").val() || [], | |
| 3055 | + assigned: jQuery("#tb-assigned").val() || [], | |
| 3056 | + category: jQuery("#tb-category").val() || [], | |
| 3057 | + start_date: jQuery("#tb-start-date").val() || "", | |
| 3058 | + end_date: jQuery("#tb-end-date").val() || "" | |
| 3059 | + }; | |
| 3060 | + } | |
| 3061 | + let wppm_project_filter_val = jQuery('#wppm_project_filter').val() || 'all'; | |
| 3062 | + jQuery('#wppm_project_container').html(wppm_admin.loading_html); | |
| 3063 | + jQuery.post(wppm_admin.ajax_url, { | |
| 3064 | + action: 'wppm_get_project_list', | |
| 3065 | + wppm_project_filter: wppm_project_filter_val, | |
| 3066 | + page: wppm_admin.page, | |
| 3067 | + page_no: page - 1, | |
| 3068 | + is_archieved: is_archieved, | |
| 3069 | + filters: JSON.stringify(projectFilters) | |
| 3070 | + }, function (response) { | |
| 3071 | + jQuery('#wppm_project_container').html(response); | |
| 3072 | + setProjectListFilterCookie(projectFilters); | |
| 3073 | + setTimeout(function () { | |
| 3074 | + syncUIWithFilters(projectFilters); | |
| 3075 | + renderActiveFilters(projectFilters); | |
| 3076 | + }, 100); | |
| 3077 | + }); | |
| 3078 | +} | |
| 3079 | + | |
| 3080 | +function wppm_archieve_project_list(){ | |
| 3081 | + jQuery('#wppm_project_container').html(wppm_admin.loading_html); | |
| 3082 | + var data = { | |
| 3083 | + action: 'wppm_archieve_project_list' | |
| 3084 | + }; | |
| 3085 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 3086 | + jQuery('#wppm_project_container').html(response); | |
| 3087 | + }); | |
| 3088 | +} | |
| 3089 | + | |
| 3090 | +function wppm_get_archieve_project_list(page_no){ | |
| 3091 | + jQuery('#wppm_project_container').html(wppm_admin.loading_html); | |
| 3092 | + var data = { | |
| 3093 | + action: 'wppm_get_project_list', | |
| 3094 | + page_no:page_no, | |
| 3095 | + is_archieved:1 | |
| 3096 | + }; | |
| 3097 | + jQuery.post(wppm_admin.ajax_url, data, function(response) { | |
| 3098 | + jQuery('#wppm_project_container').html(response); | |
| 3099 | + }); | |
| 3100 | +} | |