Browse Source

refactor: 将验证方法提取出来

qufenxi
alan 6 years ago
parent
commit
2334d1a068
  1. 1
      .eslintrc.js
  2. 2
      src/app/link_set/left/left_item/left.item.icon.component.ts
  3. 18
      src/app/link_set/right/right_edit/right.edit.component.ts
  4. 4
      src/app/link_set/right/right_edit/right.edit.constant.ts
  5. 18
      src/app/link_set/right/right_edit/right.edit.mysql.component.ts
  6. 4
      src/app/link_set/right/right_edit/right.edit.service.ts
  7. 6
      src/demo/plugin.redis.edit.ts

1
.eslintrc.js

@ -25,6 +25,7 @@ module.exports = {
'for-direction': 2,
// 关键字前后必须有空格
'keyword-spacing': 2,
'key-spacing':2,
// 最大块嵌套深度为 5 层
'max-depth': [2, 5],
// 最大回调深度为 3 层

2
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,

18
src/app/link_set/right/right_edit/right.edit.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';
let ConnectionName: any = null;
const className = 'fr.component.right.edit';
const Widget: WidgetType = {
@ -114,7 +114,13 @@ const Widget: WidgetType = {
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() {
@ -226,13 +232,7 @@ const Widget: WidgetType = {
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() {

4
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',

18
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() {
@ -86,7 +86,13 @@ const Widget: WidgetType = {
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() {
@ -198,13 +204,7 @@ const Widget: WidgetType = {
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() {

4
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);
}

6
src/demo/plugin.redis.edit.ts

@ -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);
},
}],
},

Loading…
Cancel
Save