koel/resources/assets/js/components/main-wrapper/main-content/users.vue

204 lines
5.5 KiB
Vue
Raw Normal View History

2015-12-13 04:42:28 +00:00
<template>
2016-01-06 10:57:45 +00:00
<section id="usersWrapper">
2015-12-13 04:42:28 +00:00
<h1 class="heading">
2016-01-06 11:19:00 +00:00
<span>Users
2016-03-13 17:00:32 +00:00
<i class="fa fa-angle-down toggler"
v-show="isPhone && !showingControls"
2016-01-06 11:19:00 +00:00
@click="showingControls = true"></i>
2016-03-13 17:00:32 +00:00
<i class="fa fa-angle-up toggler"
v-show="isPhone && showingControls"
2016-01-06 11:19:00 +00:00
@click.prevent="showingControls = false"></i>
</span>
2015-12-13 04:42:28 +00:00
2016-01-06 11:19:00 +00:00
<div class="buttons" v-show="!isPhone || showingControls">
2016-03-20 13:42:33 +00:00
<button class="btn btn-green" @click="creating = !creating">
2015-12-13 04:42:28 +00:00
<i class="fa fa-plus"></i>
Add</button>
</div>
</h1>
<div class="main-scroll-wrap">
<div class="users">
2016-03-20 13:42:33 +00:00
<form class="user-create user-item" v-if="creating" @submit.prevent="store">
<div class="input-row">
<label>Name</label>
<input type="text" v-model="newUser.name" required v-koel-focus="creating">
</div>
<div class="input-row">
<label>Email</label>
<input type="email" v-model="newUser.email" required>
</div>
<div class="input-row">
<label>Password</label>
<input type="password" v-model="newUser.password" required>
2015-12-13 04:42:28 +00:00
</div>
2016-03-20 13:42:33 +00:00
<div class="input-row">
<label></label>
<button class="btn btn-green">Create</button>
<button class="btn btn-red" @click.prevent="creating = false">Cancel</button>
</div>
</form>
<user-item v-for="user in state.users" :user="user"></user-item>
2015-12-13 04:42:28 +00:00
2016-01-16 18:11:24 +00:00
<article class="user-item" v-for="n in 6"></article>
2015-12-13 04:42:28 +00:00
</div>
</div>
2016-01-06 10:57:45 +00:00
</section>
2015-12-13 04:42:28 +00:00
</template>
<script>
import _ from 'lodash';
2016-01-06 11:19:00 +00:00
import isMobile from 'ismobilejs';
2016-03-13 17:00:32 +00:00
2015-12-13 04:42:28 +00:00
import userStore from '../../../stores/user';
2016-03-20 13:42:33 +00:00
import userItem from '../../shared/user-item.vue';
2015-12-13 04:42:28 +00:00
export default {
2016-03-20 13:42:33 +00:00
components: { userItem },
2015-12-13 04:42:28 +00:00
data() {
return {
state: userStore.state,
2016-01-06 11:19:00 +00:00
isPhone: isMobile.phone,
showingControls: false,
2015-12-13 04:42:28 +00:00
creating: false,
2016-03-20 13:42:33 +00:00
newUser: {},
2015-12-13 04:42:28 +00:00
};
},
methods: {
/**
* Show the "Create User" form.
*/
create() {
this.$root.loadMainView('user-create');
},
/**
* Store the newly created user.
*/
store() {
userStore.store(this.newUser.name, this.newUser.email, this.newUser.password, () => {
this.newUser = _.clone(userStore.stub);
this.creating = false;
});
},
},
};
</script>
<style lang="sass">
2016-03-13 17:00:32 +00:00
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
2015-12-13 04:42:28 +00:00
#usersWrapper {
.users {
justify-content: space-between;
flex-wrap: wrap;
display: flex;
2016-03-20 13:42:33 +00:00
}
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
form {
padding: 8px 16px;
background-size: 30px 30px;
background-image: linear-gradient(
-45deg,
rgba(black, 0.3) 25%,
transparent 25%,
transparent 50%,
rgba(black, 0.3) 50%,
rgba(black, 0.3) 75%,
transparent 75%,
transparent
);
.input-row {
2015-12-13 04:42:28 +00:00
display: flex;
2016-03-20 13:42:33 +00:00
margin: 6px 0;
2015-12-13 04:42:28 +00:00
}
2016-03-20 13:42:33 +00:00
label {
flex: 0 0 128px;
margin-bottom: 0;
font-size: 100%;
2015-12-13 04:42:28 +00:00
}
2016-03-20 13:42:33 +00:00
input {
2015-12-13 04:42:28 +00:00
flex: 1;
}
2016-03-20 13:42:33 +00:00
}
button {
font-size: 12px;
padding: 6px 14px;
margin-right: 3px;
}
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
@media only screen and (max-width: 768px) {
.users {
flex-direction: column;
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
.buttons {
margin-top: 12px;
display: block;
2015-12-13 04:42:28 +00:00
}
}
}
2016-03-20 13:42:33 +00:00
}
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
.user-item {
width: 32%;
margin-bottom: 16px;
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
.info {
display: flex;
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
img {
flex: 0 0 128px;
2015-12-13 04:42:28 +00:00
}
2016-03-20 13:42:33 +00:00
.right {
flex: 1;
padding: 16px;
display: flex;
2015-12-13 04:42:28 +00:00
flex-direction: column;
2016-03-20 13:42:33 +00:00
justify-content: space-between;
background-color: rgba(255, 255, 255, .02);
}
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
h1 {
font-size: 140%;
margin-bottom: 5px;
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
.you {
font-size: 14px;
color: $colorHighlight;
margin-left: 8px;
2015-12-13 04:42:28 +00:00
}
}
2016-03-20 13:42:33 +00:00
.buttons {
display: none;
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
margin-top: 16px;
}
2015-12-13 04:42:28 +00:00
2016-03-20 13:42:33 +00:00
&:hover, html.touchevents & {
2015-12-13 04:42:28 +00:00
.buttons {
display: block;
}
}
}
2016-03-20 13:42:33 +00:00
html.with-extra-panel & {
width: 49%;
}
@media only screen and (max-width: 1024px) {
width: 100%;
}
2015-12-13 04:42:28 +00:00
}
</style>