netzke-basepack 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
- # 0.8.0 - WIP
1
+ # 0.8.1 - 2012-12-15
2
+ * bug fix
3
+ * TabPanel now shows the active tab's nested component upon loading
4
+ * Accordion now shows the active pane's nested component upon loading
5
+
6
+ * improvements
7
+ * Add support for validation errors on before_destroy (by firemind)
8
+
9
+ # 0.8.0 - 2012-12-09
2
10
  * Basepack component renaming:
3
11
  * GridPanel -> Grid
4
12
  * FormPanel -> Form
@@ -30,10 +30,23 @@ module Netzke
30
30
  endpoint :delete_data do |params, this|
31
31
  if !config[:prohibit_delete]
32
32
  record_ids = ActiveSupport::JSON.decode(params[:records])
33
- data_adapter.destroy(record_ids)
33
+ success = true
34
+ record_ids.each {|id|
35
+ record = data_adapter.find_record(id)
36
+ if !record.destroy
37
+ success = false
38
+ record.errors.to_a.each do |msg|
39
+ flash :error => msg
40
+ end
41
+ end
42
+ }
34
43
  on_data_changed
35
- this.netzke_feedback I18n.t('netzke.basepack.grid.deleted_n_records', :n => record_ids.size)
36
- this.load_store_data get_data
44
+ if success
45
+ this.netzke_feedback I18n.t('netzke.basepack.grid.deleted_n_records', :n => record_ids.size)
46
+ this.load_store_data get_data
47
+ else
48
+ this.netzke_feedback @flash
49
+ end
37
50
  else
38
51
  this.netzke_feedback I18n.t('netzke.basepack.grid.cannot_delete')
39
52
  end
@@ -3,7 +3,7 @@ module Netzke
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 8
6
- PATCH = 0
6
+ PATCH = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
@@ -5,22 +5,23 @@ module Netzke
5
5
  # Used, for instance, in TabPanel and Accordion to dynamically load components on expanding a panel or clicking
6
6
  # a tab.
7
7
  module WrapLazyLoaded
8
- def extend_item(item)
9
- item = super
8
+ def js_configure(cfg)
9
+ super
10
+ cfg.items = cfg.items.each_with_index.map do |item,i|
11
+ c = components[item[:netzke_component]].try(:merge, item)
10
12
 
11
- c = components[item[:netzke_component]].try(:merge, item)
12
-
13
- # when a nested component with lazy loading is detected, it gets replaced with a 'fit' panel,
14
- # into which later the component itself is dynamically loaded on request.
15
- if c && !c[:eager_loading]
16
- { layout: :fit,
17
- wrapped_component: c[:item_id],
18
- title: c[:title] || c[:item_id].humanize,
19
- icon_cls: c[:icon_cls],
20
- disabled: c[:disabled]
21
- }
22
- else
23
- item
13
+ # when a nested component with lazy loading is detected, it gets replaced with a 'fit' panel,
14
+ # into which later the component itself is dynamically loaded on request.
15
+ if c && !c[:eager_loading] && i != config.active_tab.to_i # so it works for both TabPanel and Accordion
16
+ { layout: :fit,
17
+ wrapped_component: c[:item_id],
18
+ title: c[:title] || c[:item_id].humanize,
19
+ icon_cls: c[:icon_cls],
20
+ disabled: c[:disabled]
21
+ }
22
+ else
23
+ item
24
+ end
24
25
  end
25
26
  end
26
27
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "netzke-basepack"
8
- s.version = "0.8.0"
8
+ s.version = "0.8.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nomadcoder"]
12
- s.date = "2012-12-09"
12
+ s.date = "2012-12-15"
13
13
  s.description = "A set of feature-rich extendible Netzke components (such as Form, Grid, Window, TabPanel, etc) which can be used as building block for your RIA"
14
14
  s.email = "nmcoder@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -189,7 +189,7 @@ Gem::Specification.new do |s|
189
189
  "test/basepack_test_app/db/migrate/20110909071740_add_published_on_to_books.rb",
190
190
  "test/basepack_test_app/db/schema.rb",
191
191
  "test/basepack_test_app/db/seeds.rb",
192
- "test/basepack_test_app/features/accordion_panel.feature",
192
+ "test/basepack_test_app/features/accordion.feature",
193
193
  "test/basepack_test_app/features/form_panel.feature",
194
194
  "test/basepack_test_app/features/grid_panel.feature",
195
195
  "test/basepack_test_app/features/grid_panel_filters.feature",
@@ -4,7 +4,7 @@ source 'http://rubygems.org'
4
4
  gem 'rails', '~>3.2.0'
5
5
  gem 'mysql2'
6
6
 
