ruote-kit 2.2.0.3 → 2.3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/CHANGELOG.txt +28 -1
  2. data/CREDITS.txt +8 -2
  3. data/LICENSE.txt +1 -1
  4. data/Rakefile +21 -9
  5. data/lib/ruote-kit.rb +13 -4
  6. data/lib/ruote-kit/core_ext.rb +15 -0
  7. data/lib/ruote-kit/helpers/json_helpers.rb +22 -7
  8. data/lib/ruote-kit/helpers/link_helpers.rb +9 -7
  9. data/lib/ruote-kit/helpers/pagination_helpers.rb +1 -2
  10. data/lib/ruote-kit/helpers/render_helpers.rb +1 -1
  11. data/lib/ruote-kit/public/_ruote/images/favicon.png +0 -0
  12. data/lib/ruote-kit/public/_ruote/images/{ruote_buttons.png → ruote-buttons.png} +0 -0
  13. data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
  14. data/lib/ruote-kit/public/_ruote/javascripts/foolbox-all.min.js +3 -0
  15. data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.9.1.min.js +5 -0
  16. data/lib/ruote-kit/public/_ruote/javascripts/rk.js +68 -17
  17. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-all.min.js +3 -0
  18. data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +82 -12
  19. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-buttons.png +0 -0
  20. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +9 -6
  21. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo.css +62 -0
  22. data/lib/ruote-kit/resources/errors.rb +8 -3
  23. data/lib/ruote-kit/resources/expressions.rb +38 -35
  24. data/lib/ruote-kit/resources/participants.rb +1 -1
  25. data/lib/ruote-kit/resources/processes.rb +61 -4
  26. data/lib/ruote-kit/resources/workitems.rb +4 -4
  27. data/lib/ruote-kit/version.rb +1 -1
  28. data/lib/ruote-kit/views/_pagination.html.haml +2 -2
  29. data/lib/ruote-kit/views/_tree_editor.html.haml +63 -30
  30. data/lib/ruote-kit/views/error.html.haml +50 -9
  31. data/lib/ruote-kit/views/errors.html.haml +1 -1
  32. data/lib/ruote-kit/views/expression.html.haml +83 -33
  33. data/lib/ruote-kit/views/expressions.html.haml +23 -8
  34. data/lib/ruote-kit/views/http_error.html.haml +9 -2
  35. data/lib/ruote-kit/views/layout.html.haml +14 -13
  36. data/lib/ruote-kit/views/process.html.haml +75 -20
  37. data/lib/ruote-kit/views/processes.html.haml +9 -3
  38. data/lib/ruote-kit/views/processes_new.html.haml +19 -2
  39. data/lib/ruote-kit/views/schedules.html.haml +2 -2
  40. data/lib/ruote-kit/views/workitem.html.haml +17 -6
  41. data/ruote-kit.gemspec +9 -7
  42. data/spec/cases/orphan_workitem_spec.rb +141 -0
  43. data/spec/core_ext_spec.rb +19 -0
  44. data/spec/resources/errors_spec.rb +182 -156
  45. data/spec/resources/expressions_spec.rb +497 -379
  46. data/spec/resources/index_spec.rb +5 -5
  47. data/spec/resources/participants_spec.rb +64 -75
  48. data/spec/resources/processes_spec.rb +396 -277
  49. data/spec/resources/schedules_spec.rb +92 -76
  50. data/spec/resources/workitems_spec.rb +352 -343
  51. data/spec/ruote-kit_configure_spec.rb +41 -13
  52. data/spec/spec_helper.rb +6 -8
  53. data/spec/support/link_helper.rb +11 -0
  54. data/spec/webapp_helpers_spec.rb +29 -23
  55. metadata +161 -180
  56. data/README.rdoc +0 -313
  57. data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
  58. data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +0 -154
  59. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +0 -548
  60. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +0 -1118
@@ -43,7 +43,7 @@ class RuoteKit::Application
43
43
  respond_to do |format|
44
44
 
45
45
  format.html do
46
- redirect '/_ruote/participants'
46
+ redirect url('/_ruote/participants')
47
47
  end
48
48
  format.json do
49
49
  @participants = RuoteKit.engine.participant_list
@@ -24,8 +24,36 @@ class RuoteKit::Application
24
24
 
