|
@@ -1,7 +1,7 @@
|
|
|
import { LocalizedStrings } from '../../services/localizedStringsService';
|
|
|
import * as CommandsManagement from '../commands';
|
|
|
-import * as ConditionalExpressionManagement from './conditional_expression';
|
|
|
import * as GenericExpressionManagement from './generic_expression';
|
|
|
+import * as CodeGenerator from '../code_generator';
|
|
|
|
|
|
export function createFloatingCommand () {
|
|
|
return $('<div class="ui iftrue created_element"> <i class="ui icon small random"></i> <span> if (x < 1) { } </span></div>');
|
|
@@ -9,9 +9,10 @@ export function createFloatingCommand () {
|
|
|
|
|
|
export function renderCommand (command, function_obj) {
|
|
|
var ret = '';
|
|
|
- ret += '<div class="ui iftrue command_container"><div class="ui data_block_if" data-if="true"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i>';
|
|
|
+ ret += '<div class="ui iftrue command_container"><div class="ui data_block_if" data-if="true"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <button class="ui icon button minimize_block_button tiny"><i class="icon window minimize"></i></button>';
|
|
|
ret += '<span class="span_command_spec"> ' + LocalizedStrings.getUI('text_if') + '</span>';
|
|
|
- ret += ' <span class="span_command_spec"> ( </span> <div class="conditional_expression"></div> <span class="span_command_spec"> ) </span>';
|
|
|
+ ret += ' <span class="span_command_spec"> ( </span> <div class="conditional_expression"></div> <span class="textual_expression"></span> <span class="span_command_spec"> ) </span> ';
|
|
|
+ ret += '<i class="ui icon unlock button_alternate_expression"></i>';
|
|
|
ret += '<span> </span> ';
|
|
|
ret += '<div class="ui block_commands commands_if conditional_comands_block" data-if="true">';
|
|
|
ret += '</div></div>';
|
|
@@ -45,12 +46,44 @@ export function renderCommand (command, function_obj) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (command.collapsed) {
|
|
|
+ el.children('.data_block_else').toggle();
|
|
|
+ $(el.find('.block_commands')[0]).toggle();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (command.lockexpression) {
|
|
|
+ if (command.expression) {
|
|
|
+ var text = CodeGenerator.elementExpressionCode(command.expression);
|
|
|
+ if (text) {
|
|
|
+ $(el.find('.conditional_expression')[0]).toggle();
|
|
|
+ $(el.find('.textual_expression')[0]).text(text);
|
|
|
+ $(el.find('.textual_expression')[0]).toggle();
|
|
|
+ $(el.find('.button_alternate_expression')[0]).toggleClass('unlock').toggleClass('lock');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return el;
|
|
|
}
|
|
|
|
|
|
|
|
|
function addHandlers (command, function_obj, iftrue_dom) {
|
|
|
|
|
|
+ $(iftrue_dom.find('.textual_expression')[0]).toggle();
|
|
|
+
|
|
|
+ iftrue_dom.find('.button_alternate_expression').on('click', function() {
|
|
|
+ if (command.expression) {
|
|
|
+ var text = CodeGenerator.elementExpressionCode(command.expression);
|
|
|
+ if (text) {
|
|
|
+ $(iftrue_dom.find('.conditional_expression')[0]).toggle();
|
|
|
+ $(iftrue_dom.find('.textual_expression')[0]).text(text);
|
|
|
+ $(iftrue_dom.find('.textual_expression')[0]).toggle();
|
|
|
+ $(this).toggleClass('unlock').toggleClass('lock');
|
|
|
+ command.lockexpression = !command.lockexpression;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
iftrue_dom.find('.button_remove_command').on('click', function() {
|
|
|
if (CommandsManagement.removeCommand(command, function_obj, iftrue_dom)) {
|
|
|
iftrue_dom.fadeOut(400, function() {
|
|
@@ -58,4 +91,11 @@ function addHandlers (command, function_obj, iftrue_dom) {
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ iftrue_dom.find('.minimize_block_button').on('click', function() {
|
|
|
+ iftrue_dom.children('.data_block_else').toggle();
|
|
|
+ $(iftrue_dom.find('.block_commands')[0]).toggle();
|
|
|
+ command.collapsed = !command.collapsed;
|
|
|
+ });
|
|
|
+
|
|
|
}
|