active_scaffold_vho 3.0.21 → 3.0.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_scaffold_vho}
8
- s.version = "3.0.21"
8
+ s.version = "3.0.22"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Many, see README"]
12
- s.date = %q{2011-09-23}
12
+ s.date = %q{2011-10-22}
13
13
  s.description = %q{Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.}
14
14
  s.email = %q{activescaffold@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -154,6 +154,8 @@ Gem::Specification.new do |s|
154
154
  "lib/active_scaffold/bridges/shared/date_bridge.rb",
155
155
  "lib/active_scaffold/bridges/tiny_mce/bridge.rb",
156
156
  "lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb",
157
+ "lib/active_scaffold/bridges/tiny_mce/public/javascripts/jquery/tiny_mce_bridge.js",
158
+ "lib/active_scaffold/bridges/tiny_mce/public/javascripts/prototype/tiny_mce_bridge.js",
157
159
  "lib/active_scaffold/bridges/validation_reflection/bridge.rb",
158
160
  "lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb",
159
161
  "lib/active_scaffold/config/base.rb",
@@ -239,6 +239,16 @@ $(document).ready(function() {
239
239
  });
240
240
  return true;
241
241
  });
242
+ $('form.as_form').live('ajax:before', function(event) {
243
+ var as_form = $(this).closest("form");
244
+ $(this).trigger('as:form_submit');
245
+ return true;
246
+ });
247
+ $('form.as_form[data-remote!="true"]').live('submit', function(event) {
248
+ var as_form = $(this).closest("form");
249
+ $(this).trigger('as:form_submit');
250
+ return true;
251
+ });
242
252
  ActiveScaffold.trigger_load_events($('[data-as_load]'));
243
253
 
244
254
  });
