Diff
Modified: trunk/app/controllers/blobs_controller.rb (3067 => 3068)
--- trunk/app/controllers/blobs_controller.rb 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/app/controllers/blobs_controller.rb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -7,10 +7,10 @@
include ApplicationHelper
- before_filter :login_required, :except => [:index, :show, :download, :named_download, :named_download_with_version, :statistics, :search]
+ before_filter :login_required, :except => [:index, :show, :download, :named_download, :named_download_with_version, :statistics, :search, :auto_complete]
+
+ before_filter :find_blob_auth, :except => [:search, :index, :new, :create, :auto_complete]
- before_filter :find_blob_auth, :except => [:search, :index, :new, :create]
-
before_filter :initiliase_empty_objects_for_new_pages, : [:new, :create]
before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
@@ -324,6 +324,20 @@
format.html { redirect_to redirect_url }
end
end
+
+ def auto_complete
+ text = params[:file_name] || ''
+
+ files = Blob.find(:all,
+ :conditions => ["LOWER(title) LIKE ?", text.downcase + '%'],
+ :order => 'title ASC',
+ :limit => 20,
+ :select => 'DISTINCT *')
+
+ files = files.select {|f| Authorization.is_authorized?('view', nil, f, current_user) }
+
+ render :partial => 'contributions/autocomplete_list', :locals => { :contributions => files }
+ end
# GET /files/1/versions/1/suggestions
def suggestions
Modified: trunk/app/controllers/networks_controller.rb (3067 => 3068)
--- trunk/app/controllers/networks_controller.rb 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/app/controllers/networks_controller.rb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -432,6 +432,19 @@
}
end
end
+
+ def auto_complete
+ text = params[:group_name] || ''
+
+ groups = Network.find(:all,
+ :conditions => ["LOWER(title) LIKE ?", text.downcase + '%'],
+ :order => 'title ASC',
+ :limit => 20,
+ :select => 'DISTINCT *')
+
+ render :partial => 'networks/autocomplete_list', :locals => { :networks => groups }
+ end
+
protected
Modified: trunk/app/controllers/users_controller.rb (3067 => 3068)
--- trunk/app/controllers/users_controller.rb 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/app/controllers/users_controller.rb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -734,6 +734,18 @@
end
end
+ def auto_complete
+ text = params[:user_name] || ''
+
+ users = User.find(:all,
+ :conditions => ["LOWER(name) LIKE ?", text.downcase + '%'],
+ :order => 'name ASC',
+ :limit => 20,
+ :select => 'DISTINCT *')
+
+ render :partial => 'users/autocomplete_list', :locals => { :users => users }
+ end
+
protected
def find_users
Modified: trunk/app/controllers/workflows_controller.rb (3067 => 3068)
--- trunk/app/controllers/workflows_controller.rb 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/app/controllers/workflows_controller.rb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -7,11 +7,11 @@
include ApplicationHelper
- before_filter :login_required, :except => [:index, :show, :download, :named_download, :galaxy_tool, :galaxy_tool_download, :statistics, :launch, :search]
+ before_filter :login_required, :except => [:index, :show, :download, :named_download, :galaxy_tool, :galaxy_tool_download, :statistics, :launch, :search, :auto_complete]
before_filter :store_callback, : [:index, :search]
before_filter :find_workflows_rss, : [:index]
- before_filter :find_workflow_auth, :except => [:search, :index, :new, :create]
+ before_filter :find_workflow_auth, :except => [:search, :index, :new, :create, :auto_complete]
before_filter :initiliase_empty_objects_for_new_pages, : [:new, :create, :new_version, :create_version]
before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
@@ -648,6 +648,20 @@
redirect_to(workflow_url(@workflow))
end
+ def auto_complete
+ text = params[:workflow_name] || ''
+
+ wfs = Workflow.find(:all,
+ :conditions => ["LOWER(title) LIKE ?", text.downcase + '%'],
+ :order => 'title ASC',
+ :limit => 20,
+ :select => 'DISTINCT *')
+
+ wfs = wfs.select {|w| Authorization.is_authorized?('view', nil, w, current_user) }
+
+ render :partial => 'contributions/autocomplete_list', :locals => { :contributions => wfs }
+ end
+
protected
def store_callback
Added: trunk/app/views/contributions/_autocomplete_list.html.erb (0 => 3068)
--- trunk/app/views/contributions/_autocomplete_list.html.erb (rev 0)
+++ trunk/app/views/contributions/_autocomplete_list.html.erb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -0,0 +1,10 @@
+<ul>
+ <% contributions.each do |c| %>
+ <li data-cont-id="<%= c.id -%>" data-cont-name="<%= h c.title -%>" style="border-bottom: 1px dashed #bbb">
+ <%= h c.title -%><br/>
+ <span style="font-weight: normal; color: #777">
+ (ID: <%= c.id -%>) Uploader: <%= h c.contributor.name -%>
+ </span>
+ </li>
+ <% end %>
+</ul>
\ No newline at end of file
Modified: trunk/app/views/contributions/_credit_attribution_form.rhtml (3067 => 3068)
--- trunk/app/views/contributions/_credit_attribution_form.rhtml 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/app/views/contributions/_credit_attribution_form.rhtml 2012-08-01 13:24:20 UTC (rev 3068)
@@ -29,141 +29,184 @@
You can also attribute the Workflows/Files that this <%= c_type %> is <strong>based on</strong> (if any).
</p>
</div>
- <br/>
+
+ <!--- CREDITS --->
+
<p><b>Which users/groups get the credit for this <%= c_type %>?</b></p>
- <div class="box_editing" style="padding-left: 1em;">
- <p style="color: #666666;">Build up the list of credits below by adding from the options</p>
- <p id="authors_list" class="box_editing_inner">
- Me <small>[<a href="" t="me" null); return false;">delete</a>]</small><br/>
- </p>
- <div class="box_simple" style="font-size: 93%; margin-top: 1em;">
- Select an option then click on 'Add' to add to the list:
- <br />
- <br />
+ <div id="credit_section" class="box_editing" style="padding-left: 1em; overflow: auto">
+ <p style="color: #666666;">Build up the list of credits on the right by adding from the options on the left.</p>
+ <div id="author_selection" class="box_simple" style="width: 50%; float: left; font-size: 93%;">
- <p>
- <label for="" id="author_option_1" name="add_author_option" checked="checked"
- value="1" type="radio" />
- - Me</label> (<%= name current_user %>)
- </p>
+ <!--- Credit me --->
- <p>
- <label for="" id="author_option_2" name="add_author_option"
- value="2" type="radio" />
- - One of my Friends</label>
- </p>
- <div id="author_friends_box" style="display: none; padding-left: 2em;">
- <p>
- <select id="author_friends_dropdown">
- <% current_user.friends.each do |f| %>
- <option value="<%= f.id %>"><%= h(f.name) %></option>
- <% end %>
- </select>
- </p>
+ <div id="author_me" class="credit_selection_box">
+ <span style="font-size: 120%;line-height: 1.5;">Me (<%= name current_user %>)
+ <button false">Add ></button> </span>
</div>
-
- <p>
- <label for="" id="author_option_3" name="add_author_option"
- value="3" type="radio" />
- - A user on <%= Conf.sitename %> who is not a Friend.</label>
- </p>
- <div id="author_otheruser_box" style="display: none; padding-left: 2em;">
- <p>
- <select id="author_otheruser_dropdown">
- <% (nonfriends_for_credits_form(current_user)).each do |f| %>
- <option value="<%= f.id %>"><%= h(f.name) %></option>
- <% end %>
- </select>
- </p>
+
+ <!--- Credit a friend --->
+
+ <div id="author_friends_box" class="credit_selection_box">
+ <p>A Friend</p>
+ <select id="author_friends_dropdown" = (this.selectedIndex == 0)">
+ <option value="0" selected="selected">Select a friend...</option>
+ <% current_user.friends.each do |f| %>
+ <option value="<%= f.id %>"><%= h(f.name) %></option>
+ <% end %>
+ </select>
+ <button id="add_friend_author" disabled="disabled" false">Add ></button>
</div>
- <p>
- <label for="" id="author_option_4" name="add_author_option"
- value="4" type="radio" />
- - A <%= Conf.sitename %> Group</label>
- </p>
- <div id="author_networks_box" style="display: none; padding-left: 2em;">
- <p>
- <select id="author_networks_dropdown">
- <% networks_for_credits_form.each do |n| %>
- <option value="<%= n.id %>"><%= h(n.title) %></option>
- <% end %>
- </select>
- </p>
+ <!--- Credit a user --->
+
+ <div id="author_otheruser_box" class="credit_selection_box">
+ <p>A <%= Conf.sitename %> user
+ <%= help_icon_with_tooltip("Begin typing a #{Conf.sitename} user's name into the text box and a list of suggestions will appear. Select the correct user from the list and click the Add button.") -%>
+ </p>
+ <%= text_field_tag :user_name, '',
+ : %(other_user_name = null; other_user_id = null; $('add_otheruser_author').disabled = true;),
+ : %(if(event.keyCode == 13 && !$('add_otheruser_author').disabled)
+ addAuthor(3);)%>
+ <%= image_tag "/images/spinner.gif", :class => "auto_complete_spinner", :id => "add_user_indicator", :style => "vertical-align: middle; display: none;" %>
+ <script type="text/_javascript_">
+ var other_user_id;
+ var other_user_name;
+ </script>
+ <div class="auto_complete" id="users_auto_complete" ></div>
+ <%= auto_complete_field :user_name,
+ :update => "users_auto_complete",
+ :url ="" {:controller => 'users', :action ="" 'auto_complete', :authenticity_token => form_authenticity_token},
+ :frequency => 0.2,
+ :after_update_element => %(function(element,value){
+ other_user_id = value.getAttribute('data-user-id');
+ other_user_name = value.getAttribute('data-user-name');
+ $('user_name').value = other_user_name;
+ $('add_otheruser_author').disabled = false;
+ }),
+ :indicator => 'add_user_indicator' -%>
+ <button id="add_otheruser_author" disabled="disabled" false">Add ></button>
</div>
-
- <% if false %>
- <p>
- <label for="" id="author_option_5" name="add_author_option"
- value="5" type="radio" />
- - Someone else</label>
- </p>
- <div id="author_someoneelse_box" style="display: none; padding-left: 2em;">
- <p>
- <label for="" </label>
- <input id="author_someoneelse_forenames" size="25" value="" type="text"/>
- <label for="" </label>
- <input id="author_someoneelse_surname" size="25" value="" type="text"/>
- </p>
- </div>
-
+ <!--- Credit a group --->
+
+ <div id="author_networks_box" class="credit_selection_box">
<p>
- <label for="" id="author_option_6" name="add_author_option"
- value="6" type="radio" />
- - An organisation</label>
+ A <%= Conf.sitename %> Group
+ <%= help_icon_with_tooltip("Begin typing a #{Conf.sitename} Groups's name into the text box and a list of suggestions will appear. Select the correct Group from the list and click the Add button.") -%>
</p>
- <div id="author_organisation_box" style="display: none; padding-left: 2em;">
- <p>
- <input id="author__organisation" size="50" value="" type="text"/>
- </p>
- </div>
-
- <% end %>
+ <%= text_field_tag :group_name, '',
+ : %(group_name = null; group_id = null; $('add_group_author').disabled = true;),
+ : %(if(event.keyCode == 13 && !$('add_group_author').disabled)
+ addAuthor(4)) %>
+ <%= image_tag "/images/spinner.gif", :class => "auto_complete_spinner", :id => "add_group_indicator", :style => "vertical-align: middle; display: none;" %>
+ <script type="text/_javascript_">
+ var group_id;
+ var group_name;
+ </script>
+ <div class="auto_complete" id="groups_auto_complete" ></div>
+ <%= auto_complete_field :group_name,
+ :update => "groups_auto_complete",
+ :url ="" {:controller => 'networks', :action ="" 'auto_complete', :authenticity_token => form_authenticity_token},
+ :frequency => 0.2,
+ :after_update_element => %(function(element,value){
+ group_id = value.getAttribute('data-network-id');
+ group_name = value.getAttribute('data-network-name');
+ $('group_name').value = group_name;
+ $('add_group_author').disabled = false;
+ }),
+ :indicator => 'add_group_indicator' -%>
+ <button id="add_group_author" disabled="disabled" false">Add ></button>
+ </div>
+ </div>
- <br />
- <b><a href="" return false;" >Add</a></b>
- </div>
+ <!--- List of credits --->
+
+ <div style="width: 42%; float: right" class="box_simple">
+ <p>Current credits:</p>
+ <div id="authors_list" class="box_editing_inner">
+ Me <small>[<a href="" t="me" null); return false;">delete</a>]</small><br/>
+ </div>
+ </div>
</div>
- <br/>
- <br/>
+
+ <!--- ATTRIBUTIONS --->
+
<p><b>If this <%= c_type %> is based on any existing Workflows or Files, please list them below:</b></p>
- <div class="box_editing" style="padding-left: 1em;">
- <p style="color: #666666;">Build up the list of attributions below by adding from the options</p>
- <p id="attribution_list" class="box_editing_inner">
- <i>None</i>
- </p>
- <div style="font-size: 93%; margin-top: 1em;">
- <div class="box_simple" style="float: left; text-align: left; width: 300px;">
- Existing Workflows on <%= Conf.sitename %>:
- <br />
- <br />
- <select id="existingworkflows_dropdown" style="width: 280px;">
- <% workflows_for_attribution_form.each do |w| %>
- <option value="<%= w.id %>"><%=h "#{w.id}: #{w.title} (#{w.name})" -%></option>
- <% end %>
- </select>
- <br />
- <br />
- <b><a href="" return false;" >Add</a></b>
+ <div id="attribution_section" class="box_editing" style="padding-left: 1em; overflow: auto">
+ <p style="color: #666666;">Build up the list of attributions on the right by adding from the options on the left.</p>
+ <div id="attribution_selection" class="box_simple" style="width: 50%; float: left; font-size: 93%;">
+
+ <!--- Attribute a workflow --->
+
+ <div id="attribute_workflows" class="credit_selection_box">
+ <p>
+ A Workflow on <%= Conf.sitename %>
+ <%= help_icon_with_tooltip("Begin typing a #{Conf.sitename} Workflows's title into the text box and a list of suggestions will appear. Select the correct Workflow from the list and click the Add button.") -%>
+ </p>
+ <%= text_field_tag :workflow_name, '',
+ : %(workflow_name = null; workflow_id = null; $('add_workflow_attrib').disabled = true;),
+ : %(if(event.keyCode == 13 && !$('add_workflow_attrib').disabled)
+ addAttribution('existing_workflow')) %>
+ <%= image_tag "/images/spinner.gif", :class => "auto_complete_spinner", :id => "add_workflow_indicator", :style => "vertical-align: middle; display: none;" %>
+ <script type="text/_javascript_">
+ var workflow_id;
+ var workflow_name;
+ </script>
+ <div class="auto_complete" id="workflows_auto_complete" ></div>
+ <%= auto_complete_field :workflow_name,
+ :update => "workflows_auto_complete",
+ :url ="" {:controller => 'workflows', :action ="" 'auto_complete', :authenticity_token => form_authenticity_token},
+ :frequency => 0.2,
+ :after_update_element => %(function(element,value){
+ workflow_id = value.getAttribute('data-cont-id');
+ workflow_name = value.getAttribute('data-cont-name');
+ $('workflow_name').value = workflow_name;
+ $('add_workflow_attrib').disabled = false;
+ }),
+ :indicator => 'add_workflow_indicator' -%>
+ <button id="add_workflow_attrib" disabled="disabled" ;return false">Add ></button>
</div>
+
+ <!--- Attribute a file --->
- <div class="box_simple" style="float: left; margin-left: 1em; text-align: left; width: 300px;">
- Existing Files on <%= Conf.sitename %>:
- <br />
- <br />
- <select id="existingfiles_dropdown" style="width: 280px;">
- <% blobs_for_attribution_form.each do |b| %>
- <option value="<%= b.id %>"><%=h "#{b.id}: #{b.title} (#{b.name})" -%></option>
- <% end %>
- </select>
- <br />
- <br />
- <b><a href="" return false;" >Add</a></b>
+ <div id="attribute_files" class="credit_selection_box">
+ <p>
+ A File on <%= Conf.sitename %>
+ <%= help_icon_with_tooltip("Begin typing a #{Conf.sitename} File's title into the text box and a list of suggestions will appear. Select the correct File from the list and click the Add button.") -%>
+ </p>
+ <%= text_field_tag :file_name, '',
+ : %(file_name = null; file_id = null; $('add_file_attrib').disabled = true;),
+ : %(if(event.keyCode == 13 && !$('add_file_attrib').disabled)
+ addAttribution('existing_file')) %>
+ <%= image_tag "/images/spinner.gif", :class => "auto_complete_spinner", :id => "add_file_indicator", :style => "vertical-align: middle; display: none;" %>
+ <script type="text/_javascript_">
+ var file_id;
+ var file_name;
+ </script>
+ <div class="auto_complete" id="files_auto_complete" ></div>
+ <%= auto_complete_field :file_name,
+ :update => "files_auto_complete",
+ :url ="" {:controller => 'blobs', :action ="" 'auto_complete', :authenticity_token => form_authenticity_token},
+ :frequency => 0.2,
+ :after_update_element => %(function(element,value){
+ file_id = value.getAttribute('data-cont-id');
+ file_name = value.getAttribute('data-cont-name');
+ $('file_name').value = file_name;
+ $('add_file_attrib').disabled = false;
+ }),
+ :indicator => 'add_file_indicator' -%>
+ <button id="add_file_attrib" disabled="disabled" false">Add ></button>
</div>
-
- <div style="clear: both;"> </div>
- </div>
+ </div>
+
+ <!--- Attribution list --->
+
+ <div style="width: 42%; float: right" class="box_simple">
+ <p>Current attributions:</p>
+ <div id="attribution_list" class="box_editing_inner">
+ <i>None</i>
+ </div>
+ </div>
</div>
</div>
</div>
@@ -203,15 +246,15 @@
credit_me = false;
<% contributable.creditors.each do |c| %>
<% if c.creditor_type == 'User' and c.creditor_id == current_user.id %>
- credit_me = true;
- <% elsif c.creditor_type == 'User' %>
- credit_users[<%= c.creditor_id %>] = '<%= escape_javascript contributor_name(c.creditor_id, 'User') %>';
- <% elsif c.creditor_type == 'Network' %>
- credit_groups[<%= c.creditor_id %>] = '<%= escape_javascript contributor_name(c.creditor_id, 'Network') %>';
+ credit_me = true;
+ <% elsif c.creditor_type == 'User' %>
+ credit_users[<%= c.creditor_id %>] = '<%= escape_javascript contributor_name(c.creditor_id, 'User') %>';
+ <% elsif c.creditor_type == 'Network' %>
+ credit_groups[<%= c.creditor_id %>] = '<%= escape_javascript contributor_name(c.creditor_id, 'Network') %>';
+ <% end %>
<% end %>
- <% end %>
updateAuthorList();
-
+
// Attributions
<% contributable.attributors.each do |a| %>
<% if Authorization.is_authorized?("show", nil, a.attributor, current_user) -%>
Added: trunk/app/views/networks/_autocomplete_list.html.erb (0 => 3068)
--- trunk/app/views/networks/_autocomplete_list.html.erb (rev 0)
+++ trunk/app/views/networks/_autocomplete_list.html.erb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -0,0 +1,8 @@
+<ul>
+ <% networks.each do |network| %>
+ <li data-network-id="<%= network.id -%>" data-network-name="<%= h network.title -%>" style="border-bottom: 1px dashed #bbb">
+ <%= h network.title -%><br/>
+ <span style="font-weight: normal; color: #777"><%= network.members.count -%> members</span>
+ </li>
+ <% end %>
+</ul>
\ No newline at end of file
Modified: trunk/app/views/networks/invite.rhtml (3067 => 3068)
--- trunk/app/views/networks/invite.rhtml 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/app/views/networks/invite.rhtml 2012-08-01 13:24:20 UTC (rev 3068)
@@ -9,12 +9,12 @@
<% invite_existing_selected = invite_existing_selected?(params[:radio_choice]) -%>
<label for=""
- <%= radio_button_tag ("radio_invite", "existing", invite_existing_selected, : "$('radio_invite_new').checked=false;$('div_invite_existing').show();$('div_invite_new').hide();return true;" ) -%>
+ <%= radio_button_tag("radio_invite", "existing", invite_existing_selected, : "$('radio_invite_new').checked=false;$('div_invite_existing').show();$('div_invite_new').hide();return true;" ) -%>
Invite an existing <%= Conf.sitename %> user to your group
</label>
<br/>
<label for=""
- <%= radio_button_tag ("radio_invite", "new", !invite_existing_selected, : "$('radio_invite_existing').checked=false;$('div_invite_existing').hide();$('div_invite_new').show();return true;" ) -%>
+ <%= radio_button_tag("radio_invite", "new", !invite_existing_selected, : "$('radio_invite_existing').checked=false;$('div_invite_existing').hide();$('div_invite_new').show();return true;" ) -%>
Invite someone to join <%= Conf.sitename -%> and your group
</label>
@@ -25,15 +25,74 @@
<fieldset>
<legend>Invite an existing <%= Conf.sitename %> user to your group</legend>
<p class="box_infotext" style="margin: 0.4em 0em 0.7em 0em" >
- Select a name from the list, type in a message to the user and click "Invite".
+ Select a user by typing their name into the text box and choosing an option from the list which appears, then type in a message to the user and click "Invite".
</p>
- <% form_tag(membership_invite_network_path(@network), :method => :post) do %>
+ <% form_tag(membership_invite_network_path(@network), :method => :post, : "if(event.keyCode === 13) return false;") do %>
<table cellpadding="0" cellspacing="0">
<tr>
- <td> </td>
+ <td><%= help_icon_with_tooltip("Begin typing a #{Conf.sitename} user's name into the text box and a list of suggestions will appear. Select the correct user from the list.") -%></td>
<td style="text-align: left;">User:</td>
- <td style="text-align: left;"><%= select_tag :user_id, options_from_collection_for_select(User.find(:all, :order => "name ASC"), :id.to_i, :name), :style => "width: 400px;" -%></td>
+ <td style="text-align: left;">
+ <%= text_field_tag :user_name, '', :class => "auto_complete_field" -%>
+ <%= hidden_field_tag :user_id, '' -%>
+ <script type="text/_javascript_">
+ function userSelectSuccess() {
+ $('user_name').addClassName('accepted');
+ $('user_name').removeClassName('error');
+ $('add_user_error_msg').hide();
+ $('user_name').disabled = true;
+ $('add_user_reset').show();
+ }
+ function userSelectError() {
+ $('user_name').addClassName('error');
+ $('user_name').removeClassName('accepted');
+ $('add_user_error_msg').show();
+ $('add_user_reset').show();
+ }
+
+
+ svn commit -m "Replaced big dropdown lists in credits and attributions interface and group invite page" app/controllers/networks_controller.rb app/controllers/workflows_controller.rb app/controllers/blobs_controller.rb app/controllers/users_controller.rb app/views/users/_autocomplete_list.html.erb app/views/contributions/_autocomplete_list.html.erb app/views/contributions/_credit_attribution_form.rhtml app/views/networks/_autocomplete_list.html.erb public/_javascript_s/osp.js public/stylesheets/styles.css app/views/networks/invite.rhtml
+
+
+ function userSelectReset() {
+ $('user_name').removeClassName('error');
+ $('user_name').removeClassName('accepted');
+ $('add_user_error_msg').hide();
+ $('user_id').value = '';
+ $('user_name').value = '';
+ $('user_name').disabled = false;
+ $('add_user_reset').hide();
+ $('user_name').focus();
+ }
+ // Make sure the user clicked a name from the list, or that user's ID won't be saved in the form!
+ Event.observe('user_name', 'blur', function(event) {
+ setTimeout(function(){ // Hack to avoid the error flashing briefly after the user clicks a name
+ if(document.activeElement.id != 'user_name' && $('user_id').value == '')
+ userSelectError();
+ }, 300);
+ });
+ </script>
+ <%= image_tag "/images/spinner.gif", :class => "auto_complete_spinner", :id => "add_user_indicator", :style => "vertical-align: middle; display: none;" %>
+ <%= image_tag "/images/famfamfam_silk/pencil.png", :id => "add_user_reset",
+ :style => "vertical-align: middle; display: none; cursor: pointer;",
+ : "userSelectReset(); return false;",
+ :title => "Click to clear the selection" %>
+ <span id="add_user_error_msg" style="display: none; font-size: 75%; color: red">
+ Please make sure to <strong>click</strong> on the user you wish to invite from the dropdown menu.
+ </span>
+ <div class="auto_complete" id="users_auto_complete" ></div>
+ <%= auto_complete_field :user_name,
+ :update => "users_auto_complete",
+ :url ="" {:controller => 'users', :action ="" 'auto_complete', :authenticity_token => form_authenticity_token},
+ :frequency => 0.2,
+ :after_update_element => %(function(element,value){
+ $('user_id').value = value.getAttribute('data-user-id');
+ $('user_name').value = value.getAttribute('data-user-name');
+ userSelectSuccess();
+ }),
+ :indicator => 'add_user_indicator' -%>
+ </td>
</tr>
<tr style="vertical-align: top;">
<td><%= info_icon_with_tooltip("This message is optional: if you leave it blank, your invitation will be sent without it") -%></td>
@@ -55,7 +114,7 @@
Type in email addresses you want to send invitations to, personal message to new users and click "Invite".
</p>
- <% form_tag (membership_invite_external_network_path(@network), :method => :post) do %>
+ <% form_tag(membership_invite_external_network_path(@network), :method => :post) do %>
<%= hidden_field_tag "radio_choice", "" -%>
<table>
<tr>
Added: trunk/app/views/users/_autocomplete_list.html.erb (0 => 3068)
--- trunk/app/views/users/_autocomplete_list.html.erb (rev 0)
+++ trunk/app/views/users/_autocomplete_list.html.erb 2012-08-01 13:24:20 UTC (rev 3068)
@@ -0,0 +1,11 @@
+<ul>
+ <% users.each do |user| %>
+ <li data-user-id="<%= user.id -%>" data-user-name="<%= h user.name -%>" style="border-bottom: 1px dashed #bbb">
+ <%= flag_icon(user.profile.location_country, user.profile.location) if user.profile -%>
+ <%= h user.name -%><br/>
+ <% unless user.profile.nil? || user.profile.email.nil? || user.profile.email.empty? %>
+ <span style="font-weight: normal; color: #777"><%= user.profile.email.gsub("@", " [at] ") %></span>
+ <% end %>
+ </li>
+ <% end %>
+</ul>
\ No newline at end of file
Modified: trunk/public/_javascript_s/osp.js (3067 => 3068)
--- trunk/public/_javascript_s/osp.js 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/public/_javascript_s/osp.js 2012-08-01 13:24:20 UTC (rev 3068)
@@ -158,45 +158,41 @@
document.getElementById('credits_groups').value = groups_list;
}
-function addAuthor() {
+function addAuthor(author_option, author_id, author_name) {
// Me
- if (document.getElementById('author_option_1').checked)
+ if (author_option == 1)
{
credit_me = true;
}
// One of my Friends
- else if (document.getElementById('author_option_2').checked)
+ else if (author_option == 2)
{
var x = document.getElementById('author_friends_dropdown');
- if (x.options.length > 0)
+ if (x.options.length > 0 && x.selectedIndex != 0)
{
var y = x.options[x.selectedIndex];
- credit_users[y.value] = y.text;
+ credit_users[y.value] = y.text;
}
}
// A user on myExperiment who is not a Friend.
- else if (document.getElementById('author_option_3').checked)
+ else if (author_option == 3)
{
- var x = document.getElementById('author_otheruser_dropdown');
-
- if (x.options.length > 0)
- {
- var y = x.options[x.selectedIndex];
- credit_users[y.value] = y.text;
- }
+ credit_users[other_user_id] = other_user_name;
+ other_user_id = null;
+ other_user_name = null;
+ $('user_name').value = '';
+ $('add_otheruser_author').disabled = true;
}
// A myExperiment Group
- else if (document.getElementById('author_option_4').checked)
+ else if (author_option == 4)
{
- var x = document.getElementById('author_networks_dropdown');
-
- if (x.options.length > 0)
- {
- var y = x.options[x.selectedIndex];
- credit_groups[y.value] = y.text;
- }
+ credit_groups[group_id] = group_name;
+ group_id = null;
+ group_name = null;
+ $('group_name').value = '';
+ $('add_group_author').disabled = true;
}
updateAuthorList();
@@ -298,20 +294,18 @@
function addAttribution(type) {
if (type == 'existing_workflow') {
- var x = document.getElementById('existingworkflows_dropdown');
-
- if (x.options.length > 0) {
- var y = x.options[x.selectedIndex];
- attributions_workflows[y.value] = y.text;
- }
+ attributions_workflows[workflow_id] = workflow_name;
+ workflow_id = null;
+ workflow_name = null;
+ $('workflow_name').value = '';
+ $('add_workflow_attrib').disabled = true;
}
else if (type == 'existing_file') {
- var x = document.getElementById('existingfiles_dropdown');
-
- if (x.options.length > 0) {
- var y = x.options[x.selectedIndex];
- attributions_files[y.value] = y.text;
- }
+ attributions_files[file_id] = file_name;
+ file_id = null;
+ file_name = null;
+ $('file_name').value = '';
+ $('add_file_attrib').disabled = true;
}
updateAttributionsList();
Modified: trunk/public/stylesheets/styles.css (3067 => 3068)
--- trunk/public/stylesheets/styles.css 2012-07-31 15:25:14 UTC (rev 3067)
+++ trunk/public/stylesheets/styles.css 2012-08-01 13:24:20 UTC (rev 3068)
@@ -2325,6 +2325,42 @@
background: #ffc0c0;
}
+div.credit_selection_box, div.credit_selection_box {
+ margin-top: 0.5em;
+ padding: 0.5em;
+ background-color: #eee;
+ overflow: auto;
+}
+
+div.credit_selection_box button {
+ float: right;
+ margin-left: 0.5em;
+}
+
+div.credit_selection_box input,
+div.credit_selection_box select {
+ width: 20em;
+ min-height: 19px;
+}
+
+.auto_complete_spinner {
+ margin-left: -24px;
+}
+
+input.auto_complete_field {
+ min-height: 20px;
+}
+
+input.auto_complete_field.accepted {
+ background-color: transparent;
+ border: none;
+ color: #4dbf00;
+}
+
+input.auto_complete_field.error {
+ background-color: #FFCCCC;
+}
+
.version_history .title {
font-size: 16px;
}
@@ -2343,4 +2379,3 @@
line-height: 1.2;
font-size: 85%;
}
-