Permalink
Browse files

Add popovers to allow elements to be edited and deleted. Implement de…

…letion.
  • Loading branch information...
1 parent 6893c76 commit 4cdf1a5c0c9660d70485b2ffebc581b16bc5fe71 Karthik Viswanathan committed Jul 12, 2012
Showing with 848 additions and 104 deletions.
  1. +1 −0 .jshintignore
  2. +2 −2 lib/elements.js
  3. +2 −2 lib/scaffold.js
  4. +14 −10 lib/utils.js
  5. +5 −0 public/javascripts/.jshintrc
  6. +442 −0 public/javascripts/bootstrap.js
  7. +18 −7 public/javascripts/bootstrap.min.js
  8. +2 −2 public/javascripts/example.js
  9. +2 −2 public/javascripts/main.js
  10. +176 −34 public/javascripts/prototype.js
  11. +24 −0 public/stylesheets/bootstrap-stripped.css
  12. +1 −1 public/stylesheets/bootstrap-stripped.min.css
  13. +32 −1 public/stylesheets/main.styl
  14. +23 −11 test/test.components.js
  15. +17 −11 test/test.elements.js
  16. +1 −0 todo.txt
  17. +2 −2 views/index.jade
  18. +19 −10 views/prototype.jade
  19. 0 views/templates/{ → collections}/project.jade
  20. 0 views/templates/{ → collections}/screen.jade
  21. +3 −3 views/templates/{heading-element.jade → elements/heading.jade}
  22. +1 −1 views/templates/{input-checkbox-element.jade → elements/input-checkbox.jade}
  23. +1 −1 views/templates/{input-radio-element.jade → elements/input-radio.jade}
  24. +1 −1 views/templates/{input-text-element.jade → elements/input-text.jade}
  25. +1 −1 views/templates/{paragraph-element.jade → elements/paragraph.jade}
  26. +1 −1 views/templates/{textarea-element.jade → elements/textarea.jade}
  27. 0 views/templates/{ → layouts}/layout.jade
  28. 0 views/templates/{article-element-list.jade → lists/article-element.jade}
  29. 0 views/templates/{component-list.jade → lists/component.jade}
  30. +0 −1 views/templates/{form-element-list.jade → lists/form-element.jade}
  31. +10 −0 views/templates/popovers/footer.jade
  32. +17 −0 views/templates/popovers/heading.jade
  33. +6 −0 views/templates/popovers/input-checkbox.jade
  34. +6 −0 views/templates/popovers/input-radio.jade
  35. +6 −0 views/templates/popovers/input-text.jade
  36. +6 −0 views/templates/popovers/paragraph.jade
  37. +6 −0 views/templates/popovers/textarea.jade
View
@@ -2,4 +2,5 @@ node_modules
public/javascripts/backbone.min.js
public/javascripts/underscore.min.js
public/javascripts/bootstrap.min.js
+public/javascripts/bootstrap.js
public/javascripts/json2.js
View
@@ -5,7 +5,7 @@ const ALLOWED_FIELDS = {
head: undefined,
// > id of next element to form a linked list
- next: undefined,
+ nextId: undefined,
// input fields
name: undefined,
@@ -31,7 +31,7 @@ function getDefaultElement(req) {
return {
type: req.body.type,
head: req.body.head,
- next: req.body.next,
+ nextId: req.body.nextId,
name: req.body.name,
required: req.body.required || false,
src: req.body.src,
View
@@ -115,11 +115,11 @@ exports.generate = function(parents, children, name, getDefault,
callback = callback || utils.noop;
crud.update(req, key, id, allowedFields, db,
- function(err, project) {
+ function(err, object) {
if (err) {
callback(err);
} else {
- callback(null, project);
+ callback(null, object);
}
});
};
View
@@ -15,22 +15,26 @@ exports.generateUniqueId = function(name, id) {
return name.toString().toLowerCase().replace(ALPHANUM_MATCH, '_') + id;
};
-/* Generically map object to req.body
+/* Generically map curObject to req.body. If a property exists in curObject,
+ * req.body, and allowedFields, curObject's value is updated to equal
+ * req.body's value. If a property exists in req.body and allowedFields, but
+ * not in curObject, it is added to curObject with req.body's value.
+ *
* Requires: web request, current object, allowed fields
* Returns: The updated object if it exists, else false
*/
-exports.updateObject = function(req, currObject, allowedFields) {
- if (typeof currObject !== 'object') {
- currObject = JSON.parse(currObject);
+exports.updateObject = function(req, curObject, allowedFields) {
+ if (typeof curObject !== 'object') {
+ curObject = JSON.parse(curObject);
}
- if (currObject) {
- var setFields = function(currObject, from, allowedFields) {
+ if (curObject) {
+ var setFields = function(curObject, from, allowedFields) {
var props = Object.getOwnPropertyNames(from);
- var dest = currObject;
+ var dest = curObject;
props.forEach(function(name) {
- if (name in dest && name in allowedFields) {
+ if (name in allowedFields) {
var destination = Object.getOwnPropertyDescriptor(from, name);
if (destination) {
@@ -39,10 +43,10 @@ exports.updateObject = function(req, currObject, allowedFields) {
}
});
- return currObject;
+ return curObject;
};
- return setFields(currObject, req.body, allowedFields);
+ return setFields(curObject, req.body, allowedFields);
}
return false;
@@ -0,0 +1,5 @@
+{
+ "node": true,
+ "strict": false,
+ "esnext": true
+}
Oops, something went wrong.

0 comments on commit 4cdf1a5

Please sign in to comment.