25
25
  @process = RuoteKit.engine.process(params[:wfid])
26
26
 
27
+ return http_error(404) if @process.nil? or @process.expressions.empty?
28
+
29
+ @pins =
30
+ @process.leaves.collect { |fexp|
31
+ pin =
32
+ if fexp.error
33
+ [ 'error', 'er' ]
34
+ elsif fexp.class == Ruote::Exp::ParticipantExpression
35
+ [ 'workitem', 'wi' ]
36
+ else
37
+ [ 'other', '-' ]
38
+ end
39
+ [ fexp.fei.expid, *pin ]
40
+ }
41
+
42
+ respond_with :process
43
+ end
44
+
45
+ put '/_ruote/processes/:wfid' do
46
+
47
+ @process = RuoteKit.engine.process(params[:wfid])
48
+
27
49
  return http_error(404) unless @process
28
50
 
51
+ if fetch_put_info['state'] == 'paused'
52
+ RuoteKit.engine.pause(params[:wfid])
53
+ else
54
+ RuoteKit.engine.resume(params[:wfid])
55
+ end
56
+
29
57
  respond_with :process
30
58
  end
31
59
 
@@ -38,7 +66,11 @@ class RuoteKit::Application
38
66
  @wfid = RuoteKit.engine.launch(
39
67
  @info.definition, @info.fields || {}, @info.variables || {})
40
68
 
41
- rescue Exception => e
69
+ rescue => e
70
+ #p e
71
+ #p e.ruby
72
+ #puts e.ruby.backtrace
73
+ #puts e.backtrace
42
74
  return http_error(400, e)
43
75
  end
44
76
 
@@ -59,22 +91,47 @@ class RuoteKit::Application
59
91
  end
60
92
 
61
93
  respond_to do |format|
62
- format.html { redirect '/_ruote/processes' }
94
+ format.html { redirect url('/_ruote/processes') }
63
95
  format.json { json :status, :ok }
64
96
  end
65
97
  end
66
98
 
67
99
  protected
68
100
 
101
+ class LaunchInfo
102
+
103
+ attr_accessor :definition, :fields, :variables
104
+
105
+ def initialize(h={})
106
+
107
+ @definition = h['definition'].strip
108
+ @fields = h['fields']
109
+ @variables = h['variables']
110
+
111
+ if @definition.match(/^define /) && @definition.match(/\bend$/)
112
+ @definition = 'Ruote.' + @definition
113
+ end
114
+ end
115
+ end
116
+
117
+ def fetch_put_info
118
+
119
+ if request.content_type.match(/^application\/json(;.+)?$/)
120
+ Rufus::Json.decode(request.body.read)
121
+ else
122
+ params
123
+ end
124
+ end
125
+
69
126
  def fetch_launch_info
70
127
 
71
128
  if request.content_type == 'application/json' then
72
129
 
73
- OpenStruct.new(Rufus::Json.decode(request.body.read))
130
+ LaunchInfo.new(Rufus::Json.decode(request.body.read))
74
131
 
75
132
  else
76
133
 
77
- info = OpenStruct.new('definition' => params[:definition])
134
+ info = LaunchInfo.new('definition' => params[:definition])
78
135
 
79
136
  fields = params[:fields] || ''
80
137
  fields = '{}' if fields.empty?
@@ -35,7 +35,6 @@ class RuoteKit::Application
35
35
 
36
36
  if @workitem
37
37
  etag @workitem.to_h['_rev']
38
-
39
38
  respond_with :workitem
40
39
  else
41
40
  respond_with :workitems
@@ -62,15 +61,16 @@ class RuoteKit::Application
62
61
  end
63
62
 
64
63
  if options[:proceed]
65
- RuoteKit.engine.storage_participant.reply(@workitem)
64
+ RuoteKit.engine.storage_participant.proceed(@workitem)
66
65
  end
67
66
 
68
67
  respond_to do |format|
69
68
 
70
69
  format.html do
71
70
  redirect(options[:proceed] ?
72
- "/_ruote/workitems/#{@workitem.fei.wfid}" :
73
- "/_ruote/workitems/#{@workitem.fei.sid}")
71
+ url("/_ruote/workitems/#{@workitem.fei.wfid}") :
72
+ url("/_ruote/workitems/#{@workitem.fei.sid}")
73
+ )
74
74
  end
