r9686 - in helma-ng/trunk/apps: filestore filestore/skins googlestore googlestore/skins
[email protected] Tue, 28 Apr 2009 11:01:24 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090428090124.14BE23D0D6@mia> |
Author: hannes
Date: 2009-04-28 11:01:23 +0200 (Tue, 28 Apr 2009)
New Revision: 9686
Modified:
helma-ng/trunk/apps/filestore/config.js
helma-ng/trunk/apps/filestore/main.js
helma-ng/trunk/apps/filestore/skins/index.html
helma-ng/trunk/apps/googlestore/config.js
helma-ng/trunk/apps/googlestore/main.js
helma-ng/trunk/apps/googlestore/skins/index.html
Log:
Implement book edit action.
Details at http://dev.helma.org/trac/helma/changeset/9686
Modified: helma-ng/trunk/apps/filestore/config.js
===================================================================
--- helma-ng/trunk/apps/filestore/config.js 2009-04-28 09:01:17 UTC (rev 9685)
+++ helma-ng/trunk/apps/filestore/config.js 2009-04-28 09:01:23 UTC (rev 9686)
@@ -4,7 +4,7 @@
exports.middleware = [
'helma/logging'
-]
+];
exports.charset = 'UTF-8';
exports.contentType = 'text/html';
Modified: helma-ng/trunk/apps/filestore/main.js
===================================================================
--- helma-ng/trunk/apps/filestore/main.js 2009-04-28 09:01:17 UTC (rev 9685)
+++ helma-ng/trunk/apps/filestore/main.js 2009-04-28 09:01:23 UTC (rev 9686)
@@ -1,7 +1,7 @@
include('helma/webapp/response');
include('./model');
-export('index');
+export('index', 'edit');
// the main action is invoked for http://localhost:8080/
// this also shows simple skin rendering
@@ -19,6 +19,23 @@
});
}
+function edit(req, id) {
+ var book = Book.get(id);
+ if (req.isPost) {
+ var author = book.author;
+ author.name = req.params.author;
+ book.title = req.params.title;
+ author.save();
+ book.save();
+ return new RedirectResponse("../");
+ }
+ return SkinnedResponse(getResource('./skins/edit.html'), {
+ title: 'Storage',
+ book: book,
+ action: req.path
+ })
+}
+
function createBook(req) {
var author = new Author({name: req.params.author});
var book = new Book({author: author, title: req.params.title});
Modified: helma-ng/trunk/apps/filestore/skins/index.html
===================================================================
--- helma-ng/trunk/apps/filestore/skins/index.html 2009-04-28 09:01:17 UTC (rev 9685)
+++ helma-ng/trunk/apps/filestore/skins/index.html 2009-04-28 09:01:23 UTC (rev 9686)
@@ -17,4 +17,6 @@
<% subskin 'book' ----------------------------------- %>
<div><% book.author.name %>: <% book.title %>
- <a href="?remove=<% book._id %>">[remove]</a></div>
+ <a href="edit/<% book._id %>">[edit]</a>
+ <a href="?remove=<% book._id %>">[remove]</a>
+</div>
Modified: helma-ng/trunk/apps/googlestore/config.js
===================================================================
--- helma-ng/trunk/apps/googlestore/config.js 2009-04-28 09:01:17 UTC (rev 9685)
+++ helma-ng/trunk/apps/googlestore/config.js 2009-04-28 09:01:23 UTC (rev 9686)
@@ -4,7 +4,7 @@
exports.middleware = [
'helma/logging'
-]
+];
exports.charset = 'UTF-8';
exports.contentType = 'text/html';
Modified: helma-ng/trunk/apps/googlestore/main.js
===================================================================
--- helma-ng/trunk/apps/googlestore/main.js 2009-04-28 09:01:17 UTC (rev 9685)
+++ helma-ng/trunk/apps/googlestore/main.js 2009-04-28 09:01:23 UTC (rev 9686)
@@ -1,7 +1,7 @@
include('helma/webapp/response');
include('./model');
-export('index');
+export('index', 'edit');
// the main action is invoked for http://localhost:8080/
// this also shows simple skin rendering
@@ -19,6 +19,23 @@
});
}
+function edit(req, id) {
+ var book = Book.get(id);
+ if (req.isPost) {
+ var author = book.author;
+ author.name = req.params.author;
+ book.title = req.params.title;
+ author.save();
+ book.save();
+ return new RedirectResponse("../");
+ }
+ return SkinnedResponse(getResource('./skins/edit.html'), {
+ title: 'Storage',
+ book: book,
+ action: req.path
+ })
+}
+
function createBook(req) {
var author = new Author({name: req.params.author});
author.save(); // no cascading save yet
Modified: helma-ng/trunk/apps/googlestore/skins/index.html
===================================================================
--- helma-ng/trunk/apps/googlestore/skins/index.html 2009-04-28 09:01:17 UTC (rev 9685)
+++ helma-ng/trunk/apps/googlestore/skins/index.html 2009-04-28 09:01:23 UTC (rev 9686)
@@ -17,4 +17,6 @@
<% subskin 'book' ----------------------------------- %>
<div><% book.author.name %>: <% book.title %>
- <a href="?remove=<% book.getId %>">[remove]</a></div>
+ <a href="edit/<% book.getId %>">[edit]</a>
+ <a href="?remove=<% book.getId %>">[remove]</a>
+</div>