easy_admin_ui 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 513d2dbb36980dd4af655db1099431b8350fe0cd
4
- data.tar.gz: 159c898813aa7f1419f35519650d6e245d8270ee
3
+ metadata.gz: 30eea89e6040f709fd974b92c901c0c1aa8d54a5
4
+ data.tar.gz: 5dc3f627ef2df96049f4e1d034c194e959a07ee9
5
5
  SHA512:
6
- metadata.gz: 8b279eb13d7789daa621311d82fe89dc926618976cc1aeb8293cb352ca5d4da0e7d334c2964bd3844911d608be3028813c03c516bd8aa3b9adbec618cf972287
7
- data.tar.gz: aab2ba2305a650268e463da9bfd2d820657dddcab8e21ba66660296868e752a96f554608d02884c1fa18f36c2a82db0d7e8a67974a87518f85910330b7a0832d
6
+ metadata.gz: 10d9bdc9d479b7ddc40be58b95694ae6126a378bace121e4271f50014927fcff2a17e1bee484ede2ee0e12aa68d459a86639d8ded1e5c42fafb9e273fd6f40ca
7
+ data.tar.gz: 01a5a205d2e0a54a1f0b15043efacb9c4f53cdc5ba1af2cc4f2c73331f21288926588dd01b0b4d00eff95e7bff718a2a23b8cb74284eb3a3e062ae8f1e70bb3b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_admin_ui (0.7.0)
4
+ easy_admin_ui (0.7.1)
5
5
  formtastic (>= 2.2.1)
6
6
  kaminari (>= 0.12.4)
7
7
  rails (>= 4.0.0)
@@ -48,9 +48,10 @@ GEM
48
48
  hike (1.2.3)
49
49
  httpclient (2.3.4.1)
50
50
  i18n (0.6.9)
51
- kaminari (0.15.1)
51
+ kaminari (0.13.0)
52
52
  actionpack (>= 3.0.0)
53
53
  activesupport (>= 3.0.0)
54
+ railties (>= 3.0.0)
54
55
  mail (2.5.4)
55
56
  mime-types (~> 1.16)
56
57
  treetop (~> 1.4.8)
@@ -0,0 +1,24 @@
1
+ $(document).ready(function() {
2
+ var confirm_html = '\
3
+ <span id="confirm_delete_OBJID" class="admin_delete-confirm_delete" style="display: none;">\
4
+ Are you sure?\
5
+ <a href="DELETE_URL" data-id="OBJID" data-method="delete" data-remote="true">Yes</a> | <a href="" class="no">No</a>\
6
+ </span>';
7
+
8
+ $('body').on('click', '.admin_delete', function(e) {
9
+ e.preventDefault();
10
+
11
+ var a_link = $(e.target).parent('a')
12
+ var obj_id = a_link.attr('data-id')
13
+
14
+ a_link.after(confirm_html.replace(/OBJID/g, obj_id).replace(/DELETE_URL/, window.location + '/' + obj_id))
15
+
16
+ a_link.siblings('#confirm_delete_' + obj_id).show()
17
+ });
18
+
19
+ // User clicks No.
20
+ $('body').on('click', '.admin_delete-confirm_delete .no', function(e) {
21
+ $(e.target).parent('.admin_delete-confirm_delete').remove()
22
+ e.preventDefault()
23
+ });
24
+ });
@@ -68,7 +68,7 @@ module EasyAdminUi
68
68
  end
69
69
 
70
70
  def admin_show_link(item, html_options = {})
71
- link_to(image_tag("easy_admin_ui/show.png"), {:action => 'show', :id => item}.merge(html_options))
71
+ link_to(show_icon_image_tag, {:action => 'show', :id => item}.merge(html_options))
72
72
  end
73
73
 
74
74
  def admin_new_link(html_options = {})
@@ -76,7 +76,7 @@ module EasyAdminUi
76
76
  end
77
77
 
78
78
  def admin_edit_link(item, html_options = {})
