GetModesToPlot.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="row items-baseline">
  3. <div
  4. class="col-xs-12 col-sm-auto text-weight-bold text-center q-px-md q-py-sm"
  5. >
  6. <div :style="flexRowTitleStyle">Modes to plot</div>
  7. </div>
  8. <div class="col-xs-grow col-sm q-px-xs">
  9. <div class="row justify-xs-center justify-sm-start items-center">
  10. <div class="col-auto">
  11. <q-input
  12. v-model.number="numberOfModesToPlot"
  13. outlined
  14. type="number"
  15. min="1"
  16. :max="maxModes"
  17. step="1"
  18. dense
  19. :style="'width: ' + basicSelectorWidthStyle"
  20. />
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script lang="ts">
  27. import { defineComponent, computed, watch } from 'vue';
  28. import { useStore } from 'src/store';
  29. import {
  30. flexRowTitleStyle,
  31. maxNumberOfModesToPlot as maxModes,
  32. basicSelectorWidthStyle,
  33. basicWidthStyle,
  34. } from 'components/config';
  35. export default defineComponent({
  36. name: 'GetModesToPlot',
  37. setup() {
  38. const $store = useStore();
  39. const numberOfModesToPlot = computed({
  40. get: () => $store.state.simulationSetup.gui.numberOfModesToPlot,
  41. set: (val) => {
  42. let intVal = parseInt(val.toString());
  43. if (isNaN(intVal)) return;
  44. if (intVal < 1) intVal = 1;
  45. if (intVal > maxModes) intVal = maxModes;
  46. $store.commit('simulationSetup/setNumberOfModesToPlot', intVal);
  47. $store.commit('plotRuntime/resizeSelectorIsPlotMode', intVal);
  48. },
  49. });
  50. watch(numberOfModesToPlot, () => {
  51. const intVal = parseInt(numberOfModesToPlot.value.toString());
  52. if (isNaN(intVal)) return;
  53. if (intVal < 1) numberOfModesToPlot.value = 1;
  54. if (intVal > maxModes) numberOfModesToPlot.value = maxModes;
  55. });
  56. return {
  57. flexRowTitleStyle,
  58. basicSelectorWidthStyle,
  59. basicWidthStyle,
  60. numberOfModesToPlot,
  61. maxModes,
  62. };
  63. },
  64. });
  65. </script>