Skip to content

Commit 277671c

Browse files
committed
refactor: canvas shape-point style update
1 parent 1e0a329 commit 277671c

File tree

10 files changed

+46
-22
lines changed

10 files changed

+46
-22
lines changed

backend/apps/dashboard/api/dashboard_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ async def update_canvas_api(session: SessionDep, user: CurrentUser, dashboard: C
4444

4545

4646
@router.post("/check_name")
47-
async def check_name_api(session: SessionDep, dashboard: QueryDashboard):
48-
return validate_name(session, dashboard)
47+
async def check_name_api(session: SessionDep, user: CurrentUser, dashboard: QueryDashboard):
48+
return validate_name(session, user, dashboard)

backend/apps/dashboard/crud/dashboard_service.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,18 @@ def update_canvas(session: SessionDep, user: CurrentUser, dashboard: CreateDashb
9999
return record
100100

101101

102-
def validate_name(session: SessionDep, dashboard: QueryDashboard) -> bool:
103-
if not dashboard.workspace_id:
104-
raise ValueError("workspace_id is required")
105-
if not dashboard.pid:
106-
raise ValueError("pid is required")
102+
def validate_name(session: SessionDep,user: CurrentUser, dashboard: QueryDashboard) -> bool:
107103
if not dashboard.opt:
108104
raise ValueError("opt is required")
105+
oid = str(user.oid if user.oid is not None else 1)
106+
uid = str(user.id)
107+
109108

110109
if dashboard.opt in ('newLeaf', 'newFolder'):
111110
query = session.query(CoreDashboard).filter(
112111
and_(
113-
CoreDashboard.workspace_id == dashboard.workspace_id,
114-
CoreDashboard.pid == dashboard.pid,
112+
CoreDashboard.workspace_id == oid,
113+
CoreDashboard.create_by == uid,
115114
CoreDashboard.name == dashboard.name
116115
)
117116
)
@@ -120,8 +119,8 @@ def validate_name(session: SessionDep, dashboard: QueryDashboard) -> bool:
120119
raise ValueError("id is required for update operation")
121120
query = session.query(CoreDashboard).filter(
122121
and_(
123-
CoreDashboard.workspace_id == dashboard.workspace_id,
124-
CoreDashboard.pid == dashboard.pid,
122+
CoreDashboard.workspace_id == oid,
123+
CoreDashboard.create_by == uid,
125124
CoreDashboard.name == dashboard.name,
126125
CoreDashboard.id != dashboard.id
127126
)

frontend/src/i18n/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"password_reset_successful": "Password reset successful"
3333
},
3434
"dashboard": {
35+
"name_repeat": "Name Repeat",
36+
"rich_text_tips": "Double-click to enter text content",
3537
"exit_preview": "Exit preview",
3638
"no_chat": "No conversations",
3739
"today": "Today",
@@ -471,4 +473,4 @@
471473
"back_community": "Restore to Community Edition",
472474
"confirm_tips": "Are you sure to restore to Community Edition?"
473475
}
474-
}
476+
}

frontend/src/i18n/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
"password_reset_successful": "重置密码成功"
3535
},
3636
"dashboard": {
37+
"name_repeat": "仪表板名称已被使用",
38+
"rich_text_tips": "双击输入文本内容",
3739
"exit_preview": "退出预览",
3840
"no_chat": "暂无对话",
3941
"today": "今日",
@@ -483,4 +485,4 @@
483485
"back_community": "还原至社区版",
484486
"confirm_tips": "确定还原至社区版?"
485487
}
486-
}
488+
}

frontend/src/views/dashboard/canvas/ResizeHandle.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function getPointStyle(point: string) {
2828
2929
// Points at the four corners
3030
if (point.length === 2) {
31-
newLeft = hasL ? '0px' : '100%'
32-
newTop = hasT ? '0px' : '100%'
31+
newLeft = hasL ? '3px' : 'calc(100% - 3px)'
32+
newTop = hasT ? '3px' : 'calc(100% - 3px)'
3333
} else {
3434
// The point between the upper and lower points, with a width centered
3535
if (hasT || hasB) {

frontend/src/views/dashboard/components/component-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const COMPONENT_LIST = [
4949
component: 'SQText',
5050
name: 'new text',
5151
locked: false,
52-
propValue: 'Double click to edit text',
52+
propValue: null,
5353
editing: false,
5454
x: 1,
5555
y: 1,

frontend/src/views/dashboard/components/sq-text/index.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
<template>
22
<div class="rich-main-class" :class="{ 'edit-model': configItem.editing }" draggable="false">
33
<div
4-
v-if="isDisabled"
4+
v-if="isDisabled && !configItem.propValue"
5+
class="rich-text-empty"
6+
@keydown.stop
7+
@keyup.stop
8+
@mousedown.stop
9+
@dblclick.stop="setEdit"
10+
>
11+
{{ t('dashboard.rich_text_tips') }}
12+
</div>
13+
<div
14+
v-else-if="isDisabled"
515
draggable="false"
616
:class="{ 'custom-text-content': true, 'preview-text': true }"
717
@keydown.stop
@@ -32,7 +42,9 @@ import { computed, nextTick, type PropType, reactive, toRefs } from 'vue'
3242
import { onMounted } from 'vue'
3343
import type { CanvasItem } from '@/utils/canvas.ts'
3444
import { dashboardStoreWithOut } from '@/stores/dashboard/dashboard.ts'
45+
import { useI18n } from 'vue-i18n'
3546
const dashboardStore = dashboardStoreWithOut()
47+
const { t } = useI18n()
3648
3749
const props = defineProps({
3850
configItem: {
@@ -114,7 +126,16 @@ onMounted(() => {
114126
height: 100%;
115127
overflow-y: auto !important;
116128
position: relative;
117-
129+
padding: 12px !important;
130+
.rich-text-empty {
131+
display: flex;
132+
width: 100%;
133+
height: 100%;
134+
align-items: center;
135+
justify-content: center;
136+
font-size: 16px;
137+
color: rgba(100, 106, 115, 1);
138+
}
118139
div::-webkit-scrollbar {
119140
width: 0px !important;
120141
height: 0px !important;

frontend/src/views/dashboard/css/CanvasStyle.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
width: 8px;
3333
height: 8px;
3434
border-radius: 50%;
35-
z-index: 2;
35+
z-index: 10;
3636
}
3737

3838
.sq-component {

frontend/src/views/dashboard/editor/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ const addComponent = (componentType: string, viewInfo?: any) => {
3232
viewInfo['sourceId'] = viewInfo['id']
3333
viewInfo['id'] = component.id
3434
dashboardStore.addCanvasViewInfo(viewInfo)
35-
}
36-
if (component.component === 'SQTab') {
35+
} else if (component.component === 'SQTab') {
3736
const subTabName = guid('tab')
3837
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
3938
component.propValue[0].name = subTabName
4039
component.activeTabName = subTabName
4140
}
41+
4242
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
4343
dashboardEditorInnerRef.value.addItemToBox(component)
4444
}

frontend/src/views/dashboard/utils/canvasUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const saveDashboardResource = (params: any, callBack: Function) => {
8787
} else {
8888
ElMessage({
8989
type: 'warning',
90-
message: 'Name Already In Use',
90+
message: '名称重复',
9191
})
9292
}
9393
})

0 commit comments

Comments
 (0)