Skip to content

Commit

Permalink
Added a custom tab in edit popup [#76 state:resolved]. To use this ta…
Browse files Browse the repository at this point in the history
…b, you must create

a template with '*edit' mode. The content of this template will be rendered inside the tab.
You need to have JS turned on for this to work. This solution has *no performance impact* on
popup load time due to the fact that tab rendering is only executed later.
  • Loading branch information
gaspard committed Sep 24, 2008
1 parent b9b3176 commit 68803bd
Show file tree
Hide file tree
Showing 12 changed files with 442 additions and 430 deletions.
6 changes: 6 additions & 0 deletions app/controllers/versions_controller.rb
Expand Up @@ -72,6 +72,12 @@ def edit
end
end

def custom_tab
render :file => template_url(:mode=>'*edit', :format=>'html'), :layout=>false
rescue ActiveRecord::RecordNotFound
render :inline => "no custom form for this class (#{@node.klass})"
end

# TODO: test/improve or remove (experiments)
def diff
# drive view
Expand Down
1 change: 1 addition & 0 deletions app/helpers/versions_helper.rb
Expand Up @@ -12,6 +12,7 @@ def form_tabs
break if k == 'node'
end
tabs << klass if klass
tabs << 'custom'
tabs << 'help'
end
end
2 changes: 1 addition & 1 deletion app/models/template.rb
Expand Up @@ -57,7 +57,7 @@ def document_before_validation
content.format = 'html' if content.format.blank?
self[:name] = name_from_content(:format => content.format, :mode => content.mode, :klass => content.klass)

if version.text.blank? && content.format == 'html'
if version.text.blank? && content.format == 'html' && content.mode != '*edit'
# set a default text

if content.klass == 'Node'
Expand Down
6 changes: 6 additions & 0 deletions app/views/templates/edit_tabs/_custom.rhtml
@@ -0,0 +1,6 @@
<%= javascript_start %>
var custom_loaded = false;
function load_custom_tab() {
new Ajax.Updater('custom_tab', '/nodes/<%= @node.zip %>/versions/0/custom_tab', {asynchronous:true, evalScripts:true, method:'get'});
}
<%= javascript_end %>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -23,6 +23,7 @@
nodes.resources :versions,
:name_prefix => nil,
:member => { :edit => :get,
:custom_tab => :get,
:propose => :put,
:publish => :put,
:unpublish => :put,
Expand Down
1 change: 1 addition & 0 deletions lib/gettext_strings.rb
Expand Up @@ -18,6 +18,7 @@ def CustomGettext
N_('file_tab') # document form tab name
N_('template_tab') # document form tab name
N_('text_doc_tab') # document form tab name
N_('custom_tab') # custom form tab name

N_('btn_add_doc') # used by zafu layout template
N_('btn_add') # used by zafu layout template
Expand Down
Binary file modified locale/en/LC_MESSAGES/zena.mo
Binary file not shown.
Binary file modified locale/fr/LC_MESSAGES/zena.mo
Binary file not shown.

0 comments on commit 68803bd

Please sign in to comment.