variables-schemes.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // *********************************************************************************
  2. // Scheme for the variables list
  3. // *********************************************************************************
  4. import {variables} from "./variables";
  5. export const variableScheme = {
  6. hash: 'UUID for the variable',
  7. name: 'Variable name',
  8. type: 'Varaible type',
  9. value: 'Variable value',
  10. editing: true
  11. };
  12. // *********************************************************************************
  13. // Variable types
  14. // *********************************************************************************
  15. export const VariableType = [
  16. {
  17. name: 'inteiro',
  18. value: 'INTEGER',
  19. defaultValue: 0,
  20. htmlType: 'number',
  21. barrier: ''
  22. },
  23. {
  24. name: 'real',
  25. value: 'DOUBLE',
  26. defaultValue: 0.0,
  27. htmlType: 'number',
  28. barrier: ''
  29. },
  30. {
  31. name: 'cadeia',
  32. value: 'STRING',
  33. defaultValue: '',
  34. htmlType: 'text',
  35. barrier: '"'
  36. },
  37. {
  38. name: 'lógico',
  39. value: 'BOOLEAN',
  40. vales: [
  41. {
  42. name: 'verdadeiro',
  43. value: true
  44. },
  45. {
  46. name: 'falso',
  47. value: false
  48. }
  49. ],
  50. defaultValue: true,
  51. htmlType: 'select',
  52. barrier: ''
  53. }
  54. ];
  55. export function getVariableTypeByValue (value) {
  56. for (let i = 0; i < VariableType.length; i++) {
  57. if (VariableType[i].value === value)
  58. return VariableType[i];
  59. }
  60. return null;
  61. }
  62. // *********************************************************************************
  63. // Html Schemes
  64. // *********************************************************************************
  65. export function htmlVariableScheme () {
  66. let variableTypesHtml = '';
  67. for (let i = 0; i < VariableType.length; i++) {
  68. variableTypesHtml += `<option value="${VariableType[i].value}">${VariableType[i].name}</option>\n`;
  69. }
  70. return `<li id="variable<variableId>Li">
  71. <form id="variable<variableId>Form">
  72. <div class="row p-2 w-100 variable-item" style="background-color: antiquewhite;">
  73. <div class="col-2">
  74. <select name="tipo" class="form-control" title="Tipo da variável" id="variable<variableId>Type" variable-id="<variableId>">
  75. ${variableTypesHtml}
  76. </select>
  77. </div>
  78. <div class="col-2">
  79. <input type="text" class="form-control" title="nome da variável" id="variable<variableId>Name" value="<variableName>" variable-id="<variableId>">
  80. </div>
  81. <div class="col-1 text-center my-auto" style="margin-bottom: 0px !important">
  82. <label for="variable<variableId>Value" tabindex="0" title="Recebe">recebe</label>
  83. </div>
  84. <div class="col-2">
  85. <input type="${VariableType[0].htmlType}" class="form-control" id ="variable<variableId>Value" title="Valor da variável" value="0" variable-id="<variableId>">
  86. </div>
  87. <div class="col-7 my-auto" style="display: none;" id="variable<variableId>Display" tabindex="0" variable-id="<variableId>" title="Precione 'Enter' para editar">
  88. <code id="variable<variableId>DisplayCode">
  89. </code>
  90. </div>
  91. <div class="col my-auto" style="text-align: end;">
  92. <div class="row justify-content-end">
  93. <div class="col-1">
  94. <a id="variable<variableId>Resume" href="javascript:void(0)" class="text-info" variable-id="<variableId>">
  95. <i class="fas fa-eye"></i>
  96. </a>
  97. </div>
  98. <div class="col-1">
  99. <a id="variable<variableId>Delete" href="javascript:void(0)" class="text-danger" variable-id="<variableId>" title="Excluir">X</a>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </form>
  105. </li>`;
  106. }
  107. // *********************************************************************************