variables-schemes.js 4.3 KB

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