Skip to content

Commit

Permalink
fix(item): fixed issue with checked and visible status detection
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoterrinoni committed May 17, 2018
1 parent 01c845b commit a65bc2d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { merge, deepCopy, orderBy } from './helpers'

import SF from 'src/searchfield/model'

import I from 'src/icon/model'

import C from 'src/checkbox/model'

const listRowHeight = 50
const codepickerHeight = 250
const codepickerWidth = 250
Expand Down Expand Up @@ -110,8 +116,8 @@ export const getColumnStyle = <T>(c: Column<T>) => {
return style
}

const isVisible = <T>(i: Item<T>) => i.visible
const isChecked = <T>(i: Item<T>) => i.checked
const isVisible = <T>(i: Item<T>) => (i.visible ? true : false)
const isChecked = <T>(i: Item<T>) => (i.checked ? true : false)
const clean = <T>(i: Item<T>) => {
i.checked && delete i.checked
i.visible && delete i.visible
Expand All @@ -137,7 +143,7 @@ export const givenItem = <T>(i: Item<T>) => ({
visible: () => isVisible(i),
checked: () => isChecked(i),
clean: () => clean(i),
toggleCheck: (val?) => (i.checked = val !== undefined ? !val : !i.checked),
toggleCheck: (val?) => (i.checked = val !== undefined ? val : !i.checked),
equal: (_i: Item<T>) => !Object.keys(_i).find(k => i[k] !== _i[k])
})

Expand Down Expand Up @@ -169,6 +175,9 @@ const CP = {
width: codepickerWidth
},
classNames: {
...SF.classNames,
...I.classNames,
...C.classNames,
wrapper: `${BASE_NAME}-wrapper`,
main: BASE_NAME,
container: `${BASE_NAME}-container`,
Expand All @@ -178,8 +187,7 @@ const CP = {
isActionCol: isActionCol => (isActionCol ? 'action-col' : ''),
rowIndex: (index: number) => `list-item-index-${index}`,
row: 'list-item',
rowColumn: 'list-item-column',
icon: 'material-icons'
rowColumn: 'list-item-column'
},
defaultContainerStyle: (height?: number) => ({
height: height || 'auto'
Expand Down

0 comments on commit a65bc2d

Please sign in to comment.