social_stream 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/app/controllers/activities_controller.rb +1 -0
  2. data/app/controllers/avatars_controller.rb +17 -10
  3. data/app/controllers/comments_controller.rb +2 -0
  4. data/app/controllers/conversations_controller.rb +98 -103
  5. data/app/controllers/groups_controller.rb +3 -1
  6. data/app/controllers/likes_controller.rb +2 -0
  7. data/app/controllers/messages_controller.rb +4 -0
  8. data/app/controllers/posts_controller.rb +2 -2
  9. data/app/controllers/ties_controller.rb +6 -0
  10. data/app/helpers/subjects_helper.rb +32 -7
  11. data/app/helpers/ties_helper.rb +7 -2
  12. data/app/models/activity.rb +1 -1
  13. data/app/models/actor.rb +5 -8
  14. data/app/models/relation.rb +65 -0
  15. data/app/models/tie.rb +27 -7
  16. data/app/views/activities/_child.html.erb +1 -5
  17. data/app/views/activities/_root.html.erb +2 -4
  18. data/app/views/avatars/_form.html.erb +5 -16
  19. data/app/views/avatars/_precrop.html.erb +24 -17
  20. data/app/views/avatars/index.html.erb +47 -36
  21. data/app/views/avatars/new.html.erb +19 -3
  22. data/app/views/contacts/index.html.erb +1 -1
  23. data/app/views/contacts/index.js.erb +2 -0
  24. data/app/views/conversations/_conversation_full.html.erb +2 -1
  25. data/app/views/conversations/_index.html.erb +0 -7
  26. data/app/views/conversations/_show.html.erb +0 -7
  27. data/app/views/conversations/index.html.erb +9 -1
  28. data/app/views/conversations/index.js.erb +1 -0
  29. data/app/views/conversations/show.html.erb +1 -1
  30. data/app/views/conversations/show.js.erb +2 -0
  31. data/app/views/groups/_new.html.erb +9 -2
  32. data/app/views/groups/new.html.erb +5 -1
  33. data/app/views/layouts/_header.erb +23 -1
  34. data/app/views/layouts/_representation.html.erb +1 -1
  35. data/app/views/messages/new.html.erb +1 -1
  36. data/app/views/messages/new.js.erb +3 -0
  37. data/app/views/profiles/_profile.html.erb +18 -13
  38. data/app/views/profiles/edit.html.erb +29 -4
  39. data/app/views/profiles/update.js.erb +3 -3
  40. data/app/views/subjects/_toolbar_home_menu_options.html.erb +1 -1
  41. data/app/views/subjects/_toolbar_home_menu_options_subjects.html.erb +2 -2
  42. data/app/views/subjects/_toolbar_logo.html.erb +14 -2
  43. data/app/views/subjects/_toolbar_message_menu.html.erb +1 -1
  44. data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +18 -7
  45. data/app/views/ties/_edit.html.erb +102 -0
  46. data/app/views/ties/_new.html.erb +48 -19
  47. data/app/views/ties/edit.html.erb +1 -0
  48. data/config/locales/en.yml +42 -27
  49. data/config/routes.rb +0 -6
  50. data/lib/generators/social_stream/templates/public/images/btn/arrowBlue.png +0 -0
  51. data/lib/generators/social_stream/templates/public/images/btn/shadow.png +0 -0
  52. data/lib/generators/social_stream/templates/public/javascripts/addContact.js +100 -0
  53. data/lib/generators/social_stream/templates/public/javascripts/avatars.js +8 -0
  54. data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +84 -0
  55. data/lib/generators/social_stream/templates/public/javascripts/main.js +10 -1
  56. data/lib/generators/social_stream/templates/public/javascripts/menu.js +22 -6
  57. data/lib/generators/social_stream/templates/public/stylesheets/default/activities.css +2 -2
  58. data/lib/generators/social_stream/templates/public/stylesheets/default/addContact.css +29 -0
  59. data/lib/generators/social_stream/templates/public/stylesheets/default/avatars.css +79 -0
  60. data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +44 -5
  61. data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +151 -1
  62. data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -1
  63. data/lib/generators/social_stream/templates/public/stylesheets/default/jquery-ui.css +1 -1
  64. data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +6 -4
  65. data/lib/social_stream.rb +1 -1
  66. data/lib/social_stream/ability.rb +20 -0
  67. data/lib/social_stream/models/subject.rb +5 -1
  68. data/lib/social_stream/test_helpers/controllers.rb +55 -0
  69. data/lib/social_stream/version.rb +1 -1
  70. data/social_stream.gemspec +1 -1
  71. data/spec/controllers/comments_controller_spec.rb +38 -0
  72. data/spec/controllers/groups_controller_spec.rb +75 -5
  73. data/spec/factories/comment.rb +4 -0
  74. data/spec/models/tie_spec.rb +25 -15
  75. metadata +18 -10
  76. data/app/controllers/pshb_controller.rb +0 -55
  77. data/app/views/ties/new.js.erb +0 -12
  78. data/lib/social_stream/relations.rb +0 -46
