From db993e2d2f8940fe8b13ee770c72c3ead23caa2a Mon Sep 17 00:00:00 2001 From: Markus Grigull Date: Wed, 29 Jun 2016 17:08:42 +0200 Subject: [PATCH] Add todo.md Fix project and visualization delete Start with plot styling --- app/components/plot-container.js | 4 ++- app/components/plot-table.js | 5 +++- app/controllers/project/delete.js | 31 +++++++++++---------- app/controllers/visualization/delete.js | 20 +++++++------ app/router.js | 3 ++ app/routes/404.js | 4 +++ app/styles/app.css | 25 +++++++++++++++-- app/templates/404.hbs | 1 + app/templates/components/plot-container.hbs | 2 +- app/templates/components/plot-table.hbs | 24 ++++++++++------ app/templates/visualization/edit.hbs | 2 +- tests/unit/routes/404-test.js | 11 ++++++++ todo.md | 8 ++++++ 13 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 app/routes/404.js create mode 100644 app/templates/404.hbs create mode 100644 tests/unit/routes/404-test.js create mode 100644 todo.md diff --git a/app/components/plot-container.js b/app/components/plot-container.js index b4b402b..2297b13 100644 --- a/app/components/plot-container.js +++ b/app/components/plot-container.js @@ -3,11 +3,13 @@ import Ember from 'ember'; export default Ember.Component.extend({ tagName: 'div', attributeBindings: [ 'style' ], + classNames: [ 'plotContainer' ], plot: null, + editing: false, style: function() { - return 'width: ' + this.get('plot.width') + 'px; height: ' + this.get('plot.height') + 'px; border: 1px solid black;'; + return 'width: ' + this.get('plot.width') + 'px; height: ' + this.get('plot.height') + 'px;'; }.property('plot'), isTable: function() { diff --git a/app/components/plot-table.js b/app/components/plot-table.js index e4b1f11..7c66b4e 100644 --- a/app/components/plot-table.js +++ b/app/components/plot-table.js @@ -1,5 +1,8 @@ import Ember from 'ember'; export default Ember.Component.extend({ - tagName: 'table' + tagName: 'div', + classNames: [ '' ], + + editing: false }); diff --git a/app/controllers/project/delete.js b/app/controllers/project/delete.js index 6435bed..dbc5cc7 100644 --- a/app/controllers/project/delete.js +++ b/app/controllers/project/delete.js @@ -20,24 +20,25 @@ export default Ember.Controller.extend({ let projectId = project.get('id'); // delete the project and remove from user projects - user.get('projects').removeObject(projectId); - user.save().then(function() { - // destroy all visualizations - var visualizations = project.get('visualizations'); - visualizations.forEach(function(visualization) { - // destroy all plots - var plots = visualization.get('plots'); - plots.forEach(function(plot) { - plot.destroyRecord(); - }); - - visualization.destroyRecord(); + var visualizations = project.get('visualizations'); + visualizations.forEach(function(visualization) { + // destroy all plots + var plots = visualization.get('plots'); + plots.forEach(function(plot) { + plot.destroyRecord(); }); - project.destroyRecord(); + visualization.destroyRecord(); + }); - // go back to project list - this.transitionToRoute('/projects'); + project.destroyRecord(); + + // save the changes to project + var controller = this; + + user.get('projects').removeObject(projectId); + user.save().then(function() { + controller.transitionToRoute('/projects'); }); } } diff --git a/app/controllers/visualization/delete.js b/app/controllers/visualization/delete.js index 6ceee2b..37c2c9b 100644 --- a/app/controllers/visualization/delete.js +++ b/app/controllers/visualization/delete.js @@ -16,18 +16,20 @@ export default Ember.Controller.extend({ var projectId = this.get('model.project.id'); var project = this.store.peekRecord('project', projectId); + // destroy all plots + var plots = visualization.get('plots'); + plots.forEach(function(plot) { + plot.destroyRecord(); + }); + + visualization.destroyRecord(); + // delete the visualization and remove from the project + var controller = this; + project.get('visualizations').removeObject(visualizationId); project.save().then(function() { - // destroy all plots - var plots = visualization.get('plots'); - plots.forEach(function(plot) { - plot.destroyRecord(); - }); - - visualization.destroyRecord(); - - this.transitionToRoute('/project/' + projectId); + controller.transitionToRoute('/project/' + projectId); }); } } diff --git a/app/router.js b/app/router.js index 3b52f3d..c8d5437 100644 --- a/app/router.js +++ b/app/router.js @@ -19,12 +19,15 @@ Router.map(function() { this.route('user', function() { this.route('edit'); }); + this.route('visualization', function() { this.route('index', { path: '/:visualizationid' }); this.route('new'); this.route('edit', { path: '/edit/:visualizationid' }); this.route('delete', { path: '/delete/:visualizationid' }); }); + + this.route('404', { path: '/*path' }); }); export default Router; diff --git a/app/routes/404.js b/app/routes/404.js new file mode 100644 index 0000000..26d9f31 --- /dev/null +++ b/app/routes/404.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ +}); diff --git a/app/styles/app.css b/app/styles/app.css index 9530318..83d5df6 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -122,9 +122,6 @@ footer { min-height: 200px; - padding-top: 5px; - padding-left: 10px; - border: 3px dashed #aaa; &.activated { @@ -148,3 +145,25 @@ footer { background-color: #aaa; } } + +.plotContainer { + border: 1px solid lightgray; + + margin: 10px; + padding: 5px 10px; +} + +.plotTable { + width: 100%; + height: 100%; + + border: 1px solid gray; + + border-collapse: collapse; +} + +.plotTable td, th { + border: 1px solid gray; + + padding: 2px 5px; +} diff --git a/app/templates/404.hbs b/app/templates/404.hbs new file mode 100644 index 0000000..9a83fd7 --- /dev/null +++ b/app/templates/404.hbs @@ -0,0 +1 @@ +

404 - Not found

diff --git a/app/templates/components/plot-container.hbs b/app/templates/components/plot-container.hbs index 53fbc14..b223224 100644 --- a/app/templates/components/plot-container.hbs +++ b/app/templates/components/plot-container.hbs @@ -1,5 +1,5 @@ {{#if isTable}} - {{#plot-table plot=plot}}{{/plot-table}} + {{#plot-table plot=plot editing=editing}}{{/plot-table}} {{else}} Plot {{/if}} diff --git a/app/templates/components/plot-table.hbs b/app/templates/components/plot-table.hbs index 0a1d321..6b2091a 100644 --- a/app/templates/components/plot-table.hbs +++ b/app/templates/components/plot-table.hbs @@ -1,8 +1,16 @@ - - Name - Value - - - Signal X - 1.234 - +{{#if editing}} + {{input value=plot.title placeholder='Enter title'}} +{{else}} +

{{plot.title}}

+{{/if}} + + + + + + + + + + +
NameValue
Signal X1.234
diff --git a/app/templates/visualization/edit.hbs b/app/templates/visualization/edit.hbs index 2a10125..d23a362 100644 --- a/app/templates/visualization/edit.hbs +++ b/app/templates/visualization/edit.hbs @@ -18,7 +18,7 @@
{{#draggable-dropzone dropped='addPlot'}} {{#each model.plots as |plot|}} - {{#plot-container plot=plot}}{{/plot-container}} + {{#plot-container plot=plot editing=true}}{{/plot-container}} {{/each}} {{/draggable-dropzone}}
diff --git a/tests/unit/routes/404-test.js b/tests/unit/routes/404-test.js new file mode 100644 index 0000000..260a5bc --- /dev/null +++ b/tests/unit/routes/404-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:404', 'Unit | Route | 404', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +}); diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..a4fc8ca --- /dev/null +++ b/todo.md @@ -0,0 +1,8 @@ +# To-Do + - Logout route + - Change password + - Create/register user + - User management + - Rename preferences into account + - ! Don't save user password + - ! Fix user logged-in on invalidate account (after account was deleted)