75
75
  format.json do
76
76
  json :workitem
@@ -8,6 +8,6 @@
8
8
 
9
9
  module RuoteKit
10
10
 
11
- VERSION = '2.2.0'
11
+ VERSION = '2.3.0.2'
12
12
  end
13
13
 
@@ -17,7 +17,7 @@
17
17
  = @count
18
18
  = res
19
19
 
20
- - las = ((@count / lim.to_f).ceil - 1) * lim
20
+ - las = lim < 1 ? @count : ((@count / lim.to_f).ceil - 1) * lim
21
21
  - pre = [ 0, @skip - lim ].max
22
22
  - nex = [ @skip + lim, las ].min
23
23
 
@@ -35,4 +35,4 @@
35
35
 
36
36
  - if resources = instance_variable_get("@#{res}")
37
37
  = "#{resources.size} #{res}"
38
-
38
+
@@ -1,10 +1,13 @@
1
1
 
2
2
  #overlay
3
3
  #editor
4
- %canvas#efluo
4
+ #fluo
5
5
  #fluo_editor
6
- %a.ruote_button.ruote_go_button{ :title => 'close and use that definition', :href => '', :onclick => 'hideEditor(true); return false;' }
7
- %a.ruote_button.ruote_cross_button{ :title => 'close', :href => '', :onclick => 'hideEditor(false); return false;' }
6
+ .editor_buttons
7
+ %button.use{ :value => 'Ruby' } use (Ruby)
8
+ %button.use{ :value => 'Json' } use (JSON)
9
+ %button.use{ :value => 'Radial' } use (Radial)
10
+ %button.discard{ :title => 'close' } discard
8
11
 
9
12
  :javascript
10
13
 
@@ -13,40 +16,70 @@
13
16
  $('#overlay').hide();
14
17
  $('#editor').hide();
15
18
 
