Created
April 12, 2013 14:13
-
-
Save fritz-gerneth/5372305 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (Template) { | |
"use strict"; | |
Template.setProjectsCursor = function (cursor) { | |
Template.projects = function () { | |
return cursor; | |
}; | |
}; | |
Template.createProjectCallback = undefined; | |
Template.events({ | |
'click .btn': function (event) { | |
var el = $("#account-newproject-name"); | |
if (el.val() !== "") { | |
if (Template.createProjectCallback) | |
Template.createProjectCallback(el.val()); | |
else | |
console.log('No create callback registered'); | |
} else { | |
console.log('empty!'); | |
} | |
} | |
}); | |
}(Template['projects.account.list'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (Controller, Template, parent) { | |
"use strict"; | |
Controller.Project = function (view) { | |
parent.call(this, {module: 'account', 'action': 'projects'}); | |
this.canDispatch = function (match) { | |
if (null === Meteor.user()) { | |
Meteor.Location.setPath('/authorization/login'); | |
} | |
return this.matchParams(match); | |
}; | |
this.dispatch = function (match) { | |
Meteor.subscribe('projects.participating'); | |
Template['projects.account.list'].setProjectsCursor(InnoAccel.Project.Collection.Projects.find()); | |
Template['projects.account.list'].createProjectCallback = this.createProject; | |
view.set( | |
Template['account.layout'], | |
Template['projects.account.list'] | |
); | |
}; | |
this.createProject = function (name) { | |
InnoAccel.Project.Collection.Projects.insert({ | |
name: name, | |
participants: [{ | |
id: Meteor.userId(), | |
role: "owner" | |
}] | |
}); | |
}; | |
}; | |
function SurrogateConstructor() {} | |
SurrogateConstructor.prototype = parent.prototype; | |
Controller.Project.prototype = new SurrogateConstructor(); | |
Controller.Project.prototype.constructor = Controller.Project; | |
}(InnoAccel.Account.Controller, Template, Controller.BasicController)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment