-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
600 additions
and
317 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { MenuItem } from '@blueprintjs/core'; | ||
import { FMultiSelect } from '../Forms'; | ||
import classNames from 'classnames'; | ||
import { Classes } from '@blueprintjs/popover2'; | ||
|
||
/** | ||
* | ||
* @param {*} query | ||
* @param {*} account | ||
* @param {*} _index | ||
* @param {*} exactMatch | ||
* @returns | ||
*/ | ||
const accountItemPredicate = (query, account, _index, exactMatch) => { | ||
const normalizedTitle = account.name.toLowerCase(); | ||
const normalizedQuery = query.toLowerCase(); | ||
|
||
if (exactMatch) { | ||
return normalizedTitle === normalizedQuery; | ||
} else { | ||
return `${account.code}. ${normalizedTitle}`.indexOf(normalizedQuery) >= 0; | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @param {*} account | ||
* @param {*} param1 | ||
* @returns | ||
*/ | ||
const accountItemRenderer = ( | ||
account, | ||
{ handleClick, modifiers, query }, | ||
{ isSelected }, | ||
) => { | ||
return ( | ||
<MenuItem | ||
icon={isSelected ? 'tick' : 'blank'} | ||
text={account.name} | ||
label={account.code} | ||
key={account.id} | ||
onClick={handleClick} | ||
/> | ||
); | ||
}; | ||
|
||
const accountSelectProps = { | ||
itemPredicate: accountItemPredicate, | ||
itemRenderer: accountItemRenderer, | ||
valueAccessor: (item) => item.id, | ||
labelAccessor: (item) => item.code, | ||
tagRenderer: (item) => item.name, | ||
}; | ||
|
||
/** | ||
* branches mulit select. | ||
* @param {*} param0 | ||
* @returns {JSX.Element} | ||
*/ | ||
export function AccountMultiSelect({ accounts, ...rest }) { | ||
return ( | ||
<FMultiSelect | ||
items={accounts} | ||
popoverProps={{ | ||
minimal: true, | ||
}} | ||
{...accountSelectProps} | ||
{...rest} | ||
/> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './AccountMultiSelect'; |
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Intent, Tag } from '@blueprintjs/core'; | ||
import { Choose, FormattedMessage as T } from '../../../components'; | ||
|
||
/** | ||
* items inactive status. | ||
* @returns {React.JSX} | ||
*/ | ||
export function inactiveStatus(item) { | ||
return ( | ||
<Choose> | ||
<Choose.When condition={!item.active}> | ||
{item.name} | ||
<StatusTag intent={Intent.NONE} minimal={true} round={true}> | ||
<T id={'item.details.inactive'} /> | ||
</StatusTag> | ||
</Choose.When> | ||
<Choose.Otherwise>{item.name}</Choose.Otherwise> | ||
</Choose> | ||
); | ||
} | ||
|
||
const StatusTag = styled(Tag)` | ||
font-size: 11px; | ||
margin-left: 10px; | ||
`; |
Oops, something went wrong.