Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9513: remove_in_place_editing.patch

File remove_in_place_editing.patch, 10.8 kB (added by lifofifo, 10 months ago)

Remove in place editing stuff from actionpack

  • actionpack/test/template/java_script_macros_helper_test.rb

    old new  
    6464      text_field_with_auto_complete(:message, :recipient, {}, :skip_style => true) 
    6565  end 
    6666   
    67   def test_in_place_editor_external_control 
    68       assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {externalControl:'blah'})\n//]]>\n</script>), 
    69         in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :external_control => 'blah'}) 
    70   end 
    71    
    72   def test_in_place_editor_size 
    73       assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {size:4})\n//]]>\n</script>), 
    74         in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :size => 4}) 
    75   end 
    76    
    77   def test_in_place_editor_cols_no_rows 
    78       assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {cols:4})\n//]]>\n</script>), 
    79         in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :cols => 4}) 
    80   end 
    81    
    82   def test_in_place_editor_cols_with_rows 
    83       assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {cols:40, rows:5})\n//]]>\n</script>), 
    84         in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :rows => 5, :cols => 40}) 
    85   end 
    86  
    87   def test_inplace_editor_loading_text 
    88       assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {loadingText:'Why are we waiting?'})\n//]]>\n</script>), 
    89         in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :loading_text => 'Why are we waiting?'}) 
    90   end 
    91    
    92   def test_in_place_editor_url 
    93     assert_match "Ajax.InPlaceEditor('id-goes-here', 'http://www.example.com/action_to_set_value')", 
    94     in_place_editor( 'id-goes-here', :url => { :action => "action_to_set_value" })     
    95   end 
    96    
    97   def test_in_place_editor_load_text_url 
    98     assert_match "Ajax.InPlaceEditor('id-goes-here', 'http://www.example.com/action_to_set_value', {loadTextURL:'http://www.example.com/action_to_get_value'})", 
    99     in_place_editor( 'id-goes-here',  
    100       :url => { :action => "action_to_set_value" },  
    101       :load_text_url => { :action => "action_to_get_value" }) 
    102   end 
    103    
    104   def test_in_place_editor_eval_scripts 
    105     assert_match "Ajax.InPlaceEditor('id-goes-here', 'http://www.example.com/action_to_set_value', {evalScripts:true})", 
    106     in_place_editor( 'id-goes-here',  
    107       :url => { :action => "action_to_set_value" },  
    108       :script => true ) 
    109   end 
    110    
    11167end 
  • actionpack/lib/action_controller/macros/in_place_editing.rb

    old new  
    1 module ActionController 
    2   module Macros 
    3     module InPlaceEditing #:nodoc: 
    4       def self.included(base) #:nodoc: 
    5         base.extend(ClassMethods) 
    6       end 
    7  
    8       # DEPRECATION WARNING: This method will become a separate plugin when Rails 2.0 ships. 
    9       # 
    10       # Example: 
    11       # 
    12       #   # Controller 
    13       #   class BlogController < ApplicationController 
    14       #     in_place_edit_for :post, :title 
    15       #   end 
    16       # 
    17       #   # View 
    18       #   <%= in_place_editor_field :post, 'title' %> 
    19       # 
    20       # For help on defining an in place editor in the browser, 
    21       # see ActionView::Helpers::JavaScriptHelper. 
    22       module ClassMethods 
    23         def in_place_edit_for(object, attribute, options = {}) 
    24           define_method("set_#{object}_#{attribute}") do 
    25             @item = object.to_s.camelize.constantize.find(params[:id]) 
    26             @item.update_attribute(attribute, params[:value]) 
    27             render :text => @item.send(attribute) 
    28           end 
    29         end 
    30       end 
    31     end 
    32   end 
    33 end 
  • actionpack/lib/action_controller.rb

    old new  
    5555require 'action_controller/components' 
    5656require 'action_controller/record_identifier' 
    5757require 'action_controller/macros/auto_complete' 
    58 require 'action_controller/macros/in_place_editing' 
    5958 
    6059require 'action_view' 
    6160ActionController::Base.template_class = ActionView::Base 
     
    7776  include ActionController::Components 
    7877  include ActionController::RecordIdentifier 
    7978  include ActionController::Macros::AutoComplete 
    80   include ActionController::Macros::InPlaceEditing 
    8179end 
  • actionpack/lib/action_view/helpers/java_script_macros_helper.rb

    old new  
    66    # larger units. These macros also rely on counterparts in the controller that provide them with their backing. The in-place 
    77    # editing relies on ActionController::Base.in_place_edit_for and the autocompletion relies on  
    88    # ActionController::Base.auto_complete_for. 
    9     module JavaScriptMacrosHelper 
     9    module JavaScriptMacrosHelper       
    1010      # DEPRECATION WARNING: This method will become a separate plugin when Rails 2.0 ships. 
    1111      # 
    12       # Makes an HTML element specified by the DOM ID +field_id+ become an in-place 
    13       # editor of a property. 
    14       # 
    15       # A form is automatically created and displayed when the user clicks the element, 
    16       # something like this: 
    17       #   <form id="myElement-in-place-edit-form" target="specified url"> 
    18       #     <input name="value" text="The content of myElement"/> 
    19       #     <input type="submit" value="ok"/> 
    20       #     <a onclick="javascript to cancel the editing">cancel</a> 
    21       #   </form> 
    22       #  
    23       # The form is serialized and sent to the server using an AJAX call, the action on 
    24       # the server should process the value and return the updated value in the body of 
    25       # the reponse. The element will automatically be updated with the changed value 
    26       # (as returned from the server). 
    27       #  
    28       # Required +options+ are: 
    29       # <tt>:url</tt>::       Specifies the url where the updated value should 
    30       #                       be sent after the user presses "ok". 
    31       #  
    32       # Addtional +options+ are: 
    33       # <tt>:rows</tt>::              Number of rows (more than 1 will use a TEXTAREA) 
    34       # <tt>:cols</tt>::              Number of characters the text input should span (works for both INPUT and TEXTAREA) 
    35       # <tt>:size</tt>::              Synonym for :cols when using a single line text input. 
    36       # <tt>:cancel_text</tt>::       The text on the cancel link. (default: "cancel") 
    37       # <tt>:save_text</tt>::         The text on the save link. (default: "ok") 
    38       # <tt>:loading_text</tt>::      The text to display while the data is being loaded from the server (default: "Loading...") 
    39       # <tt>:saving_text</tt>::       The text to display when submitting to the server (default: "Saving...") 
    40       # <tt>:external_control</tt>::  The id of an external control used to enter edit mode. 
    41       # <tt>:load_text_url</tt>::     URL where initial value of editor (content) is retrieved. 
    42       # <tt>:options</tt>::           Pass through options to the AJAX call (see prototype's Ajax.Updater) 
    43       # <tt>:with</tt>::              JavaScript snippet that should return what is to be sent 
    44       #                               in the AJAX call, +form+ is an implicit parameter 
    45       # <tt>:script</tt>::            Instructs the in-place editor to evaluate the remote JavaScript response (default: false) 
    46       # <tt>:click_to_edit_text</tt>::The text shown during mouseover the editable text (default: "Click to edit") 
    47       def in_place_editor(field_id, options = {}) 
    48         function =  "new Ajax.InPlaceEditor(" 
    49         function << "'#{field_id}', " 
    50         function << "'#{url_for(options[:url])}'" 
    51  
    52         js_options = {} 
    53         js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text] 
    54         js_options['okText'] = %('#{options[:save_text]}') if options[:save_text] 
    55         js_options['loadingText'] = %('#{options[:loading_text]}') if options[:loading_text] 
    56         js_options['savingText'] = %('#{options[:saving_text]}') if options[:saving_text] 
    57         js_options['rows'] = options[:rows] if options[:rows] 
    58         js_options['cols'] = options[:cols] if options[:cols] 
    59         js_options['size'] = options[:size] if options[:size] 
    60         js_options['externalControl'] = "'#{options[:external_control]}'" if options[:external_control] 
    61         js_options['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if options[:load_text_url]         
    62         js_options['ajaxOptions'] = options[:options] if options[:options] 
    63         js_options['evalScripts'] = options[:script] if options[:script] 
    64         js_options['callback']   = "function(form) { return #{options[:with]} }" if options[:with] 
    65         js_options['clickToEditText'] = %('#{options[:click_to_edit_text]}') if options[:click_to_edit_text] 
    66         function << (', ' + options_for_javascript(js_options)) unless js_options.empty? 
    67          
    68         function << ')' 
    69  
    70         javascript_tag(function) 
    71       end 
    72        
    73       # DEPRECATION WARNING: This method will become a separate plugin when Rails 2.0 ships. 
    74       # 
    75       # Renders the value of the specified object and method with in-place editing capabilities. 
    76       # 
    77       # See the RDoc on ActionController::InPlaceEditing to learn more about this. 
    78       def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {}) 
    79         tag = ::ActionView::Helpers::InstanceTag.new(object, method, self) 
    80         tag_options = {:tag => "span", :id => "#{object}_#{method}_#{tag.object.id}_in_place_editor", :class => "in_place_editor_field"}.merge!(tag_options) 
    81         in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object}_#{method}", :id => tag.object.id }) 
    82         tag.to_content_tag(tag_options.delete(:tag), tag_options) + 
    83         in_place_editor(tag_options[:id], in_place_editor_options) 
    84       end 
    85        
    86       # DEPRECATION WARNING: This method will become a separate plugin when Rails 2.0 ships. 
    87       # 
    8812      # Adds AJAX autocomplete functionality to the text input field with the  
    8913      # DOM ID specified by +field_id+. 
    9014      #