diff --git a/js/apps/system/aardvark/foxxTemplates.js b/js/apps/system/aardvark/foxxTemplates.js index 9382217729..3c36572891 100644 --- a/js/apps/system/aardvark/foxxTemplates.js +++ b/js/apps/system/aardvark/foxxTemplates.js @@ -61,6 +61,7 @@ controller.post("/generate", function(req, res) { if (isDevMode()) { FoxxManager.devSetup(conf.get("name")); + internal.executeGlobalContextFunction("reloadRouting"); } else { // TODO Zip and ship it } diff --git a/js/apps/system/aardvark/frontend/js/views/applicationsView.js b/js/apps/system/aardvark/frontend/js/views/applicationsView.js index 009ce549c4..11ec4c39ee 100644 --- a/js/apps/system/aardvark/frontend/js/views/applicationsView.js +++ b/js/apps/system/aardvark/frontend/js/views/applicationsView.js @@ -634,10 +634,13 @@ author: $("#new-app-author").val(), license: $("#new-app-license").val(), description: $("#new-app-description").val() - }; + }, + self = this; console.log(info); $.post("templates/generate", JSON.stringify(info), function(a) { - alert("GENERATOOOO!", a); + //TODO Error Handling + window.modalView.hide(); + self.reload(); }); }, diff --git a/js/apps/system/aardvark/lib/foxxTemplateEngine.js b/js/apps/system/aardvark/lib/foxxTemplateEngine.js index 3731a785dd..e051e9b0e1 100644 --- a/js/apps/system/aardvark/lib/foxxTemplateEngine.js +++ b/js/apps/system/aardvark/lib/foxxTemplateEngine.js @@ -56,20 +56,24 @@ this.models = []; _.each(collectionNames, function (collectionName) { - var modelName = i.singularize(collectionName), + var modelBase = i.singularize(collectionName).substr(1), collectionStart, repositoryBase = collectionName.substr(1), repositoryName, repositoryPath, repositoryInstance, - modelPath; + modelPath, + modelName, + modelInstance; collectionStart = collectionName.charAt(0); if (collectionStart.match("[a-zA-Z]") === null) { throw "Collection Name has to start with a letter"; } - if (modelName === collectionName) { + if (modelBase === repositoryBase) { repositoryBase += "_repo"; } + modelName = collectionStart.toUpperCase() + modelBase; + modelInstance = collectionStart.toLowerCase() + modelBase; repositoryName = collectionStart.toUpperCase() + repositoryBase; repositoryInstance = collectionStart.toLowerCase() + repositoryBase; repositoryPath = 'repositories/' + collectionName; @@ -82,7 +86,8 @@ repositoryInstance: repositoryName, repository: repositoryInstance, repositoryPath: repositoryPath, - model: i.titleize(modelName), + modelInstance: modelInstance, + model: modelName, modelPath: modelPath, basePath: collectionName, collectionName: collectionName diff --git a/js/apps/system/aardvark/templates/controller.js.tmpl b/js/apps/system/aardvark/templates/controller.js.tmpl index 7ea112af58..8d701d0a5d 100644 --- a/js/apps/system/aardvark/templates/controller.js.tmpl +++ b/js/apps/system/aardvark/templates/controller.js.tmpl @@ -30,9 +30,9 @@ * requestBody. */ controller.post('/<%= basePath %>', function (req, res) { - var todo = req.params('todo'); + var <%= modelInstance %> = req.params('<%= modelInstance %>'); res.json(<%= repositoryInstance %>.save(todo).forClient()); - }).bodyParam('todo', 'The <%= model %> you want to create', <%= model %>); + }).bodyParam('<%= modelInstance %>', 'The <%= model %> you want to create', <%= model %>); /** Updates a <%= model %> * @@ -41,12 +41,12 @@ */ controller.put('/<%= basePath %>/:id', function (req, res) { var id = req.params('id'), - todo = req.params('todo'); - res.json(<%= repositoryInstance %>.replaceById(id, todo)); + <%= modelInstance %> = req.params('<%= modelInstance %>'); + res.json(<%= repositoryInstance %>.replaceById(id, <%= modelInstance %>)); }).pathParam('id', { description: 'The id of the <%= model %>-Item', type: 'string' - }).bodyParam('todo', 'The <%= model %> you want your old one to be replaced with', <%= model %>); + }).bodyParam('<%= modelInstance %>', 'The <%= model %> you want your old one to be replaced with', <%= model %>); /** Removes a <%= model %> *