@@ -1,15 +1,8 @@
1
- <% content_for :headers do %>
2
- <%= stylesheet_link_tag "messages.css", :media => "screen, projection" %>
3
- <% end %>
4
-
5
1
  <%= location(
6
2
  link_to(image_tag("btn/message_" + @box + ".png", :class => "menu_icon")+t('message.' + @box), conversations_path(:box => @box),:remote => true)
7
3
  ) %>
8
4
 
9
5
 
10
- <% content_for :javascript do %>
11
- $('.pagination a').attr('data-remote', 'true');
12
- <% end %>
13
6
 
14
7
  <br class="clearfloat" />
15
8
  <div class="space_center">
@@ -7,13 +7,6 @@
7
7
  <br class="clearfloat" />
8
8
  <div class="space_center">
9
9
  </div>
10
- <div id="new_message">
11
- <% if @box.present? %>
12
- <%= link_to 'Back', conversations_path(:box => @box, :page => params[:page]), :remote => true %>
13
- <% else %>
14
- <%= link_to 'Back', conversations_path(:page => params[:page]), :remote => true %>
15
- <% end %>
16
- </div>
17
10
  <div class="space_center">
18
11
  </div>
19
12
  <div class="conversation_full">
@@ -2,6 +2,14 @@
2
2
  <%= render :partial => 'home/sidebar' %>
3
3
  <% end %>
4
4
 
5
- <% toolbar %>
5
+ <% content_for :headers do %>
6
+ <%= stylesheet_link_tag "messages.css", :media => "screen, projection" %>
7
+ <% end %>
8
+
9
+ <% content_for :javascript do %>
10
+ $('.pagination a').attr('data-remote', 'true');
11
+ <% end %>
12
+
13
+ <% toolbar :option => :messages %>
6
14
 
7
15
  <%= render :partial => 'index' %>
@@ -5,3 +5,4 @@ $('.pagination a').attr('data-remote', 'true');
5
5
 
6
6
  $("head").append($("<%= escape_javascript(stylesheet_link_tag "messages.css", :media => "screen, projection") %>"));
7
7
 
8
+ <%= toolbar :option => :messages %>
@@ -2,7 +2,7 @@
2
2
  <%= render :partial => 'home/sidebar' %>
3
3
  <% end %>
4
4
 
5
- <% toolbar %>
5
+ <% toolbar :option => :messages %>
6
6
 
7
7
  <% content_for :headers do %>
8
8
  <%= stylesheet_link_tag "messages.css", :media => "screen, projection" %>
