variables-schemes.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 variableTypes = [
  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 < variableTypes.length; i++) {
  56. if (variableTypes[i].value === value)
  57. return variableTypes[i];
  58. }
  59. return null;
  60. }
  61. // *********************************************************************************
  62. // Html Schemes
  63. // *********************************************************************************
  64. let htmlVariableSchemeBuilt = '';
  65. export function htmlVariableScheme () {
  66. if (htmlVariableSchemeBuilt !== '')
  67. return htmlVariableSchemeBuilt;
  68. let variableTypesHtml = '';
  69. for (let i = 0; i < variableTypes.length; i++) {
  70. variableTypesHtml += `<option value="${variableTypes[i].value}">${variableTypes[i].name}</option>\n`;
  71. }
  72. return `<li id="variable<variableId>Li">
  73. <form id="variable<variableId>Form">
  74. <div class="row p-2 w-100 variable-item" style="background-color: antiquewhite;">
  75. <!-- <div class="col-1 text-center my-auto">
  76. <h5>${variables.length}</h5>
  77. </div> -->
  78. <div class="col-2">
  79. <select name="tipo" class="form-control" title="Tipo da variável" id="variable<variableId>Type" variable-id="<variableId>">
  80. ${variableTypesHtml}
  81. </select>
  82. </div>
  83. <div class="col-2">
  84. <input type="text" class="form-control" title="nome da variável" id="variable<variableId>Name" value="<variableName>" variable-id="<variableId>">
  85. </div>
  86. <div class="col-1 text-center my-auto" style="margin-bottom: 0px !important">
  87. <label for="variable<variableId>Value" tabindex="0" title="Recebe">recebe</label>
  88. </div>
  89. <div class="col-2">
  90. <input type="${variableTypes[0].htmlType}" class="form-control" id ="variable<variableId>Value" title="Valor da variável" value="0" variable-id="<variableId>">
  91. </div>
  92. <div class="col my-auto" style="text-align: end;">
  93. <a id="variable<variableId>Delete" href="javascript:void(0)" class="text-danger" variable-id="<variableId>" title="Excluir">X</a>
  94. </div>
  95. </div>
  96. </form>
  97. </li>`;
  98. }
  99. // *********************************************************************************