Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some polishing in contacts screen

  • Loading branch information...
commit a5fcd4db91701d1227e9434b83bf16decb88ac8e 1 parent 9537e4b
@atd atd authored
View
3  app/assets/stylesheets/contacts.css
@@ -18,7 +18,8 @@ div.sphere-name {
color: #1F4A75;
}
-#contact-new {
+#relation-new {
+ margin-left: 20px;
font-weight: bold;
}
View
15 app/models/contact.rb
@@ -100,6 +100,21 @@ def relation_ids=(ids)
association(:relations).ids_writer(ids)
end
+ # Is this {Contact} +new+ or +edit+ for {SocialStream::Models::Subject subject} ?
+ #
+ # action is +new+ when, despite of being created, it has not {Tie ties} or it has a {Tie} with a
+ # {Relation::Public public relation}.
+ #
+ # The contact's action is +edit+ when it has any {Tie} with a {Relation::Custom custom relation}
+ #
+ def action
+ if ties_count > 0 && relations.where(:type => 'Relation::Custom').any?
+ 'edit'
+ else
+ 'new'
+ end
+ end
+
private
def remove_follower(ids)
View
4 app/views/contacts/_form.html.erb
@@ -34,7 +34,7 @@
<% end %>
</ul>
- <div id="contact-new">
+ <div id="relation-new">
<%= link_to t('contact.type.new'), relation_customs_path %>
</div>
@@ -44,7 +44,7 @@
</div>
<div id="contact-submit">
- <%= submit_tag t("contact.#{ controller.action_name }.submit"), :class => "button" %>
+ <%= submit_tag t("contact.#{ f.object.action }.submit"), :class => "button" %>
</div>
<% end %>
</div>
View
2  app/views/contacts/edit.html.erb
@@ -1,6 +1,6 @@
<% toolbar :profile => @contact.receiver_subject, :option => 'contacts' %>
<% location link_to(image_tag("btn/btn_friend.png", :class => "menu_icon") +
- t('contact.edit.title', :name => @contact.receiver.name), edit_contact_path(@contact.to_param)) %>
+ t("contact.#{ @contact.action }.title", :name => @contact.receiver.name), edit_contact_path(@contact.to_param)) %>
<%= render :partial => 'form' %>
Please sign in to comment.
Something went wrong with that request. Please try again.