allow use of custom form components, add textarea component, add checkbox input, use more absolute imports

This commit is contained in:
2017-09-06 17:14:04 +02:00
parent 9eda1b1260
commit 8aa903d8e4
14 changed files with 189 additions and 69 deletions

View File

@@ -89,7 +89,7 @@ a:hover {color:#901624;}
--------------------------------------------------------------*/
.input_holder {margin-bottom:20px; display:block;}
.input_header {margin-bottom:10px;}
.input_description {font-size:13px; color: @text_color;}
.input_description {font-size:13px; color: lighten(@text_color, 20%);}
input, textarea, select {
font-family: @font_family;
width: 100%;
@@ -98,20 +98,41 @@ input, textarea, select {
padding: 0px 10px;
color: @text_color;
background: white;
border: solid 1px #CCC;
outline: none;
font-size: 14px;
transition: all 0.3s;
border: solid 1px #CCC;
outline: none;
font-size: 14px;
transition: background 0.3s, color 0.3s, border 0.3s;
}
textarea {padding:10px; height:auto;}
input:focus, textarea:focus, select:focus {background:#FFF; border-color: @cms_brand_primary;}
label {font-weight:600; color: @text_color;}
.checkbox_holder {
position: relative;
height: 100%;
min-height: 18px;
&:hover .check_checkbox {
border: 1px solid @cms_brand_primary;
}
label {
display: block;
position: absolute;
top: 50%;
margin-top: -9px;
width: 18px;
height: 18px;
cursor: pointer;
z-index: 10;
}
}
input[type="checkbox"] {
position: absolute;
top: -10px;
left: -10px;
line-height:50px;
line-height: 50px;
visibility: hidden;
display: inline-block;
margin: 0;
@@ -119,7 +140,6 @@ input[type="checkbox"] {
width: auto;
height: auto;
}
.checkbox_holder {position:absolute; top:0px; bottom:0px;}
.check_checkbox {
background: #FFF;
display: block;
@@ -167,8 +187,6 @@ button{
padding: 0px 30px;
border-radius: 20px;
}
.cell_checkbox label {width:18px; height:18px; display:block; cursor:pointer; z-index:10; position: absolute; top:50%; margin-top:-9px;}
.checkbox_holder:hover .check_checkbox {border: 1px solid @cms_brand_primary;}
/*--------------------------------------------------------------
# CMS CONTENT FORM

View File

@@ -1,18 +1,18 @@
<template>
<form @submit.prevent="submit()">
<div v-for="(item, key) in elements" :key="key">
<my-input
:description="item.description"
:label="item.label"
<component
:is="item.element"
:name="key"
:placeholder="item.placeholder"
:type="item.type"
:label="item.label"
:description="item.description"
:props="item.props"
v-model="formData[key]"
@validate="validateData(key)"
:invalid="formErrors[key]"
:validatorMessage="formErrors[key] ? formErrors[key].message : ''"
>
</my-input>
</component>
</div>
<div>
<button class="button" v-for="(b, i) in buttons" :key="i" @click.prevent="buttonClick(b.type)">{{ b.label }}</button>
@@ -21,13 +21,9 @@
</template>
<script>
import MyInput from './my-input.vue';
export default {
name: "MyForm",
components: {
MyInput
},
components: {},
props: {
elements: {
type: Object,

View File

@@ -5,44 +5,54 @@
<div class="input_description" v-if="description">{{ description }}</div>
</div>
<input type="text" v-if="type == 'text'"
<!-- -->
<input type="text" v-if="props && props.type == 'text'"
v-model="currentValue"
:name="name"
:placeholder="placeholder"
@blur="validate()"
@change="() => $emit('change', currentValue)"
:class="{invalid}"
:id="name"
:name="name"
:placeholder="props.placeholder"
@blur="validate"
@change="handleChange"
>
<input type="password" v-else-if="type == 'password'"
<input type="password" v-else-if="props && props.type == 'password'"
v-model="currentValue"
:name="name"
:placeholder="placeholder"
@blur="validate()"
@change="() => $emit('change', currentValue)"
:class="{invalid}"
:id="name"
:name="name"
:placeholder="props.placeholder"
@blur="validate"
@change="handleChange"
>
<div class="checkbox_holder" v-else-if="props && props.type == 'checkbox'">
<label :for="name"></label>
<input type="checkbox"
v-model="currentValue"
:id="name"
:name="name"
@change="handleChange"
>
<div class="check_checkbox"></div>
</div>
<div v-if="invalid && validatorMessage">{{ validatorMessage }}</div>
</div>
</template>
<style scoped>
.invalid {
background-color: #fcc;
}
</style>
<script>
export default {
name: "MyInput",
name: "BasicInput",
props: [
'description',
'label',
'name',
'placeholder',
'type',
'props',
'value',
'invalid',
'validatorMessage'
@@ -55,6 +65,9 @@ export default {
methods: {
validate() {
this.$emit('validate', this.currentValue);
},
handleChange() {
this.$emit('change', this.currentValue);
}
},
watch: {

View File

@@ -1,6 +1,6 @@
<template>
<div class="Scroll-Table">
<my-input placeholder="Suche" type="text" @change="searchChanged" v-model="currentSearch"></my-input>
<my-input :props="{type: 'text', placeholder: 'Suche'}" @change="searchChanged" v-model="currentSearch"></my-input>
<my-table :actions="actions" :columns="columns" :rows="rows"
:currentOrderBy="currentOrderBy"
:currentOrderDesc="currentOrderDesc"
@@ -14,8 +14,8 @@
</template>
<script>
import MyTable from './my-table.vue';
import MyInput from './my-input.vue';
import MyTable from 'components/my-table';
import MyInput from 'components/my-input';
import { ObserveVisibility } from 'vue-observe-visibility/dist/vue-observe-visibility';

View File

@@ -0,0 +1,61 @@
<template>
<div class="input_holder">
<div class="input_header" v-if="label || description">
<label :for="name" v-if="label">{{ label }}</label>
<div class="input_description" v-if="description">{{ description }}</div>
</div>
<textarea v-model="currentValue"
:id="name"
:name="name"
:class="{invalid}"
:placeholder="props ? props.placeholder : ''"
@blur="validate"
@change="handleChange"
>
</textarea>
<div v-if="invalid && validatorMessage">{{ validatorMessage }}</div>
</div>
</template>
<style scoped>
.invalid {
background-color: #fcc;
}
</style>
<script>
export default {
name: "TextareaInput",
props: [
'description',
'label',
'name',
'props',
'value',
'invalid',
'validatorMessage'
],
data() {
return {
currentValue: this.value
}
},
methods: {
validate() {
this.$emit('validate', this.currentValue);
},
handleChange() {
this.$emit('change', this.currentValue);
}
},
watch: {
currentValue(val) {
this.$emit('input', val);
}
}
}
</script>

View File

@@ -162,6 +162,7 @@ export default {
padding: 4px 10px;
font-size: 0;
color: white;
user-select: none;
&:hover {
cursor: pointer;

View File

@@ -5,7 +5,7 @@
@font_family: "Open Sans", sans-serif;
@text_color: #333;
@font_size: 14px;
@font_size: 15px;
@line_height_base: 1.4;
@line_height_heading: 1.2;

View File

@@ -1,6 +1,6 @@
<template>
<div class="Dashboard">
<h2>Dashboard</h2>
<h1>Dashboard</h1>
</div>
</template>

View File

@@ -18,11 +18,13 @@
<script>
import MyForm from "components/my-form";
import MyInput from "components/my-input";
export default {
name: "LoginForm",
components: {
MyForm
MyForm,
MyInput
},
data() {
return {
@@ -30,18 +32,24 @@ export default {
password: "",
elements: {
username: {
placeholder: "Benutzername",
element: MyInput,
icon: "icon-user",
type: "text",
required: true,
requiredMessage: "Der Benutzername wird benötigt!"
requiredMessage: "Der Benutzername wird benötigt!",
props: {
type: "text",
placeholder: "Benutzername"
}
},
password: {
placeholder: "Passwort",
element: MyInput,
icon: "icon-key",
type: "password",
required: true,
requiredMessage: "Das Passwort wird benötigt!"
requiredMessage: "Das Passwort wird benötigt!",
props: {
type: "password",
placeholder: "Passwort"
}
}
},
buttons: [{
@@ -115,7 +123,6 @@ export default {
}
.logo{
.clearfix();
line-height:0; margin-bottom:15px; text-align:center;
img {width:100%; max-width:72px;}
}

View File

@@ -106,11 +106,15 @@
<script>
import MyForm from "components/my-form";
import MyInput from "components/my-input";
import TextareaInput from "components/textarea-input";
export default {
name: "FormDemo",
components: {
MyForm
MyForm,
MyInput,
TextareaInput
},
data() {
return {
@@ -119,18 +123,39 @@ export default {
elements: {
title: {
label: "Titel",
placeholder: "Titel hier eintragen",
icon: "icon-user",
type: "text",
required: true
required: true,
element: MyInput,
props: {
type: "text",
placeholder: "Titel hier eintragen"
}
},
permalink: {
label: "Permalink",
placeholder: "Permalink",
description: "Hier steht ein Beschreibungstext für etwas begriffsstutzige Menschen, die eine Beschreibung zum Befüllen des Feldes brauchen.",
icon: "icon-key",
type: "password",
required: true
required: true,
element: MyInput,
props: {
type: "text",
placeholder: "Permalink"
}
},
content: {
label: "Inhalt",
description: "Hier steht ein Beschreibungstext für etwas begriffsstutzige Menschen, die eine Beschreibung zum Befüllen des Feldes brauchen.",
required: true,
element: TextareaInput,
props: {
placeholder: "Inhalt"
}
},
public: {
label: "Is Public",
required: true,
element: MyInput,
props: {
type: "checkbox"
}
}
},
buttons: [{
@@ -141,7 +166,7 @@ export default {
},
methods: {
submit(formData) {
console.log("submit", formData);
console.log("submit", JSON.stringify(formData));
// this.$store.dispatch("login", formData)
// .then(user => {
// console.log("---- user login --------");

View File

@@ -1,12 +1,12 @@
<template>
<div class="Domainlist">
<h2>Domainlist</h2>
<h1>Domainlist</h1>
<scroll-table :actions="actions" :columns="columns" :new-rows="newRows" :has-more="hasMore" :loading="loading" :handler="more" orderBy="Name" :orderDesc="false" :limit="50"></scroll-table>
</div>
</template>
<script>
import ScrollTable from '../../components/scroll-table.vue';
import ScrollTable from 'components/scroll-table.vue';
export default {
name: "Domainlist",

View File

@@ -1,12 +1,12 @@
<template>
<div class="Userlist">
<h2>Userlist</h2>
<h1>Userlist</h1>
<scroll-table :actions="actions" :columns="columns" :new-rows="newRows" :has-more="hasMore" :loading="loading" :handler="more" orderBy="username" :orderDesc="false" :limit="50"></scroll-table>
</div>
</template>
<script>
import ScrollTable from '../../components/scroll-table.vue';
import ScrollTable from 'components/scroll-table.vue';
export default {
name: "Userlist",

View File

@@ -11,5 +11,5 @@ export default {
Logout,
Userlist,
Domainlist,
Settings,
}
Settings
}