ruby_mvc 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,11 +35,12 @@ module Models
|
|
35
35
|
class ActiveRecordTableModel < TableModel
|
36
36
|
attr_reader :keys
|
37
37
|
|
38
|
-
def initialize(entity_type,
|
38
|
+
def initialize(entity_type, options = {})
|
39
39
|
super()
|
40
40
|
@row_idx = []
|
41
41
|
@entity_type = entity_type
|
42
|
-
@rows = rows
|
42
|
+
@rows = options[:rows]
|
43
|
+
@filter = options[:filter]
|
43
44
|
@keys = @entity_type.attribute_names.sort
|
44
45
|
|
45
46
|
# FIXME: this is a hack because I'm not sure how best to
|
@@ -49,7 +50,7 @@ module Models
|
|
49
50
|
|
50
51
|
def create_rows(count = 1)
|
51
52
|
rows = []
|
52
|
-
count.times { rows << @entity_type.new }
|
53
|
+
count.times { rows << @entity_type.new(@filter) }
|
53
54
|
rows
|
54
55
|
end
|
55
56
|
|
@@ -123,7 +124,11 @@ module Models
|
|
123
124
|
|
124
125
|
protected
|
125
126
|
def _rows
|
126
|
-
|
127
|
+
if @filter
|
128
|
+
x = @entity_type.where(@filter)
|
129
|
+
else
|
130
|
+
x = @rows || @entity_type.find(:all)
|
131
|
+
end
|
127
132
|
puts "working with #{x.count} rows"
|
128
133
|
x
|
129
134
|
end
|
@@ -49,7 +49,7 @@ module RubyMVC
|
|
49
49
|
end
|
50
50
|
|
51
51
|
evt_grid_range_select do |e|
|
52
|
-
puts "Event alt: #{e.alt_down}; ctrl: #{e.control_down}; brc: #{e.get_bottom_right_coords}; bottom: #{e.get_bottom_row}; left: #{e.get_left_col}; right: #{e.get_right_col}; tlc: #{e.get_top_left_coords}; top: #{e.get_top_row}; meta: #{e.meta_down}; selecting: #{e.selecting}; shift: #{e.shift_down}" if !e.selecting
|
52
|
+
# puts "Event alt: #{e.alt_down}; ctrl: #{e.control_down}; brc: #{e.get_bottom_right_coords}; bottom: #{e.get_bottom_row}; left: #{e.get_left_col}; right: #{e.get_right_col}; tlc: #{e.get_top_left_coords}; top: #{e.get_top_row}; meta: #{e.meta_down}; selecting: #{e.selecting}; shift: #{e.shift_down}" if !e.selecting
|
53
53
|
next if !e.selecting
|
54
54
|
|
55
55
|
# FIXME: this should be a bit more clever in the
|
@@ -87,6 +87,7 @@ module RubyMVC
|
|
87
87
|
@model.signal_connect("rows-removed") do |s, i, r|
|
88
88
|
puts "refresh rows-removed"
|
89
89
|
@gm = GridModel.new(model)
|
90
|
+
selected_rows.delete(i)
|
90
91
|
set_table(@gm, Wx::Grid::GridSelectRows, false)
|
91
92
|
end
|
92
93
|
@model.signal_connect("row-changed") do |s, i, r|
|
@@ -30,7 +30,7 @@ module Views
|
|
30
30
|
def initialize(app, parent, entity_type, options = {}, &block)
|
31
31
|
options[:editable] = false
|
32
32
|
options[:show_row_labels] = false
|
33
|
-
@model = Models::ActiveRecordTableModel.new(entity_type)
|
33
|
+
@model = Models::ActiveRecordTableModel.new(entity_type, options)
|
34
34
|
@template = options[:template]
|
35
35
|
super((@template ? @template.apply(@model) : @model), options)
|
36
36
|
signal_connect("row-edit") do |s, m, i, r|
|
@@ -40,6 +40,8 @@ module Views
|
|
40
40
|
begin
|
41
41
|
r.save!
|
42
42
|
m.update_row(i, r)
|
43
|
+
rescue ActiveRecord::StatementInvalid => e
|
44
|
+
app.error(e, :title => "Database Error", :parent => dlg)
|
43
45
|
rescue ActiveRecord::RecordInvalid => e
|
44
46
|
app.error(e, :title => "Validation Error", :parent => dlg)
|
45
47
|
end
|
@@ -28,7 +28,7 @@ module Views
|
|
28
28
|
|
29
29
|
class ActiveRecordWebTypeList < WebContentTableView
|
30
30
|
def initialize(entity_type, options = {}, &block)
|
31
|
-
@model = Models::ActiveRecordTableModel.new(entity_type)
|
31
|
+
@model = Models::ActiveRecordTableModel.new(entity_type, options)
|
32
32
|
if options.is_a? Hash
|
33
33
|
@template = options[:template]
|
34
34
|
else
|
data/ruby_mvc.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ruby_mvc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andrew S. Townley
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-10 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: A simple, cross-platform MVC framework for Ruby
|