clevic 0.7.0 → 0.8.0
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.
- data/History.txt +12 -999
- data/Manifest.txt +1 -0
- data/README.txt +13 -10
- data/Rakefile +4 -3
- data/TODO +28 -13
- data/bin/clevic +64 -11
- data/config/hoe.rb +1 -1
- data/lib/clevic/browser.rb +86 -116
- data/lib/clevic/cache_table.rb +14 -4
- data/lib/clevic/db_options.rb +13 -8
- data/lib/clevic/delegates.rb +3 -1
- data/lib/clevic/extensions.rb +16 -0
- data/lib/clevic/field.rb +13 -3
- data/lib/clevic/field_builder.rb +42 -0
- data/lib/clevic/model_builder.rb +285 -92
- data/lib/clevic/record.rb +45 -2
- data/lib/clevic/table_model.rb +137 -40
- data/lib/clevic/table_view.rb +345 -150
- data/lib/clevic/ui/browser.ui +18 -73
- data/lib/clevic/ui/browser_ui.rb +57 -99
- data/lib/clevic/ui/search_dialog_ui.rb +51 -50
- data/lib/clevic/version.rb +1 -1
- data/models/accounts_models.rb +21 -26
- data/models/minimal_models.rb +2 -0
- data/models/times_models.rb +78 -79
- data/models/times_sqlite_models.rb +8 -8
- data/models/values_models.rb +7 -6
- data/website/index.html +24 -27
- metadata +4 -3
data/lib/clevic/version.rb
CHANGED
data/models/accounts_models.rb
CHANGED
@@ -16,21 +16,18 @@ class Entry < Clevic::Record
|
|
16
16
|
belongs_to :debit, :class_name => 'Account', :foreign_key => 'debit_id'
|
17
17
|
belongs_to :credit, :class_name => 'Account', :foreign_key => 'credit_id'
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
records :order => 'date, id'
|
33
|
-
end
|
19
|
+
define_ui do
|
20
|
+
plain :date, :sample => '88-WWW-99'
|
21
|
+
distinct :description, :conditions => "now() - date <= '1 year'", :sample => 'm' * 26
|
22
|
+
relational :debit, :display => 'name', :conditions => 'active = true', :order => 'lower(name)', :sample => 'Leilani Member Loan'
|
23
|
+
relational :credit, :display => 'name', :conditions => 'active = true', :order => 'lower(name)', :sample => 'Leilani Member Loan'
|
24
|
+
plain :amount, :sample => 999999.99
|
25
|
+
distinct :category
|
26
|
+
plain :cheque_number
|
27
|
+
plain :active, :sample => 'WW'
|
28
|
+
plain :vat, :label => 'VAT', :sample => 'WW', :tooltip => 'Does this include VAT?'
|
29
|
+
|
30
|
+
records :order => 'date, id'
|
34
31
|
end
|
35
32
|
|
36
33
|
# called when data is changed in the UI
|
@@ -82,16 +79,14 @@ class Account < Clevic::Record
|
|
82
79
|
has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
|
83
80
|
|
84
81
|
# define how fields are displayed
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
records :order => 'name,account_type'
|
95
|
-
end
|
82
|
+
define_ui do
|
83
|
+
plain :name
|
84
|
+
restricted :vat, :label => 'VAT', :set => %w{ yes no all }
|
85
|
+
plain :account_type
|
86
|
+
plain :pastel_number, :alignment => Qt::AlignRight, :label => 'Pastel'
|
87
|
+
plain :fringe, :format => "%.1f"
|
88
|
+
plain :active
|
89
|
+
|
90
|
+
records :order => 'name,account_type'
|
96
91
|
end
|
97
92
|
end
|
data/models/minimal_models.rb
CHANGED
data/models/times_models.rb
CHANGED
@@ -14,67 +14,73 @@ class Entry < Clevic::Record
|
|
14
14
|
belongs_to :activity
|
15
15
|
belongs_to :project
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
records :order => 'date, start, id'
|
17
|
+
define_ui do
|
18
|
+
plain :date, :sample => '28-Dec-08'
|
19
|
+
relational :project, :display => 'project', :conditions => 'active = true', :order => 'lower(project)'
|
20
|
+
relational :invoice, :display => 'invoice_number', :conditions => "status = 'not sent'", :order => 'invoice_number'
|
21
|
+
plain :start
|
22
|
+
plain :end
|
23
|
+
plain :description, :sample => 'This is a long string designed to hold lots of data and description'
|
24
|
+
|
25
|
+
relational :activity do
|
26
|
+
display 'activity'
|
27
|
+
order 'lower(activity)'
|
28
|
+
sample 'Troubleshooting'
|
29
|
+
conditions 'active = true'
|
32
30
|
end
|
31
|
+
|
32
|
+
distinct :module, :tooltip => 'Module or sub-project'
|
33
|
+
plain :charge, :tooltip => 'Is this time billable?'
|
34
|
+
distinct :person, :tooltip => 'The person who did the work'
|
35
|
+
|
36
|
+
records :order => 'date, start, id'
|
33
37
|
end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
model = current_index.model
|
43
|
-
previous_item = model.collection[current_index.row - 1]
|
44
|
-
|
45
|
-
# copy the relevant fields
|
46
|
-
current_index.entity.start = previous_item.end
|
47
|
-
[:date, :project, :invoice, :activity, :module, :charge, :person].each do |attr|
|
48
|
-
current_index.entity.send( "#{attr.to_s}=", previous_item.send( attr ) )
|
49
|
-
end
|
50
|
-
|
51
|
-
# tell view to update
|
52
|
-
top_left_index = model.create_index( current_index.row, 0 )
|
53
|
-
bottom_right_index = model.create_index( current_index.row, current_index.column + view.builder.fields.size )
|
54
|
-
view.dataChanged( top_left_index, bottom_right_index )
|
55
|
-
|
56
|
-
# move to end time field
|
57
|
-
view.override_next_index( model.create_index( current_index.row, view.builder.index( :end ) ) )
|
58
|
-
end
|
59
|
-
# don't let anybody else handle the keypress
|
60
|
-
return true
|
61
|
-
|
62
|
-
when event.ctrl? && event.i?
|
63
|
-
invoice_from_project( current_index, view )
|
64
|
-
# don't let anybody else handle the keypress
|
65
|
-
return true
|
39
|
+
def self.actions( view, action_builder )
|
40
|
+
action_builder.action :smart_copy, 'Smart Copy', :shortcut => 'Ctrl+"' do
|
41
|
+
smart_copy( view )
|
42
|
+
end
|
43
|
+
|
44
|
+
action_builder.action :invoice_from_project, 'Invoice from Project', :shortcut => 'Ctrl+Shift+I' do
|
45
|
+
invoice_from_project( view.current_index, view )
|
66
46
|
end
|
67
47
|
end
|
68
48
|
|
49
|
+
# do a smart copy from the previous line
|
50
|
+
def self.smart_copy( view )
|
51
|
+
view.sanity_check_read_only
|
52
|
+
view.sanity_check_ditto
|
53
|
+
|
54
|
+
if view.current_index.row > 1
|
55
|
+
# fetch previous item
|
56
|
+
model = view.model
|
57
|
+
previous_item = model.collection[view.current_index.row - 1]
|
58
|
+
|
59
|
+
# copy the relevant fields
|
60
|
+
view.current_index.entity.start = previous_item.end
|
61
|
+
[:date, :project, :invoice, :activity, :module, :charge, :person].each do |attr|
|
62
|
+
view.current_index.entity.send( "#{attr.to_s}=", previous_item.send( attr ) )
|
63
|
+
end
|
64
|
+
|
65
|
+
# tell view to update
|
66
|
+
top_left_index = model.create_index( view.current_index.row, 0 )
|
67
|
+
bottom_right_index = model.create_index( view.current_index.row, view.current_index.column + view.builder.fields.size )
|
68
|
+
view.dataChanged( top_left_index, bottom_right_index )
|
69
|
+
|
70
|
+
# move to end time field
|
71
|
+
view.override_next_index( model.create_index( view.current_index.row, view.builder.index( :end ) ) )
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
69
75
|
# called when data is changed in this model's table view
|
70
76
|
def self.data_changed( top_left, bottom_right, view )
|
71
77
|
invoice_from_project( top_left, view ) if ( top_left == bottom_right )
|
72
78
|
end
|
73
79
|
|
80
|
+
# auto-complete invoice number field from project
|
74
81
|
def self.invoice_from_project( current_index, view )
|
75
|
-
# auto-complete invoice number field from project
|
76
82
|
current_field = current_index.attribute
|
77
|
-
if current_field
|
83
|
+
if [:project,:invoice].include?( current_field ) && current_index.entity.project != nil
|
78
84
|
# most recent entry, ordered in reverse
|
79
85
|
invoice = current_index.entity.project.latest_invoice
|
80
86
|
|
@@ -97,36 +103,31 @@ end
|
|
97
103
|
class Invoice < Clevic::Record
|
98
104
|
has_many :entries
|
99
105
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
records :order => 'invoice_number'
|
113
|
-
end
|
106
|
+
define_ui do
|
107
|
+
plain :date
|
108
|
+
distinct :client
|
109
|
+
plain :invoice_number
|
110
|
+
restricted :status, :set => ['not sent', 'sent', 'paid', 'debt', 'writeoff', 'internal']
|
111
|
+
restricted :billing, :set => %w{Hours Quote Internal}
|
112
|
+
plain :quote_date
|
113
|
+
plain :quote_amount
|
114
|
+
plain :description
|
115
|
+
|
116
|
+
records :order => 'invoice_number'
|
114
117
|
end
|
115
118
|
end
|
116
119
|
|
117
120
|
class Project < Clevic::Record
|
118
121
|
has_many :entries
|
119
122
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
records :order => 'project'
|
129
|
-
end
|
123
|
+
define_ui do
|
124
|
+
plain :project
|
125
|
+
plain :description
|
126
|
+
distinct :client
|
127
|
+
plain :rate
|
128
|
+
plain :active
|
129
|
+
|
130
|
+
records :order => 'project'
|
130
131
|
end
|
131
132
|
|
132
133
|
# Return the latest invoice for this project
|
@@ -145,12 +146,10 @@ class Activity < Clevic::Record
|
|
145
146
|
has_many :entries
|
146
147
|
|
147
148
|
# define how fields are displayed
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
records :order => 'activity'
|
154
|
-
end
|
149
|
+
define_ui do
|
150
|
+
plain :activity
|
151
|
+
plain :active
|
152
|
+
|
153
|
+
records :order => 'activity'
|
155
154
|
end
|
156
155
|
end
|
@@ -13,8 +13,8 @@ class Entry < Clevic::Record
|
|
13
13
|
belongs_to :project
|
14
14
|
|
15
15
|
# define how fields are displayed
|
16
|
-
def self.
|
17
|
-
|
16
|
+
def self.build_table_model( model_builder )
|
17
|
+
model_builder.instance_exec do
|
18
18
|
plain :date, :sample => '28-Dec-08'
|
19
19
|
relational :project, :display => 'project', :conditions => "active = true", :order => 'lower(project)'
|
20
20
|
relational :invoice, :display => 'invoice_number', :conditions => "status = 'not sent'", :order => 'invoice_number'
|
@@ -95,8 +95,8 @@ end
|
|
95
95
|
class Project < Clevic::Record
|
96
96
|
has_many :entries
|
97
97
|
|
98
|
-
def self.
|
99
|
-
|
98
|
+
def self.build_table_model( model_builder )
|
99
|
+
model_builder.instance_exec do
|
100
100
|
plain :project
|
101
101
|
plain :description
|
102
102
|
distinct :client
|
@@ -123,8 +123,8 @@ class Activity < Clevic::Record
|
|
123
123
|
has_many :entries
|
124
124
|
|
125
125
|
# define how fields are displayed
|
126
|
-
def self.
|
127
|
-
|
126
|
+
def self.build_table_model( model_builder )
|
127
|
+
model_builder.instance_exec do
|
128
128
|
plain :activity
|
129
129
|
plain :active
|
130
130
|
|
@@ -137,8 +137,8 @@ class Invoice < Clevic::Record
|
|
137
137
|
has_many :entries
|
138
138
|
|
139
139
|
# define how fields are displayed
|
140
|
-
def self.
|
141
|
-
|
140
|
+
def self.build_table_model( model_builder )
|
141
|
+
model_builder.instance_exec do
|
142
142
|
plain :date
|
143
143
|
distinct :client
|
144
144
|
plain :invoice_number
|
data/models/values_models.rb
CHANGED
@@ -8,13 +8,14 @@ Clevic::DbOptions.connect( $options ) do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# This is a read-only view, which is currently not implemented
|
11
|
-
class
|
11
|
+
class Value < Clevic::Record
|
12
12
|
set_table_name 'values'
|
13
|
-
has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
|
14
|
-
has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
#~ has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
|
14
|
+
#~ has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
|
15
|
+
|
16
|
+
def self.build_table_model( model_builder )
|
17
|
+
model_builder.instance_exec do
|
18
|
+
read_only!
|
18
19
|
plain :date
|
19
20
|
plain :description
|
20
21
|
plain :debit
|
data/website/index.html
CHANGED
@@ -31,12 +31,14 @@
|
|
31
31
|
<p><a href="rdoc">RDoc</a> | <a href="http://rubyforge.org/projects/clevic/">Rubyforge Project</a></p>
|
32
32
|
|
33
33
|
|
34
|
-
<p>Code for
|
34
|
+
<p>Code for minimal UI definition</p>
|
35
35
|
|
36
36
|
|
37
37
|
<pre><code>
|
38
38
|
require 'clevic.rb'
|
39
39
|
|
40
|
+
# see sql/accounts.sql for schema
|
41
|
+
|
40
42
|
# db connection
|
41
43
|
Clevic::DbOptions.connect do
|
42
44
|
database 'accounts_test'
|
@@ -85,21 +87,18 @@ class Entry < Clevic::Record
|
|
85
87
|
belongs_to :debit, :class_name => 'Account', :foreign_key => 'debit_id'
|
86
88
|
belongs_to :credit, :class_name => 'Account', :foreign_key => 'credit_id'
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
records :order => 'date, id'
|
102
|
-
end
|
90
|
+
define_ui do
|
91
|
+
plain :date, :sample => '88-WWW-99'
|
92
|
+
distinct :description, :conditions => "now() - date <= '1 year'", :sample => 'm' * 26
|
93
|
+
relational :debit, :display => 'name', :conditions => 'active = true', :order => 'lower(name)', :sample => 'Leilani Member Loan'
|
94
|
+
relational :credit, :display => 'name', :conditions => 'active = true', :order => 'lower(name)', :sample => 'Leilani Member Loan'
|
95
|
+
plain :amount, :sample => 999999.99
|
96
|
+
distinct :category
|
97
|
+
plain :cheque_number
|
98
|
+
plain :active, :sample => 'WW'
|
99
|
+
plain :vat, :label => 'VAT', :sample => 'WW', :tooltip => 'Does this include VAT?'
|
100
|
+
|
101
|
+
records :order => 'date, id'
|
103
102
|
end
|
104
103
|
|
105
104
|
# called when data is changed in the UI
|
@@ -151,17 +150,15 @@ class Account < Clevic::Record
|
|
151
150
|
has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
|
152
151
|
|
153
152
|
# define how fields are displayed
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
records :order => 'name,account_type'
|
164
|
-
end
|
153
|
+
define_ui do
|
154
|
+
plain :name
|
155
|
+
restricted :vat, :label => 'VAT', :set => %w{ yes no all }
|
156
|
+
plain :account_type
|
157
|
+
plain :pastel_number, :alignment => Qt::AlignRight, :label => 'Pastel'
|
158
|
+
plain :fringe, :format => "%.1f"
|
159
|
+
plain :active
|
160
|
+
|
161
|
+
records :order => 'name,account_type'
|
165
162
|
end
|
166
163
|
end
|
167
164
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clevic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Anderson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-21 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.5.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/clevic/delegates.rb
|
86
86
|
- lib/clevic/extensions.rb
|
87
87
|
- lib/clevic/field.rb
|
88
|
+
- lib/clevic/field_builder.rb
|
88
89
|
- lib/clevic/item_delegate.rb
|
89
90
|
- lib/clevic/model_builder.rb
|
90
91
|
- lib/clevic/model_column.rb
|