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(evaluate): create expression-delete modal #4609

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
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import { computed, reactive } from 'vue';

import {
PIconButton, PI, PFieldGroup, PSelectButton, PTextInput, PButton, PTextarea,
PIconButton, PI, PFieldGroup, PSelectButton, PTextInput, PButton, PTextarea, PButtonModal,
} from '@cloudforet/mirinae';
import type { MenuItem } from '@cloudforet/mirinae/types/inputs/context-menu/type';

import { i18n } from '@/translations';

import { showSuccessMessage } from '@/lib/helper/notice-alert-helper';
import getRandomId from '@/lib/random-id-generator';

import { useProxyValue } from '@/common/composables/proxy-state';
Expand All @@ -29,15 +30,20 @@ const state = reactive({
fieldTypeMenuItems: computed<MenuItem[]>(() => [
{
name: EVAL_EXPRESSION_TYPE.LABEL,
label: i18n.t('Label Field'),
label: i18n.t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.TYPE_LABEL_FIELD'),
},
{
name: EVAL_EXPRESSION_TYPE.DATA,
label: i18n.t('Data Field'),
label: i18n.t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.TYPE_DATA_FIELD'),
},
]),
});

const modalState = reactive({
visible: false,
currentSelectionKey: undefined as string|undefined,
});

/* Events */
const handleToggleExpressionCard = (key: string) => {
state.proxyExpressions = state.proxyExpressions.map((expression) => {
Expand All @@ -51,7 +57,19 @@ const handleToggleExpressionCard = (key: string) => {
});
};
const handleClickDeleteExpression = (key: string) => {
state.proxyExpressions = state.proxyExpressions.filter((expression) => expression.key !== key);
modalState.visible = true;
modalState.currentSelectionKey = key;
};
const handleConfirmDeleteExpression = () => {
if (!modalState.currentSelectionKey) return;
state.proxyExpressions = state.proxyExpressions.filter((expression) => expression.key !== modalState.currentSelectionKey);
modalState.visible = false;
modalState.currentSelectionKey = undefined;
showSuccessMessage(i18n.t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.DELETE_SUCCESS_TOOLTIP'));
};
const handleCancelModal = () => {
modalState.visible = false;
modalState.currentSelectionKey = undefined;
};
const handleChangeFieldType = (key: string, selected: EvaluateExpressionType) => {
state.proxyExpressions = state.proxyExpressions.map((expression) => {
Expand Down Expand Up @@ -99,7 +117,7 @@ const handleClickAddLabel = () => {
<span v-else
class="expression-name placeholder"
>
{{ $t('Input Field Name') }}
{{ $t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.TITLE_PLACEHOLDER') }}
</span>
</div>
<p-icon-button name="ic_delete"
Expand All @@ -109,7 +127,7 @@ const handleClickAddLabel = () => {
/>
</div>
<div class="form-body">
<p-field-group :label="$t('Field Type')"
<p-field-group :label="$t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.FIELD_TYPE')"
required
style-type="secondary"
>
Expand All @@ -125,20 +143,20 @@ const handleClickAddLabel = () => {
</p-select-button>
</div>
</p-field-group>
<p-field-group :label="$t('Field Name')"
<p-field-group :label="$t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.FIELD_NAME')"
required
style-type="secondary"
>
<p-text-input v-model="expression.name"
block
/>
</p-field-group>
<p-field-group :label="$t('Field Formula')"
<p-field-group :label="$t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.FIELD_FORMULA')"
required
style-type="secondary"
>
<p-textarea v-model="expression.expression"
:placeholder="$t('Enter your formula in a pandas format.')"
:placeholder="$t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.FORMULA_PLACEHOLDER')"
/>
</p-field-group>
</div>
Expand All @@ -150,6 +168,19 @@ const handleClickAddLabel = () => {
>
{{ $t('Add Field') }}
</p-button>
<p-button-modal :header-title="$t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.DELETE_MODAL_TITLE')"
:visible.sync="modalState.visible"
size="sm"
theme-color="alert"
@confirm="handleConfirmDeleteExpression"
@cancel="handleCancelModal"
>
<template #body>
<p>
{{ $t('COMMON.WIDGETS.DATA_TABLE.FORM.EVAL.DELETE_MODAL_DESC') }}
</p>
</template>
</p-button-modal>
</div>
</template>

Expand Down
173 changes: 173 additions & 0 deletions packages/language-pack/console-translation-2.8.babel
Original file line number Diff line number Diff line change
Expand Up @@ -26466,6 +26466,179 @@
</translation>
</translations>
</concept_node>
<folder_node>
<name>EVAL</name>
<children>
<concept_node>
<name>DELETE_MODAL_DESC</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>DELETE_MODAL_TITLE</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>DELETE_SUCCESS_TOOLTIP</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>FIELD_FORMULA</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>FIELD_NAME</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>FIELD_TYPE</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>FORMULA_PLACEHOLDER</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>TITLE_PLACEHOLDER</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<concept_node>
<name>EVAL_DESC</name>
<definition_loaded>false</definition_loaded>
Expand Down
10 changes: 10 additions & 0 deletions packages/language-pack/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,16 @@
"DATA_TABLE_NAME_SUCCESS": "Data name successfully changed.",
"DATA_TABLE_NAME_WARNING": "A data with this name already exists.",
"DATA_UNIT": "Data Unit",
"EVAL": {
"DELETE_MODAL_DESC": "Are you sure you want to delete this Field?",
"DELETE_MODAL_TITLE": "Delete Cost Field",
"DELETE_SUCCESS_TOOLTIP": "Cost Field successfully deleted.",
"FIELD_FORMULA": "Field Formula",
"FIELD_NAME": "Field Name",
"FIELD_TYPE": "Field Type",
"FORMULA_PLACEHOLDER": "Enter your formula in a pandas format.",
"TITLE_PLACEHOLDER": "Input Field Name"
},
"EVAL_DESC": "Apply Functions or calculations to data fields. ",
"FIELD_NAME_DATE_INVALID_TEXT": "Date/Year/Month/Day cannot be used as field names.",
"FIELD_NAME_GROUP_BY_INVALID_TEXT": "Group by names cannot be used as field names.",
Expand Down
Loading
Loading