79
- link_to(image_tag("easy_admin_ui/pencil.png"), {:action => 'edit', :id => item}.merge(html_options))
79
+ link_to(edit_icon_image_tag, {:action => 'edit', :id => item}.merge(html_options))
80
80
  end
81
81
 
82
82
  # Use if below /admin/.
@@ -87,10 +87,7 @@ module EasyAdminUi
87
87
 
88
88
  def delete_link_with_confirmation(obj, delete_path=nil)
89
89
  delete_path ||= eval("#{obj.class.to_s.underscore.singularize}_path(obj)")
90
- link_to_function(image_tag('easy_admin_ui/delete.png'), "$('#cnf_#{obj.id}').show();") + ' ' +
91
- raw('<span id="cnf_' + obj.id.to_s + '" class="conf_link" style="display: none;">Are you sure? ') +
92
- link_to("Yes", delete_path, :method => :delete, :remote => true) + ' ' +
93
- link_to_function("No", "$('#cnf_#{obj.id}').hide();") + raw('</span>')
90
+ link_to(delete_icon_image_tag, '', class: "admin_delete", 'data-id' => obj.id.to_s)
94
91
  end
95
92
 
96
93
  def partial_exists?(filename)
@@ -100,7 +97,7 @@ module EasyAdminUi
100
97
  def filename_from_partial(partial)
101
98
  "_#{partial}.html.erb"
102
99
  end
103
-
100
+
104
101
  # Render partial if it exists.
105
102
  def render_optional(partial)
106
103
  return '' unless partial_exists?(filename_from_partial(partial))
@@ -118,5 +115,17 @@ module EasyAdminUi
118
115
  end
119
116
  end.html_safe
120
117
  end
118
+
119
+ def show_icon_image_tag
120
+ image_tag("easy_admin_ui/show.png")
121
+ end
122
+
123
+ def edit_icon_image_tag
124
+ image_tag("easy_admin_ui/pencil.png")
125
+ end
126
+
127
+ def delete_icon_image_tag
128
+ image_tag('easy_admin_ui/delete.png')
129
+ end
121
130
  end
122
131
  end
@@ -95,11 +95,12 @@ module EasyAdminUi
95
95
 
96
96
  class_eval do
97
97
  def object_parameters
98
- current_object
99
- if @item.new_record?
98
+ if request.post?
100
99
  respond_to?(:allowed_params) ? allowed_params : create_params
101
- else
100
+ elsif request.put?
102
101
  respond_to?(:allowed_params) ? allowed_params : update_params
102
+ else
103
+ {}
103
104
  end
104
105
  end
105
106
 
@@ -113,7 +114,7 @@ module EasyAdminUi
113
114
 
114
115
  def current_object
115
116
  @item ||= current_model.find(params[:id]) if params[:id]
116
- @item ||= current_model.new(create_params)
117
+ @item ||= current_model.new(object_parameters)
117
118
  end
118
119
 
119
120
  def instance_variable_name
@@ -1,3 +1,3 @@
1
1
  module EasyAdminUi
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -50,14 +50,14 @@ module Resourceful
50
50
  def update
51
51
  #load_object
52
52
  before :update
53
-
53
+
54
54
  begin
55
55
  result = current_object.update_attributes object_parameters
56
56
  rescue ActiveRecord::StaleObjectError
57
57
  current_object.reload
58
58
  result = false
59
59
  end
60
-
60
+
61
61
  if result
62
62
  save_succeeded!
63
63
  after :update
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_admin_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Moen Wulffeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,6 +112,7 @@ files:
112
112
  - app/assets/images/easy_admin_ui/disconnect.png
113
113
  - app/assets/images/easy_admin_ui/pencil.png
114
114
  - app/assets/images/easy_admin_ui/show.png
115
+ - app/assets/javascripts/easy_admin_ui/easy_admin_ui.js
115
116
  - app/assets/stylesheets/easy_admin_ui/easy_admin_ui.sass
116
117
  - app/helpers/easy_admin_ui/easy_admin_ui_helper.rb
117
118
  - app/views/easy_admin_ui/destroy.js.erb