@@ -104,7 +104,7 @@ import VAggregatorCell from './VAggregatorCell.vue'
104
104
import VDragAndDropCell from ' ./VDragAndDropCell.vue'
105
105
import { VPivottable } from ' @/'
106
106
import { computed , ref , toRefs , watch } from ' vue'
107
- import { usePropsState } from ' @/composables'
107
+ import { usePropsState , usePivotDataProcessing } from ' @/composables'
108
108
import TableRenderer from ' ../pivottable/renderer/index'
109
109
110
110
const props = defineProps ({
@@ -153,7 +153,14 @@ const pivotUiState = ref({
153
153
})
154
154
const propsRefs = toRefs (props)
155
155
156
- const { state , updateState , updateMultiple } = usePropsState (propsRefs)
156
+ const { state , updateState } = usePropsState (propsRefs)
157
+ const { allFilters } = usePivotDataProcessing (
158
+ computed (() => props .data ),
159
+ {
160
+ derivedAttributes: computed (() => props .derivedAttributes )
161
+ }
162
+ )
163
+
157
164
const rendererItems = computed (() => Object .keys (state .value .renderers ).length ? state .value .renderers : TableRenderer)
158
165
const aggregatorItems = computed (() => state .value .aggregators )
159
166
const rowAttrs = computed (() => {
@@ -170,8 +177,14 @@ const colAttrs = computed(() => {
170
177
! state .value .hiddenFromDragDrop .includes (e)
171
178
)
172
179
})
180
+ const attributeNames = computed (() => {
181
+ return Object .keys (allFilters .value ).filter (e =>
182
+ ! state .value .hiddenAttributes .includes (e) &&
183
+ ! state .value .hiddenFromAggregators .includes (e)
184
+ )
185
+ })
173
186
const unusedAttrs = computed (() => {
174
- return state .value . attributes
187
+ return attributeNames .value
175
188
.filter (
176
189
e =>
177
190
! state .value .rows .includes (e) &&
@@ -182,48 +195,6 @@ const unusedAttrs = computed(() => {
182
195
.sort (sortAs (state .value .unusedOrder ))
183
196
})
184
197
185
- const materializeInput = nextData => {
186
- if (props .data === nextData) {
187
- return
188
- }
189
- const newState = {
190
- data: nextData,
191
- attrValues: {},
192
- materializedInput: []
193
- }
194
-
195
- let recordsProcessed = 0
196
- PivotData .forEachRecord (
197
- newState .data ,
198
- props .derivedAttributes ,
199
- function (record ) {
200
- newState .materializedInput .push (record)
201
- for (const attr of Object .keys (record)) {
202
- if (! (attr in newState .attrValues )) {
203
- newState .attrValues [attr] = {}
204
- if (recordsProcessed > 0 ) {
205
- newState .attrValues [attr].null = recordsProcessed
206
- }
207
- }
208
- }
209
- for (const attr in newState .attrValues ) {
210
- const value = attr in record ? record[attr] : ' null'
211
- if (! (value in newState .attrValues [attr])) {
212
- newState .attrValues [attr][value] = 0
213
- }
214
- newState .attrValues [attr][value]++
215
- }
216
- recordsProcessed++
217
- }
218
- )
219
-
220
- updateMultiple ({
221
- ... state .value ,
222
- ... newState,
223
- ... pivotUiState .value
224
- })
225
- }
226
-
227
198
const onMoveFilterBoxToTop = ({ attribute }) => {
228
199
updateState (' maxZIndex' , state .value .maxZIndex ++ )
229
200
updateState (' zIndices' , {
@@ -256,7 +227,6 @@ const pivotData = computed(() => new PivotData(state.value))
256
227
257
228
watch (() => props .data , value => {
258
229
updateState (' unusedOrder' , props .unusedAttrs )
259
- materializeInput (value)
260
230
})
261
231
</script >
262
232
0 commit comments