A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/commit/c7c14ea1d023b26af8a12c12dbc2c3d8220b7f67 below:

make sure to apply all formatters of field configuratio… · bootstrap-vue/bootstrap-vue@c7c14ea · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+68

-31

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+68

-31

lines changed Original file line number Diff line number Diff line change

@@ -34,27 +34,27 @@

34 34

},

35 35

{

36 36

"path": "./dist/bootstrap-vue.js",

37 -

"maxSize": "230 kB"

37 +

"maxSize": "235 kB"

38 38

},

39 39

{

40 40

"path": "./dist/bootstrap-vue.min.js",

41 -

"maxSize": "100 kB"

41 +

"maxSize": "105 kB"

42 42

},

43 43

{

44 44

"path": "./dist/bootstrap-vue.common.js",

45 -

"maxSize": "305 kB"

45 +

"maxSize": "310 kB"

46 46

},

47 47

{

48 48

"path": "./dist/bootstrap-vue.common.min.js",

49 -

"maxSize": "190 kB"

49 +

"maxSize": "195 kB"

50 50

},

51 51

{

52 52

"path": "./dist/bootstrap-vue.esm.js",

53 -

"maxSize": "300 kB"

53 +

"maxSize": "310 kB"

54 54

},

55 55

{

56 56

"path": "./dist/bootstrap-vue.esm.min.js",

57 -

"maxSize": "190 kB"

57 +

"maxSize": "195 kB"

58 58

},

59 59

{

60 60

"path": "./dist/bootstrap-vue.css",

Original file line number Diff line number Diff line change

@@ -1,32 +1,41 @@

1 -

import { keys } from '../../../utils/object'

2 -

import { arrayIncludes } from '../../../utils/array'

1 +

import { arrayIncludes, isArray } from '../../../utils/array'

3 2

import { isFunction } from '../../../utils/inspect'

3 +

import { clone, keys, pick } from '../../../utils/object'

4 4

import { IGNORED_FIELD_KEYS } from './constants'

5 5 6 6

// Return a copy of a row after all reserved fields have been filtered out

7 -

const sanitizeRow = (row, ignoreFields, includeFields, fieldsObj = {}) =>

8 -

keys(row).reduce((obj, key) => {

9 -

// Ignore special fields that start with `_`

10 -

// Ignore fields in the `ignoreFields` array

11 -

// Include only fields in the `includeFields` array

12 -

if (

13 -

!IGNORED_FIELD_KEYS[key] &&

14 -

!(ignoreFields && ignoreFields.length > 0 && arrayIncludes(ignoreFields, key)) &&

15 -

!(includeFields && includeFields.length > 0 && !arrayIncludes(includeFields, key))

16 -

) {

17 -

const f = fieldsObj[key] || {}

18 -

const val = row[key]

19 -

// `f.filterByFormatted` will either be a function or boolean

20 -

// `f.formater` will have already been noramlized into a function ref

21 -

const filterByFormatted = f.filterByFormatted

22 -

const formatter = isFunction(filterByFormatted)

23 -

? /* istanbul ignore next */ filterByFormatted

24 -

: filterByFormatted

25 -

? /* istanbul ignore next */ f.formatter

26 -

: null

27 -

obj[key] = isFunction(formatter) ? formatter(val, key, row) : val

7 +

const sanitizeRow = (row, ignoreFields, includeFields, fieldsObj = {}) => {

8 +

// We first need to format the row based on the field configurations

9 +

// This ensures that we add formatted values for keys that may not

10 +

// exist in the row itself

11 +

const formattedRow = keys(fieldsObj).reduce((result, key) => {

12 +

const field = fieldsObj[key]

13 +

const { filterByFormatted } = field

14 +

const formatter = isFunction(filterByFormatted)

15 +

? /* istanbul ignore next */ filterByFormatted

16 +

: filterByFormatted

17 +

? /* istanbul ignore next */ field.formatter

18 +

: null

19 + 20 +

if (isFunction(formatter)) {

21 +

result[key] = formatter(row[key], key, row)

28 22

}

29 -

return obj

30 -

}, {})

23 + 24 +

return result

25 +

}, clone(row))

26 + 27 +

// Determine the allowed keys:

28 +

// - Ignore special fields that start with `_`

29 +

// - Ignore fields in the `ignoreFields` array

30 +

// - Include only fields in the `includeFields` array

31 +

const allowedKeys = keys(formattedRow).filter(

32 +

key =>

33 +

!IGNORED_FIELD_KEYS[key] &&

34 +

!(isArray(ignoreFields) && arrayIncludes(ignoreFields, key)) &&

35 +

!(isArray(includeFields) && !arrayIncludes(includeFields, key))

36 +

)

37 + 38 +

return pick(formattedRow, allowedKeys)

39 +

}

31 40 32 41

export default sanitizeRow

Original file line number Diff line number Diff line change

@@ -207,6 +207,34 @@ describe('table > filtering', () => {

207 207

wrapper.destroy()

208 208

})

209 209 210 +

it('should filter for formatted values for keys which are not present in row', async () => {

211 +

const wrapper = mount(BTable, {

212 +

propsData: {

213 +

items: [{ a: 'A', b: 'B' }],

214 +

fields: [

215 +

{ key: 'a' },

216 +

{

217 +

key: 'b',

218 +

formatter: () => 'Foo',

219 +

filterByFormatted: true

220 +

},

221 +

{

222 +

key: 'c',

223 +

formatter: () => 'Bar',

224 +

filterByFormatted: true

225 +

}

226 +

],

227 +

filter: 'Bar'

228 +

}

229 +

})

230 +

expect(wrapper).toBeDefined()

231 +

await waitNT(wrapper.vm)

232 + 233 +

expect(wrapper.findAll('tbody > tr').length).toBe(1)

234 + 235 +

wrapper.destroy()

236 +

})

237 + 210 238

it('should show empty filtered message when no matches and show-empty=true', async () => {

211 239

const wrapper = mount(BTable, {

212 240

propsData: {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4