wheels 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -0,0 +1,2 @@
1
+ class AppConfigsController < InheritedResources::Base
2
+ end
@@ -68,7 +68,7 @@ class SitemapsController < InheritedResources::Base
68
68
  resource.parent = parent
69
69
  update! do |format|
70
70
  if params.stringify_keys["sitemap"]["position"]
71
- childrunz = Array.new(parent.children.sort{|t,u| t.position <=> u.position})
71
+ childrunz = Array.new(parent.children.sorted)
72
72
  childrunz.delete(resource)
73
73
  childrunz.insert(params.stringify_keys["sitemap"]["position"].to_i, resource)
74
74
  childrunz.each_with_index do |child, idx|
@@ -0,0 +1,2 @@
1
+ module AppConfigsHelper
2
+ end
@@ -0,0 +1,18 @@
1
+ class AppConfig < ActiveRecord::Base
2
+ after_save :reload
3
+ validates :name, :presence=>true
4
+ def self.[](name)
5
+ val = select{|t| t.name==name}[0].try(:value)
6
+ if val && (val==val.to_i.to_s)
7
+ val = val.to_i
8
+ end
9
+ val
10
+ end
11
+ def self.current
12
+ @current ||= AppConfig.all
13
+ end
14
+ def self.reload
15
+ @current = nil
16
+ end
17
+ end
18
+
@@ -1,7 +1,9 @@
1
1
  class Sitemap < ActiveRecord::Base
2
2
  has_many :children, :class_name=>'Sitemap', :foreign_key=>'parent_id', :dependent => :destroy do
3
3
  def sorted
4
- sort{|t, u| t.position <=> u.position}
4
+ sort{|t, u| if t.nil? || t.position.nil?; 1;
5
+ elsif u.nil? || u.position.nil?; -1;
6
+ else t.position <=> u.position end}
5
7
  end
6
8
  end
7
9
 
@@ -26,6 +28,7 @@ class Sitemap < ActiveRecord::Base
26
28
 
27
29
  def as_json(*a)
28
30
  {
31
+ :position=>self.position,
29
32
  :data=>{
30
33
  :title=>self.menu_text,
31
34
  :icon=>icon_name,
@@ -39,7 +42,7 @@ class Sitemap < ActiveRecord::Base
39
42
  :data_id => self.id
40
43
  },
41
44
  :state=>treeview_state,
42
- :children=> children.sort{|t,u| t.position <=> u.position}
45
+ :children=> children.sorted
43
46
  }.as_json(*a)
44
47
  end
45
48
 
@@ -51,7 +54,7 @@ class Sitemap < ActiveRecord::Base
51
54
  end
52
55
 
53
56
  def create_resource
54
- resource ||= resource_type.constantize.new unless resource_type.nil?
57
+ self.resource ||= resource_type.constantize.new unless resource_type.nil?
55
58
  end
56
59
 
57
60
  def url
@@ -59,13 +59,11 @@
59
59
  "format" : "json",
60
60
  #{authenticity_token_json}
61
61
  }
62
- if (data['parent_id']) {post_data['parent_id'] = data['parent_id']}
63
- if (data['menu_text']) {post_data['sitemap[menu_text]'] = data['menu_text']}
64
- if (data['position']) {post_data['sitemap[position]'] = data['position']}
65
- if (data['resource_id']) {post_data['sitemap[resource_id]'] = data['resource_id']}
66
- if (data['resource_type']) {post_data['sitemap[resource_type]'] = data['resource_type']}
67
- array_print('updateSiteMap Args', data);
68
- array_print('updateSiteMap Data', post_data);
62
+ if (data['parent_id'] != null) {post_data['parent_id'] = data['parent_id']}
63
+ if (data['menu_text'] != null) {post_data['sitemap[menu_text]'] = data['menu_text']}
64
+ if (data['position'] != null) {post_data['sitemap[position]'] = data['position']}
65
+ if (data['resource_id'] != null) {post_data['sitemap[resource_id]'] = data['resource_id']}
66
+ if (data['resource_type'] != null) {post_data['sitemap[resource_type]'] = data['resource_type']}
69
67
 
70
68
  $.ajax({
71
69
  async : false,
data/wheels.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wheels}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyler Gannon"]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  "Rakefile",
22
22
  "VERSION",
23
23
  "app/controllers/access_control_entries_controller.rb",
24
+ "app/controllers/app_configs_controller.rb",
24
25
  "app/controllers/attachments_controller.rb",
25
26
  "app/controllers/blogs_controller.rb",
26
27
  "app/controllers/discussions_controller.rb",
@@ -36,6 +37,7 @@ Gem::Specification.new do |s|
36
37
  "app/controllers/sitemaps_controller.rb",
37
38
  "app/controllers/users_controller.rb",
38
39
  "app/helpers/access_control_entries_helper.rb",
40
+ "app/helpers/app_configs_helper.rb",
39
41
  "app/helpers/application_helper.rb",
40
42
  "app/helpers/blogs_helper.rb",
41
43
  "app/helpers/discussions_helper.rb",
@@ -48,6 +50,7 @@ Gem::Specification.new do |s|
48
50
  "app/mailers/feedback_mailer.rb",
49
51
  "app/models/ability.rb",
50
52
  "app/models/access_control_entry.rb",
53
+ "app/models/app_config.rb",
51
54
  "app/models/attachment.rb",
52
55
  "app/models/blog.rb",
53
56
  "app/models/discussion.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tyler Gannon
@@ -44,6 +44,7 @@ files:
44
44
  - Rakefile
45
45
  - VERSION
46
46
  - app/controllers/access_control_entries_controller.rb
47
+ - app/controllers/app_configs_controller.rb
47
48
  - app/controllers/attachments_controller.rb
48
49
  - app/controllers/blogs_controller.rb
49
50
  - app/controllers/discussions_controller.rb
@@ -59,6 +60,7 @@ files:
59
60
  - app/controllers/sitemaps_controller.rb
60
61
  - app/controllers/users_controller.rb
61
62
  - app/helpers/access_control_entries_helper.rb
63
+ - app/helpers/app_configs_helper.rb
62
64
  - app/helpers/application_helper.rb
63
65
  - app/helpers/blogs_helper.rb
64
66
  - app/helpers/discussions_helper.rb
@@ -71,6 +73,7 @@ files:
71
73
  - app/mailers/feedback_mailer.rb
72
74
  - app/models/ability.rb
73
75
  - app/models/access_control_entry.rb
76
+ - app/models/app_config.rb
74
77
  - app/models/attachment.rb
75
78
  - app/models/blog.rb
76
79
  - app/models/discussion.rb