Commit abb810e5 authored by Bertrand PINEL's avatar Bertrand PINEL

Add delete feature

parent c5ba9d52
import Component from '@ember/component';
import {get} from '@ember/object';
import layout from '../templates/components/delete-row';
export default Component.extend({
layout,
sendAction: null,
record: null,
actions: {
sendAction(actionName, record, event) {
get(this, 'sendAction')(actionName, record);
event.stopPropagation();
}
}
});
\ No newline at end of file
a:hover {
text-decoration: none;
}
a.active {
font-weight: 700;
}
pre {
text-align: left;
white-space: pre-line;
}
.table-footer {
border: 1px solid #ddd;
padding: 5px 0;
}
.models-table-wrapper {
margin-bottom: 20px;
}
.btn-default {
background-image: none !important;
}
.columns-dropdown {
margin-bottom: 20px;
}
.table-column-options.table > tbody > tr > td {
border-top-width: 0;
}
tr.selected-row>td:not(.grouping-cell), tr.selected-expand>td:not(.grouping-cell) {
background: #C6E746;
}
.navbar-text.gh {
margin-top: 13px !important;
margin-bottom: 11px !important;
}
\ No newline at end of file
<button
class="btn btn-default"
onclick={{action "sendAction" "delete" record}}>
Delete
</button>
export { default } from 'ember-aws-ehipster/components/delete-row';
\ No newline at end of file
......@@ -33,6 +33,12 @@ module.exports = {
"\treturn usingProxyArg || hasGeneratedProxies;\n}\n";
addLineToFile(this, configPath, /'use strict';/, proxy);
addLineToFile(this, configPath, /when it is created/, "\t\tproxy: usingProxy(),");
// Add import of ember_aws_ehipster.css to apps.css
let stylePath = (options.dummy) ? "tests/dummy/app/styles/app.css" : "app/styles/app.css";
let importcss = "@import 'ember-aws-ehipster.css';\n";
let fileContents = importcss + fs.readFileSync(stylePath, 'utf-8');
fs.writeFileSync(stylePath, fileContents, 'utf-8');
}
};
......
......@@ -10,6 +10,10 @@ isAddingEntry: false,
var col = A([
<%=tableCols%>
]);
col.pushObject({
title: 'Delete',
component: 'delete-row'
});
return col;
}),
......@@ -25,6 +29,10 @@ actions: {
this.set('addEntryModal', false).then((entry) => {
console.log("new entry of id "+entry.get('id')+" created");
});
},
deleteRecord (record) {
console.log('record is '+ record);
record.destroyRecord();
}
}
});
\ No newline at end of file
......@@ -2,9 +2,12 @@
<div class="container-fluid">
<h2>List of <%=singularEntityName%> Entities</h2>
{{models-table
data=<%=singularEntityName%>TableContent
columns=<%=singularEntityName%>TableColumns}}
{{#models-table data=<%=singularEntityName%>TableContent columns=<%=singularEntityName%>TableColumns delete="deleteRecord" as |mt|}}
{{mt.global-filter}}
{{mt.table}}
{{mt.footer}}
{{/models-table}}
{{#bs-button onClick=(action (mut addEntryModal) true)}}
Add new entry
......
......@@ -161,7 +161,10 @@ module.exports = {
// Complete /mirage/config.js
let mirageConfigPath = (options.dummy) ? "tests/dummy/mirage/config.js" : "mirage/config.js";
let configLine = "\t\tthis.get('/"+inflection.pluralize(entityName)+"', '"+inflection.pluralize(entityName)+"');\n"+
let configLine = "\t\tthis.get('/"+inflection.pluralize(entityName)+"');\n"+
"\t\tthis.get('/"+inflection.pluralize(entityName)+"/:id');\n"+
"\t\tthis.delete('/"+inflection.pluralize(entityName)+"/:id');\n"+
"\t\tthis.patch('/"+inflection.pluralize(entityName)+"/:id');\n"+
"\t\tthis.post('/"+inflection.pluralize(entityName)+"');";
if (!fs.existsSync(mirageConfigPath)) {
this.ui.writeLine("Creating file "+mirageConfigPath);
......
This diff is collapsed.
{
"name": "ember-aws-ehipster",
"version": "0.1.1",
"version": "0.1.4",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
"ember-addon"
......
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
module('Integration | Component | delete-row', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`{{delete-row}}`);
assert.equal(this.element.textContent.trim(), '');
// Template block usage:
await render(hbs`
{{#delete-row}}
template block text
{{/delete-row}}
`);
assert.equal(this.element.textContent.trim(), 'template block text');
});
});
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