7
- gem 'netzke-core', github: "nomadcoder/netzke-core"
7
+ gem 'netzke-core', '~>0.8.0'
8
8
 
9
9
  group :test do
10
10
  gem 'factory_girl'
@@ -1,10 +1,3 @@
1
- GIT
2
- remote: git://github.com/nomadcoder/netzke-core.git
3
- revision: 74e19672cd7c270415714f1805f09b3262e577bc
4
- specs:
5
- netzke-core (0.8.0)
6
- activesupport (>= 3.0.0)
7
-
8
1
  GEM
9
2
  remote: http://rubygems.org/
10
3
  specs:
@@ -70,15 +63,18 @@ GEM
70
63
  json (1.7.5)
71
64
  launchy (2.1.2)
72
65
  addressable (~> 2.3)
73
- libwebsocket (0.1.6.1)
66
+ libwebsocket (0.1.7.1)
67
+ addressable
74
68
  websocket
75
69
  mail (2.4.4)
76
70
  i18n (>= 0.4.0)
77
71
  mime-types (~> 1.16)
78
72
  treetop (~> 1.4.8)
79
73
  mime-types (1.19)
80
- multi_json (1.3.7)
74
+ multi_json (1.4.0)
81
75
  mysql2 (0.3.11)
76
+ netzke-core (0.8.0)
77
+ activesupport (>= 3.1.0)
82
78
  nokogiri (1.5.5)
83
79
  pickle (0.4.11)
84
80
  cucumber (>= 0.8)
@@ -109,7 +105,7 @@ GEM
109
105
  rake (10.0.2)
110
106
  rdoc (3.12)
111
107
  json (~> 1.4)
112
- rspec-core (2.12.0)
108
+ rspec-core (2.12.1)
113
109
  rspec-expectations (2.12.0)
114
110
  diff-lcs (~> 1.1.3)
115
111
  rspec-mocks (2.12.0)
@@ -121,7 +117,7 @@ GEM
121
117
  rspec-expectations (~> 2.12.0)
122
118
  rspec-mocks (~> 2.12.0)
123
119
  rubyzip (0.9.9)
124
- selenium-webdriver (2.26.0)
120
+ selenium-webdriver (2.27.1)
125
121
  childprocess (>= 0.2.5)
126
122
  libwebsocket (~> 0.1.3)
127
123
  multi_json (~> 1.0)
@@ -153,7 +149,7 @@ DEPENDENCIES
153
149
  factory_girl
154
150
  launchy
155
151
  mysql2
156
- netzke-core!
152
+ netzke-core (~> 0.8.0)
157
153
  pickle
158
154
  rails (~> 3.2.0)
159
155
  rspec-rails
@@ -3,7 +3,6 @@ class SimplePanel < Netzke::Base
3
3
 
4
4
  js_configure do |c|
5
5
  c.title = "SimplePanel"
6
- c.html = "Original HTML"
7
6
  c.on_update_html = <<-JS
