variables-schemes.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. <div class="row">
  74. <div class="col-2">
  75. <select name="tipo" class="form-control" title="tipo da variável" id="variable<variableId>Type" variable-id="<variableId>">
  76. ${variableTypesHtml}
  77. </select>
  78. </div>
  79. <div class="col-2">
  80. <input type="text" class="form-control" title="nome da variável" id="variable<variableId>Name" value="<variableName>" variable-id="<variableId>">
  81. </div>
  82. <div class="col-1 text-center my-auto" style="margin-bottom: 0px !important">
  83. <label for="variable<variableId>Value" tabindex="0" tile="recebe">recebe</label>
  84. </div>
  85. <div class="col-2">
  86. <input type="${variableTypes[0].htmlType}" class="form-control" id ="variable<variableId>Value" title="valor da variável" value="0" variable-id="<variableId>">
  87. </div>
  88. <div class="col-1">
  89. <button id="variable<variableId>Delete" type="button" class="btn btn-danger">Excluir</button>
  90. </div>
  91. </div>
  92. </form>
  93. </li>`;
  94. }
  95. // *********************************************************************************