Commit cdd8f967 authored by Bertrand PINEL's avatar Bertrand PINEL

Complete refactoring of the templating in entity-factory

parent 99940274
import Component from '@ember/component';
import injectService from 'ember-service/inject';
import { computed } from '@ember/object';
import { A } from '@ember/array';
import EmberObject from '@ember/object';
export default Component.extend({
store: injectService(),
entityType: '',
entityKey: '',
selectedEntities: [],
entities: [],
tableColumns: computed(function() {
var col = A([
EmberObject.create({
propertyName: "id",
title: "id"
}),
EmberObject.create({
propertyName: this.get('entityKey'),
title: this.get('entityKey')
})
]);
return col;
}),
init(){
this._super(...arguments);
this._getEntities();
},
_getEntities() {
this.get('store').findAll(this.get('entityType')).then((entities) => {
// because this is async you need to guard against the component
// being destroyed before the api call has finished because
// because `this.set` will throw an error.
if (this.isDestroyed) { return; }
this.set('entities', entities);
}
)}
})
{{models-table
data=entities
columns=tableColumns
multipleSelect=true
selectedItems=selectedEntities}}
\ No newline at end of file
export { default } from 'ember-aws-ehipster/components/multiple-entity-selector';
\ No newline at end of file
......@@ -7,9 +7,6 @@ const Router = EmberRouter.extend({
});
Router.map(function() {
this.route('entity-factory/tag');
this.route('entity-factory/entry');
this.route('entity-factory/blog');
});
export default Router;
import {
Factory,
faker
} from 'ember-cli-mirage';
export default Factory.extend({
<%= factories.length ? '//default generated factory\n\t' + factories + '\n' : '' %>
})
<%= mirageFactory %>
\ No newline at end of file
import {
Model<%= imports.length ? ', '+imports : '' %>
} from 'ember-cli-mirage';
export default Model.extend({<%= rel.length ? rel : '' %>
});
\ No newline at end of file
<%= mirageModel %>
\ No newline at end of file
......@@ -4,27 +4,15 @@ import { A } from '@ember/array';
import EmberObject from '@ember/object';
export default Controller.extend({
isAddingEntry: false,
<%=ctrlVars%>
<%=singularEntityName%>TableColumns: computed(function() {
var col = A([
<%=tableCols%>
]);
col.pushObject({
title: 'Delete',
component: 'delete-row'
});
return col;
}),
isAddingEntry: false,
newEntry: EmberObject.create({<%=controllerInitEntity%>}),
<%=singularEntityName%>TableContent: computed(function() {
return this.get("model");
}),
<%=controllerModelTable%>
actions: {
actions: {
submit() {
event.preventDefault();
let newEntity = this.store.createRecord('<%=singularEntityName%>',<%=toCreateEntity%>);
let newEntity = this.store.createRecord('<%=singularEntityName%>',{<%=controllerCreateEntity%>});
newEntity.save();
this.set('addEntryModal', false).then((entry) => {
console.log("new entry of id "+entry.get('id')+" created");
......
import DS from 'ember-data';
export default DS.Model.extend({
<%= attrs.length ? ' ' + attrs : '' %>
});
\ No newline at end of file
<%= entityModel %>
......@@ -20,7 +20,7 @@
</h4>
{{/modal.header}}
{{#modal.body}}
<%=form%>
<%=templateEntityForm%>
{{/modal.body}}
{{#modal.footer}}
{{#bs-button onClick=(action modal.close)}}Cancel{{/bs-button}}
......
<%= entityValidation %>
\ No newline at end of file
This diff is collapsed.
......@@ -2,21 +2,7 @@ import ENV from './../config/environment';
export default function() {
this.namespace = '';
if (!ENV.APP.proxy) {
this.get('/tags');
this.get('/tags/:id');
this.delete('/tags/:id');
this.patch('/tags/:id');
this.post('/tags');
this.get('/entries');
this.get('/entries/:id');
this.delete('/entries/:id');
this.patch('/entries/:id');
this.post('/entries');
this.get('/blogs');
this.get('/blogs/:id');
this.delete('/blogs/:id');
this.patch('/blogs/:id');
this.post('/blogs');
} else {
this.passthrough();
}
......
export default function(server) {
server.createList('tag', 8);
server.createList('entry', 8);
server.createList('blog', 8);
}
{
"name": "ember-aws-ehipster",
"version": "0.2.21",
"version": "0.3.9",
"description": "Attempt to build a complete web application using serverless architecture on AWS",
"keywords": [
"ember-addon", "aws", "jhipster", "generator", "serverless"
"ember-addon",
"aws",
"jhipster",
"generator",
"serverless"
],
"repository": "",
"license": "MIT",
......@@ -31,12 +35,18 @@
"ember-truth-helpers": "^2.1.0",
"ember-pikaday": "^2.3.0",
"jhipster-core": "^3.4.0",
"shelljs": "^0.8.2"
"shelljs": "^0.8.2",
"ember-validated-form": "^2.0.0-alpha.3",
"ember-concurrency": "^0.8.26",
"ember-changeset": "^1.6.0",
"ember-changeset-validations": "^1.3.3"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-auto-import": "^1.2.15",
"ember-changeset": "^1.6.0",
"ember-changeset-validations": "^1.3.3",
"ember-cli": "~3.1.4",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.2.1",
......
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