wejsv2old-plugin-cdp-profile
Version:
We.js plugin wejsv2old-plugin-cdp-profile
58 lines (53 loc) • 1.7 kB
JavaScript
App.StudiesWorkMixin = Ember.Mixin.create({
checkCourseType: function (){
if (Ember.isNone(this.get('type'))) return this.set('typeErr', false);
if (Ember.isEmpty(this.get('type'))) {
return this.setProperties({
typeErr: true,
})
} else {
return this.set('typeErr', false);
}
}.observes('type'),
checkCourseName: function (){
if (Ember.isNone(this.get('name'))) return this.set('nameErr', false);
if (Ember.isEmpty(this.get('name'))) {
return this.setProperties({
nameErr: true,
})
} else {
return this.set('nameErr', false);
}
}.observes('name'),
checkCourseSchool: function (){
if (Ember.isNone(this.get('school'))) return this.set('schoolErr', false);
if (Ember.isEmpty(this.get('school'))) {
return this.setProperties({
schoolErr: true,
})
} else {
return this.set('schoolErr', false);
}
}.observes('school'),
checkCourseYear: function (){
if (Ember.isNone(this.get('endyear'))) return this.set('endyearErr', false);
var userYear = this.get('birthday').getFullYear();
var ano = /^[12][0-9]{3}$/;
if (!ano.test(this.get('endyear'))) {
return this.setProperties({
endyearErr: true,
})
} else if (this.get('endyear') <= userYear){
return this.set('endyearErr', true);
} else {
return this.set('endyearErr', false);
}
}.observes('endyear'),
invalidCourse: function (){
var bool = Boolean( Ember.isEmpty(this.get('type')) ||
Ember.isEmpty(this.get('name')) ||
Ember.isEmpty(this.get('school')) ||
this.get('endyearErr') || Ember.isEmpty(this.get('endyear')) )
return bool;
}.property('type','name','school', 'endyearErr')
});