GetPlotSettings.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="row items-baseline">
  3. <div class="col-xs-12 col-sm-auto text-center q-px-md q-py-sm">
  4. <div :style="flexRowTitleStyle">
  5. <span class="text-weight-bold">Plot label</span> (optional)
  6. </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 v-model="plotLabel"
  12. :shadow-text="plotLabel=='' ? shadowText+' (Tab to complete)' : ''"
  13. outlined
  14. dense
  15. class="q-py-xs"
  16. :style="'width: '+basicWidthStyle"
  17. @keydown="processInputFill"
  18. @focus="processInputFill"
  19. />
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script lang="ts">
  26. import {
  27. defineComponent,
  28. computed,
  29. } from 'vue'
  30. import { event } from 'quasar'
  31. const { stopAndPrevent } = event
  32. import { useStore } from 'src/store'
  33. import { flexRowTitleStyle,
  34. basicSelectorWidthStyle,
  35. basicWidthStyle
  36. } from 'components/config'
  37. export default defineComponent({
  38. name: 'GetPlotSettings',
  39. setup() {
  40. const $store = useStore()
  41. const plotLabel = computed({
  42. get: ()=> $store.state.simulationSetup.gui.plotLabel,
  43. set: val => $store.commit('simulationSetup/setPlotLabel', val)
  44. })
  45. const shadowText = computed(()=>{
  46. const numberOfLayers = $store.state.simulationSetup.gui.layers.length
  47. let particleType = 'bulk'
  48. if (numberOfLayers == 2) return 'core-shell'
  49. if (numberOfLayers > 2) return 'multilayer'
  50. const R = $store.state.simulationSetup.gui.layers[0].layerWidth.toString()
  51. const units = $store.state.guiRuntime.units
  52. return particleType+' R='+R+units
  53. })
  54. return { flexRowTitleStyle, basicSelectorWidthStyle, basicWidthStyle,
  55. plotLabel, shadowText,
  56. processInputFill (e:KeyboardEvent) {
  57. if (e === void 0) {
  58. return
  59. }
  60. if (e.code === 'Tab') {
  61. if (shadowText.value.length > 0 && plotLabel.value == '') {
  62. stopAndPrevent(e)
  63. plotLabel.value = shadowText.value
  64. }
  65. }
  66. },
  67. }
  68. },
  69. })
  70. </script>