8
7
  function(){
9
8
  this.updateHtmlFromServer();
@@ -12,8 +11,13 @@ class SimplePanel < Netzke::Base
12
11
  end
13
12
 
14
13
  def configure(c)
15
- super
14
+ c.html = "Original HTML"
16
15
  c.bbar = [:update_html]
16
+ super
17
+ end
18
+
19
+ def self.server_side_config_options
20
+ super << :update_text
17
21
  end
18
22
 
19
23
  endpoint :update_html_from_server do |params, this|
@@ -1,4 +1,11 @@
1
1
  class SomeAccordion < Netzke::Basepack::Accordion
2
+ # This component will be rendered immediately in the first tab
3
+ #
4
+ component :panel_zero do |c|
5
+ c.klass = SimplePanel
6
+ c.title = "Panel Zero"
7
+ end
8
+
2
9
  # This component will be dynamically loaded on expanding the second accordion pane
3
10
  component :simple_panel do |c|
4
11
  c.update_text = "Update for Panel Two"
@@ -10,6 +17,7 @@ class SomeAccordion < Netzke::Basepack::Accordion
10
17
  def configure(c)
11
18
  c.title = "Some Accordion"
12
19
  c.items = [
20
+ :panel_zero,
13
21
  { :html => "I'm a simple Ext.Panel", :title => "Panel One" },
14
22
  :simple_panel
15
23
  ]
@@ -1,9 +1,16 @@
1
1
  class SomeTabPanel < Netzke::Basepack::TabPanel
2
+ # This component will be rendered immediately in the first tab
3
+ #
4
+ component :tab_one do |c|
5
+ c.klass = SimplePanel
6
+ c.title = "Panel Zero"
7
+ end
8
+
2
9
  # This component will be dynamically loaded on expanding the second accordion pane
3
10
  component :simple_panel do |c|
4
11
  c.update_text = "Update for Panel Two"
5
12
  c.title = "Panel Two"
6
- c.prevent_header = true
13
+ c.header = false
7
14
  c.border = false
8
15
 
9
16
  # optionally, you can force a certain component to be eagerly loaded:
@@ -15,6 +22,7 @@ class SomeTabPanel < Netzke::Basepack::TabPanel
15
22
  c.active_tab = 0
16
23
 
17
24
  c.items = [
25
+ :tab_one,
18
26
  { :html => "I'm a simple Ext.Panel", :title => "Panel One" },
19
27
  :simple_panel
20
28
  ]
@@ -2,4 +2,10 @@ class User < ActiveRecord::Base
2
2
  # scope :latest, lambda {|param| where(:created_at.gt => param)}
3
3
  belongs_to :role
4
4
  has_one :address
5
+
6
+ before_destroy :is_admin
7
+ def is_admin
8
+ errors.add :base, "Can't delete Admin User." if self.first_name == "Admin"
9
+ errors.blank?
10
+ end
5
11
  end
@@ -5,8 +5,10 @@ Feature: Accordion panel
5
5
 
6
6
  @javascript
7
7
  Scenario: Lazy loading of a component into a panel when the latter gets expanded
8
- Given I am on the SomeAccordion test page
8
+ When I go to the SomeAccordion test page
9
+ Then expanded panel should have button "Update html"
9
10
  When I expand "Panel Two"
10
- Then I should see "Original HTML"
11
+ And I sleep 1 second
12
+ Then expanded panel should have button "Update html"
11
13
  When I press "Update html"
12
14
  Then I should see "Update for Panel Two"
@@ -52,6 +52,17 @@ Scenario: Deleting a record
52
52
  Then I should see "Deleted 1 record(s)"
53
53
  Then a user should not exist with first_name: "Anton"
54
54
 
55
+ @javascript
56
+ Scenario: Try deleting an undeletable record
57
+ Given a user exists with first_name: "Admin", last_name: "Admin"
58
+ When I go to the UserGrid test page
59
+ And I select all rows in the grid
60
+ And I press "Delete"
61
+ Then I should see "Are you sure?"
62
+ When I press "Yes"
63
+ Then I should see "Can't delete Admin User"
64
+ Then a user should exist with first_name: "Admin"
65
+
55
66
  @javascript
56
67
  Scenario: Multi-editing records
57
68
  Given a user exists with first_name: "Carlos", last_name: "Castaneda"
@@ -147,3 +147,22 @@ Then /^I should not see window$/ do
147
147
  return out;
148
148
  JS
149
149
  end
150
+
151
+ Then /^active tab should have button "(.*?)"$/ do |text|
152
+ page.driver.browser.execute_script(<<-JS).should == true
153
+ var tp = Ext.ComponentQuery.query('tabpanel')[0],
154
+ at = tp.getActiveTab();
155
+ return !!at.down('button[text="#{text}"]');
156
+ JS
157
+ end
158
+
159
+ Then /^expanded panel should have button "(.*?)"$/ do |text|
160
+ page.driver.browser.execute_script(<<-JS).should == true
161
+ for (var prop in Netzke.page) {
162
+ var panel = Netzke.page[prop];
163
+ break;
164
+ }
165
+ ap = panel.down("[collapsed=false]");
166
+ return !!ap.down('button[text="#{text}"]');
167
+ JS
168
+ end
@@ -5,8 +5,9 @@ Feature: Tab panel
5
5
 
6
6
  @javascript
7
7
  Scenario: Lazy loading of a component into a tab when the latter gets open
8
- Given I am on the SomeTabPanel test page
8
+ When I go to the SomeTabPanel test page
9
+ Then active tab should have button "Update html"
9
10
  When I press "Panel Two"
10
- Then I should see "Original HTML"
11
+ Then active tab should have button "Update html"
11
12
  When I press "Update html"
12
13
  Then I should see "Update for Panel Two"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-basepack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
12
+ date: 2012-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: netzke-core
@@ -208,7 +208,7 @@ files:
208
208
  - test/basepack_test_app/db/migrate/20110909071740_add_published_on_to_books.rb
209
209
  - test/basepack_test_app/db/schema.rb
210
210
  - test/basepack_test_app/db/seeds.rb
211
- - test/basepack_test_app/features/accordion_panel.feature
211
+ - test/basepack_test_app/features/accordion.feature
212
212
  - test/basepack_test_app/features/form_panel.feature
213
213
  - test/basepack_test_app/features/grid_panel.feature
214
214
  - test/basepack_test_app/features/grid_panel_filters.feature