This is an automated email from the ASF dual-hosted git repository.

xxyu pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit 07fae26ff7f06fa0d2c42239c23db728649fc8e3
Author: Qian Xia <lauraxiaq...@gmail.com>
AuthorDate: Thu Jul 27 17:08:48 2023 +0800

    KYLIN-5671 refine del agg issue
---
 .../StudioModel/ModelList/AggregateModal/index.vue | 45 +++++++++++++++++-----
 .../ModelList/AggregateModal/locales.js            |  3 ++
 .../StudioModel/ModelList/AggregateModal/store.js  |  6 ++-
 kystudio/src/locale/en.js                          |  2 +-
 4 files changed, 44 insertions(+), 12 deletions(-)

diff --git 
a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/index.vue 
b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/index.vue
index a53beaa4f0..e41fd3c783 100644
--- 
a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/index.vue
+++ 
b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/index.vue
@@ -417,7 +417,7 @@
             <span v-if="isWaitingCheckAllCuboids">{{$t('numTitle', {num: 
$t('needCheck')})}}</span>
             <!-- 正在检测的情况 -->
             <span v-if="!isWaitingCheckAllCuboids && 
renderCoboidTextCheck(cuboidsInfo.total_count) === 
'loading'">{{$t('numTitle1')}}<i class="el-icon-loading"></i></span>
-            <common-tip :content="$t('includesEmpty')" 
v-if="isDisabledSaveBtn" >
+            <common-tip :content="disabledTips" v-if="isDisabledSaveBtn" >
               <i class="el-ksd-icon-refresh_22 ksd-fs-22 ksd-ml-10 
is-disabled" @click="checkCuboids(true)"></i>
             </common-tip>
             <i class="el-ksd-icon-refresh_22 ksd-fs-22 ksd-ml-10" v-else 
@click="checkCuboids(true)"></i>
@@ -457,8 +457,12 @@
         </div>
         <div class="right ksd-fs-0">
           <el-button :type="!onlyRealTimeType ? 'primary' : ''" 
:text="!onlyRealTimeType" size="medium" 
@click="handleClose(false)">{{$t('kylinLang.common.cancel')}}</el-button>
-          <el-button :type="onlyRealTimeType ? 'primary' : ''" size="medium" 
class="ksd-ml-10" :disabled="isDisabledSaveBtn || isSubmit&&isCatchUpLoading" 
v-if="isShow" :loading="isSubmit&&!isCatchUpLoading" 
@click="handleSubmit(false)">{{$t('kylinLang.common.save')}}</el-button>
-          <el-button v-if="isShow && !onlyRealTimeType" type="primary" 
size="medium" class="ksd-ml-10" :disabled="isDisabledSaveBtn || 
isSubmit&&!isCatchUpLoading" :loading="isSubmit&&isCatchUpLoading" 
@click="handleSubmit(true)">{{$t('saveAndBuild')}}</el-button>
+          <common-tip :content="disabledTips" :disabled="!isDisabledSaveBtn" 
effect="dark" placement="top">
+            <el-button :type="onlyRealTimeType ? 'primary' : ''" size="medium" 
class="ksd-ml-10" :disabled="isDisabledSaveBtn || isSubmit&&isCatchUpLoading" 
v-if="isShow" v-guide.saveAggBtn :loading="isSubmit&&!isCatchUpLoading" 
@click="handleSubmit(false)">{{$t('kylinLang.common.save')}}</el-button>
+          </common-tip>
+          <common-tip effect="dark" :disabled="!isDisabledSaveBtn" 
placement="top" :content="disabledTips">
+            <el-button v-if="isShow && !onlyRealTimeType" type="primary" 
size="medium" class="ksd-ml-10" :disabled="isDisabledSaveBtn || 
isSubmit&&!isCatchUpLoading" :loading="isSubmit&&isCatchUpLoading" 
@click="handleSubmit(true)">{{$t('saveAndBuild')}}</el-button>
+          </common-tip>
         </div>
       </div>
     </div>
@@ -605,7 +609,8 @@ vuex.registerModule(['modals', 'AggregateModal'], store)
       model: state => state.model,
       projectName: state => state.projectName,
       aggregateIdx: state => state.aggregateIdx,
-      formDataLoaded: state => state.formDataLoaded
+      formDataLoaded: state => state.formDataLoaded,
+      originFormData: state => state.originFormData
     }),
     ...mapGetters('AggregateModal', [
       'dimensions',
@@ -881,15 +886,36 @@ export default class AggregateModal extends Vue {
       this.$message.error(this.$t('calcError'))
     })
   }
