-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact(KtTable): turn all files in kotti-table/logic into typescript
types have been purposefully left obtuse for now Co-Authored-By: Florian Wendelborn <[email protected]>
- Loading branch information
1 parent
5c211fe
commit 7c3632e
Showing
10 changed files
with
169 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
...ti-ui/source/kotti-table/logic/disable.js → ...ti-ui/source/kotti-table/logic/disable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import negate from 'lodash/negate' | ||
|
||
export const defaultState = { | ||
enabledRows: [], | ||
isAllRowsDisabled: false, | ||
} | ||
|
||
function getDisabledRows(rows, disableRow) { | ||
return rows.filter((row, rowIndex) => { | ||
function getDisabledRows(rows: any, disableRow: any) { | ||
return rows.filter((row: any, rowIndex: number) => { | ||
return disableRow ? disableRow({ row, rowIndex }) : false | ||
}) | ||
} | ||
|
||
function getEnabledRows(rows, disableRow) { | ||
function getEnabledRows(rows: any, disableRow: any) { | ||
return getDisabledRows(rows, negate(disableRow)) | ||
} | ||
|
||
export const mutations = { | ||
updateDisabledRows({ state, table }) { | ||
updateDisabledRows({ state, table }: any): void { | ||
state.enabledRows = getEnabledRows(state.rows, table.disableRow) | ||
state.isAllRowsDisabled = state.enabledRows.length === 0 | ||
}, | ||
} | ||
|
||
export const getters = { | ||
isAllRowsDisabled(state) { | ||
isAllRowsDisabled(state: any): boolean { | ||
return ( | ||
state.rows.length === | ||
getDisabledRows(state.rows, this.table.disableRow).length | ||
getDisabledRows(state.rows, (this as any).table.disableRow).length | ||
) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
...tti-ui/source/kotti-table/logic/filter.js → ...tti-ui/source/kotti-table/logic/filter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.