mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Remove Execution Chains
This commit is contained in:
parent
7138f2430b
commit
38072ca1a6
3 changed files with 11 additions and 24 deletions
|
@ -13,16 +13,12 @@
|
|||
// Remove any callback details if any
|
||||
$('.js-paloma-hook[data-id!=' + <%= id %> + ']').remove();
|
||||
|
||||
var requests = <%= requests.to_json.html_safe %>;
|
||||
|
||||
for (var i = 0, len = requests.length; i < len; i++){
|
||||
var request = requests[i];
|
||||
|
||||
Paloma.engine.request(request['resource'],
|
||||
request['action'],
|
||||
request['params']);
|
||||
}
|
||||
var request = <%= request.to_json.html_safe %>;
|
||||
|
||||
Paloma.engine.request(
|
||||
request['resource'],
|
||||
request['action'],
|
||||
request['params']);
|
||||
|
||||
$(document).ready(function(){ Paloma.engine.start(); });
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ module Paloma
|
|||
# Use on controllers to pass variables to Paloma controller.
|
||||
#
|
||||
def js params = {}
|
||||
return session[:paloma_requests].pop if !params
|
||||
session[:paloma_requests].last[:params] = params
|
||||
return @__paloma_request = nil if !params
|
||||
@__paloma_request[:params] = params
|
||||
end
|
||||
|
||||
|
||||
|
@ -37,11 +37,7 @@ module Paloma
|
|||
def track_paloma_request
|
||||
resource = controller_path.split('/').map(&:titleize).join('/').gsub(' ', '')
|
||||
|
||||
paloma_request = {:resource => resource,
|
||||
:action => self.action_name}
|
||||
|
||||
session[:paloma_requests] ||= []
|
||||
session[:paloma_requests].push paloma_request
|
||||
@__paloma_request = {:resource => resource, :action => self.action_name}
|
||||
end
|
||||
|
||||
|
||||
|
@ -53,11 +49,11 @@ module Paloma
|
|||
# will execute the tracked Paloma requests.
|
||||
#
|
||||
def append_paloma_hook
|
||||
return true if session[:paloma_requests].empty?
|
||||
return true if @__paloma_request.nil?
|
||||
|
||||
hook = view_context.render(
|
||||
:partial => 'paloma/hook',
|
||||
:locals => {:requests => session[:paloma_requests]})
|
||||
:locals => {:request => @__paloma_request})
|
||||
|
||||
before_body_end_index = response_body[0].rindex('</body>')
|
||||
|
||||
|
@ -72,7 +68,7 @@ module Paloma
|
|||
response.body += hook
|
||||
end
|
||||
|
||||
session[:paloma_requests] = nil
|
||||
@__paloma_request = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,11 +16,6 @@ feature 'executing Paloma controller', :js => true do
|
|||
context 'coming from a redirect' do
|
||||
before { visit foo_index_path }
|
||||
|
||||
it 'executes first the Paloma action of the first Rails action' do
|
||||
first = page.evaluate_script 'window.called[0]'
|
||||
expect(first).to eq 'MyFoo#index'
|
||||
end
|
||||
|
||||
it 'executes next the Paloma action of the last Rails action' do
|
||||
last = page.evaluate_script 'window.called.pop()'
|
||||
expect(last).to eq 'Main#index'
|
||||
|
|
Loading…
Reference in a new issue