Skip to content

Commit

Permalink
Merge pull request #137 from running-elephant/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Cuiyansong authored Jul 28, 2022
2 parents eae4861 + 4ab658a commit 9f6acc6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/dev-ut-stage.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ jobs:
working-directory: ./frontend
- run: npm run test:ci
working-directory: ./frontend
- run: npm run lint:css
working-directory: ./frontend
- run: npm run lint:style
working-directory: ./frontend
13 changes: 13 additions & 0 deletions core/src/main/java/datart/core/mappers/ext/VariableMapperExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ public interface VariableMapperExt extends VariableMapper {
})
List<Variable> selectByIds(Collection<String> ids);

@Select({
"<script>",
"SELECT count(1) FROM variable WHERE org_id=#{orgId} AND `name` = #{name}",
"<if test=\"viewId==null\">",
" AND view_id IS NULL ",
"</if>",
"<if test=\"viewId!=null\">",
" AND view_id=#{viewId} ",
"</if>",
"</script>",
})
int checkVariableName(String orgId, String viewId, String name);

@Select({
"SELECT * FROM variable WHERE view_id = #{viewId}"
})
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/ChartEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export const ChartEditor: FC<ChartEditorProps> = ({
} else {
// dataChart
confirm({
title: '保存修改后不能撤销,确定继续保存吗?',
title: tg('button.saveConfirm'),
icon: <ExclamationCircleOutlined />,
async onOk() {
dispatch(
Expand Down Expand Up @@ -540,6 +540,7 @@ export const ChartEditor: FC<ChartEditorProps> = ({
chartConfig,
dataview?.computedFields,
history,
tg,
]);

const saveChartToDashBoard = useCallback(
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"saveAs": "Save As",
"cancel": "Cancel",
"ok": "OK",
"shortcuts": "Shortcuts"
"shortcuts": "Shortcuts",
"saveConfirm": "After saving the changes, it cannot be undone. Are you sure you want to continue saving?"
},
"operation": {
"archiveConfirm": "Archive confirm",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"saveAs": "另存为",
"cancel": "取消",
"ok": "确定",
"shortcuts": "快捷键"
"shortcuts": "快捷键",
"saveConfirm": "保存修改后不能撤销,确定继续保存吗?"
},
"operation": {
"archiveConfirm": "确定移至回收站?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.alibaba.fastjson.JSON;
import datart.core.base.consts.VariableTypeEnum;
import datart.core.base.exception.Exceptions;
import datart.core.base.exception.ParamException;
import datart.core.common.UUIDGenerator;
import datart.core.entity.RelVariableSubject;
import datart.core.entity.Role;
Expand Down Expand Up @@ -67,11 +69,10 @@ public void requirePermission(Variable entity, int permission) {

@Override
public boolean checkUnique(String orgId, String viewId, String name) {
Variable variable = new Variable();
variable.setOrgId(orgId);
variable.setName(name);
variable.setViewId(viewId);
return checkUnique(variable);
if (variableMapper.checkVariableName(orgId, viewId, name) != 0) {
Exceptions.tr(ParamException.class, "error.param.exists.name");
}
return true;
}

@Override
Expand Down Expand Up @@ -267,7 +268,7 @@ public boolean update(BaseUpdateParam updateParam) {
VariableUpdateParam param = (VariableUpdateParam) updateParam;
Variable retrieve = retrieve(updateParam.getId());
if (!param.getName().equalsIgnoreCase(retrieve.getName())) {
checkUnique(retrieve.getOrgId(), null, param.getName());
checkUnique(retrieve.getOrgId(), retrieve.getViewId(), param.getName());
}
if (param.getRelVariableSubjects() != null) {
rvsMapper.deleteByVariables(Collections.singleton(param.getId()));
Expand Down

0 comments on commit 9f6acc6

Please sign in to comment.