Selaa lähdekoodia

intruducing Vuex store module guiRuntime

Konstantin Ladutenko 3 vuotta sitten
vanhempi
commit
abc1523f6d

+ 5 - 0
.gitignore

@@ -49,6 +49,8 @@ cov-int*
 cov-int
 build*
 .ipynb_checkpoints
+
+# Local results
 tests/python/field.txt
 examples/*.pdf
 examples/*.png
@@ -57,6 +59,9 @@ examples/Egor*
 examples/egor*
 examples/*.txt
 examples/*.pyc
+R*mkm*.jpg
+examples/*/R*mkm.jpg
+__pycache__
 
 backup*
 

+ 11 - 5
guiapp/src/pages/Spectrum.vue

@@ -3,14 +3,14 @@
 <!--    Your code-->
     <input-with-units
         v-model:input-result="someValue"
-        v-model:is-showing-help="isShowingHelpInputWithUnits"
+        v-model:is-showing-help="isShowingHelpForInputWithUnits"
         :initial-expression="someExpr"
         title="Re(n)"
         units="nm"
     ></input-with-units>
     <input-with-units
         v-model:input-result="someValue"
-        v-model:is-showing-help="isShowingHelpInputWithUnits"
+        v-model:is-showing-help="isShowingHelpForInputWithUnits"
         :initial-expression="someExpr"
         title=""
         units=""
@@ -23,7 +23,7 @@
 
 <script lang='ts'>
 import { defineComponent, ref,
-  // computed
+  computed
 } from 'vue';
 import { useStore } from 'src/store';
 import InputWithUnits from 'components/InputWithUnits.vue';
@@ -38,8 +38,14 @@ export default defineComponent({
     let someValue = ref(10);
     let someExpr = ref('10');
     // InputWithUnits component will disable showing help after first input
-    let isShowingHelpInputWithUnits = ref(true)
-    return { someValue, someExpr, isShowingHelpInputWithUnits };
+    const isShowingHelpForInputWithUnits = computed({
+      get: () => $store.state.guiRuntime.isShowingHelpForInputWithUnits,
+      set: val => {
+        $store.commit('guiRuntime/setIsShowingHelpForInputWithUnits', val)
+      }
+    })
+    // let isShowingHelpForInputWithUnits = ref(true)
+    return { someValue, someExpr, isShowingHelpForInputWithUnits};
   }
 });
 </script>

+ 2 - 1
guiapp/src/store/gui-runtime/mutations.ts

@@ -2,8 +2,9 @@ import { MutationTree } from 'vuex';
 import { guiRuntimeStateInterface } from './state';
 
 const mutation: MutationTree<guiRuntimeStateInterface> = {
-  someMutation (/* state: guiRuntimeStateInterface */) {
+  setIsShowingHelpForInputWithUnits (state: guiRuntimeStateInterface, newVal: boolean) {
     // your code
+    state.isShowingHelpForInputWithUnits = newVal
   }
 };
 

+ 1 - 1
guiapp/src/store/gui-runtime/state.ts

@@ -4,7 +4,7 @@ export interface guiRuntimeStateInterface {
 
 function state(): guiRuntimeStateInterface {
   return {
-    isShowingHelpForInputWithUnits: false
+    isShowingHelpForInputWithUnits: true
   }
 };