|
113 | 113 | </el-badge> |
114 | 114 | </el-tooltip> |
115 | 115 | </div> |
116 | | - <div class="topic-input-container"> |
117 | | - <el-input class="publish-topic-input" placeholder="Topic" v-model="msgRecord.topic" @focus="handleInputFoucs"> |
| 116 | + <div :class="['topic-input-container', topicRequired ? 'required' : '', topicInvalid ? 'invalid' : '']"> |
| 117 | + <el-input |
| 118 | + class="publish-topic-input" |
| 119 | + placeholder="Topic" |
| 120 | + v-model="msgRecord.topic" |
| 121 | + @focus="handleInputFoucs" |
| 122 | + @blur="handleInputBlur" |
| 123 | + > |
118 | 124 | </el-input> |
119 | | - </div> |
120 | | - <el-select |
121 | | - class="header-select" |
122 | | - popper-class="header-select--popper" |
123 | | - v-model="headerValue" |
124 | | - placeholder="" |
125 | | - size="mini" |
126 | | - @change="handleHeaderChange" |
127 | | - > |
128 | | - <el-option |
129 | | - class="header-option" |
130 | | - v-for="item in headersHistory" |
131 | | - :key="item.id" |
132 | | - :label="item.label" |
133 | | - :value="item" |
| 125 | + <el-select |
| 126 | + class="header-select" |
| 127 | + popper-class="header-select--popper" |
| 128 | + v-model="headerValue" |
| 129 | + placeholder="" |
| 130 | + size="mini" |
| 131 | + @change="handleHeaderChange" |
134 | 132 | > |
135 | | - <span style="float: left; width: 160px; overflow: hidden; text-overflow: ellipsis" :title="item.topic">{{ |
136 | | - item.topic |
137 | | - }}</span> |
138 | | - <span style="color: #8492a6; font-size: 12px; margin-left: 4px">QoS:{{ item.qos }}</span> |
139 | | - <span style="float: right; color: #8492a6; font-size: 13px; margin-left: 4px"> |
140 | | - retain:{{ item.retain ? '1' : '0' }} |
141 | | - </span> |
142 | | - </el-option> |
143 | | - </el-select> |
| 133 | + <el-option |
| 134 | + class="header-option" |
| 135 | + v-for="item in headersHistory" |
| 136 | + :key="item.id" |
| 137 | + :label="item.label" |
| 138 | + :value="item" |
| 139 | + > |
| 140 | + <span style="float: left; width: 160px; overflow: hidden; text-overflow: ellipsis" :title="item.topic">{{ |
| 141 | + item.topic |
| 142 | + }}</span> |
| 143 | + <span style="color: #8492a6; font-size: 12px; margin-left: 4px">QoS:{{ item.qos }}</span> |
| 144 | + <span style="float: right; color: #8492a6; font-size: 13px; margin-left: 4px"> |
| 145 | + retain:{{ item.retain ? '1' : '0' }} |
| 146 | + </span> |
| 147 | + </el-option> |
| 148 | + </el-select> |
| 149 | + </div> |
144 | 150 | </div> |
145 | 151 | <div class="editor-container"> |
146 | 152 | <div |
@@ -231,6 +237,9 @@ export default class MsgPublish extends Vue { |
231 | 237 |
|
232 | 238 | private saveMetaLoading = false |
233 | 239 |
|
| 240 | + private topicRequired = false |
| 241 | + private topicInvalid = false |
| 242 | +
|
234 | 243 | private getHasMqtt5PropState() { |
235 | 244 | return ( |
236 | 245 | Object.entries(this.MQTT5PropsForm).filter(([_, v]) => v !== null && v !== undefined && v !== false).length > 0 |
@@ -417,10 +426,33 @@ export default class MsgPublish extends Vue { |
417 | 426 | } |
418 | 427 | } |
419 | 428 |
|
| 429 | + public setTopicRequired(isRequired = true) { |
| 430 | + this.topicRequired = isRequired |
| 431 | + } |
| 432 | +
|
| 433 | + public setTopicInvalid(isInvalid = true) { |
| 434 | + this.topicInvalid = isInvalid |
| 435 | + } |
| 436 | +
|
420 | 437 | private handleInputFoucs() { |
| 438 | + if (this.topicRequired) { |
| 439 | + this.topicRequired = false |
| 440 | + } |
| 441 | + if (this.topicInvalid) { |
| 442 | + this.topicInvalid = false |
| 443 | + } |
421 | 444 | this.$emit('foucs') |
422 | 445 | } |
423 | 446 |
|
| 447 | + private handleInputBlur() { |
| 448 | + if (this.topicRequired) { |
| 449 | + this.topicRequired = false |
| 450 | + } |
| 451 | + if (this.topicInvalid) { |
| 452 | + this.topicInvalid = false |
| 453 | + } |
| 454 | + } |
| 455 | +
|
424 | 456 | private handleLayout() { |
425 | 457 | const editorRef: EditorRef = this.$refs.payloadEditor as EditorRef |
426 | 458 | editorRef.editorLayout() |
@@ -505,19 +537,42 @@ export default class MsgPublish extends Vue { |
505 | 537 | } |
506 | 538 | } |
507 | 539 | } |
| 540 | + .topic-input-container { |
| 541 | + position: relative; |
| 542 | + display: flex; |
| 543 | + flex-wrap: nowrap; |
| 544 | + align-items: center; |
| 545 | + &.required, |
| 546 | + &.invalid { |
| 547 | + .el-input.publish-topic-input { |
| 548 | + .el-input__inner { |
| 549 | + border-right: none !important; |
| 550 | + } |
| 551 | + } |
| 552 | + .el-select { |
| 553 | + .el-input__inner { |
| 554 | + border-left: none !important; |
| 555 | + } |
| 556 | + } |
| 557 | + .el-input__inner { |
| 558 | + border: 1px solid var(--color-minor-red) !important; |
| 559 | + } |
| 560 | + } |
| 561 | + } |
508 | 562 | .publish-topic-input.el-input { |
509 | | - width: calc(100% - 20px); |
510 | | - vertical-align: top; |
511 | | - display: inline-block; |
| 563 | + flex: 1 1 0; |
| 564 | + min-width: 0; |
| 565 | + width: auto; |
| 566 | + display: block; |
512 | 567 | @include topic-input__inner; |
513 | 568 | .el-input__inner { |
514 | 569 | padding: 0px 16px; |
515 | 570 | } |
516 | 571 | } |
517 | 572 | .header-select.el-select { |
518 | | - vertical-align: top; |
| 573 | + flex: 0 0 20px; |
519 | 574 | width: 20px; |
520 | | - display: inline-block; |
| 575 | + display: block; |
521 | 576 | .el-input { |
522 | 577 | @include topic-input__inner; |
523 | 578 | &.is-focus { |
|
0 commit comments