perf: form help tip style

This commit is contained in:
ibuler 2024-04-01 19:24:28 +08:00
parent 274d14d905
commit 9315dab053
10 changed files with 47 additions and 24 deletions

View File

@ -317,11 +317,16 @@ td .el-button.el-button--mini {
.el-tooltip__popper.is-light {
background: #FFF;
max-width: 500px;
border: 1px solid #e7eaec;
box-shadow: 0 1.6px 3.6px 0 rgba(0, 0, 0, .132), 0 .3px .9px 0 rgba(0, 0, 0, .108);
line-height: 1.5;
padding: 10px;
}
.el-tooltip__popper.is-light .popper__arrow {
border-bottom-color: #e7eaec !important;
border-bottom-color: #c2d1e1 !important;
border-top-color: #c2d1e1 !important;
}
.el-dialog__headerbtn .el-dialog__close {

View File

@ -160,6 +160,18 @@ export class FormFieldGenerator {
return field
}
afterGenerateField(field) {
field.label = toSentenceCase(field.label)
if (field.helpText) {
field.helpText = toSentenceCase(field.helpText)
}
if ((!field.helpTip && field.helpText && field.helpTextAsTip) || field.component === Switcher) {
field.helpTip = field.helpText
field.helpText = ''
}
return field
}
generateField(name, fieldsMeta, remoteFieldsMeta) {
let field = { id: name, prop: name, el: {}, attrs: {}, rules: [] }
const remoteFieldMeta = remoteFieldsMeta[name] || {}
@ -174,11 +186,8 @@ export class FormFieldGenerator {
field = Object.assign(field, fieldMeta)
field.el = el
field.rules = rules
field.label = toSentenceCase(field.label)
if (field.helpText) {
field.helpText = toSentenceCase(field.helpText)
}
field = this.setPlaceholder(field, remoteFieldMeta)
field = this.afterGenerateField(field)
_.set(field, 'attrs.error', '')
Vue.$log.debug('Generate field: ', name, field)
return field

View File

@ -8,11 +8,11 @@
v-bind="data.attrs"
>
<template v-if="data.label" #label>
<span>{{ data.label }}</span>
<el-tooltip v-if="data.helpTips" effect="light" placement="top" popper-class="help-tips">
<div slot="content" v-html="data.helpTips" />
<i class="fa fa-question-circle-o" />
<el-tooltip v-if="data.helpTip" effect="light" placement="top" popper-class="help-tips">
<div slot="content" v-html="data.helpTip" />
<i class="el-icon-warning-outline help-tip-icon" />
</el-tooltip>
<span>{{ data.label }}</span>
</template>
<template v-if="readonly && hasReadonlyContent">
<div
@ -282,3 +282,12 @@ export default {
}
}
</script>
<style lang='scss'>
.help-tip-icon {
font-weight: bold;
&:hover {
cursor: pointer;
}
}
</style>

View File

@ -187,16 +187,16 @@ export default {
// this.$log.debug('Field: ', type, col.prop, col)
return col
},
addHelpTipsIfNeed(col) {
const helpTips = col.helpTips
if (!helpTips) {
addHelpTipIfNeed(col) {
const helpTip = col.helpTip
if (!helpTip) {
return col
}
col.renderHeader = (h, { column, $index }) => {
return (
<span>{column.label}
<el-tooltip placement='bottom' effect='light' popperClass='help-tips'>
<div slot='content' domPropsInnerHTML={helpTips}/>
<div slot='content' domPropsInnerHTML={helpTip}/>
<el-button style='padding: 0'>
<i class='fa fa-info-circle'/>
</el-button>
@ -282,7 +282,7 @@ export default {
col = this.generateColumnByName(name, col)
col = this.setDefaultFormatterIfNeed(col)
col = Object.assign(col, customMeta)
col = this.addHelpTipsIfNeed(col)
col = this.addHelpTipIfNeed(col)
col = this.addFilterIfNeed(col)
col = this.addOrderingIfNeed(col)
col = this.updateLabelIfNeed(col)

View File

@ -18,8 +18,7 @@ export default {
return {
url: '/api/v1/accounts/account-backup-plans/',
fields: [
[this.$t('Basic'), ['name']],
[this.$t('Types'), ['types']],
[this.$t('Basic'), ['name', 'types']],
[this.$t('Backup'),
[
'backup_type',

View File

@ -53,7 +53,8 @@ export const templateFieldsMeta = (vm) => {
secret_strategy: {
hidden: (formValue) => {
return !canRandomSecretTypes.includes(formValue.secret_type)
}
},
helpTextAsTip: true
},
secret: {
label: vm.$t('Password'),

View File

@ -27,7 +27,7 @@ export default {
},
rule_relation: {
label: this.$t('RuleRelation'),
helpTips: this.$t('RuleRelationHelpTips')
helpTip: this.$t('RuleRelationhelpTip')
},
strategy_rules: {
component: RuleInput

View File

@ -56,17 +56,17 @@ export default {
},
hostname_strategy: {
rules: [rules.RequiredChange],
helpTips: this.$t('HostnameStrategy')
helpTip: this.$t('HostnameStrategy')
},
is_always_update: {
type: 'switch',
label: this.$t('IsAlwaysUpdate'),
helpTips: this.$t('IsAlwaysUpdateHelpTips')
helpTip: this.$t('IsAlwaysUpdateHelpTip')
},
fully_synchronous: {
type: 'switch',
label: this.$t('FullySynchronous'),
helpTips: this.$t('FullySynchronousHelpTips')
helpTip: this.$t('FullySynchronousHelpTip')
},
regions: {
component: Select2,
@ -105,7 +105,7 @@ export default {
strategy: {
label: this.$t('Strategy'),
component: SyncInstanceTaskStrategy,
helpTips: this.$t('StrategyHelpTips')
helpTip: this.$t('StrategyHelpTip')
}
},
updateSuccessNextRoute: { name: 'CloudCenter' },

View File

@ -45,7 +45,7 @@ export default {
fieldsMeta: {
rule_relation: {
label: this.$t('RuleRelation'),
helpTips: this.$t('RuleRelationHelpTips')
helpTip: this.$t('RuleRelationHelpTip')
},
strategy_rules: {
label: this.$t('Rule'),

View File

@ -202,7 +202,7 @@ export default {
fieldsToUpdate.forEach(field => {
const msg = this.$t('disallowSelfUpdateFields', { attr: this.fieldsMeta[field]['label'] })
this.fieldsMeta[field].el.disabled = true
this.fieldsMeta[field].helpTips = msg
this.fieldsMeta[field].helpTip = msg
})
}
this.fieldsMeta.password.el.userIsOrgAdmin = user['is_org_admin']