Commit 93cdfa80 authored by Bertrand PINEL's avatar Bertrand PINEL

Add entity-selector in default blueprint

parent f244a7bd
export { default } from 'ember-aws-ehipster/controllers/entity-factory';
export { default } from 'ember-aws-ehipster/templates/entity-factory';
<div class="container">
Available entities :
<div class="container">
Available entities :
<select class="ember-select" onchange={{action "selectEntity" value="target.value"}}>
{{#each entities as |entityChoice|}}
<option value={{entityChoice}} selected={{eq entity entityChoice}}>{{entityChoice}}</option>
......
......@@ -14,6 +14,18 @@ module.exports = {
// foo: options.entity.options.foo
// };
// }
fileMapTokens(options) {
return {
__root__() {
if (options.inDummy) {
return 'tests/dummy/app';
} else {
return 'app';
}
},
__mirage__() { return '../mirage'}
}
},
afterInstall(options) {
// Perform extra work here.
......@@ -39,6 +51,12 @@ module.exports = {
let importcss = "@import 'ember-aws-ehipster.css';\n";
let fileContents = importcss + fs.readFileSync(stylePath, 'utf-8');
fs.writeFileSync(stylePath, fileContents, 'utf-8');
// Add master path for dealing with entities
let routerPath = (options.dummy) ? "tests/dummy/app/router.js" : "app/router.js";
let routerLine = "\tthis.route('entity-factory', function() {\n\t});\n";
addLineToFile(this, routerPath, /Router\.map\(function\(\) {/, routerLine);
}
};
......@@ -46,7 +64,7 @@ function addLineToFile(ctx, filePath, markerString, addedLine) {
let fileContents = fs.readFileSync(filePath, 'utf-8');
if (fileContents.indexOf(addedLine) === -1) {
ctx.ui.writeLine("\tAdd line "+addedLine+" to file "+filePath);
//ctx.ui.writeLine("\tAdd line "+addedLine+" to file "+filePath);
fileContents = fileContents.replace(markerString, [
'$&',
addedLine,
......
......@@ -185,12 +185,12 @@ module.exports = {
// Add route in router.js for the entity page
let routerPath = (options.dummy) ? "tests/dummy/app/router.js" : "app/router.js";
let routeName = '\tthis.route\(\''+blueprintName+'/'+entityName+'\'\);';
addLineToFile(this, routerPath, /Router\.map\(function\(\) {/, routeName);
let routeName = '\tthis.route\(\''+entityName+'\'\);';
addLineToFile(this, routerPath, /this\.route\('entity-factory', function\(\) {/, routeName);
// Add Entity select entry in the entity controller file
let entityIndexPath = (options.dummy) ? "tests/dummy/app/controllers/entity-factory.js" : "app/controllers/entity-factory.js";
let entityIndexEntry= "'"+entityName+"'";
let entityIndexEntry= "'"+entityName+"',";
addLineToFile(this, entityIndexPath, /entities: \[/, entityIndexEntry);
}
};
......
{
"name": "ember-aws-ehipster",
"version": "0.2.7",
"version": "0.2.18",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
"ember-addon"
......@@ -47,6 +47,7 @@
"ember-cli-shims": "^1.2.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^2.0.0",
"ember-cli-update": "^0.27.3",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment