Skip to content

Commit d8e5a8e

Browse files
committed
🆙 improve new fields
1 parent 4b5fc14 commit d8e5a8e

File tree

2 files changed

+24
-78
lines changed

2 files changed

+24
-78
lines changed

src/fields/fieldCleave.vue

+22-73
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template lang="jade">
2-
input.form-control(type="text")
2+
input.form-control(type="text", v-model="value", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder")
33
</template>
44

55
<script>
@@ -15,81 +15,30 @@ export default {
1515
};
1616
},
1717
18-
watch: {
19-
/*model: {
20-
get(){
21-
if (window.Cleave) {
22-
console.log("get model", this.model);
23-
}
24-
},
25-
set(value) {
26-
if (window.Cleave) {
27-
console.log("set model", this.model, value);
28-
29-
}
30-
}
31-
}*/
32-
},
33-
34-
methods: {
35-
/*formatValueToField(){
36-
console.log(" 1 formatValueToField",this.cleave);
37-
if (this.cleave) {
38-
39-
return this.cleave.getRawValue();
40-
}else{
41-
console.log("fail")
42-
// this.cleave.element.value = "";
43-
return "";
44-
}
45-
},*/
46-
/*formatValueToModel(newValue){
47-
console.log(" 2 formatValueToModel");
48-
this.cleave.setRawValue(newValue);
49-
return newValue;
50-
}*/
51-
// onCreditCardTypeChanged(type){
52-
// let onCreditCardTypeChanged = this.schema.onCreditCardTypeChanged;
53-
// if (typeof(onNewTag) == "function") {
54-
// onNewTag(newTag, id, this.options, this.value);
55-
// }
56-
// }
57-
/*onChange(value) {
58-
console.log(value);
59-
if (value.length === 1) {
60-
// Single value
61-
this.value = parseFloat(value[0]);
62-
} else {
63-
// Array (range)
64-
this.value = [parseFloat(value[0]), parseFloat(value[1])];
65-
}
66-
}*/
67-
},
68-
6918
ready() {
7019
if (window.Cleave) {
71-
this.cleave = new Cleave(this.$el, defaults(this.schema.cleaveOptions || {}, {
20+
this.cleave = new window.Cleave(this.$el, defaults(this.schema.cleaveOptions || {}, {
7221
// Credit Card
73-
creditCard: false,
74-
// onCreditCardTypeChanged: onCreditCardTypeChanged.bind(this),
75-
// Phone
76-
phone: false,
77-
phoneRegionCode: 'AU',
78-
// Date
79-
date: false,
80-
datePattern: ['d', 'm', 'Y'],
81-
// Numerals
82-
numeral: false,
83-
numeralThousandsGroupStyle: 'thousand',
84-
numeralDecimalScale: 2,
85-
numeralDecimalMark: '.',
86-
// General
87-
blocks: [],
88-
delimiter: ' ',
89-
prefix: null,
90-
numericOnly: false,
91-
uppercase: false,
92-
lowercase: false
22+
creditCard: false,
23+
// onCreditCardTypeChanged: onCreditCardTypeChanged.bind(this),
24+
// Phone
25+
phone: false,
26+
phoneRegionCode: 'AU',
27+
// Date
28+
date: false,
29+
datePattern: ['d', 'm', 'Y'],
30+
// Numerals
31+
numeral: false,
32+
numeralThousandsGroupStyle: 'thousand',
33+
numeralDecimalScale: 2,
34+
numeralDecimalMark: '.',
35+
// General
36+
blocks: [],
37+
delimiter: ' ',
38+
prefix: null,
39+
numericOnly: false,
40+
uppercase: false,
41+
lowercase: false
9342
}));
9443
} else {
9544
console.warn("Cleave is missing. Please download from https://github.com/nosir/cleave.js/ and load the script in the HTML head section!");

src/fields/fieldPikaday.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template lang="jade">
2-
input.form-control(type="text")
2+
input.form-control(type="text", v-model="value", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder")
33
</template>
44

55
<script>
@@ -39,16 +39,14 @@
3939
else
4040
value = m.toDate().valueOf();
4141
}
42-
console.log(this.value);
43-
// this.value = value;
4442
return value;
4543
}
4644
4745
},
4846
4947
ready() {
5048
if (window.Pikaday){
51-
this.picker = new Pikaday(defaults(this.schema.pikadayOptions || {}, {
49+
this.picker = new window.Pikaday(defaults(this.schema.pikadayOptions || {}, {
5250
field: this.$el, // bind the datepicker to a form field
5351
// trigger: , // use a different element to trigger opening the datepicker, see [trigger example][] (default to `field`)
5452
bound: true, // automatically show/hide the datepicker on `field` focus (default `true` if `field` is set)
@@ -86,7 +84,6 @@
8684
// onDraw: , // callback function for when the picker draws a new month
8785
}));
8886
}
89-
// this.slider.noUiSlider.on("change", this.onChange.bind(this));
9087
else{
9188
console.warn("Pikaday is missing. Please download from https://github.com/dbushell/Pikaday/ and load the script and CSS in the HTML head section!");
9289
}

0 commit comments

Comments
 (0)