skozlov-netzke-basepack 0.1.1.2 → 0.5.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/.autotest +1 -0
- data/.gitignore +5 -0
- data/LICENSE +2 -19
- data/README.rdoc +87 -0
- data/Rakefile +28 -12
- data/TODO.rdoc +7 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +3 -0
- data/init.rb +0 -1
- data/javascripts/basepack.js +839 -49
- data/lib/app/models/netzke_auto_column.rb +56 -0
- data/lib/netzke/accordion_panel.rb +113 -0
- data/lib/netzke/active_record/basepack.rb +104 -0
- data/lib/netzke/active_record/data_accessor.rb +21 -0
- data/lib/netzke/basic_app.rb +325 -0
- data/lib/netzke/border_layout_panel.rb +128 -0
- data/lib/netzke/configuration_panel.rb +24 -0
- data/lib/netzke/data_accessor.rb +71 -0
- data/lib/netzke/ext.rb +6 -0
- data/lib/netzke/field_model.rb +131 -0
- data/lib/netzke/fields_configurator.rb +95 -0
- data/lib/netzke/form_panel.rb +214 -0
- data/lib/netzke/form_panel_api.rb +74 -0
- data/lib/netzke/form_panel_extras/javascripts/xcheckbox.js +82 -0
- data/lib/netzke/form_panel_js.rb +129 -0
- data/lib/netzke/grid_panel.rb +442 -0
- data/lib/netzke/grid_panel_api.rb +352 -0
- data/lib/netzke/grid_panel_extras/javascripts/check-column.js +33 -0
- data/{javascripts → lib/netzke/grid_panel_extras/javascripts}/filters.js +0 -0
- data/lib/netzke/grid_panel_extras/javascripts/rows-dd.js +280 -0
- data/lib/netzke/grid_panel_js.rb +721 -0
- data/lib/netzke/panel.rb +13 -0
- data/lib/netzke/plugins/configuration_tool.rb +121 -0
- data/lib/netzke/property_editor.rb +105 -0
- data/lib/netzke/property_editor_extras/helper_model.rb +126 -0
- data/lib/netzke/search_panel.rb +62 -0
- data/lib/netzke/tab_panel.rb +160 -0
- data/lib/netzke/table_editor.rb +118 -0
- data/lib/netzke/tree_panel.rb +73 -0
- data/lib/netzke/wrapper.rb +42 -0
- data/lib/netzke-basepack.rb +9 -15
- data/netzke-basepack.gemspec +147 -20
- data/stylesheets/basepack.css +26 -0
- data/test/app_root/app/models/book.rb +1 -1
- data/test/app_root/config/environment.rb +1 -0
- data/test/app_root/db/migrate/20081222033440_create_genres.rb +1 -0
- data/test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb +1 -1
- data/test/app_root/db/migrate/20090102223630_create_netzke_layouts.rb +14 -0
- data/test/app_root/vendor/plugins/acts_as_list/README +23 -0
- data/test/app_root/vendor/plugins/acts_as_list/init.rb +3 -0
- data/test/app_root/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/test/test_helper.rb +1 -2
- data/test/unit/accordion_panel_test.rb +20 -0
- data/test/unit/active_record_basepack_test.rb +54 -0
- data/test/unit/grid_panel_test.rb +43 -0
- data/test/unit/helper_model_test.rb +30 -0
- data/test/unit/netzke_basepack_test.rb +4 -0
- data/test/unit/tab_panel_test.rb +21 -0
- metadata +96 -72
- data/CHANGELOG +0 -14
- data/Manifest +0 -65
- data/README.mdown +0 -18
- data/generators/netzke_basepack/USAGE +0 -8
- data/generators/netzke_basepack/netzke_basepack_generator.rb +0 -8
- data/generators/netzke_basepack/netzke_grid_generator.rb +0 -7
- data/generators/netzke_basepack/templates/create_netzke_grid_columns.rb +0 -21
- data/lib/app/models/netzke_grid_column.rb +0 -23
- data/lib/netzke/accordion.rb +0 -11
- data/lib/netzke/ar_ext.rb +0 -163
- data/lib/netzke/column.rb +0 -43
- data/lib/netzke/container.rb +0 -81
- data/lib/netzke/grid.rb +0 -120
- data/lib/netzke/grid_interface.rb +0 -156
- data/lib/netzke/grid_js_builder.rb +0 -276
- data/lib/netzke/preference_grid.rb +0 -43
- data/lib/netzke/properties_tool.rb +0 -66
- data/lib/netzke/property_grid.rb +0 -60
- data/test/ar_ext_test.rb +0 -39
- data/test/column_test.rb +0 -27
- data/test/grid_test.rb +0 -43
- data/test/netzke_basepack_test.rb +0 -8
@@ -1,66 +0,0 @@
|
|
1
|
-
module Netzke
|
2
|
-
#
|
3
|
-
# Include this module into any widget if you want a "Properties" tool button in the top toolbar which will triggger a modal window, which will load the Accordion widgets, which in its turn will contain all the aggregatees specified in "property_widgets" method (*must* be defined)
|
4
|
-
#
|
5
|
-
module PropertiesTool
|
6
|
-
def self.included(base)
|
7
|
-
base.class_eval do
|
8
|
-
[:js_extend_properties, :tools, :initial_aggregatees].each{ |m| alias_method_chain m, :properties }
|
9
|
-
end
|
10
|
-
|
11
|
-
# if you include PropertiesTool, you must define property_widgets method which will returns an array of arrgeratees that will be included in the property window (each in its own tab or accordion pane)
|
12
|
-
raise "property_widgets method undefined" unless base.instance_methods.include?("property_widgets")
|
13
|
-
end
|
14
|
-
|
15
|
-
def initial_aggregatees_with_properties
|
16
|
-
res = initial_aggregatees_without_properties
|
17
|
-
# Add the accordion as aggregatee, with in its turn aggregates widgets from the property_widgets method
|
18
|
-
res.merge!(:properties => {:widget_class_name => 'Accordion', :items => property_widgets, :ext_config => {:title => false}, :no_caching => true, :late_aggregation => true}) if config[:ext_config][:properties]
|
19
|
-
res
|
20
|
-
end
|
21
|
-
|
22
|
-
def tools_with_properties
|
23
|
-
tools = tools_without_properties
|
24
|
-
# Add the toolbutton
|
25
|
-
tools << {:id => 'gear', :on => {:click => "showConfig"}} if config[:ext_config][:properties]
|
26
|
-
tools
|
27
|
-
end
|
28
|
-
|
29
|
-
def js_extend_properties_with_properties
|
30
|
-
js_extend_properties_without_properties.merge({
|
31
|
-
:show_config => <<-JS.l
|
32
|
-
function(){
|
33
|
-
var w = new Ext.Window({
|
34
|
-
title:'Config',
|
35
|
-
layout:'fit',
|
36
|
-
modal:true,
|
37
|
-
width:window.innerWidth*.9,
|
38
|
-
height:window.innerHeight*.9,
|
39
|
-
closeAction:'destroy',
|
40
|
-
buttons:[{
|
41
|
-
text:'Submit',
|
42
|
-
handler:function(){this.ownerCt.closeRes = 'OK'; this.ownerCt.destroy()}
|
43
|
-
}]
|
44
|
-
|
45
|
-
});
|
46
|
-
|
47
|
-
w.show(null, function(){
|
48
|
-
w.loadWidget(this.initialConfig.id+"__properties__get_widget");
|
49
|
-
}, this);
|
50
|
-
|
51
|
-
w.on('destroy', function(){
|
52
|
-
if (w.closeRes == 'OK'){
|
53
|
-
widget = this;
|
54
|
-
if (widget.ownerCt) {
|
55
|
-
widget.ownerCt.loadWidget(widget.initialConfig.interface.getWidget);
|
56
|
-
} else {
|
57
|
-
this.feedback('Reload current window') // no aggregation
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}, this)
|
61
|
-
}
|
62
|
-
JS
|
63
|
-
})
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/netzke/property_grid.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
module Netzke
|
2
|
-
#
|
3
|
-
# Ext.grid.PropertyGrid
|
4
|
-
#
|
5
|
-
class PropertyGrid < Base
|
6
|
-
interface :load_source, :submit_source
|
7
|
-
|
8
|
-
def initialize(*args)
|
9
|
-
super
|
10
|
-
@config = {:ext_config => {}}.merge(@config)
|
11
|
-
end
|
12
|
-
|
13
|
-
def js_base_class
|
14
|
-
"Ext.grid.PropertyGrid"
|
15
|
-
end
|
16
|
-
|
17
|
-
def actions
|
18
|
-
[{
|
19
|
-
:text => 'Apply', :handler => 'submit'
|
20
|
-
}]
|
21
|
-
end
|
22
|
-
|
23
|
-
def js_default_config
|
24
|
-
super.merge({
|
25
|
-
:bbar => "config.actions".l
|
26
|
-
})
|
27
|
-
end
|
28
|
-
|
29
|
-
def js_extend_properties
|
30
|
-
{
|
31
|
-
:submit => <<-JS.l,
|
32
|
-
function() {
|
33
|
-
Ext.Ajax.request({
|
34
|
-
url:this.initialConfig.interface.submitSource,
|
35
|
-
params:{data:Ext.encode(this.getSource())},
|
36
|
-
scope:this
|
37
|
-
})
|
38
|
-
}
|
39
|
-
JS
|
40
|
-
:on_widget_load => <<-JS.l,
|
41
|
-
function(){
|
42
|
-
this.loadSource()
|
43
|
-
}
|
44
|
-
JS
|
45
|
-
:load_source => <<-JS.l,
|
46
|
-
function(){Ext.Ajax.request({
|
47
|
-
url:this.initialConfig.interface.loadSource,
|
48
|
-
success:function(r){
|
49
|
-
var m = Ext.decode(r.responseText);
|
50
|
-
this.setSource(m.source);
|
51
|
-
// this.feedback(m.flash);
|
52
|
-
},
|
53
|
-
scope:this
|
54
|
-
})}
|
55
|
-
JS
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
data/test/ar_ext_test.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'netzke/ar_ext'
|
4
|
-
|
5
|
-
class ArExtTest < ActiveSupport::TestCase
|
6
|
-
fixtures :cities, :countries, :continents
|
7
|
-
|
8
|
-
test "default column config" do
|
9
|
-
cc = Book.default_column_config(:title)
|
10
|
-
|
11
|
-
assert_equal("Title", cc[:label])
|
12
|
-
assert_equal(:text_field, cc[:shows_as])
|
13
|
-
|
14
|
-
cc = Book.default_column_config({:name => :amount, :label => 'AMOUNT'})
|
15
|
-
|
16
|
-
assert_equal("AMOUNT", cc[:label])
|
17
|
-
assert_equal(:number_field, cc[:shows_as])
|
18
|
-
end
|
19
|
-
|
20
|
-
test "choices for column" do
|
21
|
-
# TODO: test virtual columns, too
|
22
|
-
cities = City.choices_for("name")
|
23
|
-
assert_equal(3, cities.size)
|
24
|
-
assert(cities.include?('Cordoba') && cities.include?('Buenos Aires'))
|
25
|
-
|
26
|
-
countries = City.choices_for("country__name")
|
27
|
-
assert_equal(2, countries.size)
|
28
|
-
assert(countries.include?('Spain') && countries.include?('Argentina'))
|
29
|
-
|
30
|
-
continents = City.choices_for("country__continent__name")
|
31
|
-
assert_equal(2, continents.size)
|
32
|
-
assert(continents.include?('Europe') && continents.include?('South America'))
|
33
|
-
|
34
|
-
cities = City.choices_for("name", "Co")
|
35
|
-
assert_equal(2, cities.size)
|
36
|
-
assert(cities.include?('Cordoba') && cities.include?('Concordia'))
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
data/test/column_test.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'netzke/ar_ext'
|
4
|
-
|
5
|
-
ActiveRecord::Base.class_eval do
|
6
|
-
include Netzke::ActiveRecordExtensions
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'netzke/column'
|
10
|
-
|
11
|
-
class ColumnTest < ActiveSupport::TestCase
|
12
|
-
test "default columns" do
|
13
|
-
stub_widget = Object.new
|
14
|
-
def stub_widget.config
|
15
|
-
{:name => 'widget', :data_class_name => 'Book', :columns => [:title, {:name => :amount, :read_only => true}, :recent]}
|
16
|
-
end
|
17
|
-
|
18
|
-
columns = Netzke::Column.default_columns_for_widget(stub_widget)
|
19
|
-
|
20
|
-
assert_equal(false, columns[0][:read_only])
|
21
|
-
assert_equal(true, columns[1][:read_only])
|
22
|
-
assert_equal("Amount", columns[1][:label])
|
23
|
-
assert_equal("Recent", columns[2][:label])
|
24
|
-
assert_equal(true, columns[2][:read_only]) # read_only specified in the model itself
|
25
|
-
# puts "!!! columns: #{columns.inspect}"
|
26
|
-
end
|
27
|
-
end
|
data/test/grid_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'netzke-core'
|
3
|
-
|
4
|
-
require 'netzke/properties_tool'
|
5
|
-
require 'netzke/container'
|
6
|
-
require 'netzke/accordion'
|
7
|
-
|
8
|
-
require 'netzke/grid_interface'
|
9
|
-
require 'netzke/grid_js_builder'
|
10
|
-
require 'netzke/grid'
|
11
|
-
|
12
|
-
require 'netzke/ar_ext'
|
13
|
-
require 'netzke/column'
|
14
|
-
|
15
|
-
class GridTest < ActiveSupport::TestCase
|
16
|
-
|
17
|
-
test "interface" do
|
18
|
-
grid = Netzke::Grid.new(:name => 'grid', :data_class_name => 'Book', :layout_manager => false, :columns => [:id, :title, :recent])
|
19
|
-
|
20
|
-
# post
|
21
|
-
grid.post_data(:created_records => [{:title => 'Lord of the Rings'}].to_json)
|
22
|
-
assert_equal('Lord of the Rings', Book.first.title)
|
23
|
-
|
24
|
-
grid.post_data(:updated_records => [{:id => Book.first.id, :title => 'Lolita'}].to_json)
|
25
|
-
assert_equal('Lolita', Book.first.title)
|
26
|
-
|
27
|
-
grid.post_data(:created_records => [{:title => 'Upanishad'}].to_json)
|
28
|
-
|
29
|
-
# get
|
30
|
-
data = grid.get_data
|
31
|
-
assert_equal('Lolita', data[:data][0][1]) # title of the first book
|
32
|
-
assert_equal('Yes', data[:data][1][2]) # "recent" virtual column in the second book
|
33
|
-
|
34
|
-
# delete
|
35
|
-
res = grid.delete_data(:records => [1,2].to_json)
|
36
|
-
assert_equal(true, res[:success])
|
37
|
-
assert_equal(nil, Book.first)
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
# TODO: add tests with association columns
|
42
|
-
|
43
|
-
end
|