@@ -4,6 +4,8 @@ $("head").append($("<%= escape_javascript(stylesheet_link_tag "messages.css", :m
4
4
 
5
5
  $("head").append($("<%= escape_javascript(javascript_include_tag 'ckeditor/ckeditor.js','ckeditor/adapters/jquery.js','jquery.scrollTo.min.js', 'jquery.validate') %>"));
6
6
 
7
+ <%= toolbar :option => :messages %>
8
+
7
9
  $('.cont_conversation').validate();
8
10
  <% unless @box.eql?'trash' %>
9
11
  $('#body').ckeditor(
@@ -17,6 +17,12 @@
17
17
  });
18
18
  <% end %>
19
19
 
20
+ <%= location(
21
+ link_to(image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.other'), groups_path),
22
+ link_to(image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.new.action'), new_group_path('group' => { '_founder' => current_subject.slug }))
23
+ ) %>
24
+ <div class="space_center"></div>
25
+
20
26
  <%= form_for @group do |f| %>
21
27
  <% f.object._founder = current_subject.slug %>
22
28
  <%= f.hidden_field :_founder %>
@@ -34,9 +40,10 @@
34
40
  </div>
35
41
  <% end %>
36
42
  <div class="block">
37
- <div class="form_row center">
43
+ <div class="form_row">
38
44
  <h2><%= t('group.new.action') %></h2>
39
- </div>
45
+ </div>
46
+ <div class="space_center"></div>
40
47
  <div class="form_row">
41
48
  <div class="form_label">
42
49
  <%= f.label t('group.new.name') %>
@@ -3,6 +3,10 @@
3
3
  <%= javascript_include_tag 'jquery.fcbkcomplete.min', 'jquery.validate' %>
4
4
  <% end %>
5
5
 
6
- <% toolbar%>
6
+ <% toolbar :option => 'groups' %>
7
+
8
+ <% content_for :sidebar do %>
9
+ <%= render :partial => "sidebar_index" %>
10
+ <% end %>
7
11
 
8
12
  <%= render :partial => 'new' %>
@@ -1,3 +1,6 @@
1
+ <% content_for :headers do %>
2
+ <%= javascript_include_tag 'hoverIntent','superfish' %>
3
+ <% end %>
1
4
  <div id="headerFront">
2
5
  <div class="banner_top banner_top_height">
3
6
  <div id="header_left">
@@ -18,9 +21,28 @@
18
21
  </div>
19
22
  <div id="header_right">
20
23
  <% if user_signed_in? %>
24
+ <div id="account">
25
+ <ul class="sf-menu">
26
+ <li class="current" >
27
+ <%# link_to t('account.one')+ '<span class='+'sf-sub-indicator> »</span>' , '#' , :class=>"sf-with-ul" %>
28
+ <a href="#" class="sf-with-ul" id="btn_menu_config">Account<span class="sf-sub-indicator"> »</span></a>
29
+
30
+ <ul>
31
+ <li>
32
+ <%= link_to 'Configurations', '#' %>
33
+ </li>
34
+ <li>
35
+ <%= link_to 'Notifications', '#' %>
36
+ </li>
37
+ <li class="current">
38
+ <%= link_to 'Privacy', '#' %>
39
+ </li>
40
+ </ul>
41
+ </li>
42
+ </ul>
43
+ </div>
21
44
  <div class="menu_list menu_white" id="menu_account">
22
45
  <ul>
23
- <li class="btn_menu_config"><%= link_to t('account.one'), '#' %></li>
24
46
  <li class="pipe">|</li>
25
47
  <li class="pipe"><%= render :partial => 'layouts/representation' %></li>
26
48
  <li class="pipe"> | </li>
@@ -3,7 +3,7 @@
3
3
  <%= link_to(current_user.name, current_user) %>
4
4
  <%= t('representation.action') %>
5
5
  <%= form_for(Representation.new(current_subject), :url => representation_path) do |f| %>
6
- <%= f.select :subject_dom_id, current_user.represented.unshift(current_user).map{ |s| [ s.name, dom_id(s) ] } %>
6
+ <%= f.select :subject_dom_id, current_user.represented.unshift(current_user).map{ |s| [ s.name, dom_id(s) ] }, :class=>"button" %>
7
7
  <%= f.submit t('representation.change') %>
8
8
  <% end %>
9
9
 
@@ -2,7 +2,7 @@
2
2
  <%= render :partial => 'home/sidebar' %>
3
3
  <% end %>
4
4
 
5
- <% toolbar %>
5
+ <% toolbar :option => :messages %>
6
6
 
7
7
  <% content_for :headers do %>
8
8
  <%= stylesheet_link_tag "messages.css", :media => "screen, projection" %>
@@ -5,6 +5,9 @@ $("head").append($("<%= escape_javascript(stylesheet_link_tag "fcbkComplete.css"
5
5
 
6
6
  $("head").append($("<%= escape_javascript(javascript_include_tag 'jquery.fcbkcomplete.min','jquery.validate','ckeditor/ckeditor.js','ckeditor/adapters/jquery.js') %>"));
7
7
 
8
+ <%= toolbar :option => :messages %>
9
+
10
+
8
11
  var recipients = $("#_recipients").fcbkcomplete({
9
12
  json_url: "<%= contacts_path(:format => :json) %>",
10
13
  cache: true,
@@ -1,8 +1,13 @@
1
+ <%= location(
2
+ link_to(image_tag("btn/btn_edit.png", :class => "menu_icon")+t('menu.information'), [current_subject, :profile])
3
+ ) %>
4
+ <div class="space_center"></div>
5
+ <h2><%=t('menu.information')%></h2>
1
6
  <div class="space_center"></div>
2
7
  <div class="block" id="personal_info" >
3
8
  <div class="header">
4
9
  <div class="header_text">
5
- <%=t('profile.' + current_subject.class.to_s.downcase + '.info')%>
10
+ <%=t('profile.' + @profile.subject.class.to_s.downcase + '.info')%>
6
11
  </div>
7
12
  <div class="header_icon_right">
8
13
  <%= link_to (image_tag('/images/btn/edit.png')), :controller => :profiles , :action => :edit, :section => "about_me"%>
@@ -147,7 +152,7 @@
147
152
  <div class="block" id="experience_info">
148
153
  <div class="header">
149
154
  <div class="header_text">
150
- <%=t('profile.' + current_subject.class.to_s.downcase + '.experience')%>
155
+ <%=t('profile.' + @profile.subject.class.to_s.downcase + '.experience')%>
151
156
  </div>
152
157
  <div class="header_icon_right">
153
158
  <%= link_to (image_tag('/images/btn/edit.png')), :controller => :profiles , :action => :edit, :section => "my_experience"%>
@@ -180,15 +185,15 @@
180
185
  <% end %>
181
186
  <div class="space_center"></div>
182
187
  <% if (@profile.to_param==current_user.to_param and @profile.authentication_token) %>
183
- <div class="block" id="developer_info">
184
- <div class="header">
185
- <div class="header_text">
186
- ApiKey: <%= @profile.authentication_token %>
187
- </div>
188
- <div class="header_icon_right">
189
- <%= link_to (image_tag('/images/btn/edit.png')), :controller => :api,
190
- :action => :create_key %>
191
- </div>
192
- </div>
193
- </div>
188
+ <div class="block" id="developer_info">
189
+ <div class="header">
190
+ <div class="header_text">
191
+ ApiKey: <%= @profile.authentication_token %>
192
+ </div>
193
+ <div class="header_icon_right">
194
+ <%= link_to (image_tag('/images/btn/edit.png')), :controller => :api,
195
+ :action => :create_key %>
196
+ </div>
197
+ </div>
198
+ </div>
194
199
  <% end %>
@@ -15,9 +15,32 @@
15
15
  });
16
16
  <% end %>
17
17
 
18
+ <%if params[:section].present?
19
+ case params[:section]
20
+ when "about_me"
21
+ level2 = link_to(image_tag("btn/edit.png", :class => "menu_icon")+t('profile.' + current_subject.class.to_s.downcase + '.info'),
22
+ :controller => :profiles , :action => :edit, :section => "about_me")
23
+ when "contact_info"
24
+ level2 = link_to(image_tag("btn/edit.png", :class => "menu_icon")+t('profile.contact'),
25
+ :controller => :profiles , :action => :edit, :section => "contact_info")
26
+ when "my_experience"
27
+ level2 = link_to(image_tag("btn/edit.png", :class => "menu_icon")+t('profile.' + current_subject.class.to_s.downcase + '.experience'),
28
+ :controller => :profiles , :action => :edit, :section => "my_experience")
29
+ end
30
+ else
31
+ level2 = link_to(image_tag("btn/edit.png", :class => "menu_icon")+t('profile.one'),
32
+ :controller => :profiles , :action => :edit)
33
+ end %>
34
+
35
+ <%= location(
36
+ link_to(image_tag("btn/btn_edit.png", :class => "menu_icon")+t('menu.information'), [current_subject, :profile]),
37
+ level2
38
+ ) %>
39
+ <div class="space_center"></div>
40
+
18
41
  <%= form_for(@profile, :url => [current_subject, :profile], :remote => true) do |f| %>
19
42
 
20
- <div class="block">
43
+ <div class="block" id="profile_form">
21
44
  <% if !params[:section].present? or params[:section].eql?("about_me") %>
22
45
  <% content_for :javascript do %>
23
46
  $(function () {
@@ -156,11 +179,13 @@
156
179
  <% end %>
157
180
 
158
181
  <% if params[:section].present? %>
159
- <%= hidden_field_tag("section", params[:section]) %>
182
+ <%= hidden_field_tag("section", params[:section]) %>
160
183
  <% end %>
161
184
  <div class="form_row space_center">
162
- <%= f.submit "Update", :class => "button" %>&nbsp;
163
- <button class="button" onclick="window.location.href='<%= polymorphic_path(current_subject) %>';">Cancel</button>
185
+ <%= f.submit t('button.update'), :class => "button" %>&nbsp;
186
+ <button class="button" onclick="window.location.href='<%= polymorphic_path(current_subject) %>';">
187
+ <%= t('button.cancel')%>
188
+ </button>
164
189
  </div>
165
190
 
166
191
  <% end %>
@@ -1,11 +1,11 @@
1
1
 
2
2
  if ($("#profile_notice").length == 0){
3
- $("#content").prepend('<div id="profile_notice" class="notice"></div>');
3
+ $("#profile_form").prepend('<div id="profile_notice" class="notice"></div>');
4
4
  }
5
5
 
6
6
  <% if @profile.valid? %>
7
7
 
8
- $("#profile_notice").html("<h2>Form Submitted!</h2><br/>");
8
+ $("#profile_notice").html("<h2>Form Submitted!</h2>");
9
9
  $("#profile_notice").removeClass('error');
10
10
  $("#profile_notice").addClass('success');
11
11
 
@@ -32,7 +32,7 @@
32
32
 
33
33
  <% else %>
34
34
  $("#profile_notice").html("<h2><%= pluralize(@profile.errors.count, "error") %> prohibited this profile from being saved:</h2>"
35
- +"<ul><% @profile.errors.full_messages.each do |msg| %><li><%= msg %></li><% end %></ul><br/>");
35
+ +"<ul><% @profile.errors.full_messages.each do |msg| %><li><%= msg %></li><% end %></ul>");
36
36
  $("#profile_notice").removeClass('success');
37
37
  $("#profile_notice").addClass('error');
38
38
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  <%= menu_options[:contacts] || capture do %>
8
8
  <li>
9
- <%= link_to( image_tag("btn/btn_friend.png", :class => "menu_icon")+t('contact.other'), '#') %>
9
+ <%= link_to( image_tag("btn/btn_friend.png", :class => "menu_icon")+t('contact.other'), '#', :id => "contacts_menu") %>
10
10
  <ul>
11
11
  <% current_subject.relations.sort.each do |r| %>
12
12
  <li>
@@ -1,9 +1,9 @@
1
1
  <%= menu_options[:groups] || capture do %>
2
2
  <li>
3
- <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.other'), '#') %>
3
+ <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.other'), '#', :id => "groups_menu") %>
4
4
  <ul>
5
5
  <li>
6
- <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.new.action'), new_group_path) %>
6
+ <%= link_to( image_tag("btn/btn_group.png", :class => "menu_icon")+t('group.new.action'), new_group_path('group' => { '_founder' => current_subject.slug })) %>
7
7
  </li>
8
8
  </ul>
9
9
  </li>
@@ -1,4 +1,16 @@
1
1
  <div id="logo_index">
2
- <div class="center"><span class="title_bold" ><%= subject.name %></span></div>
3
- <%= link_to image_tag(subject.logo.url, :alt => subject.name , :size => "119x108"), subject %>
2
+ <% if subject == current_subject %>
3
+ <div class="center">
4
+ <span class="title_bold" ><%= subject.name %></span>
5
+ <div class="logo_grid logo_full">
6
+ <%= link_to image_tag(subject.logo.url, :alt => subject.name , :size => "119x119"), subject %>
7
+ <div class="logo_menu logo_caption">
8
+ <%= link_to t('avatar.profile_change'), avatars_path %>
9
+ </div>
10
+ </div>
11
+ </div>
12
+ <% else %>
13
+ <div class="center"><span class="title_bold" ><%= subject.name %></span></div>
14
+ <%= link_to image_tag(subject.logo.url, :alt => subject.name , :size => "119x119"), subject %>
15
+ <% end %>
4
16
  </div>
@@ -1,5 +1,5 @@
1
1
  <li>
2
- <%= link_to( image_tag("btn/new.png", :class => "menu_icon")+t('message.other'), '#') %>
2
+ <%= link_to( image_tag("btn/new.png", :class => "menu_icon")+t('message.other'), '#', :id => "messages_menu") %>
3
3
  <ul>
4
4
  <li>
5
5
  <%= link_to( image_tag("btn/message_new.png", :class => "menu_icon")+ t('message.new'), new_message_path) %>
@@ -9,17 +9,28 @@
9
9
  <% if user_signed_in? %>
10
10
  <% if current_subject.ties_to(subject).present? %>
11
11
  <li >
12
- <%= link_to(image_tag("btn/btn_friend.png", :class => "menu_icon")+t('tie.edit.contact', :type => current_subject.ties_to(subject).first.relation_name), '#') %>
12
+ <%= link_to image_tag("btn/btn_friend.png", :class => "menu_icon")+t('tie.edit.contact', :type => current_subject.ties_to(subject).first.relation_name), edit_tie_path(current_subject.ties_to(subject).first) %>
13
13
  </li>
14
14
  <% else %>
15
15
  <li >
16
- <%= link_to(image_tag("btn/btn_friend.png", :class => "menu_icon")+t('tie.add.contact'), '#') %>
17
- </li>
16
+ <%= link_to(image_tag("btn/btn_friend.png", :class => "menu_icon")+t('tie.add.contact'), '#', :id => 'contacts_menu') %>
17
+ <ul>
18
+ <% current_subject.relations.sort.each do |r| %>
19
+ <li>
20
+ <%= link_to image_tag("btn/twitter-follow-icon.png", :size => "19x19", :class => "menu_icon") + r.name,
21
+ ties_path('tie[sender_id]' => current_subject.actor_id,
22
+ 'tie[receiver_id]' => subject.actor_id,
23
+ 'tie[relation_id]' => r.id),
24
+ :method => :post %>
25
+ </li>
18
26
 
19
- <li>
20
- <li>
21
- <%= link_to(image_tag("btn/twitter-follow-icon.png", :size => "19x19", :class => "menu_icon")+t('tie.add.follow'), '#') %>
22
- </li>
27
+ <% end %>
28
+ <li>
29
+ <%= link_to image_tag("btn/twitter-follow-icon.png", :size => "19x19", :class => "menu_icon") + t('tie.relation.new'),
30
+ new_tie_path('tie[sender_id]' => current_subject.actor_id,
31
+ 'tie[receiver_id]' => subject.actor_id) %>
32
+ </li>
33
+ </ul>
23
34
  </li>
24
35
  <% end %>
25
36
  <% end %>
@@ -0,0 +1,102 @@
1
+ <% content_for :headers do %>
2
+ <%= stylesheet_link_tag "addContact.css", :media => "screen, projection" %>
3
+ <%= javascript_include_tag 'addContact'%>
4
+ <% end %>
5
+
6
+ <% toolbar :profile => @tie.receiver_subject, :option => 'contacts' %>
7
+
8
+ <% read_starTies_activity_id = get_permission_id("read","star_ties","activity") %>
9
+ <% follow_id = get_permission_id("follow",nil,nil) %>
10
+ <% create_tie_activity_id = get_permission_id("create","tie","activity") %>
11
+
12
+ <% content_for :javascript do %>
13
+ $(document).ready(function() {
14
+ defaultRelations = ["friend","acquaintance","public"]
15
+
16
+ relation_name = "<%=@tie.relation.name%>";
17
+ $(".dropdown dt a span").html(relation_name);
18
+ $('input[name$="tie[relation_name]"]').val(relation_name);
19
+
20
+ if (defaultRelations.indexOf(relation_name)==-1){
21
+
22
+ //Rellenar relations
23
+ var allowRead_starTies_activity = <%=(@tie.relation.permissions.find_by_id(read_starTies_activity_id)!=nil)%>
24
+ var allowFollow = <%=(@tie.relation.permissions.find_by_id(follow_id)!=nil)%>
25
+ var allowCreate_tie_activity = <%=(@tie.relation.permissions.find_by_id(create_tie_activity_id)!=nil)%>
26
+
27
+ if(allowRead_starTies_activity){
28
+ $("#<%= read_starTies_activity_id %>").attr('checked',true);
29
+ }
30
+
31
+ if(allowFollow){
32
+ $("#<%= follow_id %>").attr('checked',true);
33
+ }
34
+
35
+ if(allowCreate_tie_activity){
36
+ $("#<%= create_tie_activity_id %>").attr('checked',true);
37
+ }
38
+
39
+ $("#relationPermissions").show();
40
+ }
41
+
42
+ });
43
+ <% end %>
44
+
45
+ <div class="dialog_add_tie" id="new_tie">
46
+ <div class="content_add_user" >
47
+ <div class="activity_add_ties">
48
+
49
+
50
+ <%= location(
51
+ link_to(image_tag("btn/btn_friend.png", :class => "menu_icon")+t('tie.edit.title'), edit_tie_path,:remote => true)
52
+ ) %>
53
+
54
+ <%= form_for @tie do |f| %>
55
+ <%= f.hidden_field :receiver_id %>
56
+ <%= f.hidden_field :sender_id %>
57
+ <%= f.hidden_field :relation_name %>
58
+
59
+ <div class="block">
60
+
61
+ <div class="form_row center">
62
+ <h2> <%= t('tie.edit.title') %> </h2>
63
+ </div>
64
+ <div class="two_columns_container">
65
+ <div class="form_column_left">
66
+ <p class="colum_field_title"><%= t('message.one') %></p>
67
+ <%= f.text_area :message, :class =>"new_tie_text_area" %>
68
+ </div>
69
+
70
+ <div class="form_column_right">
71
+ <div class="select_relations">
72
+ <div id="relationsSelect" class="dropdown">
73
+ <dt><a href="#"><span><%= t('tie.relation.one') %></span></a></dt>
74
+ <dd>
75
+ <ul>
76
+ <% (@tie.sender.relations.sort.map{ |r| [ r.name] }).each do |relationArray| %>
77
+ <li><a href="#" class="option"><%=relationArray[0]%><span class="value"><%=relationArray[0]%></span></a></li>
78
+ <% end %>
79
+ <li><a href="#" class="input_link">
80
+ <span class="value"></span>
81
+ <input type="text" class="input_select"/>
82
+ </a></li>
83
+ </ul>
84
+ </dd>
85
+ </div>
86
+ </div>
87
+
88
+ <div id="relationPermissions">
89
+ <p class="relationPermision"><input type="checkbox" id="<%=read_starTies_activity_id%>" class="checkbox_permission" name="tie[relation_permissions][]" value="<%=read_starTies_activity_id%>"> <%= t('permissions.read.activity.star_ties', :user=> @tie.receiver.name) %></p>
90
+ <p class="relationPermision"><input type="checkbox" id="<%=follow_id%>" class="checkbox_permission" name="tie[relation_permissions][]" value="<%=follow_id%>"> <%= t('permissions.follow', :user=> @tie.receiver.name) %></p>
91
+ <p class="relationPermision"><input type="checkbox" id="<%=create_tie_activity_id%>" class="checkbox_permission" name="tie[relation_permissions][]" value="<%=create_tie_activity_id%>"> <%= t('permissions.create.activity.tie', :user=> @tie.receiver.name) %></p>
92
+ </div>
93
+ </div>
94
+ </div>
95
+ <div class="form_bottom">
96
+ <%= submit_tag t('contact.edit.submit'), :class => "button" %>
97
+ </div>
98
+ </div>
99
+ <% end %>
100
+ </div>
101
+ </div>
102
+ </div>