Modified: branches/elico/app/helpers/application_helper.rb (2774 => 2775)
--- branches/elico/app/helpers/application_helper.rb 2011-10-31 13:45:28 UTC (rev 2774)
+++ branches/elico/app/helpers/application_helper.rb 2011-10-31 14:56:05 UTC (rev 2775)
@@ -1611,7 +1611,9 @@
contributable = (@workflow || @pack || @blog_post || @blob)
layout = nil
- if contributable && contributable.contribution
+ if params["layout_preview"]
+ layout = Conf.layouts[params["layout_preview"]]
+ elsif contributable && contributable.contribution
layout = Conf.layouts[contributable.contribution.layout]
elsif @network
layout = @network.layout
Modified: branches/elico/app/views/contributions/_sharing_form.rhtml (2774 => 2775)
--- branches/elico/app/views/contributions/_sharing_form.rhtml 2011-10-31 13:45:28 UTC (rev 2774)
+++ branches/elico/app/views/contributions/_sharing_form.rhtml 2011-10-31 14:56:05 UTC (rev 2775)
@@ -144,33 +144,73 @@
<!-- Explicit Group Permissions -->
<p><strong>Share with my Groups:</strong></p>
- <div id="group_sharing_box" class="box_editing" style="padding-left: 1em; font-size: 93%;">
- <% for n in (current_user.networks + current_user.networks_owned) %>
- <p>
- <% perm = find_permission_for_contributor(perms, "Network", n.id) if edit -%>
- <label for="" n.id %>">
- <input <%= 'checked' if perm %> style="margin-right: 0.3em;"
- value="<%= n.id %>" type="checkbox" name="group_sharing[<%= n.id %>][id]" id="cb_group_sharing_<%= n.id %>"
- elem = $('layout_selection_<%= n.id -%>'); elem.disabled = !this.checked; elem.checked = false;"/>
- <%= h(n.title) %>
- </label>
- <select name="group_sharing[<%= n.id %>][level]" style="font-size: 85%; margin: 0 0.5em;">
- <option value="0" <%= 'selected="selected"' if perm and perm.level == 0 %>>View only</option>
- <option value="1" <%= 'selected="selected"' if !edit or !perm or (perm and perm.level == 1) %>>View and Download only</option>
- <option value="2" <%= 'selected="selected"' if perm and perm.level == 2 %>>View, Download and Update</option>
- </select>
- <% if n.layout_name %>
- <input id="layout_selection_<%= n.id %>" title="Use <%= h(n.title) -%>'s layout" class="layout_selection" type="checkbox" name="layout" value="<%= n.id -%>"
- <%= 'checked="checked"' if edit && contributable.contribution.layout == n.layout_name %>
- (box) { if(box.id != 'layout_selection_<%= n.id %>') box.checked = false;})"
- <%= 'disabled="disabled"' unless perm -%>/>
- Use <%= h(n.title) -%>'s layout
- <% end %>
- </p>
- <% end %>
- </div>
+ <div id="group_sharing_box" class="box_editing" style="padding-left: 1em; font-size: 93%;">
+ <% applicable_networks = (current_user.networks + current_user.networks_owned) %>
+ <% applicable_networks.each do |n| %>
+ <p>
+ <% perm = find_permission_for_contributor(perms, "Network", n.id) if edit -%>
+ <label for="" n.id %>">
+ <input class="group_sharing" <%= 'checked' if perm %> style="margin-right: 0.3em;"
+ value="<%= n.id %>" type="checkbox" name="group_sharing[<%= n.id %>][id]" id="cb_group_sharing_<%= n.id %>"
+ this.checked);"/>
+ <%= h(n.title) %>
+ </label>
+ <select name="group_sharing[<%= n.id %>][level]" style="font-size: 85%; margin: 0 0.5em;">
+ <option value="0" <%= 'selected="selected"' if perm and perm.level == 0 %>>View only</option>
+ <option value="1" <%= 'selected="selected"' if !edit or !perm or (perm and perm.level == 1) %>>View and Download only</option>
+ <option value="2" <%= 'selected="selected"' if perm and perm.level == 2 %>>View, Download and Update</option>
+ </select>
+ <%# 'checked="checked"' if edit && contributable.contribution.layout == n.layout_name %>
+ </p>
+ <% end %>
+ <br/>
+ <div id="layout_options_box">
+ <strong>Layout:</strong>
+ <div class="box_infotext" style="margin: 1em 0">
+ <p>
+ One or more of the groups you have elected to share this <%= c_type -%> with have custom layouts. To
+ apply a custom layout to this <%= c_type -%>, choose one from the list below. The layout can be changed at any time
+ by visiting the 'edit' page.
+ </p>
+ </div>
+ <%= select_tag "layout", "<option value="">Default</option>" + options_from_collection_for_select(applicable_networks.select {|n| n.layout_name}, 'id','title') %>
+ <%# TODO: In Rails 2, have a link that allows a user to preview the selected layout using polymorphic_path %>
+ </div>
+ </div>
</div>
</div>
<script>update_sharing(<%= @sharing_mode %>)</script>
+<script type="text/_javascript_">
+ //Code to show/hide layout selection box
+
+ var number_of_layout_options = $$('select#layout option').size();
+
+ function toggle_layout_option(id, enable) {
+ var option = $$('select#layout option[value=' + id + ']').first();
+
+ //If a "share with group" box is unticked, and that group's layout is selected, go to default.
+ if(!enable){
+ if($('layout').selectedIndex == option.index){
+ $('layout').selectedIndex = 0;
+ }
+ }
+
+ option.disabled = !enable;
+
+ //If everything except default is disabled, hide the layout option box
+ if($$('select#layout option[disabled]').size() == (number_of_layout_options - 1)) {
+ $('layout_options_box').hide();
+ }
+ else {
+ $('layout_options_box').show();
+ }
+ }
+
+ //Initial state
+ $$('input.group_sharing').each (function (box) {
+ toggle_layout_option(box.value, box.checked);
+ });
+</script>
+
<% if update_perms -%><script>update_updating(<%= @updating_mode %>)</script><% end -%>