Merge branch '1511-visual-console-elements-not-sorted-in-creation-dev' into 'develop'

Added changes to sort json in ajax return

See merge request artica/pandorafms!1001
This commit is contained in:
vgilc 2017-11-03 10:46:17 +01:00
commit 6ddf744163
3 changed files with 21 additions and 1 deletions

View File

@ -3029,7 +3029,10 @@ function ui_print_agent_autocomplete_input($parameters) {
$javascript = $parameters['javascript']; $javascript = $parameters['javascript'];
} }
$get_order_json = false;
if (isset($parameters['get_order_json'])) {
$get_order_json = true;
}
$javascript_is_function_select = false; //Default value $javascript_is_function_select = false; //Default value
if (isset($parameters['javascript_is_function_select'])) { if (isset($parameters['javascript_is_function_select'])) {
@ -3116,6 +3119,10 @@ function ui_print_agent_autocomplete_input($parameters) {
if (' . ((int) !$metaconsole_enabled) . ') { if (' . ((int) !$metaconsole_enabled) . ') {
inputs.push ("force_local_modules=1"); inputs.push ("force_local_modules=1");
} }
if (' . ((int) $get_order_json) . ') {
inputs.push ("get_order_json=1");
}
if (' . ((int)$metaconsole_enabled) . ') { if (' . ((int)$metaconsole_enabled) . ') {
if ((' . ((int)$use_input_server) . ') if ((' . ((int)$use_input_server) . ')

View File

@ -291,6 +291,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$params['use_hidden_input_idagent'] = true; $params['use_hidden_input_idagent'] = true;
$params['print_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent'; $params['hidden_input_idagent_name'] = 'id_agent';
$params['get_order_json'] = true;
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$params['javascript_ajax_page'] = '../../ajax.php'; $params['javascript_ajax_page'] = '../../ajax.php';
$params['disabled_javascript_on_blur_function'] = true; $params['disabled_javascript_on_blur_function'] = true;

View File

@ -702,6 +702,18 @@ if (is_ajax ()) {
foreach ($agent_modules as $key => $module) { foreach ($agent_modules as $key => $module) {
$agent_modules[$key]['nombre'] = io_safe_output($module['nombre']); $agent_modules[$key]['nombre'] = io_safe_output($module['nombre']);
} }
$get_order_json = (bool)get_parameter('get_order_json', false);
if ($get_order_json) {
$new_elements = array();
$index = 0;
foreach ($agent_modules as $key => $module) {
$new_elements[$index]['id_agente_modulo'] = $module['id_agente_modulo'];
$new_elements[$index]['nombre'] = io_safe_output($module['nombre']);
$index++;
}
$agent_modules = $new_elements;
}
echo json_encode ($agent_modules); echo json_encode ($agent_modules);