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

feat(MCDA): 19437 New reverse sentiments button for MCDA layer. Small UI tweaks #835

Merged
merged 6 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/core/localization/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"save_changes": "Save changes",
"range": "Value range",
"outliers": "Outliers",
"sentiment": "Sentiment",
"reverse_to_good_bad": "Reverse to Good \u2192 Bad",
"reverse_to_bad_good": "Reverse to Bad \u2192 Good",
"weight": "Weight",
"transform": "Transform",
"transformation": "Transformation",
Expand Down Expand Up @@ -149,7 +150,6 @@
},
"tips": {
"range": "The values that will be considered the worst and the best in your analysis.",
"sentiment": "Determine the direction of sentiment for the layer's impact on the analysis:\n* **Bad → Good**: Higher values indicate a positive sentiment.\n* **Good → Bad**: Higher values indicate a negative sentiment.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lost a tooltip? there is no other explanation of "Sentiment"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was removed in the new layout, along with the dropdown. Guess we need to put the info icon somewhere else

https://www.figma.com/design/cFmWZmGioB52BDMoCofzpY/MCDA?node-id=17025-59711&node-type=frame&t=E9Ji1JGqeSNTH9E7-0

"weight": "By default, all layers contribute equally to the analysis through a weighted average. Adjusting the increased weight of a layer (2, 3, etc.) allows you to assign additional importance to it in the analysis.",
"transform": "Apply calculations to the values. Achieving a more linear distribution will provide more useful information for analysis.\n\n **Note**: Calculations are done before normalization.",
"normalize": "Adjusts values to a standardized scale. This helps compare them easily and make decisions.\n* **Standard score scaling**: This option adjusts values to a standardized scale, ensuring they are all comparable.\n* **No (for specialists only)**: Leaves values unmodified.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

.layerEditContainer {
width: 100%;
margin-top: 12px;
padding: var(--half-unit) var(--unit) var(--unit);
margin-top: var(--unit);
padding: calc(3 * var(--half-unit)) var(--double-unit) var(--unit);
font-size: 12px;
border: 1px var(--faint-strong) solid;
border-radius: 10px;
}

.layer:hover {
Expand Down Expand Up @@ -110,3 +112,7 @@
display: flex;
flex-direction: row;
}

.reverseButton {
margin: var(--half-unit) 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,28 @@ export function MCDALayerParameters({ layer, onLayerEdited }: MCDALayerLegendPro
setEditMode(false);
}, []);

const onReverseSentiment = useCallback(() => {
const newSentiment = (
sentiment === sentimentsOptions[0].value
? sentimentsOptions[1].value
: sentimentsOptions[0].value
) as string;

const updatedLayer: MCDALayer = {
...layer,
sentiment: SENTIMENT_VALUES[newSentiment],
};
if (editMode) {
onCancel();
}
onLayerEdited(updatedLayer);
}, [editMode, layer, onCancel, onLayerEdited, sentiment]);

const editLayer = useCallback(async () => {
if (editMode) {
onCancel();
return;
}
setEditMode(true);
setIsLoading(true);
try {
Expand All @@ -233,43 +254,53 @@ export function MCDALayerParameters({ layer, onLayerEdited }: MCDALayerLegendPro
} finally {
setIsLoading(false);
}
}, [layer.indicators]);
}, [editMode, layer.indicators, onCancel]);

return (
<div>
<div key={layer.id} className={s.layer}>
<div className={s.layerHeader}>
<div>{layer.name}</div>
<div className={s.layerButtons}>
{!editMode && (
<LayerActionIcon
onClick={editLayer}
hint={i18n.t('layer_actions.tooltips.edit')}
className={s.editButton}
>
<Prefs16 />
</LayerActionIcon>
)}
<LayerActionIcon
onClick={editLayer}
hint={i18n.t('layer_actions.tooltips.edit')}
className={s.editButton}
>
<Prefs16 />
</LayerActionIcon>
<LayerInfo
className={s.infoButton}
layersInfo={mcdaLayerHint}
tooltipId={LAYERS_PANEL_FEATURE_ID}
/>
</div>
</div>
<div>
<Sentiments
left={sentiments.left}
right={sentiments.right}
units={layer.unit}
/>
<div>
<Button
className={s.reverseButton}
variant="invert-outline"
size="tiny"
onClick={onReverseSentiment}
>
{sentiment === sentimentsOptions[0].value
? i18n.t('mcda.layer_editor.reverse_to_good_bad')
: i18n.t('mcda.layer_editor.reverse_to_bad_good')}
</Button>
</div>
</div>
{!editMode ? (
// Static mode
<div>
<Sentiments
left={sentiments.left}
right={sentiments.right}
units={layer.unit}
/>
<div className={s.nonDefaultValues}>
{nonDefaultValues.map((v, index) => (
<div key={`nonDefault${index}`}>{`${v.paramName}: ${v.value}`}</div>
))}
</div>
<div className={s.nonDefaultValues}>
{nonDefaultValues.map((v, index) => (
<div key={`nonDefault${index}`}>{`${v.paramName}: ${v.value}`}</div>
))}
</div>
) : (
// Edit mode
Expand Down Expand Up @@ -309,23 +340,6 @@ export function MCDALayerParameters({ layer, onLayerEdited }: MCDALayerLegendPro
items={outliersOptions}
/>
</MCDALayerParameterRow>
{/* SENTIMENT */}
<MCDALayerParameterRow
name={i18n.t('mcda.layer_editor.sentiment')}
infoText={i18n.t('mcda.layer_editor.tips.sentiment')}
>
<Select
className={s.selectInput}
classes={{
menu: s.selectInputBox,
}}
value={sentiment}
onChange={(e) => {
setSentiment(e.selectedItem?.value as string);
}}
items={sentimentsOptions}
/>
</MCDALayerParameterRow>
{/* WEIGHT */}
<MCDALayerParameterRow
name={i18n.t('mcda.layer_editor.weight')}
Expand Down
3 changes: 3 additions & 0 deletions src/features/mcda/components/MCDALayerEditor/style.module.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.editor {
display: flex;
flex-direction: column;
gap: var(--unit);
margin-bottom: var(--unit);
margin-right: calc(-1 * var(--half-unit));
}
Loading