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,41 +126,43 @@ 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.
selector: "#textarea_label", tinyMCE.init({
theme: "advanced", selector: "#textarea_label",
//content_css: baseUrl + "include/styles/pandora.css", theme: "advanced",
theme_advanced_font_sizes: content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css",
"4pt=.visual_font_size_4pt, " + theme_advanced_font_sizes:
"6pt=.visual_font_size_6pt, " + "4pt=.visual_font_size_4pt, " +
"8pt=.visual_font_size_8pt, " + "6pt=.visual_font_size_6pt, " +
"10pt=.visual_font_size_10pt, " + "8pt=.visual_font_size_8pt, " +
"12pt=.visual_font_size_12pt, " + "10pt=.visual_font_size_10pt, " +
"14pt=.visual_font_size_14pt, " + "12pt=.visual_font_size_12pt, " +
"18pt=.visual_font_size_18pt, " + "14pt=.visual_font_size_14pt, " +
"24pt=.visual_font_size_24pt, " + "18pt=.visual_font_size_18pt, " +
"28pt=.visual_font_size_28pt, " + "24pt=.visual_font_size_24pt, " +
"36pt=.visual_font_size_36pt, " + "28pt=.visual_font_size_28pt, " +
"48pt=.visual_font_size_48pt, " + "36pt=.visual_font_size_36pt, " +
"60pt=.visual_font_size_60pt, " + "48pt=.visual_font_size_48pt, " +
"72pt=.visual_font_size_72pt, " + "60pt=.visual_font_size_60pt, " +
"84pt=.visual_font_size_84pt, " + "72pt=.visual_font_size_72pt, " +
"96pt=.visual_font_size_96pt, " + "84pt=.visual_font_size_84pt, " +
"116pt=.visual_font_size_116pt, " + "96pt=.visual_font_size_96pt, " +
"128pt=.visual_font_size_128pt, " + "116pt=.visual_font_size_116pt, " +
"140pt=.visual_font_size_140pt, " + "128pt=.visual_font_size_128pt, " +
"154pt=.visual_font_size_154pt, " + "140pt=.visual_font_size_140pt, " +
"196pt=.visual_font_size_196pt", "154pt=.visual_font_size_154pt, " +
theme_advanced_toolbar_location: "top", "196pt=.visual_font_size_196pt",
theme_advanced_toolbar_align: "left", theme_advanced_toolbar_location: "top",
theme_advanced_buttons1: theme_advanced_toolbar_align: "left",
"bold,italic, |,justifyleft, justifycenter, justifyright, |, undo, redo, |, image, link, |, fontselect, forecolor, fontsizeselect, |,code", theme_advanced_buttons1:
theme_advanced_buttons2: "", "bold,italic, |,justifyleft, justifycenter, justifyright, |, undo, redo, |, image, link, |, fontselect, forecolor, fontsizeselect, |,code",
theme_advanced_buttons3: "", theme_advanced_buttons2: "",
theme_advanced_statusbar_location: "none" theme_advanced_buttons3: "",
}); 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;