Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Add room creation with password (resolves #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ukatama committed Sep 10, 2017
1 parent 208ba7a commit cc4d96d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 14 deletions.
10 changes: 10 additions & 0 deletions src/browser/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@

&-leave-to
transform translate(-100%, 0)

.neko-field
&-enter-active
&-leave-active
transition transform 0.4s ease-in-out, opacity 0.4s ease-in-out

&-enter
&-leave-to
transform translate(100%, 0)
opacity 0
55 changes: 41 additions & 14 deletions src/browser/vue/RoomCreateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
v-form(v-model="valid", @submit.prevent="submit")
v-text-field(
label="タイトル"
v-model="data.title"
:rules="[requiredRule]"
v-model="title"
:rules="[notEmpty]"
required
)
v-select(
Expand All @@ -19,58 +19,85 @@
item-text="gameType"
item-value="filename"
:items="diceBotDescs"
:rules="[requiredRule]"
v-model="data.dice"
:rules="[notEmpty]"
v-model="dice"
required
)
form(@submit.prevent="submit")
v-text-field(
label="パスワード"
placeholder="空欄で公開卓"
type="password"
v-model="password"
)
transition(name="neko-field")
v-text-field(
required
label="パスワード確認"
type="password"
:rules="[notEmpty, passwordConfirmRule]"
v-if="password"
v-model="passwordConfirm"
)
v-text-field(
label="キャラクター属性"
placeholder="例: HP,MP,SP"
v-model="data.characterAttributes"
v-model="characterAttributes"
)
v-card-actions
v-spacer
v-btn.primary(:disabled="!valid",@click="submit") 作成
v-btn.primary(:disabled="!canSubmit",@click="submit") 作成
v-btn(@click.native="open = false") キャンセル
</template>

<script>
import { mapActions } from 'vuex';
export default {
computed: {
canSubmit() {
return this.valid && (!this.password || this.password === this.passwordConfirm);
},
},
data() {
return {
diceBotDescs: [{ filename: 'DiceBot', gameType: 'DiceBot' }],
open: false,
valid: false,
data: {
title: null,
dice: null,
characterAttributes: null,
},
title: null,
dice: null,
characterAttributes: null,
password: null,
passwordConfirm: null,
};
},
methods: {
...mapActions([
'createRoom',
]),
requiredRule(v) {
notEmpty(v) {
return v ? true : '入力して下さい。';
},
passwordConfirmRule(v) {
if (!this.password) return true;
return this.password === v ? true : '確認パスワードが一致しません。';
},
submit() {
if (!this.valid) return;
if (!this.canSubmit) return;
const {
title,
dice,
characterAttributes,
} = this.data;
password,
} = this;
this.createRoom({
title,
dice,
characterAttributes: characterAttributes ? characterAttributes.split(',') : [],
password,
router: this.$router,
});
},
Expand Down

0 comments on commit cc4d96d

Please sign in to comment.