From 2334d1a06814b958a986f800e5ed1e46a8501657 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 20 May 2019 10:35:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=8F=90=E5=8F=96=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 1 + .../left/left_item/left.item.component.ts | 6 +- .../left_item/left.item.icon.component.ts | 6 +- src/app/link_set/more/more.link.component.ts | 6 +- .../right/right_edit/right.edit.component.ts | 64 +++++++++---------- .../right/right_edit/right.edit.constant.ts | 4 -- .../right_edit/right.edit.mysql.component.ts | 58 ++++++++--------- .../right/right_edit/right.edit.service.ts | 4 ++ src/demo/plugin.redis.edit.ts | 16 ++--- 9 files changed, 81 insertions(+), 84 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index e8772fa..d62bd01 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { 'for-direction': 2, // 关键字前后必须有空格 'keyword-spacing': 2, + 'key-spacing':2, // 最大块嵌套深度为 5 层 'max-depth': [2, 5], // 最大回调深度为 3 层 diff --git a/src/app/link_set/left/left_item/left.item.component.ts b/src/app/link_set/left/left_item/left.item.component.ts index 6f33bc5..660d803 100644 --- a/src/app/link_set/left/left_item/left.item.component.ts +++ b/src/app/link_set/left/left_item/left.item.component.ts @@ -5,8 +5,8 @@ import {ACTION_COPY, ACTION_TEST, ACTION_DELETE, DEFAULT_INFO} from '@private/co const className = 'fr.component.linkSet.left.item'; const Widget: WidgetType = { props: { - title:'', - id:'', + title: '', + id: '', creator: '', }, _store() { @@ -30,7 +30,7 @@ const Widget: WidgetType = { }, { type: TextButton, - cls:'link-title', + cls: 'link-title', textAlign: 'left', text: title, title, diff --git a/src/app/link_set/left/left_item/left.item.icon.component.ts b/src/app/link_set/left/left_item/left.item.icon.component.ts index f0ba3b7..3079d35 100644 --- a/src/app/link_set/left/left_item/left.item.icon.component.ts +++ b/src/app/link_set/left/left_item/left.item.icon.component.ts @@ -22,7 +22,7 @@ const Widget: WidgetType = { el: { type: Icon, cls, - extraCls: 'action-icon', + baseCls: 'action-icon', height: 24, width: 26, title, @@ -47,14 +47,14 @@ const Widget: WidgetType = { eventName: BI.BubbleCombo.EVENT_EXPAND, action () { iconContent.element.css({ - visibility:'visible', + visibility: 'visible', }); }, }, { eventName: BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, action () { iconContent.element.css({ - visibility:'hidden', + visibility: 'hidden', }); }, }], diff --git a/src/app/link_set/more/more.link.component.ts b/src/app/link_set/more/more.link.component.ts index 3db61cf..8644906 100644 --- a/src/app/link_set/more/more.link.component.ts +++ b/src/app/link_set/more/more.link.component.ts @@ -10,9 +10,9 @@ const Widget: WidgetType = { cls: 'more-link', items: [ { - el:{ + el: { type: Vertical, - items:[{ + items: [{ type: SearchEditor, width: 300, watermark: BI.i18nText('Dec-Dcm_Search'), @@ -22,7 +22,7 @@ const Widget: WidgetType = { }, { type: Left, - cls:'more-link-item', + cls: 'more-link-item', ref(ref: any) { morkLinkItem = ref; }, diff --git a/src/app/link_set/right/right_edit/right.edit.component.ts b/src/app/link_set/right/right_edit/right.edit.component.ts index e7129d2..539cccc 100644 --- a/src/app/link_set/right/right_edit/right.edit.component.ts +++ b/src/app/link_set/right/right_edit/right.edit.component.ts @@ -4,14 +4,14 @@ import charset from './right.edit.constant'; import Model from '../../link-set.model'; import FormItem from '@shared/components/form.item.component'; import Title from '@shared/components/title.component'; -import {getDrivers} from './right.edit.service'; +import {getDrivers, connectNameChecker} from './right.edit.service'; let ConnectionName: any = null; const className = 'fr.component.right.edit'; const Widget: WidgetType = { _store() { return BI.Models.getModel(Model); }, - watch:{ + watch: { connectionNameErr(msg: string) { if (msg) { BI.Bubbles.show('singleBubble', msg, ConnectionName, { @@ -34,7 +34,7 @@ const Widget: WidgetType = { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'), hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'), - form:{ + form: { type: Editor, cls: 'bi-border', width: 300, @@ -62,14 +62,14 @@ const Widget: WidgetType = { type: FormItem, text: BI.i18nText('Dec-Dcm_First_Step'), height: 400, - form:{ + form: { type: Vertical, cls: 'right-form', - items:[ + items: [ { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), - form:{ + form: { type: TextValueCombo, cls: 'bi-border', width: 300, @@ -89,10 +89,10 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_URL'), - form:{ + form: { type: Editor, cls: 'bi-border', - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, value: linkSelected.url, listeners: [{ @@ -109,12 +109,18 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), - form:{ + form: { type: TextValueCombo, cls: 'bi-border', width: 300, text: linkSelected.originalCharsetName === '' ? BI.i18nText('Dec-Dcm_Connection_Form_Auto') : linkSelected.originalCharsetName, - items: BI.Constants.getConstant(charset), + items: [ + { + text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'), + value: '', + }, + ...BI.Constants.getConstant(charset), + ], listeners: [{ eventName: BI.TextValueCombo.EVENT_CHANGE, action() { @@ -129,11 +135,11 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_UserName'), - form:{ + form: { type: Editor, cls: 'bi-border', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, value: linkSelected.user, listeners: [{ @@ -150,12 +156,12 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Password'), - form:{ + form: { type: Editor, cls: 'bi-border', - inputType:'password', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + inputType: 'password', + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, value: linkSelected.password, listeners: [{ @@ -177,13 +183,13 @@ const Widget: WidgetType = { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'), height: 100, - form:{ + form: { type: TextAreaEditor, cls: 'bi-border', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, - height:100, + height: 100, value: linkSelected.validationQuery, listeners: [{ eventName: BI.Editor.EVENT_CHANGE, @@ -199,7 +205,7 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'), - form:{ + form: { type: MultiSelectItem, text: BI.i18nText('Dec-Dcm_Yes'), selected: linkSelected.testOnBorrow, @@ -218,21 +224,15 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Connection_Max_Number'), - form:{ + form: { type: Editor, cls: 'bi-border', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 60, value: linkSelected.maxActive, errorText: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input-Number'), - validationChecker (v: string) { - if (/^\+?[1-9][0-9]*$/.test(v)) { - return true; - } - - return false; - }, + validationChecker: connectNameChecker, listeners: [{ eventName: BI.Editor.EVENT_CHANGE, action() { diff --git a/src/app/link_set/right/right_edit/right.edit.constant.ts b/src/app/link_set/right/right_edit/right.edit.constant.ts index d74d953..27c3754 100644 --- a/src/app/link_set/right/right_edit/right.edit.constant.ts +++ b/src/app/link_set/right/right_edit/right.edit.constant.ts @@ -1,10 +1,6 @@ export const ConstantName = 'bi.constant.database.conf.charset.list'; export const Constant = BI.constant(ConstantName, [ - { - text: '自动', - value: '', - }, { text: 'GBK', value: 'GBK', diff --git a/src/app/link_set/right/right_edit/right.edit.mysql.component.ts b/src/app/link_set/right/right_edit/right.edit.mysql.component.ts index 161a1f1..7b65bd5 100644 --- a/src/app/link_set/right/right_edit/right.edit.mysql.component.ts +++ b/src/app/link_set/right/right_edit/right.edit.mysql.component.ts @@ -4,7 +4,7 @@ import charset from './right.edit.constant'; import Model from '../../link-set.model'; import FormItem from '@shared/components/form.item.component'; import Title from '@shared/components/title.component'; -import {getDrivers} from './right.edit.service'; +import {getDrivers, connectNameChecker} from './right.edit.service'; const className = 'fr.component.right.edit.mysql'; const Widget: WidgetType = { _store() { @@ -22,7 +22,7 @@ const Widget: WidgetType = { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'), hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'), - form:{ + form: { type: Editor, cls: 'bi-border', width: 300, @@ -41,7 +41,7 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), - form:{ + form: { type: TextValueCombo, cls: 'bi-border', width: 300, @@ -61,10 +61,10 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_URL'), - form:{ + form: { type: Editor, cls: 'bi-border', - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, value: linkSelected.url, listeners: [{ @@ -81,12 +81,18 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_OriginalCharsetName'), - form:{ + form: { type: TextValueCombo, cls: 'bi-border', width: 300, text: linkSelected.originalCharsetName === '' ? BI.i18nText('Dec-Dcm_Connection_Form_Auto') : linkSelected.originalCharsetName, - items: BI.Constants.getConstant(charset), + items: [ + { + text: BI.i18nText('Dec-Dcm_Connection_Form_Auto'), + value: '', + }, + ...BI.Constants.getConstant(charset), + ], listeners: [{ eventName: BI.TextValueCombo.EVENT_CHANGE, action() { @@ -101,11 +107,11 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_UserName'), - form:{ + form: { type: Editor, cls: 'bi-border', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, value: linkSelected.user, listeners: [{ @@ -122,12 +128,12 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Password'), - form:{ + form: { type: Editor, cls: 'bi-border', - inputType:'password', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + inputType: 'password', + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, value: linkSelected.password, listeners: [{ @@ -149,13 +155,13 @@ const Widget: WidgetType = { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_SQL_Validation_Query'), height: 100, - form:{ + form: { type: TextAreaEditor, cls: 'bi-border', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 300, - height:100, + height: 100, value: linkSelected.validationQuery, listeners: [{ eventName: BI.Editor.EVENT_CHANGE, @@ -171,7 +177,7 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Connection-Check'), - form:{ + form: { type: MultiSelectItem, text: BI.i18nText('Dec-Dcm_Yes'), selected: linkSelected.testOnBorrow, @@ -190,21 +196,15 @@ const Widget: WidgetType = { { type: FormItem, text: BI.i18nText('Dec-Dcm_Connection_Form_Connection_Max_Number'), - form:{ + form: { type: Editor, cls: 'bi-border', - allowBlank:true, - watermark:BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), + allowBlank: true, + watermark: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input'), width: 60, value: linkSelected.maxActive, errorText: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input-Number'), - validationChecker (v: string) { - if (/^\+?[1-9][0-9]*$/.test(v)) { - return true; - } - - return false; - }, + validationChecker: connectNameChecker, listeners: [{ eventName: BI.Editor.EVENT_CHANGE, action() { diff --git a/src/app/link_set/right/right_edit/right.edit.service.ts b/src/app/link_set/right/right_edit/right.edit.service.ts index 8d9fb89..90f2a9a 100644 --- a/src/app/link_set/right/right_edit/right.edit.service.ts +++ b/src/app/link_set/right/right_edit/right.edit.service.ts @@ -18,3 +18,7 @@ export function getDrivers(linkSelected: LinkType): {text: string; value: string return drivers; } + +export function connectNameChecker(name: string): boolean { + return /^\+?[1-9][0-9]*$/.test(name); +} diff --git a/src/demo/plugin.redis.edit.ts b/src/demo/plugin.redis.edit.ts index a785278..31e8802 100644 --- a/src/demo/plugin.redis.edit.ts +++ b/src/demo/plugin.redis.edit.ts @@ -1,7 +1,7 @@ import './style.scss'; const RedisConstantName = 'dec.constant.database.conf.connect.form.redis.value'; const form = { - url:'192.168.1.22', + url: '192.168.1.22', port: 6379, password: '123456', }; @@ -11,8 +11,8 @@ const Widget = BI.inherit(BI.Widget, { render() { return { type: 'bi.vertical', - cls:'bi-plugin-redis', - bgap:10, + cls: 'bi-plugin-redis', + bgap: 10, items: [ { type: 'bi.left', @@ -29,7 +29,7 @@ const Widget = BI.inherit(BI.Widget, { type: 'bi.editor', cls: 'bi-border', watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Addr'), - value:form.url, + value: form.url, allowBlank: true, width: 300, height: 24, @@ -56,11 +56,7 @@ const Widget = BI.inherit(BI.Widget, { value: form.port, errorText: BI.i18nText('Dec-Dcm_Connection_Form_Place_Input-Number'), validationChecker (v: string) { - if (/^\+?[1-9][0-9]*$/.test(v)) { - return true; - } - - return false; + return /^\+?[1-9][0-9]*$/.test(v); }, }], }, @@ -78,7 +74,7 @@ const Widget = BI.inherit(BI.Widget, { { type: 'bi.editor', cls: 'bi-border', - inputType:'password', + inputType: 'password', value: form.password, allowBlank: true, width: 300,