@@ -446,6 +456,7 @@ var ActiveScaffold = {
446
456
  replace: function(element, html) {
447
457
  if (typeof(element) == 'string') element = '#' + element;
448
458
  element = $(element);
459
+ ActiveScaffold.trigger_unload_events(element.find('[data-as_load]').andSelf());
449
460
  element.replaceWith(html);
450
461
  if (element.attr('id')) {
451
462
  element = $('#' + element.attr('id'));
@@ -457,6 +468,7 @@ var ActiveScaffold = {
457
468
  replace_html: function(element, html) {
458
469
  if (typeof(element) == 'string') element = '#' + element;
459
470
  element = $(element);
471
+ ActiveScaffold.trigger_unload_events(element.find('[data-as_load]'));
460
472
  element.html(html);
461
473
  ActiveScaffold.trigger_load_events(element.find('[data-as_load]'));
462
474
  return element;
@@ -659,6 +671,7 @@ var ActiveScaffold = {
659
671
 
660
672
  if (element) {
661
673
  if (options.is_subform == false) {
674
+ ActiveScaffold.trigger_unload_events(element.closest('li.form-element'));
662
675
  this.replace(element.closest('dl'), content);
663
676
  ActiveScaffold.trigger_load_events(element.closest('li.form-element'));
664
677
  } else {
@@ -792,6 +805,22 @@ var ActiveScaffold = {
792
805
  break;
793
806
  }
794
807
  });
808
+ },
809
+
810
+ trigger_unload_events: function(elements){
811
+ elements.each(function(index) {
812
+ switch ($(this).attr('data-as_load')) {
813
+ case 'tr':
814
+ $(this).trigger('as:list_row_unloaded');
815
+ break;
816
+ case 'form':
817
+ $(this).trigger('as:form_unloaded');
818
+ break;
819
+ case 'form-element':
820
+ $(this).trigger('as:form_element_unloaded');
821
+ break;
822
+ }
823
+ });
795
824
  }
796
825
  }
797
826
 
@@ -906,6 +935,7 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
906
935
 
907
936
  close: function() {
908
937
  this.enable();
938
+ ActiveScaffold.trigger_unload_events(this.adapter.find('[data-as_load]'));
909
939
  this.adapter.remove();
910
940
  if (this.hide_target) this.target.show();
911
941
  },
@@ -977,6 +1007,7 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
977
1007
  $.each(this.set.links, function(index, item) {
978
1008
  if (item.url != _this.url && item.is_disabled() && item.adapter) {
979
1009
  item.enable();
1010
+ ActiveScaffold.trigger_unload_events(item.adapter.find('[data-as_load]'));
980
1011
  item.adapter.remove();
981
1012
  }
982
1013
  });
@@ -314,6 +314,16 @@ document.observe("dom:loaded", function() {
314
314
  ActiveScaffold.focus_first_element_of_form(as_form);
315
315
  return true;
316
316
  });
317
+ document.on('ajax:before', 'form.as_form', function(event) {
318
+ var as_form = event.findElement('form');
319
+ element.fire('as:form_submit');
320
+ return true;
321
+ });
322
+ document.on('submit', 'form.as_form[data-remote!="true"]', function(event) {
323
+ var as_form = event.findElement('form');
324
+ element.fire('as:form_submit');
325
+ return true;
326
+ });
317
327
  ActiveScaffold.trigger_load_events($$('[data-as_load]'));
318
328
  });
319
329
 
@@ -397,10 +407,13 @@ var ActiveScaffold = {
397
407
  },
398
408
 
399
409
  replace: function(element, html) {
400
- element = $(element)
410
+ element = $(element);
411
+ var elements = element.select('[data-as_load]');
412
+ elements.unshift(element);
413
+ ActiveScaffold.trigger_unload_events(elements);
401
414
  Element.replace(element, html);
402
415
  element = $(element.readAttribute('id'));
403
- var elements = element.select('[data-as_load]');
416
+ elements = element.select('[data-as_load]');
404
417
  elements.unshift(element);
405
418
  ActiveScaffold.trigger_load_events(elements);
406
419
  return element;
@@ -408,6 +421,7 @@ var ActiveScaffold = {
408
421
 
409
422
  replace_html: function(element, html) {
410
423
  element = $(element);
424
+ ActiveScaffold.trigger_unload_events(element.select('[data-as_load]'));
411
425
  element.update(html);
412
426
  ActiveScaffold.trigger_load_events(element.select('[data-as_load]'));
413
427
  return element;
@@ -590,6 +604,7 @@ var ActiveScaffold = {
590
604
 
591
605
  if (element) {
592
606
  if (options.is_subform == false) {
607
+ ActiveScaffold.trigger_unload_events(new Array(element.up('li.form-element')));
593
608
  this.replace(element.up('dl'), content);
594
609
  ActiveScaffold.trigger_load_events(new Array(element.up('li.form-element')));
595
610
  } else {
@@ -647,6 +662,22 @@ var ActiveScaffold = {
647
662
  break;
648
663
  }
649
664
  });
665
+ },
666
+
667
+ trigger_unload_events: function(elements){
668
+ elements.each(function(element) {
669
+ switch (element.readAttribute('data-as_load')) {
670
+ case 'tr':
671
+ element.fire('as:list_row_unloaded');
672
+ break;
673
+ case 'form':
674
+ element.fire('as:form_unloaded');
675
+ break;
676
+ case 'form-element':
677
+ element.fire('as:form_element_unloaded');
678
+ break;
679
+ }
680
+ });
650
681
  }
651
682
 
652
683
  }
@@ -796,6 +827,7 @@ ActiveScaffold.ActionLink.Abstract = Class.create({
796
827
 
797
828
  close: function() {
798
829
  this.enable();
830
+ ActiveScaffold.trigger_unload_events(this.adapter.select('[data-as_load]'));
799
831
  this.adapter.remove();
800
832
  if (this.hide_target) this.target.show();
801
833
  },
@@ -866,6 +898,7 @@ ActiveScaffold.ActionLink.Record = Class.create(ActiveScaffold.ActionLink.Abstra
866
898
  this.set.links.each(function(item) {
867
899
  if (item.url != this.url && item.is_disabled() && item.adapter) {
868
900
  item.enable();
901
+ ActiveScaffold.trigger_unload_events(item.adapter.select('[data-as_load]'));
869
902
  item.adapter.remove();
870
903
  }
871
904
  }.bind(this));
@@ -2,7 +2,11 @@
2
2
  xhr = request.xhr? if xhr.nil?
3
3
  if active_scaffold_config.actions.include? form_action
4
4
  multipart ||= active_scaffold_config.send(form_action).multipart?
5
- columns ||= active_scaffold_config.send(form_action).columns
5
+ columns ||= if respond_to?("#{form_action}_columns")
6
+ self.send("#{form_action}_columns")
7
+ else
8
+ active_scaffold_config.send(form_action).columns
9
+ end
6
10
  else
7
11
  multipart ||= false
8
12
  columns ||= nil
@@ -150,7 +150,7 @@ module ActiveScaffold::Actions
150
150
  params = params[:record] || {} unless params[model.inheritance_column] # in create action must be inside record key
151
151
  model = params.delete(model.inheritance_column).camelize.constantize if params[model.inheritance_column]
152
152
  end
153
- model.respond_to?(:build) ? model.build(build_options || {}) : model.new
153
+ model.new(build_options || {})
154
154
  end
155
155
 
156
156
  private
@@ -5,6 +5,7 @@ module ActiveScaffold::Actions
5
5
  base.verify :method => :post,
6
6
  :only => :create,
7
7
  :redirect_to => { :action => :index }
8
+ base.helper_method :create_columns
8
9
  end
9
10
 
10
11
  def new
@@ -69,15 +70,15 @@ module ActiveScaffold::Actions
69
70
  end
70
71
 
71
72
  def create_respond_to_xml
72
- render :xml => response_object.to_xml(:only => active_scaffold_config.create.columns.names), :content_type => Mime::XML, :status => response_status, :location => response_location
73
+ render :xml => response_object.to_xml(:only => create_columns_names), :content_type => Mime::XML, :status => response_status, :location => response_location
73
74
  end
74
75
 
75
76
  def create_respond_to_json
76
- render :text => response_object.to_json(:only => active_scaffold_config.create.columns.names), :content_type => Mime::JSON, :status => response_status, :location => response_location
77
+ render :text => response_object.to_json(:only => create_columns_names), :content_type => Mime::JSON, :status => response_status, :location => response_location
77
78
  end
78
79
 
79
80
  def create_respond_to_yaml
80
- render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.create.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status, :location => response_location
81
+ render :text => Hash.from_xml(response_object.to_xml(:only => create_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status, :location => response_location
81
82
  end
82
83
 
83
84
  # A simple method to find and prepare an example new record for the form
@@ -97,7 +98,7 @@ module ActiveScaffold::Actions
97
98
  def do_create
98
99
  begin
99
100
  active_scaffold_config.model.transaction do
100
- @record = update_record_from_params(new_model, active_scaffold_config.create.columns, params[:record])
101
+ @record = update_record_from_params(new_model, create_columns, params[:record])
101
102
  apply_constraints_to_record(@record, :allow_autosave => true)
102
103
  if nested?
103
104
  create_association_with_parent(@record)
@@ -134,16 +135,27 @@ module ActiveScaffold::Actions
134
135
  def create_authorized?
135
136
  (!nested? || !nested.readonly?) && authorized_for?(:crud_type => :create)
136
137
  end
137
- private
138
- def create_authorized_filter
139
- link = active_scaffold_config.create.link || active_scaffold_config.create.class.link
140
- raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
141
- end
138
+
142
139
  def new_formats
143
140
  (default_formats + active_scaffold_config.formats).uniq
144
141
  end
145
142
  def create_formats
146
143
  (default_formats + active_scaffold_config.formats + active_scaffold_config.create.formats).uniq
147
144
  end
145
+
146
+ def create_columns
147
+ active_scaffold_config.create.columns
148
+ end
149
+
150
+ def create_columns_names
151
+ update_columns.collect(&:name)
152
+ end
153
+
154
+ private
155
+ def create_authorized_filter
156
+ link = active_scaffold_config.create.link || active_scaffold_config.create.class.link
157
+ raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
158
+ end
159
+
148
160
  end
149
161
  end
@@ -63,13 +63,15 @@ module ActiveScaffold::Actions
63
63
  def delete_authorized?(record = nil)
64
64
  (!nested? || !nested.readonly?) && authorized_for?(:crud_type => :delete)
65
65
  end
66
+
67
+ def destroy_formats
68
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.delete.formats).uniq
69
+ end
66
70
  private
67
71
  def delete_authorized_filter
68
72
  link = active_scaffold_config.delete.link || active_scaffold_config.delete.class.link
69
73
  raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
70
74
  end
71
- def destroy_formats
72
- (default_formats + active_scaffold_config.formats + active_scaffold_config.delete.formats).uniq
73
- end
75
+
74
76
  end
75
77
  end
@@ -6,6 +6,7 @@ module ActiveScaffold::Actions
6
6
  base.before_filter :store_search_params_into_session, :only => [:index]
7
7
  base.before_filter :do_search, :only => [:index]
8
8
  base.helper_method :field_search_params
9
+ base.helper_method :field_search_columns
9
10
  end
10
11
 
11
12
  # FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validations.
@@ -46,7 +47,7 @@ module ActiveScaffold::Actions
46
47
  text_search = active_scaffold_config.field_search.text_search
47
48
  search_conditions = []
48
49
  human_condition_columns = [] if active_scaffold_config.field_search.human_conditions
49
- columns = active_scaffold_config.field_search.columns
50
+ columns = field_search_columns
50
51
  search_params.each do |key, value|
51
52
  next unless columns.include? key
52
53
  search_condition = self.class.condition_for_column(active_scaffold_config.columns[key], value, text_search)
@@ -69,14 +70,24 @@ module ActiveScaffold::Actions
69
70
  end
70
71
  end
71
72
 
73
+ def field_search_formats
74
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.field_search.formats).uniq
75
+ end
76
+
77
+ def field_search_columns
78
+ active_scaffold_config.field_search.columns
79
+ end
80
+
81
+ def field_search_names
82
+ field_search_columns.collect(&:name)
83
+ end
84
+
72
85
  private
73
86
 
74
87
  def search_authorized_filter
75
88
  link = active_scaffold_config.field_search.link || active_scaffold_config.field_search.class.link
76
89
  raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
77
90
  end
78
- def field_search_formats
79
- (default_formats + active_scaffold_config.formats + active_scaffold_config.field_search.formats).uniq
80
- end
91
+
81
92
  end
82
93
  end
@@ -162,11 +162,6 @@ module ActiveScaffold::Actions
162
162
  def action_update_respond_to_yaml
163
163
  render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => list_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
164
164
  end
165
-
166
- private
167
- def list_authorized_filter
168
- raise ActiveScaffold::ActionNotAllowed unless list_authorized?
169
- end
170
165
 
171
166
  def list_formats
172
167
  (default_formats + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
@@ -181,6 +176,11 @@ module ActiveScaffold::Actions
181
176
  (default_formats + active_scaffold_config.formats).uniq
182
177
  end
183
178
 
179
+ private
180
+ def list_authorized_filter
181
+ raise ActiveScaffold::ActionNotAllowed unless list_authorized?
182
+ end
183
+
184
184
  def list_columns
185
185
  active_scaffold_config.list.columns.collect_visible
186
186
  end
@@ -35,13 +35,13 @@ module ActiveScaffold::Actions
35
35
  end
36
36
  end
37
37
 
38
+ def search_formats
39
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.search.formats).uniq
40
+ end
38
41
  private
39
42
  def search_authorized_filter
40
43
  link = active_scaffold_config.search.link || active_scaffold_config.search.class.link
41
44
  raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
42
45
  end
43
- def search_formats
44
- (default_formats + active_scaffold_config.formats + active_scaffold_config.search.formats).uniq
45
- end
46
46
  end
47
47
  end
@@ -2,6 +2,7 @@ module ActiveScaffold::Actions
2
2
  module Show
3
3
  def self.included(base)
4
4
  base.before_filter :show_authorized_filter, :only => :show
5
+ base.helper_method :show_columns
5
6
  end
6
7
 
7
8
  def show
@@ -20,15 +21,15 @@ module ActiveScaffold::Actions
20
21
  protected
21
22
 
22
23
  def show_respond_to_json
23
- render :text => response_object.to_json(:only => active_scaffold_config.show.columns.names), :content_type => Mime::JSON, :status => response_status
24
+ render :text => response_object.to_json(:only => show_columns_names), :content_type => Mime::JSON, :status => response_status
24
25
  end
25
26
 
26
27
  def show_respond_to_yaml
27
- render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.show.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
28
+ render :text => Hash.from_xml(response_object.to_xml(:only => show_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
28
29
  end
29
30
 
30
31
  def show_respond_to_xml
31
- render :xml => response_object.to_xml(:only => active_scaffold_config.show.columns.names), :content_type => Mime::XML, :status => response_status
32
+ render :xml => response_object.to_xml(:only => show_columns_names), :content_type => Mime::XML, :status => response_status
32
33
  end
33
34
 
34
35
  def show_respond_to_js
@@ -49,13 +50,24 @@ module ActiveScaffold::Actions
49
50
  def show_authorized?(record = nil)
50
51
  authorized_for?(:crud_type => :read)
51
52
  end
53
+
54
+ def show_formats
55
+ (default_formats + active_scaffold_config.formats + active_scaffold_config.show.formats).uniq
56
+ end
57
+
58
+ def show_columns
59
+ active_scaffold_config.show.columns
60
+ end
61
+
62
+ def show_columns_names
63
+ show_columns.collect(&:name)
64
+ end
65
+
52
66
  private
53
67
  def show_authorized_filter
54
68
  link = active_scaffold_config.show.link || active_scaffold_config.show.class.link
55
69
  raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
56
70
  end
57
- def show_formats
58
- (default_formats + active_scaffold_config.formats + active_scaffold_config.show.formats).uniq
59
- end
71
+
60
72
  end
61
73
  end
@@ -6,6 +6,7 @@ module ActiveScaffold::Actions
6
6
  :only => :update,
7
7
  :redirect_to => { :action => :index }
8
8
  base.helper_method :update_refresh_list?
9
+ base.helper_method :update_columns
9
10
  end
10
11
 
11
12
  def edit
@@ -57,13 +58,13 @@ module ActiveScaffold::Actions
57
58
  render :action => 'on_update'
58
59
  end
59
60
  def update_respond_to_xml
60
- render :xml => response_object.to_xml(:only => active_scaffold_config.update.columns.names), :content_type => Mime::XML, :status => response_status
61
+ render :xml => response_object.to_xml(:only => update_columns_names), :content_type => Mime::XML, :status => response_status
61
62
  end
62
63
  def update_respond_to_json
63
- render :text => response_object.to_json(:only => active_scaffold_config.update.columns.names), :content_type => Mime::JSON, :status => response_status
64
+ render :text => response_object.to_json(:only => update_columns_names), :content_type => Mime::JSON, :status => response_status
64
65
  end
65
66
  def update_respond_to_yaml
66
- render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.update.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
67
+ render :text => Hash.from_xml(response_object.to_xml(:only => update_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
67
68
  end
68
69
  # A simple method to find and prepare a record for editing
69
70
  # May be overridden to customize the record (set default values, etc.)
@@ -82,7 +83,7 @@ module ActiveScaffold::Actions
82
83
  def update_save(options = {})
83
84
  begin
84
85
  active_scaffold_config.model.transaction do
85
- @record = update_record_from_params(@record, active_scaffold_config.update.columns, params[:record]) unless options[:no_record_param_update]
86
+ @record = update_record_from_params(@record, update_columns, params[:record]) unless options[:no_record_param_update]
86
87
  before_update_save(@record)
87
88
  self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
88
89
  if successful?
@@ -136,16 +137,28 @@ module ActiveScaffold::Actions
136
137
  def update_authorized?(record = nil)
137
138
  (!nested? || !nested.readonly?) && authorized_for?(:crud_type => :update)
138
139
  end
139
- private
140
- def update_authorized_filter
141
- link = active_scaffold_config.update.link || active_scaffold_config.update.class.link
142
- raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
143
- end
140
+
144
141
  def edit_formats
145
142
  (default_formats + active_scaffold_config.formats).uniq
146
143
  end
144
+
147
145
  def update_formats
148
146
  (default_formats + active_scaffold_config.formats + active_scaffold_config.update.formats).uniq
149
147
  end
148
+
149
+ def update_columns
150
+ active_scaffold_config.update.columns
151
+ end
152
+
153
+ def update_columns_names
154
+ update_columns.collect(&:name)
155
+ end
156
+
157
+ private
158
+ def update_authorized_filter
159
+ link = active_scaffold_config.update.link || active_scaffold_config.update.class.link
160
+ raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
161
+ end
162
+
150
163
  end
151
164
  end
@@ -1,5 +1,21 @@
1
1
  ActiveScaffold::Bridges.bridge "TinyMCE" do
2
2
  install do
3
3
  require File.join(File.dirname(__FILE__), "lib/tiny_mce_bridge.rb")
4
+ directory = File.dirname(__FILE__)
5
+ destination = File.join(Rails.root, "public/javascripts/active_scaffold/default/")
6
+
7
+ if ActiveScaffold.js_framework == :jquery
8
+ source = File.join(directory, "public/javascripts/jquery/tiny_mce_bridge.js")
9
+ FileUtils.rm(File.join(destination, 'tiny_mce_bridge.js')) if File.exist?(File.join(destination, 'tiny_mce_bridge.js'))
10
+ FileUtils.cp(source, destination)
11
+ else
12
+ source = File.join(directory, "public/javascripts/prototype/tiny_mce_bridge.js")
13
+ FileUtils.rm(File.join(destination, 'tiny_mce_bridge.js')) if File.exist?(File.join(destination, 'tiny_mce_bridge.js'))
14
+ FileUtils.cp(source, destination)
15
+ end unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
16
+ end
17
+
18
+ install? do
19
+ true
4
20
  end
5
21
  end
@@ -1,49 +1,15 @@
1
1
  module ActiveScaffold
2
2
  module TinyMceBridge
3
3
  module ViewHelpers
4
- def active_scaffold_includes(*args)
5
- if ActiveScaffold.js_framework == :jquery
6
- tiny_mce_js = javascript_tag(%|
7
- var action_link_close = ActiveScaffold.ActionLink.Abstract.prototype.close;
8
- ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
9
- $(this.adapter).find('textarea.mceEditor').each(function(index, elem) {
10
- tinyMCE.execCommand('mceRemoveControl', false, $(elem).attr('id'));
11
- });
12
- action_link_close.apply(this);
13
- };
14
- |) if using_tiny_mce?
15
- else
16
- tiny_mce_js = javascript_tag(%|
17
- var action_link_close = ActiveScaffold.ActionLink.Abstract.prototype.close;
18
- ActiveScaffold.ActionLink.Abstract.prototype.close = function() {
19
- this.adapter.select('textarea.mceEditor').each(function(elem) {
20
- tinyMCE.execCommand('mceRemoveControl', false, elem.id);
21
- });
22
- action_link_close.apply(this);
23
- };
24
- |) if using_tiny_mce?
25
- end
26
- super(*args) + (include_tiny_mce_if_needed || '') + (tiny_mce_js || '')
27
- end
28
4
  end
29
5
 
30
6
  module FormColumnHelpers
31
7
  def active_scaffold_input_text_editor(column, options)
32
- options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip
8
+ options[:class] = "#{options[:class]} as_mceEditor #{column.options[:class]}".strip
33
9
  html = []
34
10
  html << send(override_input(:textarea), column, options)
35
- html << javascript_tag("tinyMCE.execCommand('mceAddControl', false, '#{options[:id]}');") if request.xhr?
36
11
  html.join "\n"
37
12
  end
38
-
39
- def onsubmit
40
- if ActiveScaffold.js_framework == :jquery
41
- submit_js = 'tinyMCE.triggerSave();$(\'textarea.mceEditor\').each(function(index, elem) { tinyMCE.execCommand(\'mceRemoveControl\', false, $(elem).attr(\'id\')); });' if using_tiny_mce?
42
- else
43
- submit_js = 'tinyMCE.triggerSave();this.select(\'textarea.mceEditor\').each(function(elem) { tinyMCE.execCommand(\'mceRemoveControl\', false, elem.id); });' if using_tiny_mce?
44
- end
45
- [super, submit_js].compact.join ';'
46
- end
47
13
  end
48
14
 
49
15
  module SearchColumnHelpers
@@ -0,0 +1,22 @@
1
+ $('form.as_form').live('as:form_loaded', function(event) {
2
+ var as_form = $(this).closest("form");
3
+ as_form.find('textarea.as_mceEditor').each(function(index, elem) {
4
+ tinyMCE.execCommand('mceAddControl', false, $(elem).attr('id'));
5
+ });
6
+ return true;
7
+ });
8
+ $('form.as_form').live('as:form_submit', function(event) {
9
+ var as_form = $(this).closest("form");
10
+ if (as_form.has('textarea.as_mceEditor').length > 0) {
11
+ tinyMCE.triggerSave();
12
+ }
13
+ return true;
14
+ });
15
+
16
+ $('form.as_form').live('as:form_unloaded', function(event) {
17
+ var as_form = $(this).closest("form");
18
+ as_form.find('textarea.as_mceEditor').each(function(index, elem) {
19
+ tinyMCE.execCommand('mceRemoveControl', false, $(elem).attr('id'));
20
+ });
21
+ return true;
22
+ });
@@ -0,0 +1,21 @@
1
+ document.on('as:form_loaded', 'form.as_form', function(event) {
2
+ var as_form = event.findElement('form');
3
+ as_form.select('textarea.mceEditor').each(function(elem) {
4
+ tinyMCE.execCommand('mceAddControl', false, elem.id);
5
+ });
6
+ return true;
7
+ });
8
+ document.on('as:form_submit', 'form.as_form', function(event) {
9
+ var as_form = event.findElement('form');
10
+ if (as_form.has('textarea.mceEditor').length > 0) {
11
+ tinyMCE.triggerSave();
12
+ }
13
+ return true;
14
+ });
15
+ document.on('as:form_unloaded', 'form.as_form', function(event) {
16
+ var as_form = event.findElement('form');
17
+ as_form.select('textarea.mceEditor').each(function(elem) {
18
+ tinyMCE.execCommand('mceRemoveControl', false, elem.id);
19
+ });
20
+ return true;
21
+ });
@@ -27,11 +27,16 @@ module ActiveScaffold::DataStructures
27
27
  end
28
28
 
29
29
  def include?(item)
30
- @set.each do |c|
31
- return true if !c.is_a? Symbol and c.include? item
32
- return true if c == item.to_sym
30
+ @set.any? do |c|
31
+ case c
32
+ when Symbol
33
+ c == item.to_sym
34
+ when ActiveScaffold::DataStructures::Column
35
+ c.name == item.to_sym
36
+ when ActiveScaffold::DataStructures::ActionColumns
37
+ !c.is_a? Symbol and c.include? item
38
+ end
33
39
  end
34
- return false
35
40
  end
36
41
 
37
42
  def names
@@ -42,6 +47,20 @@ module ActiveScaffold::DataStructures
42
47
  Array(@set)
43
48
  end
44
49
 
50
+ def select(&block)
51
+ self.convert_to_columns unless columns_converted?
52
+ #columns = ActiveScaffold::DataStructures::ActionColumns.new
53
+ columns = self.clone
54
+ #ActiveScaffold::DataStructures::ActionColumns.class_eval {include ActiveScaffold::DataStructures::ActionColumns::AfterConfiguration}
55
+ #columns.label = self.label
56
+ #columns.action = self.action
57
+ columns.instance_variable_get('@set').clear
58
+ cols = @set.select &block
59
+
60
+ columns.add cols
61
+ columns
62
+ end
63
+
45
64
  protected
46
65
 
47
66
  def collect_columns
@@ -53,6 +72,22 @@ module ActiveScaffold::DataStructures
53
72
  @set = from.instance_variable_get('@set').clone
54
73
  end
55
74
 
75
+ # at the beginning items are only symbolized column names to allow easy configuration
76
+ # later on we need ActiveScaffold::Datastructures:ActionColumn
77
+ def convert_to_columns
78
+ @set.collect! do|item|
79
+ unless item.is_a? ActiveScaffold::DataStructures::ActionColumns
80
+ item = (@columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, @columns.active_record_class))
81
+ end
82
+ item
83
+ end
84
+ @columns_converted = true
85
+ end
86
+
87
+ def columns_converted?
88
+ @columns_converted
89
+ end
90
+
56
91
  # A package of stuff to add after the configuration block. This is an attempt at making a certain level of functionality inaccessible during configuration, to reduce possible breakage from misuse.
57
92
  # The bulk of the package is a means of connecting the referential column set (ActionColumns) with the actual column objects (Columns). This lets us iterate over the set and yield real column objects.
58
93
  module AfterConfiguration
@@ -63,34 +98,30 @@ module ActiveScaffold::DataStructures
63
98
  # * :flatten - whether to recursively iterate on nested sets. default is false.
64
99
  # * :for - the record (or class) being iterated over. used for column-level security. default is the class.
65
100
  def each(options = {}, &proc)
101
+ self.convert_to_columns unless columns_converted?
66
102
  options[:for] ||= @columns.active_record_class
67
103
  self.unauthorized_columns = []
68
104
  @set.each do |item|
69
- unless item.is_a? ActiveScaffold::DataStructures::ActionColumns
70
- item = (@columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, @columns.active_record_class))
71
- next if self.skip_column?(item, options)
72
- end
73
- if item.is_a? ActiveScaffold::DataStructures::ActionColumns and options.has_key?(:flatten) and options[:flatten]
74
- item.each(options, &proc)
75
- else
76
- yield item
105
+ case item
106
+ when ActiveScaffold::DataStructures::Column
107
+ self.skip_column?(item, options) ? next : (yield item)
108
+ when ActiveScaffold::DataStructures::ActionColumns
109
+ options[:flatten] ? item.each(options, &proc) : (yield item)
77
110
  end
78
111
  end
79
112
  end
80
113
 
81
114
  def collect_visible(options = {}, &proc)
115
+ self.convert_to_columns unless columns_converted?
82
116
  columns = []
83
117
  options[:for] ||= @columns.active_record_class
84
118
  self.unauthorized_columns = []
85
119
  @set.each do |item|
86
- unless item.is_a? ActiveScaffold::DataStructures::ActionColumns
87
- item = (@columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, @columns.active_record_class))
88
- next if self.skip_column?(item, options)
89
- end
90
- if item.is_a? ActiveScaffold::DataStructures::ActionColumns and options.has_key?(:flatten) and options[:flatten]
91
- columns = columns + item.collect(options, &proc)
92
- else
93
- columns << item
120
+ case item
121
+ when ActiveScaffold::DataStructures::Column
122
+ self.skip_column?(item, options) ? next : (columns << item)
123
+ when ActiveScaffold::DataStructures::ActionColumns
124
+ options[:flatten] ? item.collect(options, &proc) : (columns << item)
94
125
  end
95
126
  end
96
127
  columns
@@ -232,7 +232,8 @@ module ActiveScaffold
232
232
  def visibles_and_hiddens(search_config)
233
233
  visibles = []
234
234
  hiddens = []
235
- search_config.columns.each do |column|
235
+ columns = field_search_columns
236
+ columns.each do |column|
236
237
  next unless column.search_sql
237
238
  if search_config.optional_columns.include?(column.name) && !searched_by?(column)
238
239
  hiddens << column
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- PATCH = 21
5
+ PATCH = 22
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_vho
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
4
+ hash: 43
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 21
10
- version: 3.0.21
9
+ - 22
10
+ version: 3.0.22
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-23 00:00:00 +02:00
18
+ date: 2011-10-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -267,6 +267,8 @@ files:
267
267
  - lib/active_scaffold/bridges/shared/date_bridge.rb
268
268
  - lib/active_scaffold/bridges/tiny_mce/bridge.rb
269
269
  - lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb
270
+ - lib/active_scaffold/bridges/tiny_mce/public/javascripts/jquery/tiny_mce_bridge.js
271
+ - lib/active_scaffold/bridges/tiny_mce/public/javascripts/prototype/tiny_mce_bridge.js
270
272
  - lib/active_scaffold/bridges/validation_reflection/bridge.rb
271
273
  - lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
272
274
  - lib/active_scaffold/config/base.rb