Browse files

Added feed example

And fixed some bugs
  • Loading branch information...
1 parent 9331ef3 commit b8a552ea868726e2bd4a8d5da61f17c30c9c270a @ewoudj committed Sep 18, 2011
Showing with 72 additions and 3 deletions.
  1. +5 −1 app.js
  2. +63 −0 examples/models/feed.js
  3. +1 −1 public/controls/application.js
  4. +1 −0 public/controls/topbar.js
  5. +2 −1 public/data/model.js
View
6 app.js
@@ -1,3 +1,7 @@
// Example server
-var server = require('./private/server/http').createServer(3001, null);
+var server = require('./private/server/http').createServer(3001, {
+ models :[
+ "./examples/models/feed.js"
+ ]
+ });
View
63 examples/models/feed.js
@@ -0,0 +1,63 @@
+var model = require('./../..').model.model;
+
+/*
+ * The feed model describes all aspects a feed object
+ * other runtime components can us this information to
+ * provide services.
+ * Please note: The model is not a 'Class' but an instance of type model
+ */
+var feedModel = new model({
+ name: 'feed',
+ friendlyName: 'feed',
+ submitTitle: 'Add',
+ titleField: 'title',
+ navigationTitle: 'Feeds',
+ navigatable: true,
+ canUserNavigate: function(){return true;},
+ permissions: {
+ createRoles: ['*'], // Friends can be created by authenticated users
+ readRoles: ['?'], // Friends can be read by all users, also unauthenticated users
+ updateRoles: ['_owner'], // Friend objects can only be modified by the original creator
+ deleteRoles: ['_owner'] // Creators can delete their own feeds
+ },
+ fields:{
+ title:{
+ type: 'string',
+ view: {
+ title: 'Title',
+ required: true
+ }
+ },
+ description:{
+ type: 'string',
+ view: {
+ title: 'Description',
+ type: 'memo',
+ required: true,
+ special: {
+ view: {
+ type: 'text'
+ },
+ summary: {
+ type: 'text',
+ role: 'summary'
+ }
+ }
+ }
+ },
+ url:{
+ type: 'string',
+ view: {
+ title: 'URL',
+ required: false
+ }
+ }
+ },
+ set: function(options, callback){
+ model.prototype.set.call(this, options, callback);
+ }
+});
+
+exports = module.exports = {
+ model : feedModel
+};
View
2 public/controls/application.js
@@ -86,7 +86,7 @@ var application = function(config, session, clientData){
var currentModel = null;
for(var s in registry){
var registeredModel = registry[s];
- if(!currentModel || (config.query && config.query.model === registeredModel.name)){
+ if(!currentModel || (config.model && config.model === registeredModel.name)){
currentModel = registeredModel;
}
if(registeredModel.navigatable && registeredModel.canUserNavigate(session.user)){
View
1 public/controls/topbar.js
@@ -59,6 +59,7 @@ var topbar = function(config){
attributes:{
cls: 'button'
},
+ model: this.model,
events: {
onclick: function(ctl, evt){
window.location.href = rest.toUrl({
View
3 public/data/model.js
@@ -53,7 +53,8 @@ model.prototype.getViewConfig = function(instance, mode, field, session){
result.controlType = formRegistry[mode][viewType].name;
}
else {
- debugger;
+ console.log('mode: ' + mode);
+ console.log('viewType: ' + viewType);
throw 'Error: requested form mode / type combination is not registered';
}
return result;

0 comments on commit b8a552e

Please sign in to comment.