Skip to content

Commit 077ab57

Browse files
authored
Merge pull request #65 from icebob/custom_field
support custom fields
2 parents bccc910 + 2e94d52 commit 077ab57

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

dev/app.vue

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
import { users } from "./data";
4040
import { filters } from "./utils";
4141
42+
// Test custom field
43+
import FieldAwesome from "./fieldAwesome.vue";
44+
Vue.component("fieldAwesome", FieldAwesome);
45+
4246
import {each, isFunction, cloneDeep, merge} from 'lodash';
4347
4448
Vue.use(VueFormGenerator);

dev/fieldAwesome.vue

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template lang="jade">
2+
input.form-control(type="text", v-model="value", :maxlength="schema.max", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder")
3+
</template>
4+
5+
<script>
6+
import VueFormGenerator from "../src";
7+
8+
export default {
9+
mixins: [ VueFormGenerator.abstractField ]
10+
};
11+
12+
</script>
13+
14+
<style lang="sass" scoped>
15+
input {
16+
background-color: lighten(blue, 40%) !important;
17+
font-weight: bold;
18+
}
19+
</style>

dev/schema.js

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ module.exports = {
179179
label: "E-mail (email field)",
180180
model: "email",
181181
placeholder: "User's e-mail address"
182+
}, {
183+
type: "awesome",
184+
label: "Awesome (custom field)",
185+
model: "userName"
182186
}, {
183187
type: "googleAddress",
184188
label: "Location (googleAddress)",

dist/vue-form-generator.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
component: require("./formGenerator.vue"),
33
schema: require("./utils/schema.js"),
44
validators: require("./utils/validators.js"),
5+
abstractField: require("./fields/abstractField").default,
56

67
install(Vue) {
78
Vue.component("VueFormGenerator", module.exports.component);

test/unit/specs/index.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe("module", () => {
1010
expect(VueFormGenerator).to.have.property("component");
1111
expect(VueFormGenerator).to.have.property("schema");
1212
expect(VueFormGenerator).to.have.property("validators");
13+
expect(VueFormGenerator).to.have.property("abstractField");
1314
expect(VueFormGenerator.install).to.be.a("function");
1415

1516
});

0 commit comments

Comments
 (0)