Move person extension for prefills to conversations form view
closes #7599
This commit is contained in:
parent
48630b3a04
commit
02d9d350d9
8 changed files with 34 additions and 33 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
* Fix S3 support [#7566](https://github.com/diaspora/diaspora/pull/7566)
|
* 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)
|
* 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)
|
* 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
|
## Features
|
||||||
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
||||||
|
|
|
||||||
|
|
@ -80,14 +80,9 @@ app.pages.Contacts = Backbone.View.extend({
|
||||||
|
|
||||||
showMessageModal: function(){
|
showMessageModal: function(){
|
||||||
$("#conversationModal").on("modal:loaded", 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"));
|
return contact.inAspect(app.aspect.get("id"));
|
||||||
}).map(function(contact) {
|
}), "person");
|
||||||
return _.extend({
|
|
||||||
avatar: contact.person.get("profile").avatar.small,
|
|
||||||
handle: contact.person.get("diaspora_id")
|
|
||||||
}, contact.person.attributes);
|
|
||||||
});
|
|
||||||
new app.views.ConversationsForm({prefill: people});
|
new app.views.ConversationsForm({prefill: people});
|
||||||
});
|
});
|
||||||
app.helpers.showModal("#conversationModal");
|
app.helpers.showModal("#conversationModal");
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,13 @@ app.views.ConversationsForm = app.views.Base.extend({
|
||||||
this.setupAvatarFallback(personEl);
|
this.setupAvatarFallback(personEl);
|
||||||
},
|
},
|
||||||
|
|
||||||
prefill: function(handles) {
|
prefill: function(people) {
|
||||||
handles.forEach(this.addRecipient.bind(this));
|
people.forEach(function(person) {
|
||||||
|
this.addRecipient(_.extend({
|
||||||
|
avatar: person.get("profile").avatar.small,
|
||||||
|
handle: person.get("diaspora_id")
|
||||||
|
}, person.attributes));
|
||||||
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateContactIdsListInput: function() {
|
updateContactIdsListInput: function() {
|
||||||
|
|
|
||||||
|
|
@ -81,12 +81,7 @@ app.views.ProfileHeader = app.views.Base.extend({
|
||||||
|
|
||||||
showMessageModal: function(){
|
showMessageModal: function(){
|
||||||
$("#conversationModal").on("modal:loaded", function() {
|
$("#conversationModal").on("modal:loaded", function() {
|
||||||
new app.views.ConversationsForm({
|
new app.views.ConversationsForm({prefill: [this.model]});
|
||||||
prefill: [_.extend({
|
|
||||||
avatar: this.model.get("profile").avatar.small,
|
|
||||||
handle: this.model.get("diaspora_id")
|
|
||||||
}, this.model.attributes)]
|
|
||||||
});
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
app.helpers.showModal("#conversationModal");
|
app.helpers.showModal("#conversationModal");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -297,13 +297,8 @@ describe("app.pages.Contacts", function(){
|
||||||
expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled();
|
expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled();
|
||||||
|
|
||||||
var prefill = app.views.ConversationsForm.prototype.initialize.calls.mostRecent().args[0].prefill;
|
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")); });
|
var contacts = app.contacts.filter(function(contact) { return contact.inAspect(app.aspect.get("id")); });
|
||||||
expect(prefill.length).toBe(people.length);
|
expect(_.pluck(prefill, "id")).toEqual(contacts.map(function(contact) { return contact.person.id; }));
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,11 @@ describe("app.views.ConversationsForm", function() {
|
||||||
|
|
||||||
describe("prefill", function() {
|
describe("prefill", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.prefills = [{name: "diaspora user"}, {name: "other diaspora user"}, {name: "user"}];
|
this.prefills = [
|
||||||
|
factory.personWithProfile({"diaspora_id": "alice@pod.tld"}),
|
||||||
|
factory.personWithProfile({"diaspora_id": "bob@pod.tld"}),
|
||||||
|
factory.personWithProfile({"diaspora_id": "carol@pod.tld"})
|
||||||
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls addRecipient for each prefilled participant", function() {
|
it("calls addRecipient for each prefilled participant", function() {
|
||||||
|
|
@ -95,7 +99,14 @@ describe("app.views.ConversationsForm", function() {
|
||||||
var allArgsFlattened = app.views.ConversationsForm.prototype.addRecipient.calls.allArgs().map(function(arg) {
|
var allArgsFlattened = app.views.ConversationsForm.prototype.addRecipient.calls.allArgs().map(function(arg) {
|
||||||
return arg[0];
|
return arg[0];
|
||||||
});
|
});
|
||||||
expect(allArgsFlattened).toEqual(this.prefills);
|
|
||||||
|
expect(_.pluck(allArgsFlattened, "handle")).toEqual(
|
||||||
|
this.prefills.map(function(person) { return person.get("diaspora_id"); })
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(_.pluck(allArgsFlattened, "avatar")).toEqual(
|
||||||
|
this.prefills.map(function(person) { return person.get("profile").avatar.small; })
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,9 @@ describe("app.views.ProfileHeader", function() {
|
||||||
spyOn(app.views.ConversationsForm.prototype, "initialize");
|
spyOn(app.views.ConversationsForm.prototype, "initialize");
|
||||||
spyOn($.fn, "load").and.callFake(function(url, callback) { callback(); });
|
spyOn($.fn, "load").and.callFake(function(url, callback) { callback(); });
|
||||||
this.view.showMessageModal();
|
this.view.showMessageModal();
|
||||||
expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled();
|
expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalledWith({
|
||||||
var prefill = app.views.ConversationsForm.prototype.initialize.calls.mostRecent().args[0].prefill;
|
prefill: [this.model]
|
||||||
expect(prefill.length).toBe(1);
|
});
|
||||||
expect(prefill[0].handle).toBe("my@pod");
|
|
||||||
expect(prefill[0].name).toBe("User Name");
|
|
||||||
expect(prefill[0].avatar).toBe("http://example.org/avatar.jpg");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -138,9 +138,11 @@ var factory = {
|
||||||
"full_name": "bob grimm",
|
"full_name": "bob grimm",
|
||||||
"gender": "robot",
|
"gender": "robot",
|
||||||
"id": id,
|
"id": id,
|
||||||
"image_url": "http://localhost:3000/assets/user/default.png",
|
"avatar": {
|
||||||
"image_url_medium": "http://localhost:3000/assets/user/default.png",
|
"small": "http://localhost:3000/assets/user/default.png",
|
||||||
"image_url_small": "http://localhost:3000/assets/user/default.png",
|
"medium": "http://localhost:3000/assets/user/default.png",
|
||||||
|
"large": "http://localhost:3000/assets/user/default.png"
|
||||||
|
},
|
||||||
"last_name": "Grimm",
|
"last_name": "Grimm",
|
||||||
"location": "Earth",
|
"location": "Earth",
|
||||||
"nsfw": false,
|
"nsfw": false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue