Browse Source

Continuando os comandos..

Igor Félix 6 years ago
parent
commit
abdc85e777

+ 6 - 0
css/ivprog-visual-1.0.css

@@ -285,4 +285,10 @@ div.buttons_manage_columns {
 
 .width-dynamic {
 	min-width: 100px;
+}
+
+.ui.icon.plus.square.outline.icon_add_item_to_writer {
+	margin-right: 10px;
+	margin-left: 10px;
+	cursor: pointer;
 }

+ 13 - 2
js/visualUI/commands/variable_value_menu.js

@@ -5,6 +5,7 @@ import { LocalizedStrings } from '../../services/localizedStringsService';
 import * as GlobalsManagement from '../globals';
 import * as VariablesManagement from '../variables';
 import * as AttribuitionsManagement from './attribution';
+import * as WritersManagement from './writer';
 import WatchJS from 'melanke-watchjs';
 
 
@@ -203,7 +204,7 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 		onChange: function(value, text, $selectedItem) {
 	     if ($($selectedItem).data('clear')) {
 	     	$(dom_object).text('');
-	     	ref_object = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+	     	ref_object = new Models.VariableValueMenu(ref_object.variable_and_value, null, null, null, ref_object.include_constant);
 	     	renderMenu(command, ref_object, dom_object, function_obj);
 	     }
       }
@@ -212,6 +213,12 @@ function openInputToVariable (command, ref_object, dom_object, menu_var_or_value
 	if (command.type == Models.COMMAND_TYPES.attribution) {
 		AttribuitionsManagement.renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected);
 	}
+
+	if (command.type == Models.COMMAND_TYPES.writer) {
+		WritersManagement.addContent(command, ref_object, dom_object, menu_var_or_value, function_obj, variable_selected);
+	}
+
+	
 }
 
 
@@ -245,7 +252,7 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 	     if ($($selectedItem).data('clear')) {
 	     	$(dom_object).text('');
 
-	     	ref_object = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+	     	ref_object = new Models.VariableValueMenu(ref_object.variable_and_value, null, null, null, ref_object.include_constant);
 
 	     	$(dom_object).find('.value_rendered').remove();
 			$(dom_object).find('.context_menu_clear').remove();
@@ -302,6 +309,10 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 	if (command.type == Models.COMMAND_TYPES.attribution) {
 		AttribuitionsManagement.renderMenuOperations(command, ref_object, dom_object, menu_var_or_value, function_obj);
 	}
+
+	if (command.type == Models.COMMAND_TYPES.writer) {
+		WritersManagement.addContent(command, ref_object, dom_object, menu_var_or_value, function_obj, ref_object.content);
+	}
 }
 
 

+ 16 - 0
js/visualUI/commands/writer.js

@@ -5,6 +5,7 @@ import { LocalizedStrings } from '../../services/localizedStringsService';
 import * as GlobalsManagement from '../globals';
 import * as VariablesManagement from '../variables';
 import * as VariableValueMenu from './variable_value_menu';
+import * as VariableValueMenuManagement from './variable_value_menu';
 
 export function createFloatingCommand () {
 	return $('<div class="ui writer created_element"> <i class="ui icon small upload"></i> <span> '+LocalizedStrings.getUI('text_command_write')+' var </span></div>');
@@ -22,3 +23,18 @@ export function renderCommand (command, function_obj) {
 	return el;
 }
 
+export function addContent (command, ref_object, dom_object, menu_var_or_value, function_obj, ref_object_content) {
+	
+	if ($(dom_object).hasClass('var_value_menu_div')) {
+		var icon_add_item = $( '<i class="ui icon plus square outline icon_add_item_to_writer"></i> ' );
+		$(icon_add_item).insertAfter(dom_object);
+
+		$( icon_add_item ).on('click', function(e) {
+			var new_div_item = $( '<div class="var_value_menu_div"></div>' );
+			$(new_div_item).insertAfter(icon_add_item);
+			var new_related_menu = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true);
+			VariableValueMenu.renderMenu(command, new_related_menu, new_div_item, function_obj);
+		});
+	}
+	
+}