Skip to content

Commit b2fc51d

Browse files
Minor cleanup
- Normalize validate naming - Normalize temp console.warn
1 parent f959585 commit b2fc51d

3 files changed

Lines changed: 18 additions & 20 deletions

File tree

src/mm-form/doc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
],
9898
"methods": [
9999
{
100-
"name":"validateFields",
100+
"name":"validate",
101101
"description":"Instructs the mm-form to sweep through the form fields and perform the validation provided in the configuration."
102102
},
103103

src/mm-form/mm-form.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@
122122
'changed' : '_handleChanged'
123123
},
124124

125+
// Temp warning message
126+
created: function() {
127+
console.warn('This component contains experimental features. The configuration and API are subject to change. Please use at your own risk.');
128+
},
129+
125130
attached: function() {
126131
if (this._isEmpty(this.config)) this.debounce('initConfig', this._initConfig);
127132
if (this._isEmpty(this.data)) this.debounce('initData', this._initData);
128-
129-
// Temp warning message
130-
console.warn('This component contains experimental features. The configuration and API are subject to change. Please use at your own risk.');
131133
},
132134

133135
_dataChanged: function(newVal, oldVal) {
@@ -175,7 +177,7 @@
175177
parentEleDOM: this._select('#'+attrs['parent-ele']) || Polymer.dom(field).parentNode,
176178
exclude: attrs.exclude || null
177179
};
178-
}.bind(this));
180+
}, this);
179181

180182
// Update config and mux the domConfig with the developer supplied
181183
// config - values from config override domConfig
@@ -312,17 +314,13 @@
312314
},
313315

314316
_diffData: function() {
315-
var diff = [];
316-
for (var key in this.data) {
317-
if (this.data[key] !== this._initialData[key]) {
318-
diff.push(key);
319-
}
320-
}
321-
return diff.length > 0;
317+
return Object.keys(this.data).filter(function(key) {
318+
return this.data[key] !== this._initialData[key];
319+
}.bind(this)).length > 0;
322320
},
323321

324322
// form validation
325-
validateFields: function() {
323+
validate: function() {
326324
this._invalidFields = [];
327325
this._validFields = [];
328326

@@ -354,7 +352,6 @@
354352
} else if (tagName === 'mm-repeater') {
355353
// special case for mm-repeater
356354
// mm-repeater will handle it's own validation
357-
// TODO: Make sure mm-repeater returns true or false
358355
valid = field.validate();
359356
} else if (validation && noValidate) {
360357
// clean up prior validations if they were there
@@ -435,7 +432,7 @@
435432
},
436433

437434
serializeForm: function() {
438-
this.validateFields();
435+
this.validate();
439436

440437
this.fire('serialize-form', {
441438
valid: !this._invalidFields.length > 0,

src/mm-repeater/mm-repeater.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
properties: {
1616
config: {
1717
type: Object,
18-
value: {}
18+
value: function() { return {}; }
1919
},
2020
data: {
2121
type: Array,
2222
notify: true,
2323
value: function() { return [{}]; },
2424
observer: '_handleDataChanged'
2525
},
26-
2726
template: {
2827
type: Object,
2928
value: null
3029
},
31-
3230
added: {
3331
type: Array,
3432
value: []
@@ -37,12 +35,10 @@
3735
type: Array,
3836
value: []
3937
},
40-
4138
_origData: {
4239
type: Array,
4340
value: []
4441
},
45-
4642
addRowLabel: {
4743
type: String,
4844
value: '+Add Item'
@@ -72,6 +68,11 @@
7268
'_handleDataPath(data.*)'
7369
],
7470

71+
// Temp warning message
72+
created: function() {
73+
console.warn('This component contains experimental features. The configuration and API are subject to change. Please use at your own risk.');
74+
},
75+
7576
_handleDataPath: function(e) {
7677
var path = e.path.split('.'),
7778
record = path[path.length-1];

0 commit comments

Comments
 (0)