variables-schemes.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // *********************************************************************************
  2. // Scheme for the variables list
  3. // *********************************************************************************
  4. export const variableScheme = {
  5. hash: 'UUID for the variable',
  6. name: 'Variable name',
  7. type: 'Varaible type',
  8. value: 'Variable value'
  9. };
  10. // *********************************************************************************
  11. // Variable types
  12. // *********************************************************************************
  13. export const variableTypes = [
  14. {
  15. name: 'inteiro',
  16. value: 'INTEGER',
  17. defaultValue: 0,
  18. htmlType: 'number',
  19. barrier: ''
  20. },
  21. {
  22. name: 'real',
  23. value: 'DOUBLE',
  24. defaultValue: 0.0,
  25. htmlType: 'number',
  26. barrier: ''
  27. },
  28. {
  29. name: 'cadeia',
  30. value: 'STRING',
  31. defaultValue: '',
  32. htmlType: 'text',
  33. barrier: '"'
  34. },
  35. {
  36. name: 'lógico',
  37. value: 'BOOLEAN',
  38. vales: [
  39. {
  40. name: 'verdadeiro',
  41. value: true
  42. },
  43. {
  44. name: 'falso',
  45. value: false
  46. }
  47. ],
  48. defaultValue: true,
  49. htmlType: 'select',
  50. barrier: ''
  51. }
  52. ];
  53. export function getVariableTypeByValue(value) {
  54. for (let i = 0; i < variableTypes.length; i++) {
  55. if (variableTypes[i].value === value)
  56. return variableTypes[i];
  57. }
  58. return null;
  59. }
  60. // *********************************************************************************
  61. // Html Schemes
  62. // *********************************************************************************
  63. let htmlVariableSchemeBuilt = '';
  64. export function htmlVariableScheme() {
  65. if (htmlVariableSchemeBuilt !== '')
  66. return htmlVariableSchemeBuilt;
  67. let variableTypesHtml = '';
  68. for (let i = 0; i < variableTypes.length; i++) {
  69. variableTypesHtml += `<option value="${variableTypes[i].value}">${variableTypes[i].name}</option>\n`;
  70. }
  71. return `<li id="variable<variableId>Li">
  72. <form id="variable<variableId>Form">
  73. <select name="tipo" title="tipo da variável" id="variable<variableId>Type" variable-id="<variableId>">
  74. ${variableTypesHtml}
  75. </select>
  76. <input type="text" title="nome da variável" id="variable<variableId>Name" value="<variableName>" variable-id="<variableId>">
  77. <label for="variable<variableId>Value" tabindex="0" tile="recebe">recebe</label>
  78. <input type="${variableTypes[0].htmlType}" id ="variable<variableId>Value" title="valor da variável" value="0" variable-id="<variableId>">
  79. <button id="variable<variableId>Delete" type="button" class="btn btn-danger">Excluir</button>
  80. </form>
  81. </li>`;
  82. }
  83. // *********************************************************************************