From 6d7aa32c3c710fdb58768e8f89c0e1ed608efdd0 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 4 Dec 2013 20:20:32 +0100 Subject: clear dashboard when opened package is deleted --- pyload/web/app/scripts/views/dashboard/dashboardView.js | 8 ++++++++ pyload/web/app/scripts/views/dashboard/packageView.js | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'pyload/web/app/scripts/views/dashboard') diff --git a/pyload/web/app/scripts/views/dashboard/dashboardView.js b/pyload/web/app/scripts/views/dashboard/dashboardView.js index 6a263bf03..fbf1055f5 100644 --- a/pyload/web/app/scripts/views/dashboard/dashboardView.js +++ b/pyload/web/app/scripts/views/dashboard/dashboardView.js @@ -30,6 +30,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col // When package is added we reload the data this.listenTo(App.vent, 'package:added', _.bind(this.fetch, this)); this.listenTo(App.vent, 'package:inserted', _.bind(this.fetch, this)); + this.listenTo(App.vent, 'package:destroyed', _.bind(this.packageDestroyed, this)); this.listenTo(App.vent, 'file:updated', _.bind(this.fileUpdated, this)); @@ -170,6 +171,13 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col App.vent.trigger('dashboard:updated'); }}); } + }, + + // destroys files when opened package is deleted + packageDestroyed: function(pack) { + // TODO: could be improved + if (pack.get('files') === this.files) + App.vent.trigger('dashboard:destroyContent') } }); }); \ No newline at end of file diff --git a/pyload/web/app/scripts/views/dashboard/packageView.js b/pyload/web/app/scripts/views/dashboard/packageView.js index 243ebac9b..382615212 100644 --- a/pyload/web/app/scripts/views/dashboard/packageView.js +++ b/pyload/web/app/scripts/views/dashboard/packageView.js @@ -53,9 +53,7 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb unrender: function() { itemView.prototype.unrender.apply(this); - - // TODO: display other package - App.vent.trigger('dashboard:loading', null); + App.vent.trigger('package:destroyed', this.model); }, // TODO -- cgit v1.2.3