1- <!--
2- ToDo: Refactor data editor to sigle component per fnType, instead of generating elements from consts
3- The UI is so deeply coupled with the data structure that it makes nosense to make a component for 'general' data
4- -->
51<template >
62 <div class =" plot-data" :class =" { hidden: props.self.hidden }" >
73 <div class =" selectors" >
@@ -68,57 +64,13 @@ ToDo: Refactor data editor to sigle component per fnType, instead of generating
6864 </div >
6965 </div >
7066
71- <!-- <div class="inputs">
72- <StrInputs :dataItem="dataItem" :fnType="fnType" />
73- <CoordInputs
74- v-if="fnType.coord"
75- :dataItem="dataItem"
76- :fnType="fnType"
77- :folded="false"
78- />
79- <CoordArrInputs
80- v-if="fnType.coordArr"
81- :dataItem="dataItem"
82- :fnType="fnType"
83- />
84- <SwitchInputs
85- v-if="fnType.switches"
86- :dataItem="dataItem"
87- :fnType="fnType"
88- :folded="false"
89- />
90- </div>
91- <s-fold :folded="folded">
92- <div class="inputs optional">
93- <s-divider>{{ t("title.moreOptions") }}</s-divider>
94- <CoordInputs
95- v-if="fnType.coord"
96- :dataItem="dataItem"
97- :fnType="fnType"
98- :folded="true"
99- />
100- <OptInputs
101- v-if="fnType.optInput"
102- :dataItem="dataItem"
103- :fnType="fnType"
104- />
105- <SwitchInputs
106- v-if="fnType.switches"
107- :dataItem="dataItem"
108- :fnType="fnType"
109- :folded="true"
110- />
111- </div>
112- </s-fold> -->
11367 <div class =" relative" >
114- <Transition name =" input-component" >
115- <component
116- :is =" components[fnType]"
117- :self =" props.self"
118- :index =" props.index"
119- :folded =" folded"
120- />
121- </Transition >
68+ <component
69+ :is =" components[props.self.fnType]"
70+ :self =" <PrivateDataTypes.Full>props.self"
71+ :index =" props.index"
72+ :folded =" folded"
73+ />
12274 </div >
12375 </div >
12476</template >
@@ -127,13 +79,7 @@ import { useI18n } from "vue-i18n";
12779const { t, locale } = useI18n ();
12880
12981import { fnTypeArr , getAllowedGraphType } from " ../consts" ;
130- import { ref , computed } from " vue" ;
131-
132- // import StrInputs from "./legacyInputs/strInputs.vue";
133- // import CoordInputs from "./legacyInputs/coordInputs.vue";
134- // import SwitchInputs from "./legacyInputs/switchInputs.vue";
135- // import CoordArrInputs from "./legacyInputs/coordArrInputs.vue";
136- // import OptInputs from "./legacyInputs/optInputs.vue";
82+ import { ref , computed , toRef } from " vue" ;
13783
13884import linear from " ./inputs/linear.vue" ;
13985import implicit from " ./inputs/implicit.vue" ;
@@ -151,7 +97,7 @@ const components = {
15197 points ,
15298 vector ,
15399 text ,
154- };
100+ } as const ;
155101
156102import SIconDelete from " @/ui/icons/delete.vue" ;
157103import SIconHide from " @/ui/icons/hide.vue" ;
@@ -178,27 +124,28 @@ function deleteDatum() {
178124 });
179125}
180126
181- // function fnTypeChange(dataItem: InternalDatum) {
182- // console.log(dataItem);
183- // inputTypeArr.forEach((key) => delete dataItem[key]);
184- // if (dataItem.fnType === "text") {
185- // dataItem.graphType = "text";
186- // } else {
187- // if (dataItem.fnType === "implicit") dataItem.graphType = "interval";
188- // dataItem.graphType = getAllowedGraphType(dataItem.fnType)[0].value;
189- // if (dataItem.fnType === "vector") dataItem.vector = [0, 0];
190- // if (dataItem.fnType === "points") dataItem.points = [];
191- // }
192- // }
193-
194127const allowedGraphType = computed (() => getAllowedGraphType (props .self .fnType ));
195128
196129import { watch } from " vue" ;
197- import { PrivateData } from " @/types/data" ;
130+ import { PrivateData , PrivateDataTypes , toPrivateData } from " @/types/data" ;
198131const selectKey = ref (0 );
199132watch (locale , () => selectKey .value ++ );
200133
134+ const self = toRef (profile .datum , props .index );
135+
201136const fnType = ref (props .self .fnType );
137+ watch (fnType , (newFnType ) => {
138+ const newGraphType = (<readonly string []>(
139+ PrivateDataTypes .allowedGraphTypes [newFnType ]
140+ )).includes (props .self .graphType )
141+ ? props .self .graphType
142+ : PrivateDataTypes .allowedGraphTypes [newFnType ][0 ];
143+ self .value = toPrivateData ({
144+ key: self .value .key ,
145+ fnType: newFnType ,
146+ graphType: newGraphType ,
147+ });
148+ });
202149 </script >
203150
204151<style >
@@ -263,24 +210,3 @@ const fnType = ref(props.self.fnType);
263210 z-index : 999 ;
264211}
265212 </style >
266-
267- <style lang="scss">
268- .input-component {
269- & -enter-from ,
270- & -leave-to {
271- opacity : 0 ;
272- }
273- & -enter-active {
274- transition : opacity 0.3s 0.05s ;
275- }
276- & -leave-active {
277- transition : opacity 0.15s ;
278- }
279- & -leave-active {
280- position : absolute ;
281- left : 0 ;
282- top : 0 ;
283- right : 0 ;
284- }
285- }
286- </style >
0 commit comments