{= # # # synchronize_session_paths.cfv # # # Called from client to synchronize the raw report element with the client side session paths state # # include "templates.util.base_util"; debug_message("\n\n\n#### synchronize_session_paths.cfv START \n"); string profile_name = internal.profile_name; string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); bool is_access_reports = is_root_admin or get_access_reports_permission(session_id, profile_name); string page_token = v.fp.page_token; if (is_access_reports and get_is_valid_page_token(session_id, "statistics", page_token)) then ( debug_message("\n" . node_as_string("v.fp") . "\n\n"); string report_element_id = v.fp.report_element_id; string action = v.fp.action; # set_expanded | set_ending_row | reset node raw_report_element = "profiles_cache." . profile_name . ".raw_report_elements." . report_element_id; node root_path = raw_report_element{"data"}; if (action eq "set_expanded" or action eq "set_ending_row") then ( string the_path = v.fp.the_path; # the path with underbars node path_item; if (the_path ne "root") then ( string the_path_node_name = replace_all(the_path, "_", ".next_pages."); path_item = root_path . ".next_pages." . the_path_node_name; ) else ( path_item = root_path; ); if (action eq "set_expanded") then ( bool is_expanded = v.fp.is_expanded; set_subnode_value(path_item, "expanded", is_expanded); ) else ( int ending_row = v.fp.ending_row; set_subnode_value(path_item, "ending_row", ending_row); ); ) else ( # action is "reset" int number_of_rows = v.fp.number_of_rows; subroutine(reset_raw_session_paths( node path, int ending_row), ( set_subnode_value(path, "expanded", false); if (path?{"next_pages"}) then ( node next_pages = path{"next_pages"}; int total_rows = num_subnodes(next_pages); if (ending_row < total_rows) then ( set_subnode_value(path, "ending_row", ending_row); ); node item; foreach item next_pages ( reset_raw_session_paths(item, 10); ); ); )); reset_raw_session_paths(root_path, number_of_rows); ); save_node(raw_report_element); # # # Send response # # "sessionPaths.synchronizeResponse()\n"; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}