mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-10 01:41:59 +00:00
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import intl from 'react-intl-universal';
|
|
import { RESOURCES_TYPES } from 'common/resourcesTypes';
|
|
import withDrawerActions from '../Drawer/withDrawerActions';
|
|
import {
|
|
AbilitySubject,
|
|
ManualJournalAction,
|
|
} from '../../common/abilityOption';
|
|
|
|
/**
|
|
* Universal search manual journal item select action.
|
|
*/
|
|
function JournalUniversalSearchSelectComponent({
|
|
// #ownProps
|
|
resourceType,
|
|
resourceId,
|
|
onAction,
|
|
|
|
// #withDrawerActions
|
|
openDrawer,
|
|
}) {
|
|
if (resourceType === RESOURCES_TYPES.MANUAL_JOURNAL) {
|
|
openDrawer('journal-drawer', { manualJournalId: resourceId });
|
|
onAction && onAction();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export const JournalUniversalSearchSelectAction = withDrawerActions(
|
|
JournalUniversalSearchSelectComponent,
|
|
);
|
|
|
|
/**
|
|
* Mappes the manual journal item to search item.
|
|
*/
|
|
const manualJournalsToSearch = (manualJournal) => ({
|
|
id: manualJournal.id,
|
|
text: manualJournal.journal_number,
|
|
subText: manualJournal.formatted_date,
|
|
label: manualJournal.formatted_amount,
|
|
reference: manualJournal,
|
|
});
|
|
|
|
/**
|
|
* Binds universal search invoice configure.
|
|
*/
|
|
export const universalSearchJournalBind = () => ({
|
|
resourceType: RESOURCES_TYPES.MANUAL_JOURNAL,
|
|
optionItemLabel: intl.get('manual_journals'),
|
|
selectItemAction: JournalUniversalSearchSelectAction,
|
|
itemSelect: manualJournalsToSearch,
|
|
permission: {
|
|
ability: ManualJournalAction.View,
|
|
subject: AbilitySubject.ManualJournal,
|
|
},
|
|
});
|