1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-23 00:00:02 +01:00
VILLASweb/app/controllers/visualization/delete.js
Markus Grigull 480c90530d Add visualization create, edit and delete
All plots will be saved in the plot model (no subclasses).
2016-06-28 22:05:54 +02:00

34 lines
983 B
JavaScript

import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
cancelDelete() {
// go back to visualization edit view
let visualizationId = this.get('model.id');
this.transitionToRoute('/visualization/' + visualizationId);
},
confirmDelete() {
// get the objects
var visualization = this.get('model');
let visualizationId = this.get('model.id');
var projectId = this.get('model.project.id');
var project = this.store.peekRecord('project', projectId);
// delete the visualization and remove from the project
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);
});
}
}
});