32
32
:aggregatorName =" state.aggregatorName"
33
33
:rowOrder =" state.rowOrder"
34
34
:colOrder =" state.colOrder"
35
- :attributeNames =" state. attributeNames"
35
+ :attributeNames =" attributeNames"
36
36
:hiddenFromAggregators =" state.hiddenFromAggregators"
37
37
:vals =" state.vals"
38
38
@update:aggregatorName =" onUpdateAggregatorName"
@@ -107,7 +107,7 @@ import VAggregatorCell from './VAggregatorCell.vue'
107
107
import VDragAndDropCell from ' ./VDragAndDropCell.vue'
108
108
import { VPivottable } from ' @/'
109
109
import { computed , ref , toRefs , watch } from ' vue'
110
- import { usePropsState } from ' @/composables'
110
+ import { usePropsState , useMaterializeInput } from ' @/composables'
111
111
import TableRenderer from ' ../pivottable/renderer/index'
112
112
113
113
const props = defineProps ({
@@ -145,6 +145,7 @@ const props = defineProps({
145
145
default: false
146
146
}
147
147
})
148
+ // TODO
148
149
const pivotUiState = ref ({
149
150
unusedOrder: props .unusedAttrs ,
150
151
zIndices: {},
@@ -156,7 +157,14 @@ const pivotUiState = ref({
156
157
})
157
158
const propsRefs = toRefs (props)
158
159
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
+
160
168
const rendererItems = computed (() => Object .keys (state .value .renderers ).length ? state .value .renderers : TableRenderer)
161
169
const aggregatorItems = computed (() => state .value .aggregators )
162
170
const rowAttrs = computed (() => {
@@ -173,8 +181,14 @@ const colAttrs = computed(() => {
173
181
! state .value .hiddenFromDragDrop .includes (e)
174
182
)
175
183
})
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
+ })
176
190
const unusedAttrs = computed (() => {
177
- return state .value . attributes
191
+ return attributeNames .value
178
192
.filter (
179
193
e =>
180
194
! state .value .rows .includes (e) &&
@@ -185,48 +199,6 @@ const unusedAttrs = computed(() => {
185
199
.sort (sortAs (state .value .unusedOrder ))
186
200
})
187
201
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
-
230
202
const onMoveFilterBoxToTop = ({ attribute }) => {
231
203
updateState (' maxZIndex' , state .value .maxZIndex ++ )
232
204
updateState (' zIndices' , {
@@ -268,7 +240,6 @@ const pivotData = computed(() => new PivotData(state.value))
268
240
269
241
watch (() => props .data , value => {
270
242
updateState (' unusedOrder' , props .unusedAttrs )
271
- materializeInput (value)
272
243
})
273
244
</script >
274
245
0 commit comments