Skip to content

Commit

Permalink
show 'stop ignoring' button in hovercards
Browse files Browse the repository at this point in the history
  • Loading branch information
kas70 committed Mar 26, 2018
1 parent c84411e commit 7b2f271
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/app/views/hovercard_view.js
Expand Up @@ -5,7 +5,7 @@ app.views.Hovercard = app.views.Base.extend({
id: 'hovercard_container',

subviews: {
"#hovercard_dropdown_container": "aspectMembershipDropdown"
"#hovercard_dropdown_container": "aspectDropdownOrUnblock"
},

events: {
Expand Down Expand Up @@ -103,8 +103,10 @@ app.views.Hovercard = app.views.Base.extend({
throw new Error("received data is not a person object");
}

if (app.currentUser.authenticated()) {
self.aspectMembershipDropdown = new app.views.AspectMembership({person: new app.models.Person(person)});
if ( app.currentUser.authenticated() ) {
self.aspectDropdownOrUnblock = person.block ?
new app.views.UnblockPerson({person: new app.models.Person(person), parent: self}) :
new app.views.AspectMembership({person: new app.models.Person(person)});
}

self.render();
Expand Down
24 changes: 24 additions & 0 deletions app/assets/javascripts/app/views/unblock_person_view.js
@@ -0,0 +1,24 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

app.views.UnblockPerson = app.views.Base.extend({
templateName: 'unblock_person',

events: {
"click #unblock_user_button": 'unblock'
},

initialize: function(opts) {
_.extend(this, opts);
this.parent = opts.parent;
},

unblock: function() {
var block = this.person.unblock();
block.fail(function() {
app.flashMessages.error(Diaspora.I18.t("unblock_failed"));
});
this.parent._populateHovercard();
return false;
},
});
// @license-end
3 changes: 3 additions & 0 deletions app/assets/templates/unblock_person_tpl.jst.hbs
@@ -0,0 +1,3 @@
<button id="unblock_user_button" class="btn btn-danger">
<span class="text">{{ t "people.stop_ignoring" }}</span>
</button>
8 changes: 6 additions & 2 deletions app/presenters/person_presenter.rb
Expand Up @@ -13,7 +13,7 @@ def base_hash
def full_hash
base_hash_with_contact.merge(
relationship: relationship,
block: is_blocked? ? BlockPresenter.new(current_user_person_block).base_hash : false,
block: block_details,
is_own_profile: own_profile?,
show_profile_info: public_details? || own_profile? || person_is_following_current_user
)
Expand All @@ -24,7 +24,7 @@ def as_json(_options={})
end

def hovercard
base_hash_with_contact.merge(profile: ProfilePresenter.new(profile).for_hovercard)
base_hash_with_contact.merge(block: block_details, profile: ProfilePresenter.new(profile).for_hovercard)
end

def metas_attributes
Expand Down Expand Up @@ -109,6 +109,10 @@ def is_blocked?
current_user_person_block.present?
end

def block_details
is_blocked? ? BlockPresenter.new(current_user_person_block).base_hash : false
end

def title
name
end
Expand Down

0 comments on commit 7b2f271

Please sign in to comment.