Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
user: function(data){
console.log('DATA', data);
var me = this, i;
me.name = m.p(data.name||"");
me.email = m.p(data.email||"");
// Password is always empty first
me.password = m.p(data.password||"");
me.id = m.p(data._id||"");
me.roles = [];
rolesEnum.map(function(role, index){
// This will just be true/false - we need the string for saving...
me.roles.push(m.p( (data.roles && data.roles.indexOf(role.name) !== -1)? role.name: false ));
});
// Validate the model
me.isValid = validate.bind(this, {
name: {
isRequired: "You must enter a name"
},
password: {
isRequired: "You must enter a password"
},
email: {
user: function(data){
console.log('DATA', data);
var me = this, i;
me.name = m.p(data.name||"");
me.email = m.p(data.email||"");
// Password is always empty first
me.password = m.p(data.password||"");
me.id = m.p(data._id||"");
me.roles = [];
rolesEnum.map(function(role, index){
// This will just be true/false - we need the string for saving...
me.roles.push(m.p( (data.roles && data.roles.indexOf(role.name) !== -1)? role.name: false ));
});
// Validate the model
me.isValid = validate.bind(this, {
name: {
isRequired: "You must enter a name"
},
password: {
isRequired: "You must enter a password"
},
intro: function() {
this.text = m.p("Create apps in a snap!");
this.ani = m.p(0);
this.demoImgSrc = m.p("img/misodemo.gif");
}
},
todo: function(data){
data.done = data.done == "false"? false: data.done;
this.text = data.text;
this.done = m.p(data.done);
this._id = data._id;
}
},
user: function(data){
this.name = m.p(data.name||"");
this.email = m.p(data.email||"");
this.id = m.p(data._id||"");
// Validate the model
this.isValid = validate.bind(this, {
name: {
isRequired: "You must enter a name"
},
email: {
isRequired: "You must enter an email address",
isEmail: "Must be a valid email address"
}
});
return this;
}
},
intro: function() {
this.headerText = "<img src="/img/miso_logo_mfirst.png" class="miso-logo">";
this.textByline = m.p("CREATE APPS IN A SNAP");
this.scrollOffset = m.p();
}
},
user: function(data){
this.name = m.p(data.name||"");
this.email = m.p(data.email||"");
this.id = m.p(data._id||"");
// Validate the model
this.isValid = validate.bind(this, {
name: {
isRequired: "You must enter a name"
},
email: {
isRequired: "You must enter an email address",
isEmail: "Must be a valid email address"
}
});
return this;
}
var ctrl = this;
// View model
ctrl.vm = {
todoList: function(todos){
this.todos = m.p(todos);
},
// How many are left
left: function(){
var count = 0;
ctrl.model.todos().map(function(todo) {
count += todo.done() ? 0 : 1;
});
return count;
},
input: m.p("")
};
ctrl.addTodo = function(e){
var value = ctrl.vm.input();
if(value) {
var newTodo = new self.models.todo({
text: ctrl.vm.input(),
done: false
});
ctrl.model.todos.push(newTodo);
ctrl.vm.input("");
api.save({ type: 'todo.index.todo', model: newTodo } ).then(function(res){
newTodo._id = res.result;
});
}
e.preventDefault();
userList: function(users){
this.users = m.p(users);
}
};
user: function(data){
this.name = m.p(data.name||"");
this.email = m.p(data.email||"");
this.id = m.p(data._id||"");
// Validate the model
this.isValid = validate.bind(this, {
name: {
isRequired: "You must enter a name"
},
email: {
isRequired: "You must enter an email address",
isEmail: "Must be a valid email address"
}
});
return this;
}
},