Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use typeahead on conversations #7129

Closed
wants to merge 7 commits into from
Closed

Use typeahead on conversations #7129

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 30, 2016

Typeahead results:
screen shot 2016-09-30 at 14 15 46
Conversation with one recipiant:
screen shot 2016-09-30 at 14 09 30
When recipient tag is hovered:
screen shot 2016-09-30 at 14 09 47

@Flaburgan
Copy link
Member

Those are design propositions?

@ghost
Copy link
Author

ghost commented Sep 30, 2016

Yep. We can discuss the design of the tags.

@Flaburgan
Copy link
Member

I'll be in favour of keeping the design as close as possible of the mention one. Unifying, you know :p

@ghost
Copy link
Author

ghost commented Sep 30, 2016

Ready for review.

@svbergerem
Copy link
Member

I'd prefer a representation of the recipients that is similar to the representation in the dropdown: name and handle left aligned, the handle smaller than the name. The margins for the avatar should all be the same. (Currently the left margin is bigger.) I'd also like a smaller close icon that is in the right upper corner and uses an Entypo icon.

@ghost
Copy link
Author

ghost commented Oct 1, 2016

Yes, you're right, that's better:

screen shot 2016-10-01 at 08 51 54

But I prefer the close icon as it is, though:

screen shot 2016-10-01 at 08 59 11

@ghost
Copy link
Author

ghost commented Oct 3, 2016

BTW, the pills also show hovercard when hovered. I though it would be handy.
screen shot 2016-10-03 at 10 16 45

post :create, @hash
expect(response).not_to be_success
expect(response.body).to eq(I18n.t("conversations.create.fail"))
context "with nil contact" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary spacing detected.

@ghost
Copy link
Author

ghost commented Nov 1, 2016

Rebased and ready for another review.

Copy link
Member

@svbergerem svbergerem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good so far. I reviewed everything except for the tests.

this.bindTypeaheadEvents();

this.getTagListElement().empty();
if (opts.prefills) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I'd prefer opts.prefill.

});
$("#contact_ids").attr("aria-labelledby", "toLabel").focus();
addRecipient: function(person) {
var isRecipientAbsent = _(this.conversationRecipients).findIndex(_.matcher({handle: person.handle})) < 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already use customSearch so this shouldn't be necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep it because it is also used when prefilling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you add users more than once when prefilling the list of recipients?

Our mentions view also uses the custom search and we don't need the extra check there.
prefillMention:

prefillMention: function(persons) {

addPersonToMentions:
addPersonToMentions: function(person) {

$(evt.target).parents("form").submit();
}
},

onRemoveRecipient: function(evt) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removeRecipient since that's what this function does.


getTypeaheadElement: function() {
return this.$el.find("#contacts-search-input");
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with

this.typeaheadElement = this.$el.find("#contacts-search-input");

in initialize?


getContactsIdsListInput: function() {
return this.$el.find("#as-values-contact-ids");
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.contactsIdsListInput = this.$el.find("#as-values-contacts-ids");

@@ -0,0 +1,12 @@
<div class="conversation-recipient-tag clearfix btn btn-primary" data-diaspora-handle="{{ handle }}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a button so I don't like using the btn class here. Changing the color on hover and showing the cursor as a pointer gives me the impression that you can click on it to change something. I'd rather just have the same background as the primary buttons.

.form-group
%label#subject-label{for: "conversation-subject"}
= t(".subject")
%label#subject-label{for: "conversation-subject"}= t(".subject")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was more readable before.

.recipients-tag-list.clearfix#recipients-tag-list
= text_field_tag "contact_autocomplete", nil, id: "contacts-search-input", class: "form-control"
- unless defined?(mobile) && mobile
= text_field_tag "person_ids", nil, id: "as-values-contact-ids", type: "hidden",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why as-values-contact-ids? I thought as would be autoSuggest.

elsif params[:aspect_id]
@contact_ids = current_user.aspects.find(params[:aspect_id]).contacts.map{|c| c.id}.join(',')
gon.push conversation_prefill: current_user.aspects.find(params[:aspect_id]).contacts.map {|c| c.person.as_json }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these for the mobile view, too? Otherwise you could move this down into the else branch.

# This will have to be removed when mobile autocomplete is ported to Typeahead
recipients_param, column = [%i(contact_ids id), %i(person_ids person_id)].find {|param, _| params[param].present? }
if recipients_param
person_ids = current_user.contacts.where(column => params[recipients_param].split(",")).pluck(:person_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use current_user.contacts.mutual... here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno. @jhass wrote this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to #7002. The UI already doesn't allow you to create a conversation with non-mutual contacts and doing the same in the controller would be the next logical step.

But that would be another change of behavior that would need some additional tests. So I'd say let's keep it like it is and change it to mutual contacts later.

@ghost
Copy link
Author

ghost commented Nov 13, 2016

Done.

because the desktop view doesn't use the name parameter anymore
* append html to spec.content() instead of body
* don't append the unused conversations modal fixture
* actually test that showModal has been called
* test that tag element are removed when clicking the tag's remove button
* append html to spec.content() instead of body
* don't append the unused conversations modal fixture
* actually test that showModal has been called
@SuperTux88 SuperTux88 added this to the 0.6.2.0 milestone Nov 13, 2016
@SuperTux88
Copy link
Member

Merged.

Thanks @AugierLe42e and @svbergerem for the work!

@ghost ghost deleted the port-conversations-typeahead branch November 13, 2016 20:19
@Flaburgan
Copy link
Member

Awesome work guys :D

@SansPseudoFix
Copy link
Contributor

Nice!
Fixes #5091, no?

@svbergerem
Copy link
Member

@SansPseudoFix Yes, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants