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

Custom Labels Step 2 #1120

Merged
merged 49 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1b57f5e
show customized modes (used dummy data for now)
jiji14 Dec 1, 2023
cad2d7c
fix prettier issu
jiji14 Dec 1, 2023
74e2dfe
fetch post/mode
jiji14 Dec 4, 2023
0402a34
use displayErrorMsg
jiji14 Dec 4, 2023
09b56ee
Done with fetching data to server
jiji14 Dec 7, 2023
a3cb1f2
update mode - old mode and new mode
jiji14 Dec 8, 2023
abc7f8a
Change modes type to string array and call it when modal opens
jiji14 Dec 11, 2023
cb1c491
add comments
jiji14 Dec 11, 2023
0a7a4ba
change mode text in a desired format (ex) my_car => My Car
jiji14 Dec 12, 2023
8ba3fb6
add default mode & custom mode label
jiji14 Dec 13, 2023
aa18e98
noted that getModes & updateMode need to be tested after e2e testing …
jiji14 Dec 14, 2023
7548de7
reuse existing common function and delete the original function
jiji14 Dec 18, 2023
01c1afe
use dynamic color
jiji14 Dec 18, 2023
b5a63be
change logic for showing custom modes before 'other' option
jiji14 Dec 18, 2023
f64d719
change function names more descriptive
jiji14 Dec 18, 2023
14c4438
delete unnecessary variable and change variable names more intuitive
jiji14 Dec 18, 2023
447e7e2
add new translation entry
jiji14 Dec 18, 2023
0509d5e
Fetch custom modes on initial rendering to prevent unnecessary api calls
jiji14 Dec 27, 2023
23f4758
add 'custom modes' tab in Profile
jiji14 Dec 27, 2023
0ef37b4
Move customModes state to AppContext to be shared between the 'Label'…
jiji14 Dec 27, 2023
de9008f
separate the component for clean code
jiji14 Dec 27, 2023
07f4534
Add insert user custom mode feature
jiji14 Dec 29, 2023
189f79d
check if inputType is 'MODE' for custom mode label
jiji14 Jan 3, 2024
643ae90
Modify the mode functions to encompass all types of labels (purpose, …
jiji14 Jan 5, 2024
315561e
Merge branch 'customize-modes' into customize-modes-step2
jiji14 Jan 8, 2024
939480f
fix merge conflict related to LabelTabContext
jiji14 Jan 9, 2024
bf3754d
Done with "manage custom labels" in profile setting tab
jiji14 Jan 9, 2024
01a3729
fix radio button issue when 'other' option is selected
jiji14 Jan 9, 2024
8cec495
change variable names for better understanding
jiji14 Jan 9, 2024
606816b
update radio button comment
jiji14 Jan 9, 2024
2d7352b
combine replaced_mode and mode
jiji14 Jan 11, 2024
32e5708
Merge branch 'customize-modes' into customize-modes-step2
jiji14 Jan 11, 2024
5f87ab3
update merge changes
jiji14 Jan 11, 2024
d02d7aa
combine mode and replaced_mode for Label Setting
jiji14 Jan 11, 2024
f5f5551
error handling for empty label array
jiji14 Jan 12, 2024
4192269
add skipped test functions
jiji14 Jan 12, 2024
0e0569e
Change list title "edit custom labels" -> "manage custom labels""
jiji14 Jan 12, 2024
7eb31dd
Merge branch 'service_rewrite_2023' into customize-modes-step2
jiji14 Jan 12, 2024
2a1a12c
Merge branch 'customize-modes' of https://github.com/jiji14/e-mission…
JGreenlee Feb 9, 2024
0c87797
bump 'react-native-paper' to ^5.11.0
JGreenlee Feb 9, 2024
7e09923
Merge branch 'master' into customize-modes-step2
jiji14 Feb 9, 2024
ae66eff
fix label context issue after merge
jiji14 Feb 15, 2024
3453205
ignore commHelper from coverage report
jiji14 Feb 15, 2024
26264ce
delete not operator
jiji14 Feb 16, 2024
cba51b8
add comment why we need to ingnore commHelper in coverage report
jiji14 Feb 17, 2024
96386a3
delete duplicated code
jiji14 Feb 17, 2024
15c994a
show customLabel setting conditionally
jiji14 Feb 17, 2024
45bfc2d
Merge branch 'master' into customize-modes-step2
JGreenlee Mar 25, 2024
52b0fb9
Merge branch 'master' of https://github.com/e-mission/e-mission-phone…
JGreenlee Jul 12, 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
Prev Previous commit
Next Next commit
update mode - old mode and new mode
increase new mode frequency and decrease old mode frequency
  • Loading branch information
jiji14 committed Dec 8, 2023
commit a3cb1f2953bcd5bbc5e34c9aae72c67e416126aa
13 changes: 9 additions & 4 deletions www/js/services/commHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,17 @@ export function getModes() {
});
}

export function createMode(mode) {
export function updateMode(oldMode, newMode, isNewModeMustAdded) {
const updatedMode = {
old_mode: oldMode,
new_mode: newMode,
is_new_mode_must_added: isNewModeMustAdded,
};
return new Promise((rs, rj) => {
window['cordova'].plugins.BEMServerComm.postUserPersonalData(
'/mode/create',
'mode',
mode,
'/mode/update',
'updated_mode',
updatedMode,
rs,
rj,
);
Expand Down
17 changes: 9 additions & 8 deletions www/js/survey/multilabel/MultiLabelButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import {
verifiabilityForTrip,
} from './confirmHelper';
import useAppConfig from '../../useAppConfig';
import { createMode, getModes } from '../../services/commHelper';
import { updateMode, getModes } from '../../services/commHelper';

const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
const { colors } = useTheme();
const { t } = useTranslation();
const appConfig = useAppConfig();
const { repopulateTimelineEntry, labelOptions, timelineLabelMap } = useContext(LabelTabContext);
const { height: windowHeight } = useWindowDimensions();
const [customMode, setCustomMode] = useState({});
const [customModes, setCustomModes] = useState({});
// modal visible for which input type? (mode or purpose or replaced_mode, null if not visible)
const [modalVisibleFor, setModalVisibleFor] = useState<
'MODE' | 'PURPOSE' | 'REPLACED_MODE' | null
Expand All @@ -46,7 +46,7 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
if (otherLabel != null) return 'other';
return timelineLabelMap[trip._id.$oid]?.[modalVisibleFor]?.value;
}, [modalVisibleFor, otherLabel]);

const initialLabel = chosenLabel;
// to mark 'inferred' labels as 'confirmed'; turn yellow labels blue
function verifyTrip() {
const inferredLabelsForTrip = inferFinalLabels(trip, timelineLabelMap[trip._id.$oid]);
Expand Down Expand Up @@ -79,9 +79,11 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
/* Let's make the value for user entered inputs look consistent with our other values
(i.e. lowercase, and with underscores instead of spaces) */
chosenLabel = readableLabelToKey(chosenLabel);
createMode(chosenLabel)
}
if (isOther || customModes[initialLabel] || customModes[chosenLabel]) {
updateMode(initialLabel, chosenLabel, isOther)
.then((res) => {
setCustomMode(res['modes']);
setCustomModes(res['modes']);
logDebug('Successfuly stored custom mode ' + JSON.stringify(res));
})
.catch((e) => {
Expand All @@ -93,7 +95,6 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
end_ts: trip.end_ts,
label: chosenLabel,
};

const storageKey = getLabelInputDetails()[inputType].key;
window['cordova'].plugins.BEMUserCache.putMessage(storageKey, inputDataToStore).then(() => {
dismiss();
Expand All @@ -107,7 +108,7 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
useEffect(() => {
getModes()
.then((res) => {
setCustomMode(res);
setCustomModes(res);
logDebug('Successfully get custom mode ' + JSON.stringify(res));
})
.catch((e) => {
Expand Down Expand Up @@ -182,7 +183,7 @@ const MultilabelButtonGroup = ({ trip, buttonsInline = false }) => {
style={{ paddingVertical: 2 }}
/>
))}
{Object.keys(customMode).map((key, i) => (
{Object.keys(customModes).map((key, i) => (
// @ts-ignore
<RadioButton.Item
key={key + i}
Expand Down
Loading