allow use of custom form components, add textarea component, add checkbox input, use more absolute imports
This commit is contained in:
@@ -22,9 +22,9 @@
|
|||||||
"icon": "icon-contacts"
|
"icon": "icon-contacts"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "FormDemo",
|
"name": "Settings",
|
||||||
"to": "/formdemo",
|
"to": "/settings",
|
||||||
"icon": "icon-contacts"
|
"icon": "icon-cog"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"profile": [
|
"profile": [
|
||||||
@@ -65,7 +65,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Settings",
|
"name": "Settings",
|
||||||
"to": "/settings",
|
"to": "/settings",
|
||||||
"icon": "icon-cog",
|
|
||||||
"content": "<settings></settings>"
|
"content": "<settings></settings>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
36
src/app.less
36
src/app.less
@@ -89,7 +89,7 @@ a:hover {color:#901624;}
|
|||||||
--------------------------------------------------------------*/
|
--------------------------------------------------------------*/
|
||||||
.input_holder {margin-bottom:20px; display:block;}
|
.input_holder {margin-bottom:20px; display:block;}
|
||||||
.input_header {margin-bottom:10px;}
|
.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 {
|
input, textarea, select {
|
||||||
font-family: @font_family;
|
font-family: @font_family;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -98,20 +98,41 @@ input, textarea, select {
|
|||||||
padding: 0px 10px;
|
padding: 0px 10px;
|
||||||
color: @text_color;
|
color: @text_color;
|
||||||
background: white;
|
background: white;
|
||||||
border: solid 1px #CCC;
|
border: solid 1px #CCC;
|
||||||
outline: none;
|
outline: none;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
transition: all 0.3s;
|
transition: background 0.3s, color 0.3s, border 0.3s;
|
||||||
}
|
}
|
||||||
textarea {padding:10px; height:auto;}
|
textarea {padding:10px; height:auto;}
|
||||||
input:focus, textarea:focus, select:focus {background:#FFF; border-color: @cms_brand_primary;}
|
input:focus, textarea:focus, select:focus {background:#FFF; border-color: @cms_brand_primary;}
|
||||||
label {font-weight:600; color: @text_color;}
|
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"] {
|
input[type="checkbox"] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -10px;
|
top: -10px;
|
||||||
left: -10px;
|
left: -10px;
|
||||||
line-height:50px;
|
line-height: 50px;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -119,7 +140,6 @@ input[type="checkbox"] {
|
|||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
.checkbox_holder {position:absolute; top:0px; bottom:0px;}
|
|
||||||
.check_checkbox {
|
.check_checkbox {
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
display: block;
|
display: block;
|
||||||
@@ -167,8 +187,6 @@ button{
|
|||||||
padding: 0px 30px;
|
padding: 0px 30px;
|
||||||
border-radius: 20px;
|
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
|
# CMS CONTENT FORM
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="submit()">
|
<form @submit.prevent="submit()">
|
||||||
<div v-for="(item, key) in elements" :key="key">
|
<div v-for="(item, key) in elements" :key="key">
|
||||||
<my-input
|
<component
|
||||||
:description="item.description"
|
:is="item.element"
|
||||||
:label="item.label"
|
|
||||||
:name="key"
|
:name="key"
|
||||||
:placeholder="item.placeholder"
|
:label="item.label"
|
||||||
:type="item.type"
|
:description="item.description"
|
||||||
|
:props="item.props"
|
||||||
v-model="formData[key]"
|
v-model="formData[key]"
|
||||||
@validate="validateData(key)"
|
@validate="validateData(key)"
|
||||||
:invalid="formErrors[key]"
|
:invalid="formErrors[key]"
|
||||||
:validatorMessage="formErrors[key] ? formErrors[key].message : ''"
|
:validatorMessage="formErrors[key] ? formErrors[key].message : ''"
|
||||||
>
|
>
|
||||||
</my-input>
|
</component>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="button" v-for="(b, i) in buttons" :key="i" @click.prevent="buttonClick(b.type)">{{ b.label }}</button>
|
<button class="button" v-for="(b, i) in buttons" :key="i" @click.prevent="buttonClick(b.type)">{{ b.label }}</button>
|
||||||
@@ -21,13 +21,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MyInput from './my-input.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MyForm",
|
name: "MyForm",
|
||||||
components: {
|
components: {},
|
||||||
MyInput
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
elements: {
|
elements: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|||||||
@@ -5,44 +5,54 @@
|
|||||||
<div class="input_description" v-if="description">{{ description }}</div>
|
<div class="input_description" v-if="description">{{ description }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="text" v-if="type == 'text'"
|
<!-- -->
|
||||||
|
<input type="text" v-if="props && props.type == 'text'"
|
||||||
v-model="currentValue"
|
v-model="currentValue"
|
||||||
:name="name"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
@blur="validate()"
|
|
||||||
@change="() => $emit('change', currentValue)"
|
|
||||||
:class="{invalid}"
|
: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"
|
v-model="currentValue"
|
||||||
:name="name"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
@blur="validate()"
|
|
||||||
@change="() => $emit('change', currentValue)"
|
|
||||||
:class="{invalid}"
|
: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 v-if="invalid && validatorMessage">{{ validatorMessage }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.invalid {
|
.invalid {
|
||||||
background-color: #fcc;
|
background-color: #fcc;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "MyInput",
|
name: "BasicInput",
|
||||||
props: [
|
props: [
|
||||||
'description',
|
'description',
|
||||||
'label',
|
'label',
|
||||||
'name',
|
'name',
|
||||||
'placeholder',
|
'props',
|
||||||
'type',
|
|
||||||
'value',
|
'value',
|
||||||
'invalid',
|
'invalid',
|
||||||
'validatorMessage'
|
'validatorMessage'
|
||||||
@@ -55,6 +65,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
validate() {
|
validate() {
|
||||||
this.$emit('validate', this.currentValue);
|
this.$emit('validate', this.currentValue);
|
||||||
|
},
|
||||||
|
handleChange() {
|
||||||
|
this.$emit('change', this.currentValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="Scroll-Table">
|
<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"
|
<my-table :actions="actions" :columns="columns" :rows="rows"
|
||||||
:currentOrderBy="currentOrderBy"
|
:currentOrderBy="currentOrderBy"
|
||||||
:currentOrderDesc="currentOrderDesc"
|
:currentOrderDesc="currentOrderDesc"
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MyTable from './my-table.vue';
|
import MyTable from 'components/my-table';
|
||||||
import MyInput from './my-input.vue';
|
import MyInput from 'components/my-input';
|
||||||
|
|
||||||
import { ObserveVisibility } from 'vue-observe-visibility/dist/vue-observe-visibility';
|
import { ObserveVisibility } from 'vue-observe-visibility/dist/vue-observe-visibility';
|
||||||
|
|
||||||
|
|||||||
61
src/components/textarea-input.vue
Normal file
61
src/components/textarea-input.vue
Normal 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>
|
||||||
@@ -162,6 +162,7 @@ export default {
|
|||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
color: white;
|
color: white;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
@font_family: "Open Sans", sans-serif;
|
@font_family: "Open Sans", sans-serif;
|
||||||
@text_color: #333;
|
@text_color: #333;
|
||||||
@font_size: 14px;
|
@font_size: 15px;
|
||||||
|
|
||||||
@line_height_base: 1.4;
|
@line_height_base: 1.4;
|
||||||
@line_height_heading: 1.2;
|
@line_height_heading: 1.2;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="Dashboard">
|
<div class="Dashboard">
|
||||||
<h2>Dashboard</h2>
|
<h1>Dashboard</h1>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MyForm from "components/my-form";
|
import MyForm from "components/my-form";
|
||||||
|
import MyInput from "components/my-input";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "LoginForm",
|
name: "LoginForm",
|
||||||
components: {
|
components: {
|
||||||
MyForm
|
MyForm,
|
||||||
|
MyInput
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -30,18 +32,24 @@ export default {
|
|||||||
password: "",
|
password: "",
|
||||||
elements: {
|
elements: {
|
||||||
username: {
|
username: {
|
||||||
placeholder: "Benutzername",
|
element: MyInput,
|
||||||
icon: "icon-user",
|
icon: "icon-user",
|
||||||
type: "text",
|
|
||||||
required: true,
|
required: true,
|
||||||
requiredMessage: "Der Benutzername wird benötigt!"
|
requiredMessage: "Der Benutzername wird benötigt!",
|
||||||
|
props: {
|
||||||
|
type: "text",
|
||||||
|
placeholder: "Benutzername"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
placeholder: "Passwort",
|
element: MyInput,
|
||||||
icon: "icon-key",
|
icon: "icon-key",
|
||||||
type: "password",
|
|
||||||
required: true,
|
required: true,
|
||||||
requiredMessage: "Das Passwort wird benötigt!"
|
requiredMessage: "Das Passwort wird benötigt!",
|
||||||
|
props: {
|
||||||
|
type: "password",
|
||||||
|
placeholder: "Passwort"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buttons: [{
|
buttons: [{
|
||||||
@@ -115,7 +123,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.logo{
|
.logo{
|
||||||
.clearfix();
|
|
||||||
line-height:0; margin-bottom:15px; text-align:center;
|
line-height:0; margin-bottom:15px; text-align:center;
|
||||||
img {width:100%; max-width:72px;}
|
img {width:100%; max-width:72px;}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,11 +106,15 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MyForm from "components/my-form";
|
import MyForm from "components/my-form";
|
||||||
|
import MyInput from "components/my-input";
|
||||||
|
import TextareaInput from "components/textarea-input";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "FormDemo",
|
name: "FormDemo",
|
||||||
components: {
|
components: {
|
||||||
MyForm
|
MyForm,
|
||||||
|
MyInput,
|
||||||
|
TextareaInput
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -119,18 +123,39 @@ export default {
|
|||||||
elements: {
|
elements: {
|
||||||
title: {
|
title: {
|
||||||
label: "Titel",
|
label: "Titel",
|
||||||
placeholder: "Titel hier eintragen",
|
required: true,
|
||||||
icon: "icon-user",
|
element: MyInput,
|
||||||
type: "text",
|
props: {
|
||||||
required: true
|
type: "text",
|
||||||
|
placeholder: "Titel hier eintragen"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
permalink: {
|
permalink: {
|
||||||
label: "Permalink",
|
label: "Permalink",
|
||||||
placeholder: "Permalink",
|
|
||||||
description: "Hier steht ein Beschreibungstext für etwas begriffsstutzige Menschen, die eine Beschreibung zum Befüllen des Feldes brauchen.",
|
description: "Hier steht ein Beschreibungstext für etwas begriffsstutzige Menschen, die eine Beschreibung zum Befüllen des Feldes brauchen.",
|
||||||
icon: "icon-key",
|
required: true,
|
||||||
type: "password",
|
element: MyInput,
|
||||||
required: true
|
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: [{
|
buttons: [{
|
||||||
@@ -141,7 +166,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit(formData) {
|
submit(formData) {
|
||||||
console.log("submit", formData);
|
console.log("submit", JSON.stringify(formData));
|
||||||
// this.$store.dispatch("login", formData)
|
// this.$store.dispatch("login", formData)
|
||||||
// .then(user => {
|
// .then(user => {
|
||||||
// console.log("---- user login --------");
|
// console.log("---- user login --------");
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="Domainlist">
|
<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>
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ScrollTable from '../../components/scroll-table.vue';
|
import ScrollTable from 'components/scroll-table.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Domainlist",
|
name: "Domainlist",
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="Userlist">
|
<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>
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ScrollTable from '../../components/scroll-table.vue';
|
import ScrollTable from 'components/scroll-table.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Userlist",
|
name: "Userlist",
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ export default {
|
|||||||
Logout,
|
Logout,
|
||||||
Userlist,
|
Userlist,
|
||||||
Domainlist,
|
Domainlist,
|
||||||
Settings,
|
Settings
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user