PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.6
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.6
6.0.6 6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 All 58 releases
← All changes | asset/js/admin.js +290 -42 6.0.36.0.6 View file →
@@ -214,8 +214,9 @@
214 214 var dataform=new FormData(jQuery('#wppm_project_list_frm')[0]);
215 215 dataform.append("page_no", page_no);
216 216 dataform.append("action", 'wppm_get_project_list');
217 217 dataform.append("page", wppm_admin.page);
218 + dataform.append("wppm_project_filter", wppm_project_filter);
218 219 jQuery.ajax( {
219 220 url: wppm_admin.ajax_url,
220 221 type: 'POST',
221 222 data: dataform,
@@ -247,9 +248,10 @@
247 248 var data = {
248 249 action: 'wppm_get_task_list',
249 250 page_no:page_no,
250 251 page:wppm_admin.page,
251 - project_id:id
252 + project_id:id,
253 + wppm_task_filter:wppm_task_filter
252 254 };
253 255 jQuery.post(wppm_admin.ajax_url, data, function(response) {
254 256 jQuery('#wppm_task_container').html(response);
255 257 });
@@ -377,8 +379,16 @@
377 379 function wppm_open_dashboard_task(id){
378 380 window.location.href = 'admin.php?page=wppm-tasks&task_id=' + id;
379 381 }
380 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 +
381 391 function wppm_open_project_tasks(id,proj_id){
382 392 wppm_modal_open('Open Tasks');
383 393 jQuery('#wppm_task_container').show();
384 394 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
@@ -501,8 +511,101 @@
501 511 wppm_open_task(task_id);
502 512 });
503 513 }
504 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 +
505 608 function wppm_open_individual_task(id){
506 609 jQuery('#wppm_project_container').show();
507 610 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
508 611 var data = {
@@ -521,8 +624,9 @@
521 624 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
522 625 var data = {
523 626 action: 'wppm_get_task_list_card_view',
524 627 task_search: task_search,
628 + wppm_task_filter: wppm_task_filter,
525 629 page:page,
526 630 id:id
527 631 };
528 632 jQuery.post(wppm_admin.ajax_url, data, function(response) {
@@ -1921,9 +2025,10 @@
1921 2025 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1922 2026 jQuery.post(wppm_admin.ajax_url, {
1923 2027 action: 'wppm_get_task_list',
1924 2028 wppm_task_filter: wppm_task_filter,
1925 - page: page,
2029 + page: wppm_admin.page,
2030 + page_no: page - 1,
1926 2031 listFilters: JSON.stringify(listFilters) // ✅ ALWAYS stringify
1927 2032 }, function (response) {
1928 2033 jQuery('#wppm_task_container').html(response);
1929 2034 // 🔥 save cookie
@@ -1937,8 +2042,30 @@
1937 2042 });
1938 2043 }
1939 2044
1940 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 +
1941 2068 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1942 2069 var data = {
1943 2070 action: 'wppm_get_task_list',
1944 2071 wppm_task_filter:'all',
@@ -1949,20 +2076,9 @@
1949 2076 page:page
1950 2077 };
1951 2078 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1952 2079 jQuery('#wppm_task_container').html(response);
1953 - });
1954 - // ✅ close popup
1955 - jQuery("#tb-advanced-panel").removeClass("tb-open");
1956 - jQuery("#tb-backdrop").removeClass("active");
1957 -
1958 - // ✅ clear inputs
1959 - jQuery('#tb-advanced-panel input').val('');
1960 - jQuery('#tb-advanced-panel select').val([]);
1961 -
1962 - // ✅ clear chips
1963 - jQuery("#tb-active-filters").html('');
1964 - resetFilters('list');
2080 + });
1965 2081 }
1966 2082
1967 2083 function wppm_apply_task_filter_grid_view(page,id,filters){
1968 2084 wppm_task_filter = jQuery('#wppm_task_filter').find(":selected").val();
@@ -1974,13 +2090,14 @@
1974 2090 start_date: jQuery("#tb-start-date").val() || "",
1975 2091 end_date: jQuery("#tb-end-date").val() || ""
1976 2092 };
1977 2093 }
1978 - jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2094 + jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1979 2095 var data = {
1980 2096 action: 'wppm_view_project_tasks',
1981 2097 wppm_task_filter:wppm_task_filter,
1982 - page:page,
2098 + page: wppm_admin.page,
2099 + page_no: (typeof page === 'number' ? page - 1 : 0),
1983 2100 id:id,
1984 2101 filters: JSON.stringify(filters)
1985 2102 };
1986 2103 jQuery.post(wppm_admin.ajax_url, data, function(response) {
@@ -1996,22 +2113,14 @@
1996 2113 });
1997 2114 }
1998 2115
1999 2116 function wppm_tl_reset_grid_view_filter(page,id){
2000 - jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2001 - var data = {
2002 - action: 'wppm_view_project_tasks',
2003 - wppm_task_filter:'all',
2004 - task_search:"",
2005 - sort_by:"task_name",
2006 - order:"ASC",
2007 - wppm_proj_filter:"0",
2008 - page:page,
2009 - id:id
2010 - };
2011 - jQuery.post(wppm_admin.ajax_url, data, function(response) {
2012 - jQuery('#wppm_task_container').html(response);
2013 - });
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 + }
2014 2123 // ✅ close popup
2015 2124 jQuery("#tb-advanced-panel").removeClass("tb-open");
2016 2125 jQuery("#tb-backdrop").removeClass("active");
2017 2126
@@ -2020,31 +2129,73 @@
2020 2129 jQuery('#tb-advanced-panel select').val([]);
2021 2130
2022 2131 // ✅ clear chips
2023 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
2024 2138 if(id!=0){
2025 2139 resetFilters('kanban');
2026 2140 }else{
2027 2141 resetFilters('grid');
2028 - }
2029 -}
2142 + }
2030 2143
2031 -function wppm_pl_reset_filter(is_archieved){
2032 - jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2144 + jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2033 2145 var data = {
2034 - action: 'wppm_get_project_list',
2035 - wppm_project_filter:'all',
2036 - project_search:"",
2037 - sort_by:"project_name",
2146 + action: 'wppm_view_project_tasks',
2147 + wppm_task_filter:'all',
2148 + task_search:"",
2149 + sort_by:"task_name",
2038 2150 order:"ASC",
2039 - page:wppm_admin.page,
2040 - is_archieved:is_archieved
2151 + wppm_proj_filter:"0",
2152 + page:page,
2153 + id:id
2041 2154 };
2042 2155 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2043 - jQuery('#wppm_project_container').html(response);
2044 - });
2156 + jQuery('#wppm_task_container').html(response);
2157 + });
2045 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('');
2046 2174
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 + });
2196 +}
2197 +
2047 2198 function wppm_tasks_by_select_project(page){
2048 2199 wppm_proj_filter = jQuery('#wppm_task_list_proj_filter').find(":selected").val();
2049 2200 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2050 2201 var data = {
@@ -2625,8 +2776,18 @@
2625 2776 }
2626 2777 });
2627 2778 }
2628 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 +
2629 2790 // DATE CHIP
2630 2791 if (filters.start_date || filters.end_date) {
2631 2792 let dateText =
2632 2793 (filters.start_date || "") +
@@ -2685,8 +2846,12 @@
2685 2846 jQuery("#tb-priority")
2686 2847 .val(filters.priority || [])
2687 2848 .trigger("change");
2688 2849
2850 + jQuery("#tb-category")
2851 + .val(filters.category || [])
2852 + .trigger("change");
2853 +
2689 2854 jQuery("#tb-start-date")
2690 2855 .val(filters.start_date || "");
2691 2856
2692 2857 jQuery("#tb-end-date")
@@ -2826,8 +2991,91 @@
2826 2991 filters
2827 2992 );
2828 2993 }
2829 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 + });
2830 3078 }
2831 3079
2832 3080 function wppm_archieve_project_list(){
2833 3081 jQuery('#wppm_project_container').html(wppm_admin.loading_html);