3232 :aggregatorName =" state.aggregatorName"
3333 :rowOrder =" state.rowOrder"
3434 :colOrder =" state.colOrder"
35- :attributeNames =" state. attributeNames"
35+ :attributeNames =" attributeNames"
3636 :hiddenFromAggregators =" state.hiddenFromAggregators"
3737 :vals =" state.vals"
3838 @update:aggregatorName =" onUpdateAggregatorName"
@@ -107,7 +107,7 @@ import VAggregatorCell from './VAggregatorCell.vue'
107107import VDragAndDropCell from ' ./VDragAndDropCell.vue'
108108import { VPivottable } from ' @/'
109109import { computed , ref , toRefs , watch } from ' vue'
110- import { usePropsState } from ' @/composables'
110+ import { usePropsState , useMaterializeInput } from ' @/composables'
111111import TableRenderer from ' ../pivottable/renderer/index'
112112
113113const props = defineProps ({
@@ -145,6 +145,7 @@ const props = defineProps({
145145 default: false
146146 }
147147})
148+ // TODO
148149const pivotUiState = ref ({
149150 unusedOrder: props .unusedAttrs ,
150151 zIndices: {},
@@ -156,7 +157,14 @@ const pivotUiState = ref({
156157})
157158const propsRefs = toRefs (props)
158159
159- const { state , updateState , updateMultiple } = usePropsState (propsRefs)
160+ const { state , updateState } = usePropsState (propsRefs)
161+ const { allFilters } = useMaterializeInput (
162+ computed (() => props .data ),
163+ {
164+ derivedAttributes: computed (() => props .derivedAttributes )
165+ }
166+ )
167+
160168const rendererItems = computed (() => Object .keys (state .value .renderers ).length ? state .value .renderers : TableRenderer)
161169const aggregatorItems = computed (() => state .value .aggregators )
162170const rowAttrs = computed (() => {
@@ -173,8 +181,14 @@ const colAttrs = computed(() => {
173181 ! state .value .hiddenFromDragDrop .includes (e)
174182 )
175183})
184+ const attributeNames = computed (() => {
185+ return Object .keys (allFilters .value ).filter (e =>
186+ ! state .value .hiddenAttributes .includes (e) &&
187+ ! state .value .hiddenFromAggregators .includes (e)
188+ )
189+ })
176190const unusedAttrs = computed (() => {
177- return state .value . attributes
191+ return attributeNames .value
178192 .filter (
179193 e =>
180194 ! state .value .rows .includes (e) &&
@@ -185,48 +199,6 @@ const unusedAttrs = computed(() => {
185199 .sort (sortAs (state .value .unusedOrder ))
186200})
187201
188- const materializeInput = nextData => {
189- if (props .data === nextData) {
190- return
191- }
192- const newState = {
193- data: nextData,
194- attrValues: {},
195- materializedInput: []
196- }
197-
198- let recordsProcessed = 0
199- PivotData .forEachRecord (
200- newState .data ,
201- props .derivedAttributes ,
202- function (record ) {
203- newState .materializedInput .push (record)
204- for (const attr of Object .keys (record)) {
205- if (! (attr in newState .attrValues )) {
206- newState .attrValues [attr] = {}
207- if (recordsProcessed > 0 ) {
208- newState .attrValues [attr].null = recordsProcessed
209- }
210- }
211- }
212- for (const attr in newState .attrValues ) {
213- const value = attr in record ? record[attr] : ' null'
214- if (! (value in newState .attrValues [attr])) {
215- newState .attrValues [attr][value] = 0
216- }
217- newState .attrValues [attr][value]++
218- }
219- recordsProcessed++
220- }
221- )
222-
223- updateMultiple ({
224- ... state .value ,
225- ... newState,
226- ... pivotUiState .value
227- })
228- }
229-
230202const onMoveFilterBoxToTop = ({ attribute }) => {
231203 updateState (' maxZIndex' , state .value .maxZIndex ++ )
232204 updateState (' zIndices' , {
@@ -268,7 +240,6 @@ const pivotData = computed(() => new PivotData(state.value))
268240
269241watch (() => props .data , value => {
270242 updateState (' unusedOrder' , props .unusedAttrs )
271- materializeInput (value)
272243})
273244 </script >
274245
0 commit comments