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/78ac383c0c727be4f970874e73bf05e3f23b1a3b below:

properly handle empty included/excluded filter fields (… · bootstrap-vue/bootstrap-vue@78ac383 · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+62

-5

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+62

-5

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

@@ -3000,7 +3000,7 @@ your app handles the various inconsistencies with events.

3000 3000

:current-page="currentPage"

3001 3001

:per-page="perPage"

3002 3002

:filter="filter"

3003 -

:filterIncludedFields="filterOn"

3003 +

:filter-included-fields="filterOn"

3004 3004

:sort-by.sync="sortBy"

3005 3005

:sort-desc.sync="sortDesc"

3006 3006

:sort-direction="sortDirection"

Original file line number Diff line number Diff line change

@@ -49,10 +49,10 @@ export default {

49 49

},

50 50

computed: {

51 51

computedFilterIgnored() {

52 -

return this.filterIgnoredFields ? concat(this.filterIgnoredFields).filter(identity) : null

52 +

return concat(this.filterIgnoredFields || []).filter(identity)

53 53

},

54 54

computedFilterIncluded() {

55 -

return this.filterIncludedFields ? concat(this.filterIncludedFields).filter(identity) : null

55 +

return concat(this.filterIncludedFields || []).filter(identity)

56 56

},

57 57

computedFilterDebounce() {

58 58

const ms = toInteger(this.filterDebounce, 0)

Original file line number Diff line number Diff line change

@@ -31,8 +31,8 @@ const sanitizeRow = (row, ignoreFields, includeFields, fieldsObj = {}) => {

31 31

const allowedKeys = keys(formattedRow).filter(

32 32

key =>

33 33

!IGNORED_FIELD_KEYS[key] &&

34 -

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

35 -

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

34 +

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

35 +

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

36 36

)

37 37 38 38

return pick(formattedRow, allowedKeys)

Original file line number Diff line number Diff line change

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

207 207

wrapper.destroy()

208 208

})

209 209 210 +

it('`filter-ignored-fields` prop works', async () => {

211 +

const wrapper = mount(BTable, {

212 +

propsData: {

213 +

fields: testFields,

214 +

items: testItems,

215 +

filter: '',

216 +

filterIgnoredFields: []

217 +

}

218 +

})

219 + 220 +

expect(wrapper).toBeDefined()

221 +

await waitNT(wrapper.vm)

222 + 223 +

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

224 + 225 +

// Search for a value in "a" column

226 +

await wrapper.setProps({ filter: '3' })

227 +

await waitNT(wrapper.vm)

228 +

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

229 + 230 +

// Ignore "a" column from filtering

231 +

await wrapper.setProps({ filterIgnoredFields: ['a'] })

232 +

await waitNT(wrapper.vm)

233 +

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

234 + 235 +

wrapper.destroy()

236 +

})

237 + 238 +

it('`filter-included-fields` prop works', async () => {

239 +

const wrapper = mount(BTable, {

240 +

propsData: {

241 +

fields: testFields,

242 +

// Add a extra item with a duplicated value in another field

243 +

items: [...testItems, { a: 4, b: 'y', c: 'a' }],

244 +

filter: '',

245 +

filterIncludedFields: []

246 +

}

247 +

})

248 + 249 +

expect(wrapper).toBeDefined()

250 +

await waitNT(wrapper.vm)

251 + 252 +

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

253 + 254 +

// Search for "a"

255 +

await wrapper.setProps({ filter: 'a' })

256 +

await waitNT(wrapper.vm)

257 +

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

258 + 259 +

// Only include "a" and "b" fields

260 +

await wrapper.setProps({ filterIncludedFields: ['a', 'b'] })

261 +

await waitNT(wrapper.vm)

262 +

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

263 + 264 +

wrapper.destroy()

265 +

})

266 + 210 267

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

211 268

const wrapper = mount(BTable, {

212 269

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