Skip to content

Commit

Permalink
Improvements in contact new and edit
Browse files Browse the repository at this point in the history
  • Loading branch information
atd committed Jun 1, 2011
1 parent 2021bbf commit f26dadc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def suggestion(options = {})

# Set of ties sent by this actor received by a
def ties_to(a)
sent_ties.received_by(a)
sent_ties.received_by(a).intended
end

# Get the first of the ties created to a, or create a new one with the {Relation::Public}
Expand Down
4 changes: 4 additions & 0 deletions app/models/tie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
# integer, array
# replied:: ties having at least another tie in the other way, a tie from a to b
# is replied if there is a tie from b to a
# intended:: ties can be desactivated by subjects when they change their connections.
# This scope gathers the active ones
#
class Tie < ActiveRecord::Base
# Facilitates relation assigment along with find_relation callback
Expand Down Expand Up @@ -107,6 +109,8 @@ class Tie < ActiveRecord::Base
joins(:relation).where('relations.type' => 'Relation::Public')
}

scope :intended, where(:intended => true)

validates_presence_of :sender_id, :receiver_id, :relation

before_validation :find_or_build_relation
Expand Down
11 changes: 8 additions & 3 deletions app/views/contacts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@
</div>
</li>
<% end %>
<% end %>
</ul>
</dd>
</li>
<% end %>
<li class="new_sphere"><span class="sphere_name"><%= link_to t('contact.type.new'), spheres_path %></span></li>

</ul>

</dd>

</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/toolbar/_profile_menu_tie_options.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<% if current_subject.ties_to(subject).present? %>
<li >
<%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") +
t('tie.edit.contact', :type => current_subject.ties_to(subject).map(&:relation_name).join(", ")),
current_subject.ties_to(subject).map(&:relation_name).join(", "),
edit_contact_path(subject.actor_id) %>
</li>
<% else %>
<li >
<%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon") +
t('tie.add.contact'),
t('contact.new.title'),
edit_contact_path(subject.actor_id),
:id => 'contacts_menu' %>
</li>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ en:
one: "Suggestion"
other: "Suggestions"
all: "All"
type:
new: "New type"
copyright: "2010 Copyright - All rights reserved"
days: Days
delete:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ span.ui-radio-state-checked-hover {
}


li.sphere_name {
li.sphere_name, li.new_sphere {
background-color: #1F4A75;
padding: 5px;
text-align: left;
}

span.sphere_name{
span.sphere_name, span.sphere_name a{
color: white;
}

Expand Down

0 comments on commit f26dadc

Please sign in to comment.