Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for multiple levels of tags on workspace #34983

Merged
merged 58 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7d7c4da
extend routes
rezkiy37 Jan 23, 2024
6f723e2
clarify types
rezkiy37 Jan 23, 2024
430a72b
improve getTag of TransactionUtils
rezkiy37 Jan 23, 2024
7881a0c
Implement new logic of PolicyUtils
rezkiy37 Jan 23, 2024
8a26e37
Implement new logic of IOU
rezkiy37 Jan 23, 2024
02ae4cc
Implement new logic to components
rezkiy37 Jan 23, 2024
bd2d443
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jan 24, 2024
58ad1d3
Implement new logic for recently used tags
rezkiy37 Jan 24, 2024
c3f5116
integrate insertTagIntoReportTagsSting
rezkiy37 Jan 24, 2024
be603aa
remove fallback value
rezkiy37 Jan 24, 2024
34b02dc
integrate editing
rezkiy37 Jan 24, 2024
8de8d06
use updated reset
rezkiy37 Jan 24, 2024
66f2ab7
todo added
rezkiy37 Jan 24, 2024
0e30d0c
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jan 24, 2024
c2b4ca7
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jan 26, 2024
3e6afa8
prettify routes
rezkiy37 Jan 26, 2024
eab5b73
clarify type
rezkiy37 Jan 26, 2024
a200538
integrate hasEnabledTags
rezkiy37 Jan 26, 2024
f8e2512
integrate violations for tags
rezkiy37 Jan 27, 2024
67f05d8
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jan 28, 2024
cf53298
integrate getCountOfEnabledTagsOfList
rezkiy37 Jan 29, 2024
0e13b3c
use hasEnabledTags
rezkiy37 Jan 29, 2024
9b13a17
clarify comment
rezkiy37 Jan 29, 2024
d6ccb19
minor improvement
rezkiy37 Jan 29, 2024
8540bf6
clarify comment
rezkiy37 Jan 29, 2024
258caa7
clarify comment
rezkiy37 Jan 29, 2024
00c5448
minor improvement
rezkiy37 Jan 29, 2024
9d9d5bd
clarify comment
rezkiy37 Jan 29, 2024
9614236
minor improvement
rezkiy37 Jan 29, 2024
d134ce7
minor improvement
rezkiy37 Jan 29, 2024
b179b66
clarify comment
rezkiy37 Jan 29, 2024
54c10dd
minor improvement
rezkiy37 Jan 29, 2024
2544666
minor improvement
rezkiy37 Jan 29, 2024
bc2689a
rename variable
rezkiy37 Jan 29, 2024
cd77d07
integrate multiple levels of tags to split bill
rezkiy37 Jan 29, 2024
3a95869
integrate multiple levels of tags for modified expense message
rezkiy37 Jan 29, 2024
7872c47
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jan 30, 2024
4619e03
update violations tests for tags.
rezkiy37 Jan 30, 2024
0ff0948
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 1, 2024
674cd30
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 5, 2024
ef0ca5d
use const
rezkiy37 Feb 5, 2024
bf8d517
use new value
rezkiy37 Feb 5, 2024
5e21909
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 6, 2024
9b713ab
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 6, 2024
996438d
back import
rezkiy37 Feb 6, 2024
be8e86f
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 7, 2024
c547b3c
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 7, 2024
9f6f4d8
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 8, 2024
3d7cd9a
fix method name
rezkiy37 Feb 8, 2024
eeb4356
create a var for translation
rezkiy37 Feb 8, 2024
11b6422
use Set instead of lodash
rezkiy37 Feb 8, 2024
8710b31
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 9, 2024
8941cd1
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 12, 2024
dcac45e
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 13, 2024
b5d8e2d
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 14, 2024
0951468
fix conflicts
rezkiy37 Feb 14, 2024
e68d736
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Feb 15, 2024
bc4adbe
fix onyx tags type
rezkiy37 Feb 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.POLICY]: OnyxTypes.Policy;
[ONYXKEYS.COLLECTION.POLICY_DRAFTS]: OnyxTypes.Policy;
[ONYXKEYS.COLLECTION.POLICY_CATEGORIES]: OnyxTypes.PolicyCategories;
[ONYXKEYS.COLLECTION.POLICY_TAGS]: OnyxTypes.PolicyTags;
[ONYXKEYS.COLLECTION.POLICY_TAGS]: OnyxTypes.PolicyTagList;
[ONYXKEYS.COLLECTION.POLICY_MEMBERS]: OnyxTypes.PolicyMembers;
[ONYXKEYS.COLLECTION.POLICY_MEMBERS_DRAFTS]: OnyxTypes.PolicyMember;
[ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES]: OnyxTypes.RecentlyUsedCategories;
Expand Down
16 changes: 9 additions & 7 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ const ROUTES = {
getRoute: (reportID: string) => `r/${reportID}/avatar` as const,
},
EDIT_REQUEST: {
route: 'r/:threadReportID/edit/:field',
getRoute: (threadReportID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>) => `r/${threadReportID}/edit/${field}` as const,
route: 'r/:threadReportID/edit/:field/:tagIndex?',
getRoute: (threadReportID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>, tagIndex?: number) =>
`r/${threadReportID}/edit/${field}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const,
},
EDIT_CURRENCY_REQUEST: {
route: 'r/:threadReportID/edit/currency',
Expand Down Expand Up @@ -224,8 +225,9 @@ const ROUTES = {
getRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}` as const,
},
EDIT_SPLIT_BILL: {
route: `r/:reportID/split/:reportActionID/edit/:field`,
getRoute: (reportID: string, reportActionID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>) => `r/${reportID}/split/${reportActionID}/edit/${field}` as const,
route: `r/:reportID/split/:reportActionID/edit/:field/:tagIndex?`,
getRoute: (reportID: string, reportActionID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>, tagIndex?: number) =>
`r/${reportID}/split/${reportActionID}/edit/${field}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const,
},
EDIT_SPLIT_BILL_CURRENCY: {
route: 'r/:reportID/split/:reportActionID/edit/currency',
Expand Down Expand Up @@ -369,9 +371,9 @@ const ROUTES = {
getUrlWithBackToParam(`${action}/${iouType}/scan/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_TAG: {
route: ':action/:iouType/tag/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/tag/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/tag/:tagIndex/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, tagIndex: number, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/tag/${tagIndex}/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_WAYPOINT: {
route: ':action/:iouType/waypoint/:transactionID/:reportID/:pageIndex',
Expand Down
65 changes: 33 additions & 32 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,10 @@ function MoneyRequestConfirmationList(props) {
const shouldShowDate = shouldShowAllFields && !isTypeSend && !isSplitWithScan;
const shouldShowMerchant = shouldShowAllFields && !isTypeSend && !props.isDistanceRequest && !isSplitWithScan;

// Fetches the first tag list of the policy
const policyTag = PolicyUtils.getTag(props.policyTags);
const policyTagList = lodashGet(policyTag, 'tags', {});
const policyTagListName = lodashGet(policyTag, 'name', translate('common.tag'));
const policyTagLists = useMemo(() => PolicyUtils.getTagLists(props.policyTags), [props.policyTags]);

// A flag for showing the tags field
const shouldShowTags = props.isPolicyExpenseChat && (props.iouTag || OptionsListUtils.hasEnabledOptions(_.values(policyTagList)));
const shouldShowTags = props.isPolicyExpenseChat && (props.iouTag || OptionsListUtils.hasEnabledTags(policyTagLists));

// A flag for showing tax fields - tax rate and tax amount
const shouldShowTax = props.isPolicyExpenseChat && lodashGet(props.policy, 'tax.trackingEnabled', props.policy.isTaxTrackingEnabled);
Expand Down Expand Up @@ -781,33 +779,36 @@ function MoneyRequestConfirmationList(props) {
rightLabel={canUseViolations && Boolean(props.policy.requiresCategory) ? translate('common.required') : ''}
/>
)}
{shouldShowTags && (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly}
title={PolicyUtils.getCleanedTagName(props.iouTag)}
description={policyTagListName}
numberOfLinesTitle={2}
onPress={() => {
if (props.isEditingSplitBill) {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.SPLIT,
props.transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID));
}}
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!props.isReadOnly}
rightLabel={canUseViolations && Boolean(props.policy.requiresTag) ? translate('common.required') : ''}
/>
)}
{shouldShowTags &&
_.map(policyTagLists, ({name}, index) => (
<MenuItemWithTopDescription
key={name}
shouldShowRightIcon={!props.isReadOnly}
title={TransactionUtils.getTag(transaction, index)}
description={name}
numberOfLinesTitle={2}
onPress={() => {
if (props.isEditingSplitBill) {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.SPLIT,
index,
props.transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID));
}}
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!props.isReadOnly}
rightLabel={canUseViolations && Boolean(props.policy.requiresTag) ? translate('common.required') : ''}
/>
))}

