Skip to content

Commit

Permalink
Merge pull request #142 from weni-ai/fix/crossing-data-bugs
Browse files Browse the repository at this point in the history
[ENGAGE-1461] - Fix card data crossing bugs
  • Loading branch information
Aldemylla authored Aug 23, 2024
2 parents 110ee49 + 90e6067 commit dec0dcb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@primary-button-click="updateWidgetConfig"
@secondary-button-click="internalClose"
@close="$emit('close')"
@back="$emit('back')"
@back="configType ? $emit('back') : $emit('close')"
>
<template #content>
<section class="drawer-config-widget-dynamic__content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@ export default defineComponent({
configLocal: {
deep: true,
handler(newConfig) {
this.$emit('update:config', newConfig);
const treatedConfig = {
...newConfig,
operation:
newConfig.result_type === 'executions'
? 'count'
: newConfig.operation,
};
this.$emit('update:config', treatedConfig);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ export default {
operations: [
{
value: 'sum',
value: 'multiply',
label: this.$t('drawers.config_card.radios.multiply'),
},
{
value: 'max',
value: 'sum',
label: this.$t('drawers.config_card.radios.sum'),
},
{
value: 'avg',
value: 'sub',
label: this.$t('drawers.config_card.radios.difference'),
},
{
value: 'min',
value: 'percentage',
label: this.$t('drawers.config_card.radios.percentage'),
},
],
Expand All @@ -84,7 +84,7 @@ export default {
value: 'currency',
selected: this.config?.currency,
label: this.$t('drawers.config_card.checkbox.currency'),
disabled: this.config.operation === 'min',
disabled: this.config.operation === 'percentage',
},
];
},
Expand All @@ -109,7 +109,7 @@ export default {
...newConfig,
});
if (newConfig?.operation === 'min') this.config.currency = false;
if (newConfig?.operation === 'percentage') this.config.currency = false;
},
},
Expand Down Expand Up @@ -163,7 +163,7 @@ export default {
this.config = {
subwidget_1: createSubwidgetConfig(widgetConfig.subwidget_1),
subwidget_2: createSubwidgetConfig(widgetConfig.subwidget_2),
operation: widgetConfig.operation || 'min',
operation: widgetConfig.operation || 'percentage',
currency: widgetConfig.currency || false,
};
Expand Down
1 change: 1 addition & 0 deletions src/models/WidgetOutgoing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class OutgoingWidget {
const additionalConfig = additionalConfigMap[config.type]?.() || config;

return {
config_type: config.type === 'data_crossing' ? 'crossing_data' : '',
type_result: config.type,
friendly_id: config.friendly_id || '',
...additionalConfig,
Expand Down
1 change: 1 addition & 0 deletions src/models/types/WidgetOutgoingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface OutgoingFlowResultCardConfig extends OutgoingBaseCardConfig {
}
export interface OutgoingDataCrossingCardConfig extends OutgoingBaseCardConfig {
type_result: 'data_crossing';
config_type: 'crossing_data';
operator: string;
currency: boolean;
subwidget_1: OutgoingDataCrossingSubwidget;
Expand Down

0 comments on commit dec0dcb

Please sign in to comment.