Skip to content

Commit

Permalink
Can select multiple features and set the theme they are associated too.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Youch committed Aug 4, 2010
1 parent fd01f94 commit 4018308
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
10 changes: 9 additions & 1 deletion app/controllers/templates_controller.rb
Expand Up @@ -348,6 +348,10 @@ def display_features_table(display=true)

active_table_action('feature') do |act,fids|
SiteFeature.find(fids).map(&:destroy) if act == 'delete'
if act == 'theme'
site_template_id = params[:site_template_id].to_i
SiteFeature.update_all "site_template_id = #{site_template_id}", {:id => fids}
end
end
@tbl = features_table_generate params, :order => 'site_features.category,site_features.name', :include => :site_template

Expand All @@ -358,7 +362,11 @@ def features
cms_page_path [ "Options", "Themes" ], "Paragraph Themes"
display_features_table @tbl
end


def select_theme
render :partial => 'select_theme'
end

def new_feature
cms_page_path [ "Options", "Themes", "Paragraph Themes"], "Create a feature"
@feature = SiteFeature.new
Expand Down
3 changes: 2 additions & 1 deletion app/views/templates/_features_table.rhtml
@@ -1,6 +1,7 @@
<% active_table_for :features_table, @tbl,
:actions => [ ['Duplicate','duplicate' ],
['Delete','delete','Delete the selected paragraph themes?' ]] do |t| -%>
['Set Theme', 'js', 'SiteFeatures.selectTheme();']],
:more_actions =>[ ['Delete','delete','Delete the selected paragraph themes?' ]] do |t| -%>
<tr <%= highlight_row 'feature', t.id %>>
<td><%= entry_checkbox 'feature',t.id %></td>
<td><%= link_to v(t.name), :action => 'feature', :path => [ t.id ] %></td>
Expand Down
12 changes: 12 additions & 0 deletions app/views/templates/_select_theme.html.erb
@@ -0,0 +1,12 @@
<div class='cms_form'>

<h3><%= 'Select a Theme'.t %></h3>

<%= 'Themes:'.t %> <%= select_tag 'theme', options_for_select(SiteTemplate.select_options) %>
<br/>
<br/>
<div align='right'>
<input type='submit' value='Submit' onclick='SiteFeatures.selectThemeSubmit($("theme").value); RedBox.close(); return false;'/> <input type='submit' value='Cancel' onclick='RedBox.close(); return false;' />
</div>

</div>
26 changes: 21 additions & 5 deletions app/views/templates/features.rhtml
Expand Up @@ -4,10 +4,26 @@

<hr/>

<div class='admin_content'>
<script>
<%= active_table_javascript %>

<div id='features_table'>
<%= render :partial => 'features_table' %>
</div>
</div>
SiteFeatures = {
selectTheme: function() {
SCMS.remoteOverlay("<%= url_for :action => 'select_theme' %>");
},

selectThemeSubmit: function(theme_id) {
this.tableAction('theme', "site_template_id=" + theme_id);
},

tableAction: function(action,params) {
ActiveTable.action(action,null,"features_table","<%= url_for :action => 'display_features_table' %>",'features_table',params);
}
}
</script>

<div class='admin_content'>
<div id='features_table'>
<%= render :partial => 'features_table' %>
</div>
</div>

0 comments on commit 4018308

Please sign in to comment.