{shouldShowTax && (
<MenuItemWithTopDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {useIsFocused} from '@react-navigation/native';
import {format} from 'date-fns';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react';
import React, {Fragment, useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand Down Expand Up @@ -80,9 +80,6 @@ const propTypes = {
/** IOU category */
iouCategory: PropTypes.string,

/** IOU tag */
iouTag: PropTypes.string,

/** IOU isBillable */
iouIsBillable: PropTypes.bool,

Expand Down Expand Up @@ -177,7 +174,6 @@ const defaultProps = {
onSelectParticipant: () => {},
iouType: CONST.IOU.TYPE.REQUEST,
iouCategory: '',
iouTag: '',
iouIsBillable: false,
onToggleBillable: () => {},
payeePersonalDetails: null,
Expand Down Expand Up @@ -217,7 +213,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
iouCurrencyCode,
iouIsBillable,
iouMerchant,
iouTag,
iouType,
isDistanceRequest,
isEditingSplitBill,
Expand Down Expand Up @@ -270,13 +265,10 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
const shouldShowDate = shouldShowSmartScanFields || isDistanceRequest;
const shouldShowMerchant = shouldShowSmartScanFields && !isDistanceRequest;

// Fetches the first tag list of the policy
const policyTag = PolicyUtils.getTag(policyTags);
const policyTagList = lodashGet(policyTag, 'tags', {});
const policyTagListName = lodashGet(policyTag, 'name', translate('common.tag'));
const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]);

// A flag for showing the tags field
const shouldShowTags = isPolicyExpenseChat && OptionsListUtils.hasEnabledOptions(_.values(policyTagList));
const shouldShowTags = useMemo(() => isPolicyExpenseChat && OptionsListUtils.hasEnabledTags(policyTagLists), [isPolicyExpenseChat, policyTagLists]);

// A flag for showing tax rate
const shouldShowTax = isPolicyExpenseChat && policy && lodashGet(policy, 'tax.trackingEnabled', policy.isTaxTrackingEnabled);
Expand Down Expand Up @@ -765,17 +757,17 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
shouldShow: shouldShowCategories,
isSupplementary: !isCategoryRequired,
},
{
..._.map(policyTagLists, ({name}, index) => ({
item: (
<MenuItemWithTopDescription
key={translate('common.tag')}
key={name}
shouldShowRightIcon={!isReadOnly}
title={PolicyUtils.getCleanedTagName(iouTag)}
description={policyTagListName}
title={TransactionUtils.getTag(transaction, index)}
description={name}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.CREATE, iouType, index, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
)
}
style={[styles.moneyRequestMenuItem]}
Expand All @@ -786,7 +778,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
),
shouldShow: shouldShowTags,
isSupplementary: !isTagRequired,
},
})),
{
item: (
<MenuItemWithTopDescription
Expand Down
Loading
Loading