Only remove photos from view when destroyed on server

This commit is contained in:
Steffen van Bergerem 2014-12-01 00:36:56 +01:00
parent 4f8cf0fe07
commit 4cc1b40443
4 changed files with 8 additions and 2 deletions

View file

@ -121,11 +121,13 @@ app.views.Base = Backbone.View.extend({
var url = this.model.urlRoot + '/' + this.model.id; var url = this.model.urlRoot + '/' + this.model.id;
if (confirm(Diaspora.I18n.t("confirm_dialog"))) { if (confirm(Diaspora.I18n.t("confirm_dialog"))) {
this.$el.addClass('deleting');
this.model.destroy({ url: url }) this.model.destroy({ url: url })
.done(function() { .done(function() {
self.remove(); self.remove();
}) })
.fail(function() { .fail(function() {
self.$el.removeClass('deleting');
var flash = new Diaspora.Widgets.FlashMessages; var flash = new Diaspora.Widgets.FlashMessages;
flash.render({ flash.render({
success: false, success: false,

View file

@ -14,7 +14,6 @@ app.views.Photo = app.views.Base.extend({
initialize : function() { initialize : function() {
$(this.el).attr("id", this.model.get("guid")); $(this.el).attr("id", this.model.get("guid"));
this.model.bind('remove', this.remove, this);
return this; return this;
}, },

View file

@ -6,6 +6,10 @@
& > .media { & > .media {
margin: 0px; margin: 0px;
} }
&.deleting {
> .media { opacity: 0.3; }
.controls { display: none !important; }
}
} }
#main_stream .stream_element { #main_stream .stream_element {

View file

@ -31,5 +31,6 @@ Feature: show photos
When I am on "robert@grimm.grimm"'s photos page When I am on "robert@grimm.grimm"'s photos page
And I delete a photo And I delete a photo
And I confirm the alert And I confirm the alert
And I am on "robert@grimm.grimm"'s page Then I should not see ".deleting" within ".stream"
When I am on "robert@grimm.grimm"'s page
Then I should not see "Photos" within "#profile_horizontal_bar" Then I should not see "Photos" within "#profile_horizontal_bar"