Skip to content

Commit

Permalink
update resources blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
igorrKurr committed Jul 26, 2015
1 parent e07ac29 commit 17be916
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 42 deletions.
5 changes: 0 additions & 5 deletions blueprints/admin-app/files/app/adapters/application.js

This file was deleted.

4 changes: 1 addition & 3 deletions blueprints/admin-app/files/app/navigation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export default function() {
this.navigate("Dashboard", {
route: "dashboard"
});
this.navigate("Dashboard", { route: "dashboard" });
}
50 changes: 32 additions & 18 deletions blueprints/table-view-resource/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var inflection = require('ember-cli/node_modules/inflection');
var processTextContent = require('ember-cli-admin/lib/proccess-text-content').processTextContent;
var path = require('path');
var chalk = require('ember-cli/node_modules/chalk');

module.exports = {
description: 'Generates tableview resource',
Expand All @@ -13,15 +13,15 @@ module.exports = {
}
return inflection.singularize(options.dasherizedModuleName);
},
__controllerName__: function(options){
__controllerName__: function(options) {
if (options.pod) {
return "controller";
}
return inflection.pluralize(options.dasherizedModuleName);
},
__controllerPath__: function(options) {
if (options.pod) {
return path.join(options.podPath, inflection.pluralize(options.dasherizedModuleName));
return path.join(options.podPath, inflection.pluralize(options.dasherizedModuleName));
}
return 'controllers';
},
Expand All @@ -30,25 +30,39 @@ module.exports = {
return path.join(options.podPath, inflection.singularize(options.dasherizedModuleName));
}
return 'models';
},
__root__: function(options) {
if (options.inRepoAddon) {
return path.join('lib', options.inRepoAddon, 'addon');
}

if (options.inDummy) {
return path.join('tests', 'dummy', 'app');
}

if (options.inAddon) {
return 'addon';
}

return 'app';
}
};
},
beforeInstall: function(options){
var process = processTextContent.bind(this);
afterInstall: function(options) {
var entityName = options.entity.name;
var navigationStr = '\n\t\tthis.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });'
var routerStr = '\n\tthis.resources("' + entityName + '");'
process('app/initializers/navigation.js',
{
insert: {
'this.navigate("Dashboard", { route: "dashboard" });': navigationStr
}
});
process('app/router.js',
{
insert: {
'MetaRoute.map(Router, function() {': routerStr
}
var navigationStr = '\n this.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });'
var routerStr = '\n this.resources("' + entityName + '");'

var self = this;

return this.insertIntoFile('app/navigation.js', navigationStr, {
after: '});'
}).then(function() {
return self.insertIntoFile('app/router.js', routerStr, {
after: 'MetaRoute.map(Router, function() {'
});
}).then(function() {
self._writeStatusToUI(chalk.green, '[ember-cli-admin] add table-view-resource', entityName);
});
}
};
46 changes: 30 additions & 16 deletions blueprints/tree-view-resource/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var inflection = require('ember-cli/node_modules/inflection');
var processTextContent = require('ember-cli-admin/lib/proccess-text-content').processTextContent;
var chalk = require('ember-cli/node_modules/chalk');
var path = require('path');

module.exports = {
Expand Down Expand Up @@ -37,25 +37,39 @@ module.exports = {
return path.join(options.podPath, inflection.singularize(options.dasherizedModuleName));
}
return 'models';
},
__root__: function(options) {
if (options.inRepoAddon) {
return path.join('lib', options.inRepoAddon, 'addon');
}

if (options.inDummy) {
return path.join('tests', 'dummy', 'app');
}

if (options.inAddon) {
return 'addon';
}

return 'app';
}
};
},
beforeInstall: function(options){
var process = processTextContent.bind(this);
afterInstall: function(options) {
var entityName = options.entity.name;
var navigationStr = '\n\t\tthis.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });'
var routerStr = '\n\tthis.resources("' + entityName + '");'
process('app/initializers/navigation.js',
{
insert: {
'this.navigate("Dashboard", { route: "dashboard" });': navigationStr
}
});
process('app/router.js',
{
insert: {
'MetaRoute.map(Router, function() {': routerStr
}
var navigationStr = '\n this.navigate("' + inflection.titleize(entityName) + '", { route: "' + entityName + '" });'
var routerStr = '\n this.resources("' + entityName + '");'

var self = this;

return this.insertIntoFile('app/navigation.js', navigationStr, {
after: '});'
}).then(function() {
return self.insertIntoFile('app/router.js', routerStr, {
after: 'MetaRoute.map(Router, function() {'
});
}).then(function() {
self._writeStatusToUI(chalk.green, '[ember-cli-admin] add tree-view-resource', entityName);
});
}
};

0 comments on commit 17be916

Please sign in to comment.