🐛 fix publish field not required

This commit is contained in:
yanyongyu 2021-09-15 21:03:18 +08:00
parent ca09fb8372
commit e0610fdcc0
3 changed files with 28 additions and 12 deletions

View File

@ -36,6 +36,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newAdapter.name" v-model="newAdapter.name"
:rules="rules"
label="协议名称" label="协议名称"
required required
></v-text-field> ></v-text-field>
@ -43,6 +44,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newAdapter.desc" v-model="newAdapter.desc"
:rules="rules"
label="协议介绍" label="协议介绍"
required required
></v-text-field> ></v-text-field>
@ -50,6 +52,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newAdapter.link" v-model="newAdapter.link"
:rules="rules"
label="PyPI 项目名" label="PyPI 项目名"
required required
></v-text-field> ></v-text-field>
@ -57,6 +60,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newAdapter.id" v-model="newAdapter.id"
:rules="rules"
label="协议 import 包名" label="协议 import 包名"
required required
></v-text-field> ></v-text-field>
@ -64,6 +68,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newAdapter.repo" v-model="newAdapter.repo"
:rules="rules"
label="仓库/主页链接" label="仓库/主页链接"
required required
></v-text-field> ></v-text-field>
@ -81,10 +86,7 @@
:disabled="!valid" :disabled="!valid"
color="blue darken-1" color="blue darken-1"
text text
@click=" @click="publishAdapter"
dialog = false;
publishAdapter();
"
> >
发布 发布
</v-btn> </v-btn>
@ -148,6 +150,7 @@ export default {
page: 1, page: 1,
dialog: false, dialog: false,
valid: false, valid: false,
rules: [(v) => !!v || "This field is required"],
newAdapter: { newAdapter: {
name: null, name: null,
desc: null, desc: null,
@ -174,10 +177,13 @@ export default {
displayAdapters() { displayAdapters() {
return this.filteredAdapters.slice((this.page - 1) * 10, this.page * 10); return this.filteredAdapters.slice((this.page - 1) * 10, this.page * 10);
}, },
},
methods: {
publishAdapter() { publishAdapter() {
if (!this.$refs.newAdapterForm.validate()) { if (!this.$refs.newAdapterForm.validate()) {
return; return;
} }
this.dialog = false;
const title = encodeURIComponent( const title = encodeURIComponent(
`Adapter: ${this.newAdapter.name}` `Adapter: ${this.newAdapter.name}`
).replace(/%2B/gi, "+"); ).replace(/%2B/gi, "+");

View File

@ -36,6 +36,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newBot.name" v-model="newBot.name"
:rules="rules"
label="机器人名称" label="机器人名称"
required required
></v-text-field> ></v-text-field>
@ -43,6 +44,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newBot.desc" v-model="newBot.desc"
:rules="rules"
label="机器人介绍" label="机器人介绍"
required required
></v-text-field> ></v-text-field>
@ -50,6 +52,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newBot.repo" v-model="newBot.repo"
:rules="rules"
label="仓库/主页链接" label="仓库/主页链接"
required required
></v-text-field> ></v-text-field>
@ -67,10 +70,7 @@
:disabled="!valid" :disabled="!valid"
color="blue darken-1" color="blue darken-1"
text text
@click=" @click="publishBot"
dialog = false;
publishBot();
"
> >
发布 发布
</v-btn> </v-btn>
@ -128,6 +128,7 @@ export default {
page: 1, page: 1,
dialog: false, dialog: false,
valid: false, valid: false,
rules: [(v) => !!v || "This field is required"],
newBot: { newBot: {
name: null, name: null,
desc: null, desc: null,
@ -151,10 +152,13 @@ export default {
displayBots() { displayBots() {
return this.filteredBots.slice((this.page - 1) * 10, this.page * 10); return this.filteredBots.slice((this.page - 1) * 10, this.page * 10);
}, },
},
methods: {
publishBot() { publishBot() {
if (!this.$refs.newBotForm.validate()) { if (!this.$refs.newBotForm.validate()) {
return; return;
} }
this.dialog = false;
const title = encodeURIComponent(`Bot: ${this.newBot.name}`).replace( const title = encodeURIComponent(`Bot: ${this.newBot.name}`).replace(
/%2B/gi, /%2B/gi,
"+" "+"

View File

@ -36,6 +36,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newPlugin.name" v-model="newPlugin.name"
:rules="rules"
label="插件名称" label="插件名称"
required required
></v-text-field> ></v-text-field>
@ -43,6 +44,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newPlugin.desc" v-model="newPlugin.desc"
:rules="rules"
label="插件介绍" label="插件介绍"
required required
></v-text-field> ></v-text-field>
@ -50,6 +52,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newPlugin.link" v-model="newPlugin.link"
:rules="rules"
label="PyPI 项目名" label="PyPI 项目名"
required required
></v-text-field> ></v-text-field>
@ -57,6 +60,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newPlugin.id" v-model="newPlugin.id"
:rules="rules"
label="插件 import 包名" label="插件 import 包名"
required required
></v-text-field> ></v-text-field>
@ -64,6 +68,7 @@
<v-col cols="12"> <v-col cols="12">
<v-text-field <v-text-field
v-model="newPlugin.repo" v-model="newPlugin.repo"
:rules="rules"
label="仓库/主页链接" label="仓库/主页链接"
required required
></v-text-field> ></v-text-field>
@ -81,10 +86,7 @@
:disabled="!valid" :disabled="!valid"
color="blue darken-1" color="blue darken-1"
text text
@click=" @click="publishPlugin"
dialog = false;
publishPlugin();
"
> >
发布 发布
</v-btn> </v-btn>
@ -150,6 +152,7 @@ export default {
page: 1, page: 1,
dialog: false, dialog: false,
valid: false, valid: false,
rules: [(v) => !!v || "This field is required"],
newPlugin: { newPlugin: {
name: null, name: null,
desc: null, desc: null,
@ -176,10 +179,13 @@ export default {
displayPlugins() { displayPlugins() {
return this.filteredPlugins.slice((this.page - 1) * 10, this.page * 10); return this.filteredPlugins.slice((this.page - 1) * 10, this.page * 10);
}, },
},
methods: {
publishPlugin() { publishPlugin() {
if (!this.$refs.newPluginForm.validate()) { if (!this.$refs.newPluginForm.validate()) {
return; return;
} }
this.dialog = false;
const title = encodeURIComponent( const title = encodeURIComponent(
`Plugin: ${this.newPlugin.name}` `Plugin: ${this.newPlugin.name}`
).replace(/%2B/gi, "+"); ).replace(/%2B/gi, "+");