netzke-basepack 0.6.0 → 0.6.1
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/CHANGELOG.rdoc +14 -6
- data/README.rdoc +16 -31
- data/Rakefile +22 -16
- data/TODO.rdoc +1 -1
- data/app/models/netzke_field_list.rb +29 -29
- data/app/models/netzke_model_attr_list.rb +4 -4
- data/app/models/netzke_persistent_array_auto_model.rb +9 -9
- data/config/database.yml +2 -35
- data/features/accordion_panel.feature +1 -1
- data/features/form_panel.feature +2 -2
- data/features/grid_panel.feature +15 -3
- data/features/search_in_grid.feature +4 -4
- data/features/simple_panel.feature +4 -4
- data/features/step_definitions/pickle_steps.rb +2 -2
- data/features/step_definitions/web_steps.rb +5 -5
- data/features/support/env.rb +6 -6
- data/features/tab_panel.feature +1 -1
- data/javascripts/basepack.js +28 -28
- data/lib/netzke-basepack.rb +5 -5
- data/lib/netzke/active_record.rb +1 -1
- data/lib/netzke/active_record/association_attributes.rb +9 -9
- data/lib/netzke/active_record/attributes.rb +24 -23
- data/lib/netzke/active_record/combobox_options.rb +3 -3
- data/lib/netzke/active_record/relation_extensions.rb +4 -4
- data/lib/netzke/basepack.rb +4 -4
- data/{app/components → lib}/netzke/basepack/accordion_panel.rb +7 -7
- data/{app/components → lib}/netzke/basepack/basic_app.rb +18 -18
- data/{app/components → lib}/netzke/basepack/basic_app/statusbar_ext.js +0 -0
- data/lib/netzke/basepack/border_layout_panel.rb +101 -0
- data/{app/components → lib}/netzke/basepack/form_panel.rb +21 -21
- data/{app/components → lib}/netzke/basepack/form_panel/fields.rb +29 -36
- data/{app/components → lib}/netzke/basepack/form_panel/javascripts/netzkefileupload.js +0 -0
- data/{app/components → lib}/netzke/basepack/form_panel/javascripts/pre.js +9 -9
- data/{app/components → lib}/netzke/basepack/form_panel/javascripts/xcheckbox.js +1 -1
- data/{app/components → lib}/netzke/basepack/form_panel/services.rb +11 -11
- data/{app/components → lib}/netzke/basepack/grid_panel.rb +74 -92
- data/{app/components → lib}/netzke/basepack/grid_panel/columns.rb +34 -36
- data/{app/components → lib}/netzke/basepack/grid_panel/javascript.rb +7 -7
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/advanced_search.js +10 -10
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/edit_in_form.js +2 -2
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/pre.js +31 -31
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/rows-dd.js +1 -1
- data/{app/components → lib}/netzke/basepack/grid_panel/multi_edit_form.rb +2 -2
- data/{app/components → lib}/netzke/basepack/grid_panel/record_form_window.rb +3 -3
- data/{app/components → lib}/netzke/basepack/grid_panel/search_window.rb +11 -11
- data/{app/components → lib}/netzke/basepack/grid_panel/services.rb +28 -28
- data/{app/components → lib}/netzke/basepack/panel.rb +0 -0
- data/{app/components → lib}/netzke/basepack/search_panel.rb +11 -11
- data/{app/components → lib}/netzke/basepack/tab_panel.rb +7 -7
- data/lib/netzke/basepack/version.rb +1 -1
- data/{app/components → lib}/netzke/basepack/window.rb +14 -14
- data/{app/components → lib}/netzke/basepack/wrapper.rb +6 -6
- data/lib/netzke/data_accessor.rb +18 -18
- data/lib/netzke/fields_configurator.rb +30 -30
- data/lib/netzke/json_array_editor.rb +9 -9
- data/lib/netzke/masquerade_selector.rb +5 -5
- data/locale/en.yml +1 -1
- data/netzke-basepack.gemspec +252 -240
- data/spec/active_record/attributes_spec.rb +6 -1
- data/spec/active_record/relation_extensions_spec.rb +11 -11
- data/spec/components/form_panel_spec.rb +13 -19
- data/spec/components/grid_panel_spec.rb +1 -1
- data/test/rails_app/Gemfile +4 -3
- data/test/rails_app/Gemfile.lock +42 -50
- data/test/rails_app/app/components/book_grid.rb +4 -0
- data/test/rails_app/app/components/generic_user_form.rb +2 -2
- data/test/rails_app/app/components/simple_basic_app.rb +3 -3
- data/test/rails_app/app/components/simple_panel.rb +1 -1
- data/test/rails_app/app/components/some_border_layout.rb +12 -11
- data/test/rails_app/app/components/some_search_panel.rb +5 -5
- data/test/rails_app/app/components/user_form.rb +1 -1
- data/test/rails_app/app/components/window_component_loader.rb +2 -2
- data/test/rails_app/app/models/author.rb +7 -0
- data/test/rails_app/app/models/book.rb +3 -0
- data/test/rails_app/app/models/user.rb +1 -1
- data/test/rails_app/config/locales/es.yml +0 -1
- data/test/rails_app/config/routes.rb +2 -2
- data/test/rails_app/db/development_structure.sql +28 -3
- data/test/rails_app/db/migrate/20101026185816_create_authors.rb +14 -0
- data/test/rails_app/db/migrate/20101026190021_create_books.rb +17 -0
- data/test/rails_app/db/schema.rb +18 -1
- data/test/rails_app/public/javascripts/effects.js +1 -1
- data/test/rails_app/spec/models/author_spec.rb +5 -0
- data/test/rails_app/spec/models/book_spec.rb +5 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/accordion_panel_test.rb +2 -2
- data/test/unit/active_record_basepack_test.rb +9 -9
- data/test/unit/fields_configuration_test.rb +4 -4
- data/test/unit/grid_panel_test.rb +8 -8
- data/test/unit/tab_panel_test.rb +2 -2
- metadata +49 -36
- data/.gitignore +0 -10
- data/app/components/netzke/basepack/border_layout_panel.rb +0 -39
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
= v0.6.1 - 2010-11-04
|
|
2
|
+
* enhancements
|
|
3
|
+
* BorderLayoutPanel persistence: remembers region sizes and collapsed/expanded states
|
|
4
|
+
* tooltips for grid buttons
|
|
5
|
+
|
|
6
|
+
* bug fix
|
|
7
|
+
* auto-detection of association's method when the latter is virtual was broken in 1.9.2
|
|
8
|
+
|
|
1
9
|
= v0.6.0 - 2010-10-24
|
|
2
10
|
* netzke-core 0.6.0 compatibility, thorough refactoring
|
|
3
11
|
* Much more thorough testing (cucumber and rspec)
|
|
@@ -6,12 +14,12 @@
|
|
|
6
14
|
|
|
7
15
|
* enhancements
|
|
8
16
|
* if omitted in config, a column for the primary key is automatically added to Grid/FormPanel
|
|
9
|
-
|
|
17
|
+
|
|
10
18
|
* API incompatibilities
|
|
11
19
|
* in FormPanel, define the fields layout directly in :items, not in :fields or :columns
|
|
12
|
-
|
|
20
|
+
|
|
13
21
|
* new
|
|
14
|
-
* FormPanel allows for arbitrary layout of fields
|
|
22
|
+
* FormPanel allows for arbitrary layout of fields
|
|
15
23
|
|
|
16
24
|
= v0.5.14 - 2010-09-08
|
|
17
25
|
* bug fix
|
|
@@ -31,11 +39,11 @@
|
|
|
31
39
|
= v0.5.13 - 2010-08-11
|
|
32
40
|
* regression
|
|
33
41
|
* combobox options configuration again has effect
|
|
34
|
-
|
|
42
|
+
|
|
35
43
|
* bug fix
|
|
36
44
|
* when a TabPanel was used as a standalone widget, the first tab was rendered empty
|
|
37
45
|
* Grid/FormPanel: dynamically changing of columns doesn't erase those column settings that are not configurable via GUI, but which were specified in the code
|
|
38
|
-
|
|
46
|
+
|
|
39
47
|
* enhancements
|
|
40
48
|
* scopes can now be specified for an association combobox in Grid/FormPanels
|
|
41
49
|
* GridPanel: you can now configure add/edit/multi_edit/search panels (e.g. to override the fields) and corresponding windows (e.g. to override the title)
|
|
@@ -304,7 +312,7 @@
|
|
|
304
312
|
* Column resize & move functionality enabled by default
|
|
305
313
|
* Column filters added
|
|
306
314
|
|
|
307
|
-
= v0.1.0.1
|
|
315
|
+
= v0.1.0.1
|
|
308
316
|
* Meta work: replacing underscore with dash in the name
|
|
309
317
|
|
|
310
318
|
= v0.1.0 - 2008-12-20
|
data/README.rdoc
CHANGED
|
@@ -3,46 +3,31 @@
|
|
|
3
3
|
A pack of pre-built Netzke components, such as grid, form, tab panel, etc.
|
|
4
4
|
Learn about Netzke on http://netzke.org.
|
|
5
5
|
|
|
6
|
-
==
|
|
6
|
+
== Requirements
|
|
7
7
|
|
|
8
|
-
1.
|
|
9
|
-
|
|
8
|
+
* Ruby 1.9.2 (1.8.7 may work, too)
|
|
9
|
+
* Rails >= 3.0.0
|
|
10
|
+
* Ext JS >= 3.3.0
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
== Installation
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
In your Gemfile:
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
gem 'netzke-basepack'
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Or tell bundler to get the gem straight from github:
|
|
18
|
+
For the "edge" stuff, tell bundler to get the gem straight from GitHub:
|
|
20
19
|
|
|
21
20
|
gem 'netzke-basepack', :git => "git://github.com/skozlov/netzke-basepack.git"
|
|
22
21
|
|
|
23
22
|
== Usage
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
Read the "Embedding components into Rails views" section on http://github.com/skozlov/netzke-core
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
RailsApp::Application.routes.draw do
|
|
29
|
-
netzke
|
|
30
|
-
...
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
== Embedding components into Rails' view
|
|
34
|
-
|
|
35
|
-
Before you can use Netzke components in Rails' views, you need to add the following helper into your layout template, inside the "head" tag:
|
|
36
|
-
|
|
37
|
-
<%= netzke_init %>
|
|
38
|
-
|
|
39
|
-
This will include both ExtJS-related files (JavaScript and styles), and Netzke-related files.
|
|
40
|
-
|
|
41
|
-
To embed a component into a view, use the +netzke+ helper, e.g.:
|
|
26
|
+
Embed a basepack component into a view as any other Netzke component, e.g.:
|
|
42
27
|
|
|
43
28
|
<%= netzke :books, :class_name => 'Basepack::GridPanel', :model => 'Book' %>
|
|
44
|
-
|
|
45
|
-
(assuming
|
|
29
|
+
|
|
30
|
+
(assuming model 'Book' exists)
|
|
46
31
|
|
|
47
32
|
For more examples, see http://demo.netzke.com, and look into test/rails_app
|
|
48
33
|
|
|
@@ -53,7 +38,7 @@ Netzke-basepack is bundled with automated tests. To run them, you need to set up
|
|
|
53
38
|
After this you may run (*from the netzke-basepack folder*):
|
|
54
39
|
|
|
55
40
|
cucumber features
|
|
56
|
-
|
|
41
|
+
|
|
57
42
|
and
|
|
58
43
|
|
|
59
44
|
rspec spec
|
|
@@ -63,18 +48,18 @@ and
|
|
|
63
48
|
The test/rails_app application is also a convenient playground, as it may be run as independent Rails 3 app. After starting it, access any of the lib/netzke widgets by using the following url:
|
|
64
49
|
|
|
65
50
|
http://localhost:3000/components/<name of the component class>
|
|
66
|
-
|
|
51
|
+
|
|
67
52
|
e.g.:
|
|
68
53
|
|
|
69
54
|
http://localhost:3000/components/UserGrid
|
|
70
|
-
|
|
55
|
+
|
|
71
56
|
== Icons support
|
|
72
57
|
Netzke-basepack can make use of FamFamFam Silk icon set (http://www.famfamfam.com/archive/silk-icons-thats-your-lot/). To enable this, download the icons and put the "icons" folder into your app's public/images folder. Then restart your application.
|
|
73
58
|
|
|
74
59
|
== More info
|
|
75
60
|
Official project site: http://netzke.org
|
|
76
61
|
|
|
77
|
-
Twitter (
|
|
62
|
+
Twitter (latest news about Netzke): http://twitter.com/skozlov
|
|
78
63
|
|
|
79
64
|
Many (if a bit outdated) tutorials: http://blog.writelesscode.com
|
|
80
65
|
|
data/Rakefile
CHANGED
|
@@ -7,9 +7,9 @@ begin
|
|
|
7
7
|
gemspec.summary = "Pre-built Rails + ExtJS components for your RIA"
|
|
8
8
|
gemspec.description = "A set of full-featured extendible Netzke components (such as FormPanel, GridPanel, Window, BorderLayoutPanel, etc) which can be used as building block for your RIA"
|
|
9
9
|
gemspec.email = "sergei@playcode.nl"
|
|
10
|
-
gemspec.homepage = "http://
|
|
10
|
+
gemspec.homepage = "http://netzke.org"
|
|
11
11
|
gemspec.authors = ["Sergei Kozlov"]
|
|
12
|
-
gemspec.add_dependency("netzke-core", "~>0.6.
|
|
12
|
+
gemspec.add_dependency("netzke-core", "~>0.6.2")
|
|
13
13
|
gemspec.add_dependency("meta_where", ">=0.9.3")
|
|
14
14
|
gemspec.add_dependency("will_paginate", "~>3.0.pre2")
|
|
15
15
|
gemspec.add_dependency("acts_as_list")
|
|
@@ -18,8 +18,8 @@ begin
|
|
|
18
18
|
========================================================================
|
|
19
19
|
|
|
20
20
|
Thanks for installing Netzke Basepack!
|
|
21
|
-
|
|
22
|
-
Don't forget to run "./script/generate netzke_basepack" for each
|
|
21
|
+
|
|
22
|
+
Don't forget to run "./script/generate netzke_basepack" for each
|
|
23
23
|
Rails app that will be using this gem.
|
|
24
24
|
|
|
25
25
|
Netzke home page: http://netzke.org
|
|
@@ -29,30 +29,36 @@ begin
|
|
|
29
29
|
========================================================================
|
|
30
30
|
|
|
31
31
|
MESSAGE
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
end
|
|
34
34
|
Jeweler::GemcutterTasks.new
|
|
35
35
|
rescue LoadError
|
|
36
36
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
require 'rake/testtask'
|
|
40
|
+
Rake::TestTask.new(:test) do |test|
|
|
41
|
+
test.libs << 'lib' << 'test'
|
|
42
|
+
test.pattern = 'test/**/*_test.rb'
|
|
43
|
+
test.verbose = true
|
|
44
|
+
end
|
|
45
|
+
|
|
39
46
|
require 'rake/rdoctask'
|
|
40
47
|
Rake::RDocTask.new do |rdoc|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else
|
|
44
|
-
version = ""
|
|
45
|
-
end
|
|
48
|
+
require './lib/netzke/basepack/version'
|
|
49
|
+
version = Netzke::Basepack::Version::STRING
|
|
46
50
|
|
|
47
51
|
rdoc.rdoc_dir = 'rdoc'
|
|
48
52
|
rdoc.title = "netzke-basepack #{version}"
|
|
53
|
+
# rdoc.main = "README.rdoc"
|
|
49
54
|
rdoc.rdoc_files.include('README*')
|
|
55
|
+
rdoc.rdoc_files.include('CHANGELOG*')
|
|
50
56
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
51
57
|
end
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
+
namespace :rdoc do
|
|
60
|
+
desc "Publish rdocs"
|
|
61
|
+
task :publish => :rdoc do
|
|
62
|
+
`scp -r rdoc/* fl:www/api.netzke.org/basepack`
|
|
63
|
+
end
|
|
64
|
+
end
|
data/TODO.rdoc
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
== Priority
|
|
2
|
-
*
|
|
2
|
+
* Fix :meta => true config in columns work
|
|
3
3
|
* On grid refresh, reset the dirty fields, so that the "Apply" button doesn't do anything
|
|
4
4
|
* DataAccessor#to_array should not rescue exceptions, but rather check the availability of the attributes; `respond_to_with_basepack?` should be extended to also return true for association columns
|
|
5
5
|
* GridPanel's read_only vs editable (doesn't work now) options
|
|
@@ -20,7 +20,7 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
20
20
|
end
|
|
21
21
|
update_attribute(:value, list.to_json)
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
def append_attr(attr_hash)
|
|
25
25
|
list = ActiveSupport::JSON.decode(self.value)
|
|
26
26
|
list << attr_hash
|
|
@@ -41,7 +41,7 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
41
41
|
[]
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
def self.find_all_lists_under_current_authority(model_name)
|
|
46
46
|
authority_level, authority_id = Netzke::Base.authority_level
|
|
47
47
|
case authority_level
|
|
@@ -59,11 +59,11 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
59
59
|
else
|
|
60
60
|
[]
|
|
61
61
|
end
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# Replaces the list with the data - only for the list found for the current authority.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# Replaces the list with the data - only for the list found for the current authority.
|
|
67
67
|
# If the list is not found, it's created.
|
|
68
68
|
def self.update_list_for_current_authority(pref_name, data, model_name = nil)
|
|
69
69
|
pref = find_or_create_pref_to_read(pref_name)
|
|
@@ -71,21 +71,21 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
71
71
|
pref.model_name = model_name
|
|
72
72
|
pref.save!
|
|
73
73
|
end
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
|
|
76
76
|
# If the <tt>model</tt> param is provided, then this preference will be assigned a parent preference
|
|
77
77
|
# that configures the attributes for that model. This way we can track all preferences related to a model.
|
|
78
78
|
def self.write_list(name, list, model = nil)
|
|
79
79
|
pref_to_store_the_list = self.pref_to_write(name)
|
|
80
80
|
pref_to_store_the_list.try(:update_attribute, :value, list.to_json)
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
# link this preference to the parent that contains default attributes for the same model
|
|
83
83
|
if model
|
|
84
84
|
model_level_attrs_pref = self.pref_to_read("#{model.tableize}_model_attrs")
|
|
85
85
|
model_level_attrs_pref.children << pref_to_store_the_list if model_level_attrs_pref && pref_to_store_the_list
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
def self.read_list(name)
|
|
90
90
|
json_encoded_value = self.pref_to_read(name).try(:value)
|
|
91
91
|
ActiveSupport::JSON.decode(json_encoded_value).map(&:symbolize_keys) if json_encoded_value
|
|
@@ -96,26 +96,26 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
96
96
|
# read_list(model_name)
|
|
97
97
|
# # read_list("#{model.tableize}_model_attrs")
|
|
98
98
|
# end
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
# Write model-level attrs
|
|
101
101
|
# def self.write_attrs_for_model(model_name, data)
|
|
102
102
|
# # write_list("#{model_name.tableize}_model_attrs", data)
|
|
103
103
|
# write_list(model_name, data)
|
|
104
104
|
# end
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
# Options:
|
|
107
107
|
# :attr - attribute to propagate. If not specified, all attrs found in configuration for the model
|
|
108
108
|
# will be propagated.
|
|
109
109
|
def self.update_children_on_attr(model, options = {})
|
|
110
110
|
attr_name = options[:attr].try(:to_s)
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
parent_pref = pref_to_read("#{model.tableize}_model_attrs")
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
if parent_pref
|
|
115
115
|
parent_list = ActiveSupport::JSON.decode(parent_pref.value)
|
|
116
116
|
parent_pref.children.each do |ch|
|
|
117
117
|
child_list = ActiveSupport::JSON.decode(ch.value)
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
if attr_name
|
|
120
120
|
# propagate a certain attribute
|
|
121
121
|
propagate_attr(attr_name, parent_list, child_list)
|
|
@@ -124,12 +124,12 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
124
124
|
all_attrs = parent_list.first.try(:keys)
|
|
125
125
|
all_attrs && all_attrs.each{ |attr_name| propagate_attr(attr_name, parent_list, child_list) }
|
|
126
126
|
end
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
ch.update_attribute(:value, child_list.to_json)
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
# meta_attrs:
|
|
134
134
|
# {"city"=>{"included"=>true}, "building_number"=>{"default_value"=>100}}
|
|
135
135
|
def self.update_children(model, meta_attrs)
|
|
@@ -139,26 +139,26 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
139
139
|
if parent_pref
|
|
140
140
|
parent_pref.children.each do |ch|
|
|
141
141
|
child_list = ActiveSupport::JSON.decode(ch.value)
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
meta_attrs.each_pair do |k,v|
|
|
144
144
|
child_list.detect{ |child_attr| child_attr["name"] == k }.try(:merge!, v)
|
|
145
145
|
end
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
ch.update_attribute(:value, child_list.to_json)
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
private
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
def self.propagate_attr(attr_name, src_list, dest_list)
|
|
155
155
|
for src_field in src_list
|
|
156
156
|
dest_field = dest_list.detect{ |df| df["name"] == src_field["name"] }
|
|
157
157
|
dest_field[attr_name] = src_field[attr_name] if dest_field && src_field[attr_name]
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
|
-
|
|
161
|
-
# Overwrite pref_to_read, pref_to_write methods, and find_all_for_component if you want a different way of
|
|
160
|
+
|
|
161
|
+
# Overwrite pref_to_read, pref_to_write methods, and find_all_for_component if you want a different way of
|
|
162
162
|
# identifying the proper preference based on your own authorization strategy.
|
|
163
163
|
#
|
|
164
164
|
# The default strategy is:
|
|
@@ -168,12 +168,12 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
168
168
|
# 2) if masq_user or masq_role is defined
|
|
169
169
|
# pref_to_read and pref_to_write will always take the masquerade into account, e.g. reads/writes will go to
|
|
170
170
|
# the user/role specified
|
|
171
|
-
#
|
|
171
|
+
#
|
|
172
172
|
def self.pref_to_read(name)
|
|
173
173
|
name = name.to_s
|
|
174
174
|
session = Netzke::Base.session
|
|
175
175
|
cond = {:name => name}
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
if session[:masq_user]
|
|
178
178
|
# first, get the prefs for this user it they exist
|
|
179
179
|
res = self.find(:first, :conditions => cond.merge({:user_id => session[:masq_user]}))
|
|
@@ -200,17 +200,17 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
200
200
|
else
|
|
201
201
|
res = self.find(:first, :conditions => cond)
|
|
202
202
|
end
|
|
203
|
-
|
|
204
|
-
res
|
|
203
|
+
|
|
204
|
+
res
|
|
205
205
|
end
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
def self.find_or_create_pref_to_read(name)
|
|
208
208
|
name = name.to_s
|
|
209
209
|
attrs = {:name => name}
|
|
210
210
|
extend_attrs_for_current_authority(attrs)
|
|
211
211
|
self.first(:conditions => attrs) || self.new(attrs)
|
|
212
212
|
end
|
|
213
|
-
|
|
213
|
+
|
|
214
214
|
def self.extend_attrs_for_current_authority(hsh)
|
|
215
215
|
authority_level, authority_id = Netzke::Base.authority_level
|
|
216
216
|
case authority_level
|
|
@@ -224,12 +224,12 @@ class NetzkeFieldList < ActiveRecord::Base
|
|
|
224
224
|
hsh.merge!(:user_id => authority_id)
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
def self.pref_to_write(name)
|
|
229
229
|
name = name.to_s
|
|
230
230
|
session = Netzke::Base.session
|
|
231
231
|
cond = {:name => name}
|
|
232
|
-
|
|
232
|
+
|
|
233
233
|
if session[:masq_user]
|
|
234
234
|
cond.merge!({:user_id => session[:masq_user]})
|
|
235
235
|
# first, try to find the preference for masq_user
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
# Is used to configure attributes in the layer between a model and its representation in the Netzke application, thus providing default attributes
|
|
3
3
|
# for grids and panels.
|
|
4
4
|
class NetzkeModelAttrList < NetzkeFieldList
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
# Updates attributes for all lists owned by owner_id and below the current authority level
|
|
7
7
|
def self.update_fields(owner_id, attrs_hash)
|
|
8
8
|
super
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
NetzkeFieldList.find_all_lists_under_current_authority(owner_id).each do |list|
|
|
11
11
|
list.update_attrs(attrs_hash)
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
def self.add_attrs(attrs)
|
|
16
16
|
NetzkeFieldList.find_all_lists_under_current_authority(owner_id).each do |list|
|
|
17
17
|
attrs.each{ |attr_hash| list.append_attr(attr_hash) }
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
require 'acts_as_list'
|
|
2
2
|
class NetzkePersistentArrayAutoModel < ActiveRecord::Base
|
|
3
3
|
set_table_name "netzke_temp_table"
|
|
4
|
-
connection.create_table(table_name){} if !connection.table_exists?(table_name)
|
|
4
|
+
connection.create_table(table_name){} if !connection.table_exists?(table_name)
|
|
5
5
|
|
|
6
6
|
acts_as_list
|
|
7
7
|
default_scope :order => "position"
|
|
8
8
|
|
|
9
9
|
cattr_accessor :config
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
def self.all_columns
|
|
12
12
|
self.all.map{ |c| c.attributes.reject{ |k,v| k == 'id' || k == 'position' } }
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
# Configuration
|
|
16
16
|
def self.configure(config)
|
|
17
17
|
self.config = config
|
|
@@ -20,7 +20,7 @@ class NetzkePersistentArrayAutoModel < ActiveRecord::Base
|
|
|
20
20
|
end
|
|
21
21
|
NetzkePreference.find_or_create_by_name("netzke_persistent_array_refresh_token").update_attribute(:value, refresh_token)
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
def self.rebuild_table#(config)
|
|
25
25
|
connection.drop_table(table_name) if connection.table_exists?(table_name)
|
|
26
26
|
# create the table with the fields
|
|
@@ -36,23 +36,23 @@ class NetzkePersistentArrayAutoModel < ActiveRecord::Base
|
|
|
36
36
|
# self.create config[:initial_data]
|
|
37
37
|
self.replace_data(config[:initial_data])
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
def self.replace_data(data)
|
|
41
41
|
# only select those attributes that were provided to us as columns. The rest is ignored.
|
|
42
42
|
column_names = config[:columns].map{ |c| c[:name] }
|
|
43
|
-
clean_data = data.collect{ |c| c.reject{ |k,v| !column_names.include?(k.to_s) } }
|
|
43
|
+
clean_data = data.collect{ |c| c.reject{ |k,v| !column_names.include?(k.to_s) } }
|
|
44
44
|
Rails.logger.debug "!!! clean_data: #{clean_data.inspect}\n"
|
|
45
45
|
self.delete_all
|
|
46
46
|
self.create(clean_data)
|
|
47
47
|
end
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
private
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
def self.refresh_token
|
|
52
52
|
@@refresh_token ||= begin
|
|
53
53
|
session = Netzke::Base.session
|
|
54
54
|
config[:owner] + (session[:masq_user] || session[:masq_role] || session[:masq_world] || session[:netzke_user_id]).to_s
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
end
|