-  get isDisabledSaveBtn () {
-    // 正在计算的时候按钮disable,选的维度有空的时候,disable,聚合组数为0 时
+  getFormStringify () {
     const cloneForm = objectClone(this.form)
     if (cloneForm && cloneForm.aggregateArray.length) {
       cloneForm.aggregateArray.forEach((a) => {
         delete a.activeTab // 切换tab不属于编辑内容变化
       })
     }
-    return this.calcLoading || this.isSubmit || !this.isFormVaild || 
!this.form.aggregateArray || this.form.aggregateArray.length === 0 || 
this.cloneForm === JSON.stringify(cloneForm)
+    return cloneForm
+  }
+  get isDisabledSaveBtn () {
+    // 正在计算的时候按钮disable,选的维度有空的时候,disable,聚合组数为0 时
+    const cloneForm = this.getFormStringify()
+    return this.calcLoading || this.isSubmit || !this.isFormVaild || 
!this.form.aggregateArray || (this.form.aggregateArray.length === 0 && 
!this.cloneForm) || this.cloneForm === JSON.stringify(cloneForm)
+  }
+  get disabledTips () {
+    const cloneForm = this.getFormStringify()
+    // 初始 this.cloneForm 为空说明原来就没有聚合组,初始有聚合组,编辑时删除到无聚合组,属于删除聚合组操作,允许操作
+    if (!this.form.aggregateArray || (this.form.aggregateArray.length === 0 && 
!this.cloneForm)) {
+      return this.$t('noAgg')
+    }
+    if (!this.isFormVaild) {
+      return this.$t('includesEmpty')
+    }
+    if (this.cloneForm === JSON.stringify(cloneForm)) {
+      return this.$t('noChange')
+    }
+    if (this.calcLoading) {
+      return this.$t('calcLoading')
+    }
+    return ''
   }
   renderCoboidTextCheck (cuboidsInfo, id) {
     let cuboidText = ''
@@ -924,9 +950,10 @@ export default class AggregateModal extends Vue {
         this.isWaitingCheckCuboids[id] = true
       }
       const cloneForm = objectClone(this.form)
-      if (cloneForm && cloneForm.aggregateArray.length) {
-        cloneForm.aggregateArray.forEach((a) => {
+      if (this.originFormData.length) {
+        cloneForm.aggregateArray = this.originFormData.map((a) => {
           delete a.activeTab // 切换tab不属于编辑内容变化
+          return a
         })
       }
       this.cloneForm = JSON.stringify(cloneForm)
diff --git 
a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/locales.js
 
b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/locales.js
index 21d1a8e38e..272a94d5ff 100644
--- 
a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/locales.js
+++ 
b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/locales.js
@@ -11,6 +11,9 @@ export default {
     'joint': 'Joint',
     'includesEmpty': 'Each aggregation group can\'t be empty.',
     'selectAllDimension': 'Select all dimensions',
+    noAgg: 'No new aggregate group',
+    noChange: 'Aggregate group not updated',
+    calcLoading: 'Checking index amount',
     selectAllMeasure: 'Select all measures',
     clearAllMeasures: 'Clear all measures',
     clearAllDimension: 'Clear all dimensions',
diff --git 
a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js 
b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js
index c9385f6ca9..844157863f 100644
--- 
a/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js
+++ 
b/kystudio/src/components/studio/StudioModel/ModelList/AggregateModal/store.js
@@ -1,4 +1,4 @@
-import { handleSuccessAsync, getFullMapping } from 'util'
+import { handleSuccessAsync, getFullMapping, objectClone } from 'util'
 
 const types = {
   SHOW_MODAL: 'SHOW_MODAL',
@@ -51,7 +51,8 @@ const initialState = JSON.stringify({
     aggregateArray: [
       JSON.parse(initialAggregateData)
     ]
-  }
+  },
+  originFormData: []
 })
 
 export default {
@@ -139,6 +140,7 @@ export default {
           return { id, includes, measures, mandatory, jointArray, 
hierarchyArray, activeTab, open, dimCap, isEditDim, index_range, curAggIsEdit }
         })
         state.form.aggregateArray = aggGroups
+        state.originFormData = objectClone(aggGroups)
 
         if (payload.editType === 'new') {
           const initAggregate = JSON.parse(initialAggregateData)
diff --git a/kystudio/src/locale/en.js b/kystudio/src/locale/en.js
index 8fab4839b2..bebacbd1ce 100644
--- a/kystudio/src/locale/en.js
+++ b/kystudio/src/locale/en.js
@@ -258,7 +258,7 @@ exports.default = {
     checkModel: 'Check Model',
     buildIndexSuccess: 'Success to submit a build index job, please check it 
on the monitor page.',
     buildIndexSuccess1: ' The new {indexType} will be used for querying after 
the build is complete. ',
-    saveIndexSuccess: 'You have successfully saved the {indexType}.',
+    saveIndexSuccess: 'You have successfully updated the {indexType}.',
     buildIndexFail1: 'Fail to submit the build index job because the model 
{modelName} doesn\'t have any load data range.',
     buildIndexFail2: 'Fail to generate a build index job because the 
{indexType} has no change.',
     primaryPartitionColumn: 'Primary Partition Column',

Reply via email to