Class: Reactive::View::Wx::Helpers::ModelEditCtrl
- Inherits:
-
Wx::Panel
- Object
- Wx::Panel
- Reactive::View::Wx::Helpers::ModelEditCtrl
- Defined in:
- lib/helpers/model_edit_ctrl_class.rb
Instance Attribute Summary collapse
- #error_color ⇒ Object
-
#model ⇒ Object
readonly
Returns the value of attribute model.
- #normal_color ⇒ Object
Instance Method Summary collapse
-
#initialize(parent, record, submit_link, options = {}) ⇒ ModelEditCtrl
constructor
A new instance of ModelEditCtrl.
- #selected_records ⇒ Object
- #show_errors(record) ⇒ Object
Constructor Details
#initialize(parent, record, submit_link, options = {}) ⇒ ModelEditCtrl
Returns a new instance of ModelEditCtrl.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/helpers/model_edit_ctrl_class.rb', line 14 def initialize(parent, record, submit_link, = {}) super(parent, ) @model, @record = record.class, record @book = parent arrange_vertically(:padding => 5) nest(container = Wx::ScrolledWindow.new(self, :style => Wx::TAB_TRAVERSAL | Wx::SUNKEN_BORDER, :name => @model.to_s.demodulize.underscore), :proportion => 1) container.set_scroll_rate(2,2) fill_controls(container, record) show_errors(record) (self, container, submit_link) end |
Instance Attribute Details
#error_color ⇒ Object
44 45 46 |
# File 'lib/helpers/model_edit_ctrl_class.rb', line 44 def error_color @error_color ||= Wx::Colour.new(255, 160, 160) end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/helpers/model_edit_ctrl_class.rb', line 8 def model @model end |
Instance Method Details
#selected_records ⇒ Object
10 11 12 |
# File 'lib/helpers/model_edit_ctrl_class.rb', line 10 def selected_records [@record] end |
#show_errors(record) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/helpers/model_edit_ctrl_class.rb', line 27 def show_errors(record) @model.columns.each do |column| next if column.primary if control = find_window_by_name(column.name) if errors = record.errors.on(column.name) control.set_background_colour(error_color) control.set_tool_tip(errors.to_a.join("\n")) control.refresh else control.set_background_colour(normal_color) control.set_tool_tip(nil) control.refresh end end end end |