|
@@ -6,7 +6,7 @@ import {
|
|
|
htmlAssignVariableScheme,
|
|
|
htmlOperationKindScheme, htmlOperationTypeSelect, htmlOperatorValueInputScheme,
|
|
|
htmlOperatorVariablesSelectScheme,
|
|
|
- operationScheme, Operators, operatorScheme
|
|
|
+ operationScheme, Operators, operatorScheme, printOperationScheme
|
|
|
} from "./operations-schemes";
|
|
|
import {getVariableByHash, variables} from "../variables/variables";
|
|
|
// Imports
|
|
@@ -278,26 +278,73 @@ function updateResume (hash) {
|
|
|
function generateResume (hash) {
|
|
|
const operation = getOperationByHash(hash);
|
|
|
|
|
|
- let resume = `${operation.assignedVariable.name} recebe `;
|
|
|
-
|
|
|
- for (const i in operation.operators) {
|
|
|
- console.log(operation.operators[i]);
|
|
|
- switch (operation.operators[i].type.value) {
|
|
|
- case Operators.OPERATOR:
|
|
|
- resume += `${operation.operators[i].operator.friendlyName} `;
|
|
|
- break;
|
|
|
- case Operators.VALUE:
|
|
|
- resume += `${operation.operators[i].value} `;
|
|
|
- break;
|
|
|
- case Operators.VARIABLE:
|
|
|
- resume += `${operation.operators[i].variable.name} `;
|
|
|
- break;
|
|
|
- }
|
|
|
+ let resume;
|
|
|
+ switch (operation.type) {
|
|
|
+ case 'ASSIGN':
|
|
|
+ resume = `${operation.assignedVariable.name} recebe `;
|
|
|
+
|
|
|
+ for (const i in operation.operators) {
|
|
|
+ console.log(operation.operators[i]);
|
|
|
+ switch (operation.operators[i].type.value) {
|
|
|
+ case Operators.OPERATOR:
|
|
|
+ resume += `${operation.operators[i].operator.friendlyName} `;
|
|
|
+ break;
|
|
|
+ case Operators.VALUE:
|
|
|
+ resume += `${operation.operators[i].value} `;
|
|
|
+ break;
|
|
|
+ case Operators.VARIABLE:
|
|
|
+ resume += `${operation.operators[i].variable.name} `;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'PRINT':
|
|
|
+ resume = `Escreva ${operation.assignedVariable.name}`
|
|
|
}
|
|
|
|
|
|
return resume;
|
|
|
}
|
|
|
|
|
|
+// ***********************************************************************
|
|
|
+// Print
|
|
|
+// ***********************************************************************
|
|
|
+
|
|
|
+export function createPrintOperation () {
|
|
|
+ const operation = Object.assign({}, operationScheme);
|
|
|
+ operation.hash = generateUUID().replaceAll('-', '');
|
|
|
+ operation.assignedVariable = variables.length > 0 ? variables[0] : null;
|
|
|
+ operation.type = 'PRINT';
|
|
|
+
|
|
|
+ operations.push(operation);
|
|
|
+
|
|
|
+ const printOperation = printOperationScheme(operation);
|
|
|
+ htmlOlCommandsOperations.insertAdjacentHTML('beforeend', printOperation);
|
|
|
+
|
|
|
+ updateResume(operation.hash);
|
|
|
+
|
|
|
+ // Changing focus to the variable type after creation for screen readers
|
|
|
+ document.getElementById(`operation${operation.hash}VariableSelectLabel`).focus();
|
|
|
+
|
|
|
+ document.getElementById(`operation${operation.hash}VariableSelect`).addEventListener('change', ev => {
|
|
|
+ updatePrintOperation(ev.target.getAttribute('operation-id'), ev.target.value);
|
|
|
+ });
|
|
|
+
|
|
|
+ document.getElementById(`operation${operation.hash}Delete`).addEventListener('click', ev => {
|
|
|
+ deleteOperation(ev.target.getAttribute('operation-id'));
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// TODO:
|
|
|
+// terminal => basico
|
|
|
+function updatePrintOperation (hash, newValue) {
|
|
|
+ const operation = getOperationByHash(hash);
|
|
|
+ const variable = getVariableByHash(newValue);
|
|
|
+
|
|
|
+ operation.assignedVariable = variable;
|
|
|
+ updateResume(operation.hash);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
// ***********************************************************************
|
|
|
// Util
|
|
|
// ***********************************************************************
|