Skip to content

Commit

Permalink
Added copy to site features and moved name to top of page
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Mar 27, 2010
1 parent de9ba6f commit c15b35a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
5 changes: 5 additions & 0 deletions app/controllers/templates_controller.rb
Expand Up @@ -283,6 +283,11 @@ def feature(popup=false,data={})
if !@feature.id
@feature.body = SiteFeature.default_feature(@paragraph.feature_type)
end

if params[:copy_feature_id]
@feature = @feature.clone
@feature.name += " (Copy)".t
end

if params[:version] && !params[:version].blank?
flash[:feature_version_load] = params[:version]
Expand Down
16 changes: 10 additions & 6 deletions app/models/site_feature.rb
Expand Up @@ -82,16 +82,20 @@ def feature_details


def self.single_feature_type_hash(site_template_id,feature_type,options = {})
features = []
SiteFeature.find(:all,:select => 'id,site_template_id,name,feature_type',
:conditions => { :site_template_id => site_template_id, :feature_type => feature_type }).map do |feature|
features = []
if site_template_id
conditions = { :site_template_id => site_template_id, :feature_type => feature_type }
else
conditions = [ 'site_template_id IS NULL and feature_type = ?',feature_type ]
end
SiteFeature.find(:all,:select => 'id,site_template_id,name,feature_type',:conditions => conditions).map do |feature|
features << [ feature.name, feature.id ]
end
if options[:include_all]

if options[:include_all] && site_template_id
features += self.single_feature_type_hash(nil,feature_type)
end

features
end

Expand Down
3 changes: 2 additions & 1 deletion app/views/edit/page.rhtml
Expand Up @@ -33,7 +33,8 @@ cmsEdit.setText({ deleteText: "<%= jh('Are you sure you want to delete this para
defaultStyleText: "<%= jh 'Default Style'.t %>",
currentStyleText: "<%= jh 'Current Style:'.t %>",
createStyleText: '<%= jh "+ Create new style".t %>',
editStyleText: '<%= jh "Edit".t %>'
editStyleText: '<%= jh "Edit".t %>',
copyStyleText: '<%= jh "Copy".t %>'
});


Expand Down
13 changes: 9 additions & 4 deletions app/views/templates/feature.rhtml
Expand Up @@ -72,12 +72,18 @@ hljs.initHighlightingOnLoad();

</script>

<div align='right' id='feature_versions'>
<%= render :partial => 'feature_versions' %>
</div>


<form action='' onsubmit='FeatureEditor.saveChanges(); return false;' method='post' id='feature_form'>
<div style='float:right' id='feature_versions'>
<%= render :partial => 'feature_versions' %>
</div>
<input type='hidden' name='feature[feature_type]' value='<%= @feature.feature_type %>' />
<div class='text_field_control' style='padding:10px;'>
<% cms_unstyled_fields_for :feature, @feature do |f| -%>
Name: <%= f.text_field :name, :size => 60 %>
<% end -%>
</div>
<div id='save_notice' class='flash_notice' style='display:none;'>
</div>
<div id='ignore_xml' style='display:none; text-align:center;'>
Expand All @@ -89,7 +95,6 @@ hljs.initHighlightingOnLoad();
<% t.tab do -%>
<div class='admin_content' id='feature_options'>
<% admin_fields_for :feature, @feature do |f| -%>
<%= f.text_field :name, :size => 30 %>
<%= f.text_field :category, :size => 30 %>
<%= f.text_field :description,:size => 80 %>
<%= f.custom_field :feature_type, :value => @feature.feature_type %>
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/application.js
Expand Up @@ -52,7 +52,7 @@ SCMS = {
customPopup: function(txt,title) {
var performActionText = title ? title : "Action"

overlib(txt,CAPTION,"&nbsp;" + performActionText, STICKY,BELOW,OFFSETX,0,OFFSETY,12,WIDTH,300,
overlib(txt,CAPTION,"&nbsp;" + performActionText, STICKY,BELOW,OFFSETX,0,OFFSETY,12,WIDTH,340,
FGCLASS,'cms_popup_text',BGCLASS,'cms_popup_bg',CAPTIONFONTCLASS,'cms_popup_caption',
MOUSEOFF,CLOSETEXT,'');

Expand Down
17 changes: 15 additions & 2 deletions public/javascripts/edit.js
Expand Up @@ -1001,7 +1001,9 @@ var cmsEdit = {
style_txt = cmsEdit.txt.get('selectStyleText') + feature[0];

txt += "<a href='javascript:void(0);' onclick='cClick(); cmsEdit.selectParagraphStyle(\"" + para_index+ "\"," + feature[1] + ");'>" + style_txt + "</a>";
txt += " (<a href='javascript:void(0);' onclick='cClick(); cmsEdit.editParagraphStyle(\"" + para_index+ "\"," + feature[1] + ");'>" + cmsEdit.txt.get('editStyleText') + "</a>) <br/>";
txt += " (<a href='javascript:void(0);' onclick='cClick(); cmsEdit.editParagraphStyle(\"" + para_index+ "\"," + feature[1] + ");'>" + cmsEdit.txt.get('editStyleText') + "</a>)";
txt += " (<a href='javascript:void(0);' onclick='cClick(); cmsEdit.copyParagraphStyle(\"" + para_index+ "\"," + feature[1] + ");'>" + cmsEdit.txt.get('copyStyleText') + "</a>) <br/>";

});
});

Expand Down Expand Up @@ -1078,11 +1080,22 @@ var cmsEdit = {
var params = $H({ para_index: para_index,
paragraph_id: para.paragraph_id,
feature_id: feature_id });
cmsEdit.styleWin = openWindow(cmsEdit.templateUrl('popup_feature',feature_id) + "?" + Object.toQueryString(params),'EditStyle' + cmsEdit.revisionId,900,600,'yes','yes');
cmsEdit.styleWin = openWindow(cmsEdit.templateUrl('popup_feature',feature_id) + "?" + Object.toQueryString(params),'EditStyle' + cmsEdit.revisionId,900,650,'yes','yes');
cmsEdit.styleWin.focus();
cClick();
},

copyParagraphStyle: function(para_index,feature_id) {
var para = cmsEdit.paragraphs.get(para_index);
var params = $H({ para_index: para_index,
paragraph_id: para.paragraph_id,
copy_feature_id: feature_id });
cmsEdit.styleWin = openWindow(cmsEdit.templateUrl('popup_feature',feature_id) + "?" + Object.toQueryString(params),'EditStyle' + cmsEdit.revisionId,900,650,'yes','yes');
cmsEdit.styleWin.focus();
cClick();
},



/* Modification History */

Expand Down

0 comments on commit c15b35a

Please sign in to comment.