Fixed errors in VC

This commit is contained in:
Daniel Barbero Martin 2020-01-10 13:48:07 +01:00
parent f34387b24e
commit d4b92a6913
4 changed files with 92 additions and 52 deletions

View File

@ -1920,6 +1920,10 @@ function load_modal(settings) {
}; };
} }
if (settings.beforeClose == undefined) {
settings.beforeClose = function() {};
}
settings.target.html("Loading modal..."); settings.target.html("Loading modal...");
settings.target settings.target
.dialog({ .dialog({
@ -1989,7 +1993,6 @@ function load_modal(settings) {
text: settings.modal.ok, text: settings.modal.ok,
click: function() { click: function() {
if (AJAX_RUNNING) return; if (AJAX_RUNNING) return;
if (settings.onsubmit != undefined) { if (settings.onsubmit != undefined) {
if (settings.onsubmit.preaction != undefined) { if (settings.onsubmit.preaction != undefined) {
settings.onsubmit.preaction(); settings.onsubmit.preaction();
@ -2107,7 +2110,7 @@ function load_modal(settings) {
} }
}, },
error: function(data) { error: function(data) {
console.log(data); //console.log(data);
AJAX_RUNNING = 0; AJAX_RUNNING = 0;
} }
}); });
@ -2140,7 +2143,8 @@ function load_modal(settings) {
if (id_modal_target != undefined) { if (id_modal_target != undefined) {
$(id_modal_target).remove(); $(id_modal_target).remove();
} }
} },
beforeClose: settings.beforeClose()
}); });
}, },
error: function(data) { error: function(data) {

View File

@ -1344,7 +1344,7 @@ function cleanupDOM() {
$("#modalVCItemForm").empty(); $("#modalVCItemForm").empty();
} }
/* Defined in operations/visual_console/view.php */ /* Defined in operations/visual_console/view.php */
/* global $, load_modal */ /* global $, load_modal, tinyMCE */
function createOrUpdateVisualConsoleItem( function createOrUpdateVisualConsoleItem(
visualConsole, visualConsole,
asyncTaskManager, asyncTaskManager,
@ -1415,7 +1415,23 @@ function createOrUpdateVisualConsoleItem(
}, },
onsubmit: { onsubmit: {
page: "include/rest-api/index", page: "include/rest-api/index",
method: "processForm" method: "processForm",
preaction: function() {
if (
tinyMCE != undefined &&
tinyMCE.editors.length > 0 &&
item.itemProps.type != 12 &&
item.itemProps.type != 13
) {
// Content tiny.
var label = tinyMCE.activeEditor.getContent();
$("#textarea_label").val(label);
}
}
},
beforeClose: function() {
tinyMCE.remove("#textarea_label");
tinyMCE.execCommand("mceRemoveControl", true, "textarea_label");
} }
}); });

View File

@ -1899,7 +1899,6 @@ class Item extends CachedModel
switch ($values['tabSelected']) { switch ($values['tabSelected']) {
case 'label': case 'label':
// Label. // Label.
// TODO tinyMCE.
$inputs[] = ['label' => __('Label')]; $inputs[] = ['label' => __('Label')];
$inputs[] = [ $inputs[] = [
@ -1913,6 +1912,25 @@ class Item extends CachedModel
'return' => true, 'return' => true,
], ],
]; ];
// Label Position.
$fields = [
'down' => __('Bottom'),
'up' => __('Top'),
'right' => __('Right'),
'left' => __('Left'),
];
$inputs[] = [
'label' => __('Label position'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'labelPosition',
'selected' => $values['labelPosition'],
'return' => true,
],
];
break; break;
case 'general': case 'general':
@ -2401,8 +2419,10 @@ class Item extends CachedModel
* *
* @return string Html images. * @return string Html images.
*/ */
static function imagesElementsVC(string $image, ?bool $only=false):string public static function imagesElementsVC(
{ string $image,
?bool $only=false
):string {
$type_image = ['']; $type_image = [''];
if ($only === false) { if ($only === false) {
$type_image = [ $type_image = [

View File

@ -92,7 +92,7 @@ class View extends \HTML
'img' => 'pencil.png', 'img' => 'pencil.png',
], ],
]; ];
} else if ($type === LINE_ITEM) { } else if ($type === LINE_ITEM || $type === BOX_ITEM) {
$tabs = [ $tabs = [
[ [
'name' => __('Specific settings'), 'name' => __('Specific settings'),
@ -126,12 +126,13 @@ class View extends \HTML
}); });
}, },
load: function( event, ui ) { load: function( event, ui ) {
console.log(event); var active = $( "#html-tabs" ).tabs( "option", "active" );
console.log(ui); if (active === 0 && tinyMCE.editors.length == 0) {
tinymce.init({ // Initialice.
tinyMCE.init({
selector: "#textarea_label", selector: "#textarea_label",
theme: "advanced", theme: "advanced",
//content_css: baseUrl + "include/styles/pandora.css", content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css",
theme_advanced_font_sizes: theme_advanced_font_sizes:
"4pt=.visual_font_size_4pt, " + "4pt=.visual_font_size_4pt, " +
"6pt=.visual_font_size_6pt, " + "6pt=.visual_font_size_6pt, " +
@ -161,6 +162,7 @@ class View extends \HTML
theme_advanced_buttons3: "", theme_advanced_buttons3: "",
theme_advanced_statusbar_location: "none" theme_advanced_statusbar_location: "none"
}); });
}
}, },
active: 2 active: 2
});'; });';
@ -255,6 +257,7 @@ class View extends \HTML
// Page Label for each item. // Page Label for each item.
$data['label'] = \get_parameter('label'); $data['label'] = \get_parameter('label');
$data['labelPosition'] = \get_parameter('labelPosition');
// Page general for each item. // Page general for each item.
$tabGeneral = (bool) \get_parameter('tabGeneral', false); $tabGeneral = (bool) \get_parameter('tabGeneral', false);
@ -353,18 +356,10 @@ class View extends \HTML
$data['moduleId'] = \get_parameter('moduleId'); $data['moduleId'] = \get_parameter('moduleId');
break; break;
case LABEL:
// Nothing. no specific items.
break;
case ICON: case ICON:
$data['imageSrc'] = \get_parameter('imageSrc'); $data['imageSrc'] = \get_parameter('imageSrc');
break; break;
case SERVICE:
// TODO:Enterprise item. It may not exist.
break;
case GROUP_ITEM: case GROUP_ITEM:
$data['imageSrc'] = \get_parameter('imageSrc'); $data['imageSrc'] = \get_parameter('imageSrc');
$data['showStatistics'] = \get_parameter_switch( $data['showStatistics'] = \get_parameter_switch(
@ -423,6 +418,11 @@ class View extends \HTML
// TODO:XXX. // TODO:XXX.
break; break;
case SERVICE:
// TODO:Enterprise item. It may not exist.
break;
case LABEL:
default: default:
// Not posible. // Not posible.
break; break;