16
- function initEditor () {
19
+ $('button.use').each(function(i, e) {
20
+ $(e).attr('title', 'close and use this definition as ' + e.value);
21
+ });
22
+
23
+ $('button.use').on('click', function(ev) {
24
+ RkEditor.hide(ev.target.value);
25
+ return false;
26
+ });
27
+ $('button.discard').on('click', function() {
28
+ RkEditor.hide(false);
29
+ return false;
30
+ });
31
+
32
+ // disable "save as Ruby" for now
33
+ //
34
+ var $ruby = $('button.use[value="Ruby"]');
35
+ $ruby.attr(
36
+ 'disabled',
37
+ 'disabled');
38
+ $ruby.attr(
39
+ 'title',
40
+ $ruby.attr('title') +
41
+ ' (disabled for now, Radial and JSON are sufficient)');
42
+
43
+ var RkEditor = (function() {
44
+
45
+ var self = this;
46
+
47
+ this.init = function() {
48
+
49
+ var tree = window.tree || #{sample_process_tree};
50
+ var def = $('#tree').val();
51
+ if (def.match(/\s*\[/)) tree = JSON.parse(def);
52
+
53
+ RuoteFluoEditor.render('#fluo_editor', tree);
54
+ RuoteFluo.render('#fluo', tree);
55
+
56
+ $('#fluo_editor')[0].onChange = function(tree) {
57
+ RuoteFluo.render('#fluo', tree);
58
+ }
59
+ $('#fluo_editor')[0].onOver = function(expid) {
60
+ RuoteFluo.highlight('#fluo', expid);
61
+ }
62
+ }
17
63
 
18
- var tree = tree || #{sample_process_tree};
19
- var def = $('#tree')[0].value;
20
- if (def.match(/\s*\[/)) tree = JSON.parse(def);
64
+ this.show = function() {
21
65
 
22
- FluoEditor.renderFlow('fluo_editor', tree);
23
- Fluo.renderFlow('efluo', tree);
24
- Fluo.crop('efluo');
66
+ $('#overlay').css('height', '' + $(document).height() + 'px');
25
67
 
26
- $('#fluo_editor')[0].onChange = function (tree) {
27
- Fluo.renderFlow('efluo', tree);
28
- Fluo.crop('efluo');
29
- }
30
- $('#fluo_editor')[0].onOver = function (expid) {
31
- Fluo.highlight('efluo', expid);
68
+ $('#overlay').slideDown(function() {
69
+ $('#editor').show();
70
+ RkEditor.init()
71
+ });
32
72
  }
33
- }
34
-
35
- function showEditor () {
36
73
 
37
- initEditor();
74
+ this.hide = function(use) {
38
75
 
39
- document.getElementById('overlay').style.height =
40
- '' + window.outerHeight + 'px';
76
+ $('#editor').hide();
77
+ $('#overlay').hide();
41
78
 
42
- $('#overlay').slideDown(function () { $('#editor').show(); });
43
- }
44
-
45
- function hideEditor (use) {
79
+ if (use) $('#tree').val(RuoteFluoEditor['as' + use]('#fluo_editor'));
80
+ }
46
81
 
47
- $('#editor').hide();
48
- $('#overlay').hide();
82
+ return this;
49
83
 
50
- if (use) $('#tree')[0].value = FluoEditor.asJson('fluo_editor');
51
- }
84
+ }).apply({});
52
85
 
@@ -1,15 +1,25 @@
1
1
 
2
2
  - # under the MIT license, see LICENSE.txt
3
3
 
4
+ - @_uses_fluo = true
5
+
4
6
  %h1 error #{@error.fei.sid}
5
7
 
8
+ #fluo
9
+
6
10
  %table.details
7
11
 
8
12
  %tr
9
13
  %td
10
14
  id
11
15
  %td
12
- = @error.fei.sid
16
+ &= @error.fei.sid
17
+
18
+ %tr
19
+ %td
20
+ at
21
+ %td
22
+ &= @error.at
13
23
 
14
24
  %tr
15
25
  %td
@@ -27,8 +37,19 @@
27
37
  %td
28
38
  trace
29
39
  %td
30
- %pre.trace{ :onclick => 'Rk.toggleNext(this);' } #{h(@error.trace[0, 80] + '...')}
31
- %pre.trace{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{h(@error.trace)}
40
+ %pre.trace #{h(@error.trace[0, 80] + '...')}
41
+ %pre.trace{ :style => 'display: none;' } #{h(@error.trace)}
42
+
43
+ %tr
44
+ %td
45
+ details
46
+ %td
47
+ - if @error.details.nil?
48
+ %pre.details nil
49
+ - else
50
+ - details = Ruote.pps(@error.details)
51
+ %pre.details #{h(details[0, 80] + '...')}
52
+ %pre.details{ :style => 'display: none;' } #{h(details)}
32
53
 
33
54
  %tr
34
55
  %td.no_border{ :colspan => 2 }
@@ -40,8 +61,8 @@
40
61
  %td
41
62
  GET
42
63
  = alink(:expressions, @error.fei.sid)
43
- %span.explanation
44
- you can re-apply the expression (and hopefully nuke the error) from there
64
+ -#%span.explanation
65
+ -# you can re-apply the expression (and hopefully nuke the error) from there
45
66
  %tr
46
67
  %td
47
68
  process
@@ -50,7 +71,7 @@
50
71
  = alink(:processes, @error.wfid)
51
72
  %tr
52
73
  %td
53
- errors of this process
74
+ process errors
54
75
  %td
55
76
  GET
56
77
  = alink(:errors, @error.wfid)
@@ -62,8 +83,28 @@
62
83
  %td
63
84
  %td
64
85
  %form{ :method => 'POST' }
65
- %input{ :type => 'hidden', :name => '_method', :value => 'delete' }
86
+ %input{ :type => 'hidden', :name => '_method', :value => 'DELETE' }
66
87
  %input{ :type => 'submit', :value => "DELETE /_ruote/errors/#{@error.fei.sid}", :title => 'replay at this error' }
67
- %span.explanation
68
- replay at this error
88
+ -#%span.explanation
89
+ -# replay at this error
90
+
91
+ :javascript
92
+
93
+ $(document).ready(function() {
94
+
95
+ $('pre.trace').on('click', Rk.toggleNext);
96
+ $('pre.details').on('click', Rk.toggleNext);
97
+
98
+ Rk.fitFluo();
99
+
100
+ var proc_rep = #{process_tree(@process)};
101
+ var pins = #{Rufus::Json.encode(@pins)};
102
+
103
+ RuoteFluo.render('#fluo', proc_rep, { fit: 'down' });
104
+ Rk.onClickZoom('#fluo');
105
+
106
+ pins.forEach(function(pin) {
107
+ RuoteFluo.pin('#fluo', pin[0], pin[1], pin[2])
108
+ });
109
+ });
69
110
 
@@ -6,7 +6,7 @@
6
6
  = haml :_pagination, :layout => false
7
7
 
8
8
  %table.list
9
-
9
+
10
10
  %thead
11
11
  %td
12
12
  error
@@ -7,11 +7,12 @@
7
7
  expression
8
8
  = @expression.fei.sid
9
9
 
10
- %canvas#fluo
10
+ #exp_fluo
11
11
 
12
12
  %form{ :method => 'POST', :enctype => 'multipart/form-data', :accept_charset => 'UTF-8' }
13
13
 
14
14
  %input#_method{ :type => 'hidden', :name => '_method', :value => 'DELETE' }
15
+ %input#state{ :type => 'hidden', :name => 'state', :value => '' }
15
16
  %input{ :type => 'hidden', :name => '_snowman', :value => '&#9731;' }
16
17
 
17
18
  %table.details
@@ -33,9 +34,14 @@
33
34
  &= @expression.tree.first
34
35
  %tr
35
36
  %td
36
- expression class
37
+ class
37
38
  %td
38
39
  &= @expression.class.to_s
40
+ %tr
41
+ %td
42
+ state
43
+ %td
44
+ &= @expression.state
39
45
  - if @expression.original_tree != @expression.tree
40
46
  %tr
41
47
  %td
@@ -44,9 +50,9 @@
44
50
  - ruby = Ruote::Reader.to_ruby(@expression.original_tree)
45
51
  - rubyline = ruby.split("\n").first
46
52
  - json = Rufus::Json.pretty_encode(@expression.original_tree)
47
- %pre.pdef{ :onclick => 'Rk.toggleNext(this);' } #{rubyline}
48
- %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{ruby}
49
- %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{json}
53
+ %pre.pdef #{rubyline}
54
+ %pre.pdef{ :style => 'display: none;' } #{ruby}
55
+ %pre.pdef{ :style => 'display: none;' } #{json}
50
56
  %tr
51
57
  %td
52
58
  tree
@@ -54,9 +60,9 @@
54
60
  - ruby = Ruote::Reader.to_ruby(@expression.tree)
55
61
  - rubyline = ruby.split("\n").first
56
62
  - json = Rufus::Json.pretty_encode(@expression.tree)
57
- %pre.pdef{ :onclick => 'Rk.toggleNext(this);' } #{rubyline}
58
- %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{ruby}
59
- %pre.pdef{ :onclick => 'Rk.toggleNext(this);', :style => 'display: none;' } #{json}
63
+ %pre.pdef #{rubyline}
64
+ %pre.pdef{ :style => 'display: none;' } #{ruby}
65
+ %pre.pdef{ :style => 'display: none;' } #{json}
60
66
 
61
67
  - if sched = @process.schedules.find { |s| s['owner'] == @expression.fei }
62
68
  %tr
@@ -97,23 +103,35 @@
97
103
 
98
104
  %tr
99
105
  %td
100
- cancel
106
+ - if @expression.state == 'paused'
107
+ %input{ :type => 'submit', :value => 'resume' }
108
+ - else
109
+ %input{ :type => 'submit', :value => 'pause' }
110
+ %input{ :type => 'checkbox', :name => 'breakpoint' }
111
+ breakpoint
112
+ %td
113
+ %span.description PUT /_ruote/expressions/#{@expression.fei.sid}
114
+
115
+ %tr
116
+ %td.no_border{ :colspan => 2 }
117
+ &nbsp;
118
+
119
+ %tr
120
+ %td
121
+ %input{ :type => 'submit', :value => 'cancel' }
101
122
  %td
102
- %input{ :type => 'submit', :value => 'cancel', :onclick => 'return confirm("really ?");' }
103
123
  %span.description DELETE /_ruote/expressions/#{@expression.fei.sid}
104
124
  %tr
105
125
  %td
106
- kill
126
+ %input{ :type => 'submit', :value => 'kill' }
107
127
  %td
108
- -#%input{ :type => 'hidden', :name => '_kill', :value => '1' }
109
- %input{ :type => 'submit', :value => 'kill', :onclick => 'return confirm("really ?");' }
110
128
  %span.description DELETE /_ruote/expressions/#{@expression.fei.sid}?_kill=1
111
129
 
112
130
  %tr
113
131
  %td.no_border{ :colspan => 2 }
114
132
  &nbsp;
115
133
 
116
- %tr{ :style => 'cursor: pointer;', :onclick => 'showReApply(this);' }
134
+ %tr#show_re_apply{ :style => 'cursor: pointer;' }
117
135
  %td{ :colspan => 2 }
118
136
  re-apply
119
137
  %tr.re_apply
@@ -126,7 +144,7 @@
126
144
  %tr.re_apply
127
145
  %td
128
146
  tree
129
- %a.ruote_button.ruote_go_button{ :title => 'open process definition editor', :href => '', :onclick => 'showEditor(); return false;' }
147
+ %a.ruote_button.ruote_go_button{ :title => 'open process definition editor', :href => '' }
130
148
  %td.no_padding
131
149
  - tree = @expression.tree
132
150
  - tree = Rufus::Json.pretty_encode(tree)
@@ -135,35 +153,67 @@
135
153
  %tr.re_apply
136
154
  %td
137
155
  %td
138
- -#%input{ :type => 'hidden', :name => '_method', :value => 'put' }
139
- %input{ :type => 'submit', :value => 're-apply', :onclick => 'return confirmReApply();' }
156
+ %input{ :type => 'submit', :value => 're-apply' }
140
157
  %span.description PUT /_ruote/expressions/#{@expression.fei.sid}
141
158
 
142
159
 
143
160
  :javascript
144
161
 
145
- var proc_rep = #{process_tree(@process)};
146
- Fluo.renderFlow('fluo', proc_rep);
147
- Fluo.crop('fluo');
148
- Fluo.highlight('fluo', '#{@expression.fei.expid}');
149
- Fluo.resizeForMaxWidth('fluo', $('body').width() / 2.1);
162
+ $(document).ready(function() {
163
+
164
+ $('pre.pdef').on('click', Rk.toggleNext);
165
+
166
+ Rk.fitFluo($('#exp_fluo'), $('table.details'));
167
+
168
+ var proc_rep = #{process_tree(@process)};
169
+ RuoteFluo.render('#exp_fluo', proc_rep, { fit: 'down' });
170
+ RuoteFluo.highlight('#exp_fluo', '#{@expression.fei.expid}');
171
+
172
+ Rk.onClickZoom('#exp_fluo');
173
+
174
+ $('.re_apply').hide();
175
+
176
+ $('#show_re_apply').on('click', function(ev) {
177
+ $(ev.target).hide();
178
+ $('.re_apply').show();
179
+ });
180
+
181
+ $('a.ruote_go_button').on('click', function(ev) {
182
+ RkEditor.show();
183
+ return false;
184
+ });
185
+
186
+ function confirmPut(message) {
187
+
188
+ var r = confirm(message);
150
189
 
151
- $('.re_apply').hide();
190
+ if (r) {
191
+ $('#_method')[0].value = 'PUT';
192
+ if (message.match(/pause/)) {
193
+ $('#state')[0].value = 'paused';
194
+ } else if (message.match(/resume/)) {
195
+ $('#state')[0].value = 'resuming';
196
+ } else {
197
+ $('#state').detach();
198
+ }
199
+ }
152
200
 
153
- function showReApply (elt) {
154
- $(elt).hide();
155
- $('.re_apply').show();
156
- }
201
+ return r;
202
+ }
157
203
 
158
- function confirmReApply () {
204
+ $('input[type="submit"]').on('click', function(ev) {
159
205
 
160
- var r = confirm('really ?');
161
- if (r) $('#_method')[0].value = 'PUT';
206
+ var val = ev.target.value;
207
+ var msg = "really " + val + " expression?";
162
208
 
163
- return r;
164
- }
209
+ if (val === 'cancel' || val === 'kill') {
210
+ return confirm(msg);
211
+ }
212
+ return confirmPut(msg);
213
+ });
214
+ });
165
215
 
166
- var tree = #{Rufus::Json.encode(@expression.tree)};
216
+ window.tree = #{Rufus::Json.encode(@expression.tree)};
167
217
 
168
218
  = haml :_tree_editor, :layout => false
169
219