Skip to content

Commit 4e7d5ba

Browse files
committed
Add input mask field
1 parent 16581fb commit 4e7d5ba

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

dev/data.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ module.exports = {
2626
user.bio = faker.lorem.paragraph();
2727
let dob = faker.date.past(40, "1998-01-01");
2828
user.dob = dob.valueOf();
29+
user.time = moment().format("hh:mm:ss");
2930
user.age = moment().year() - moment(dob).year();
3031
user.rank = faker.random.number({
3132
min: 1,
3233
max: 10
3334
});
3435
user.role = faker.helpers.randomize(roles).id;
35-
36+
//user.mobile = faker.phone.phoneNumber();
3637

3738
user.skills = [];
3839
user.skills.push(faker.helpers.randomize(skills));

dev/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/7.0.2/bootstrap-slider.min.js"></script>
1919
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
2020
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js"></script>
21+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js"></script>
2122
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.min.js"></script>
2223
</head>
2324
<body>

dev/schema.js

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ module.exports = {
113113
help: "You can use any <b>formatted</b> texts. Or place a <a target='_blank' href='https://github.com/icebob/vue-form-generator'>link</a> to another site."
114114
//validator: validators.regexp
115115
},
116+
{
117+
type: "masked",
118+
label: "Mobile",
119+
model: "mobile",
120+
mask: "(99) 999-9999"
121+
},
116122
{
117123
type: "spectrum",
118124
label: "Color",

src/fields/fieldDateTime.vue

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
ready() {
4848
if ($.fn.datetimepicker)
4949
$(this.$el).datetimepicker(this.schema.dateTimePickerOptions);
50+
else
51+
console.warn("Bootstrap datetimepicker library is missing. Please download from https://eonasdan.github.io/bootstrap-datetimepicker/ and load the script and CSS in the HTML head section!");
52+
5053
}
5154
}
5255
</script>

src/fields/fieldMasked.vue

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template lang="jade">
2+
input.form-control(type="text", v-model="value", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder")
3+
</template>
4+
5+
<script>
6+
import abstractField from './abstractField';
7+
8+
export default {
9+
mixins: [ abstractField ],
10+
11+
ready() {
12+
if ($.fn.mask)
13+
$(this.$el).mask("destroy").mask(this.schema.mask, this.schema.maskOptions);
14+
else
15+
console.warn("JQuery MaskedInput library is missing. Please download from https://github.com/digitalBush/jquery.maskedinput and load the script in the HTML head section!");
16+
}
17+
}
18+
</script>
19+
20+
<style lang="sass" scoped>
21+
input {
22+
width: 100%;
23+
}
24+
</style>

src/fields/fieldSelectEx.vue

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
ready() {
4747
if ($.fn.selectpicker)
4848
$(this.$el).selectpicker("destroy").selectpicker(this.schema.selectOptions);
49+
else
50+
console.warn("Bootstrap-select library is missing. Please download from https://silviomoreto.github.io/bootstrap-select/ and load the script and CSS in the HTML head section!");
51+
4952
}
5053
}
5154
</script>

src/fields/fieldSpectrum.vue

+3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
3030
}
3131
}));
32+
else
33+
console.warn("Spectrum color library is missing. Please download from http://bgrins.github.io/spectrum/ and load the script and CSS in the HTML head section!");
3234
}
35+
3336
}
3437
</script>
3538

0 commit comments

Comments
 (0)