Unverified Commit 02d9d350 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff
Browse files

Move person extension for prefills to conversations form view

closes #7599
parent 48630b3a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
* Fix S3 support [#7566](https://github.com/diaspora/diaspora/pull/7566)
* Fix mixed username and timestamp with LTR/RTL scripts [#7575](https://github.com/diaspora/diaspora/pull/7575)
* Prevent users from zooming in IE Mobile [#7589](https://github.com/diaspora/diaspora/pull/7589)
* Fix recipient prefill on contacts and profile page [#7599](https://github.com/diaspora/diaspora/pull/7599)

## Features
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
+2 −7
Original line number Diff line number Diff line
@@ -80,14 +80,9 @@ app.pages.Contacts = Backbone.View.extend({

  showMessageModal: function(){
    $("#conversationModal").on("modal:loaded", function() {
      var people = app.contacts.filter(function(contact) {
      var people = _.pluck(app.contacts.filter(function(contact) {
        return contact.inAspect(app.aspect.get("id"));
      }).map(function(contact) {
        return _.extend({
          avatar: contact.person.get("profile").avatar.small,
          handle: contact.person.get("diaspora_id")
        }, contact.person.attributes);
      });
      }), "person");
      new app.views.ConversationsForm({prefill: people});
    });
    app.helpers.showModal("#conversationModal");
+7 −2
Original line number Diff line number Diff line
@@ -52,8 +52,13 @@ app.views.ConversationsForm = app.views.Base.extend({
    this.setupAvatarFallback(personEl);
  },

  prefill: function(handles) {
    handles.forEach(this.addRecipient.bind(this));
  prefill: function(people) {
    people.forEach(function(person) {
      this.addRecipient(_.extend({
        avatar: person.get("profile").avatar.small,
        handle: person.get("diaspora_id")
      }, person.attributes));
    }, this);
  },

  updateContactIdsListInput: function() {
+1 −6
Original line number Diff line number Diff line
@@ -81,12 +81,7 @@ app.views.ProfileHeader = app.views.Base.extend({

  showMessageModal: function(){
    $("#conversationModal").on("modal:loaded", function() {
      new app.views.ConversationsForm({
        prefill: [_.extend({
          avatar: this.model.get("profile").avatar.small,
          handle: this.model.get("diaspora_id")
        }, this.model.attributes)]
      });
      new app.views.ConversationsForm({prefill: [this.model]});
    }.bind(this));
    app.helpers.showModal("#conversationModal");
  }
+2 −7
Original line number Diff line number Diff line
@@ -297,13 +297,8 @@ describe("app.pages.Contacts", function(){
      expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled();

      var prefill = app.views.ConversationsForm.prototype.initialize.calls.mostRecent().args[0].prefill;
      var people = app.contacts.filter(function(contact) { return contact.inAspect(app.aspect.get("id")); });
      expect(prefill.length).toBe(people.length);

      var person = app.contacts.first().person;
      expect(prefill[0].handle).toBe(person.get("diaspora_id"));
      expect(prefill[0].name).toBe(person.get("name"));
      expect(prefill[0].avatar).toBe(person.get("profile").avatar.small);
      var contacts = app.contacts.filter(function(contact) { return contact.inAspect(app.aspect.get("id")); });
      expect(_.pluck(prefill, "id")).toEqual(contacts.map(function(contact) { return contact.person.id; }));
    });
  });
});
Loading