inline_forms 6.0.4 → 6.1.0

This diff has not been reviewed by any users.
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
- SHA1:
3
- metadata.gz: c7951217d1207dbac72697094e7116a1e95c012e
4
- data.tar.gz: bbc9ae8c6ff17c18c2e2e1d68c4953f65fe3dfdc
2
+ SHA256:
3
+ metadata.gz: 169ab894a2c055a03e9983a22dfa213b5a8652802b0275a00cc331383051e463
4
+ data.tar.gz: 3c8ef4b8dcd3d786f3faa0cc689b5c506415736049fe3215398e173211ea1699
5
5
  SHA512:
6
- metadata.gz: 666c1f4ff362d8104f010919dd7321d99581b985fe5431bed570062cefc9b83082e2f4d634205457191a2380cee8a19a54fc5722efe052cea9e575bfb8225e6f
7
- data.tar.gz: 72908445fde367e2da6cea09d5844389f11cee258e2c151d2c7c493c989cccd1563e63433ab64e85b068b153155f935c40865eadd3ce9560f21f96dd5aa5224d
6
+ metadata.gz: cfc1950838796ad809ed0a3dc4dfc858cdb067b0fea0fada79ee1ac3c5ac1f60690eb1d19dcd1dc2d1a24d45bb12b5d41e35ffc42261d46e4a43a2aa8b3cb6af
7
+ data.tar.gz: 1ecda9c9be6c4fa99ace420def18b0c88bc26279d56816a60d503cfbdf0e2f6d5b48203c2441810405c120fc93e53c3302971a8e857e465934992c8f9863cc24
@@ -4,6 +4,7 @@
4
4
  //= require jquery.timepicker.js
5
5
  //= require foundation
6
6
  //= require jquery.remotipart
7
+ //= require autocomplete-rails
7
8
 
8
9
  $(function(){ $(document).foundation(); });
9
10
  // initialize datepickers
@@ -2,7 +2,7 @@
2
2
  class InlineFormsApplicationController < ActionController::Base
3
3
  protect_from_forgery
4
4
  layout 'devise' if :devise_controller?
5
-
5
+
6
6
  # limit available locales by setting this. Override in applicaton_controller.
7
7
  I18n.available_locales = [ :en, :nl, :pp ]
8
8
 
@@ -10,7 +10,7 @@ class InlineFormsApplicationController < ActionController::Base
10
10
  def set_locale
11
11
  I18n.locale = extract_locale_from_subdomain || I18n.default_locale
12
12
  end
13
-
13
+
14
14
  # Get locale code from request subdomain (like http://it.application.local:3000)
15
15
  def extract_locale_from_subdomain
16
16
  locale = request.subdomains.first
@@ -95,7 +95,7 @@ class InlineFormsController < ApplicationController
95
95
  @update_span = params[:update]
96
96
  attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list
97
97
  attributes.each do | attribute, name, form_element |
98
- send("#{form_element.to_s}_update", @object, attribute) unless form_element == :tree || form_element == :associated || (cancan_enabled? && cannot?(:read, @Klass.to_s.underscore.pluralize.to_sym, attribute))
98
+ send("#{form_element.to_s}_update", @object, attribute) unless form_element == :tree || form_element == :associated || (cancan_enabled? && cannot?(:read, @object, attribute))
99
99
  end
100
100
  @parent_class = params[:parent_class]
101
101
  @parent_id = params[:parent_id]
@@ -180,29 +180,41 @@ class InlineFormsController < ApplicationController
180
180
  end
181
181
  end
182
182
 
183
- # :destroy destroys the record, but also shows an undo link (with paper_trail)
183
+ # :soft_delete
184
+ def soft_delete
185
+ @update_span = params[:update]
186
+ @object = referenced_object
187
+ # destroy the object
188
+ @object.soft_delete(current_user)
189
+ respond_to do |format|
190
+ format.html { } unless @Klass.not_accessible_through_html?
191
+ format.js { render :close }
192
+ end
193
+ end
194
+
195
+ # :soft_restore
196
+ def soft_restore
197
+ @update_span = params[:update]
198
+ @object = referenced_object
199
+ # restore the object
200
+ @object.soft_restore
201
+ respond_to do |format|
202
+ format.html { } unless @Klass.not_accessible_through_html?
203
+ format.js { render :close }
204
+ end
205
+ end
206
+
207
+ # :destroy destroys the record. There is no undo!
184
208
  def destroy
185
209
  @update_span = params[:update]
186
210
  @object = referenced_object
187
211
  if current_user.role? :superadmin
188
- if (@Klass.soft_deletable? rescue false)
189
- @object.soft_delete(current_user)
190
- respond_to do |format|
191
- format.html { } unless @Klass.not_accessible_through_html?
192
- format.js { render :close }
193
- end
194
- elsif
195
- @object.destroy
196
- respond_to do |format|
197
- format.html { } unless @Klass.not_accessible_through_html?
198
- format.js { render :show_undo }
199
- end
200
- end
201
- elsif (@Klass.soft_deletable? rescue false)
202
- @object.soft_delete(current_user)
212
+ # destroy the object
213
+ @undo_object = @object.versions.last
214
+ @object.destroy
203
215
  respond_to do |format|
204
216
  format.html { } unless @Klass.not_accessible_through_html?
205
- format.js { render :close }
217
+ format.js { render :record_destroyed }
206
218
  end
207
219
  end
208
220
  end
@@ -211,27 +223,12 @@ class InlineFormsController < ApplicationController
211
223
  # Thanks Ryan Bates: http://railscasts.com/episodes/255-undo-with-paper-trail
212
224
  def revert
213
225
  @update_span = params[:update]
226
+ @object = referenced_object
214
227
  if current_user.role? :superadmin
215
- if (@Klass.soft_deletable? rescue false)
216
- @object = referenced_object
217
- @object.soft_restore
218
- respond_to do |format|
219
- format.html { } unless @Klass.not_accessible_through_html?
220
- format.js { render :close }
221
- end
222
- elsif
223
- @version = PaperTrail::Version.find(params[:id])
224
- @version.reify.save!
225
- @object = @Klass.find(@version.item_id)
226
- authorize!(:revert, @object) if cancan_enabled?
227
- respond_to do |format|
228
- format.html { } unless @Klass.not_accessible_through_html?
229
- format.js { render :close }
230
- end
231
- end
232
- elsif (@Klass.soft_deletable? rescue false)
233
- @object = referenced_object
234
- @object.soft_restore
228
+ @version = PaperTrail::Version.find(params[:id])
229
+ @version.reify.save!
230
+ @object = @Klass.find(@version.item_id)
231
+ authorize!(:revert, @object) if cancan_enabled?
235
232
  respond_to do |format|
236
233
  format.html { } unless @Klass.not_accessible_through_html?
237
234
  format.js { render :close }
@@ -30,37 +30,44 @@ module InlineFormsHelper
30
30
  :title => t('inline_forms.view.close')
31
31
  end
32
32
 
33
- # destroy link
34
- def link_to_destroy( object, update_span )
35
- if current_user.role? :superadmin
36
- if cancan_disabled? || ( can? :delete, object )
37
- link_to "<i class='fi-trash'></i>".html_safe,
38
- send( object.class.to_s.underscore + '_path',
39
- object,
40
- :update => update_span ),
41
- :method => :delete,
42
- :remote => true,
43
- :title => t('inline_forms.view.trash')
44
- end
45
- elsif (object.class.safe_deletable? rescue false)
46
- if object.deleted? && (cancan_disabled? || ( can? :revert, object ))
47
- link_to "undelete".html_safe,
48
- send( 'revert_' + object.class.to_s.underscore + '_path',
33
+ # delete link. Mind the difference between delete and destroy.
34
+ def link_to_soft_delete( object, update_span )
35
+ soft=''
36
+ if (object.soft_deletable? rescue false)
37
+ if object.deleted? && (cancan_disabled? || ( can? :soft_restore, object ))
38
+ soft = link_to "<i class='fi-refresh'></i>".html_safe,
39
+ send( 'soft_restore_' + object.class.to_s.underscore + '_path',
49
40
  object,
50
41
  :update => update_span ),
51
42
  :method => :post,
52
43
  :remote => true,
53
- :title => t('inline_forms.view.trash')
54
- elsif !object.deleted? && (cancan_disabled? || ( can? :delete, object ))
55
- link_to "<i class='fi-trash'></i>".html_safe,
56
- send( object.class.to_s.underscore + '_path',
57
- object,
58
- :update => update_span ),
59
- :method => :delete,
60
- :remote => true,
61
- :title => t('inline_forms.view.trash')
44
+ :title => t('inline_forms.view.undelete')
45
+ elsif !object.deleted? && (cancan_disabled? || ( can? :soft_delete, object ))
46
+ soft = link_to "<i class='fi-trash'></i>".html_safe,
47
+ send( 'soft_delete_' + object.class.to_s.underscore + '_path',
48
+ object,
49
+ :update => update_span ),
50
+ :method => :post,
51
+ :remote => true,
52
+ :title => t('inline_forms.view.trash')
62
53
  end
63
54
  end
55
+ soft.html_safe
56
+ end
57
+
58
+ # destroy link. Mind the difference between delete and destroy.
59
+ def link_to_destroy( object, update_span )
60
+ hard=''
61
+ if cancan_disabled? || ( can? :destroy, object )
62
+ hard = link_to "&nbsp;&nbsp;<font color='FF0000'><i class='fi-x'></i></font>".html_safe,
63
+ send( object.class.to_s.underscore + '_path',
64
+ object,
65
+ :update => update_span ),
66
+ :method => :delete,
67
+ :remote => true,
68
+ :title => t('inline_forms.view.trash')
69
+ end
70
+ hard.html_safe
64
71
  end
65
72
 
66
73
  # new link
@@ -76,7 +83,7 @@ module InlineFormsHelper
76
83
  :title => t('inline_forms.view.add_new', :model => model.model_name.human )
77
84
  )
78
85
  if cancan_enabled?
79
- if can? :create, model.to_s.pluralize.underscore.to_sym
86
+ if can? :create, model
80
87
  if parent_class.nil?
81
88
  raw out
82
89
  else
@@ -99,7 +106,7 @@ module InlineFormsHelper
99
106
  :class => html_class,
100
107
  :title => t('inline_forms.view.list_versions')
101
108
  )
102
- if can? :list_versions, object.class.name.pluralize.underscore.to_sym
109
+ if can? :list_versions, object
103
110
  raw out
104
111
  end
105
112
  end
@@ -123,7 +130,8 @@ module InlineFormsHelper
123
130
  spaces = attribute_value.length > 40 ? 0 : 40 - attribute_value.length
124
131
  value = h(attribute_value) + ("&nbsp;" * spaces).html_safe
125
132
  css_class_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}"
126
- if cancan_disabled? || ( can? :update, object, attribute )
133
+ if (cancan_disabled? rescue true) || ( can? :update, object, attribute )
134
+ # some problem with concerns makes this function not available when called direct. FIXME
127
135
  link_to value,
128
136
  send( 'edit_' + object.class.to_s.underscore + '_path',
129
137
  object,
@@ -19,16 +19,16 @@ module InlineForms::SoftDeletable
19
19
  end
20
20
 
21
21
  def soft_delete(current_user)
22
- deleted = 2
23
- deleter = current_user
24
- deleted_at = Time.current
22
+ self.deleted = 2
23
+ self.deleter = current_user
24
+ self.deleted_at = Time.current
25
25
  save
26
26
  end
27
27
 
28
28
  def soft_restore
29
- deleted = 1
30
- deleted_by = nil
31
- deleted_at = nil
29
+ self.deleted = 1
30
+ self.deleted_by = nil
31
+ self.deleted_at = nil
32
32
  save
33
33
  end
34
34
 
@@ -1,5 +1,6 @@
1
- <% if cancan_disabled? || ( can? :delete, @object ) %>
1
+ <% if cancan_disabled? || ( can? :soft_delete, @object ) %>
2
2
  <div class="small-1 column">
3
+ <%= link_to_soft_delete(@object, @update_span) -%>
3
4
  <%= link_to_destroy(@object, @update_span) -%>
4
5
  </div>
5
6
  <div class="small-11 column">
@@ -22,7 +22,7 @@
22
22
  <% MODEL_TABS.each do |m| %>
23
23
  <% model = m.singularize.camelcase.constantize rescue nil %>
24
24
  <% unless model.nil? || model.not_accessible_through_html? %>
25
- <% if can? :update, m.to_sym %>
25
+ <% if can? :update, model %>
26
26
  <li>
27
27
  <%= link_to model.model_name.human, '/' + m %>
28
28
  </li>
@@ -53,8 +53,9 @@
53
53
  <% path_to_object = attribute.to_s.singularize.underscore + "_path" %>
54
54
  <% end %>
55
55
  <div class="row <%= cycle('odd', 'even') %><%= " top-level" if parent_class.nil? %>" id="<%= css_class_id -%>">
56
- <% if cancan_disabled? || ( can? :delete, object ) %>
56
+ <% if cancan_disabled? || ( can? :soft_delete, object ) %>
57
57
  <div class="small-1 column">
58
+ <%= link_to_soft_delete(object, css_class_id) -%>
58
59
  <%= link_to_destroy(object, css_class_id) -%>
59
60
  </div>
60
61
  <div class="small-11 column">
@@ -23,7 +23,7 @@
23
23
  :multipart => true, :remote => true, :class => "edit_form" do -%>
24
24
  <% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
25
25
  <% attributes.each do | attribute, name, form_element | -%>
26
- <% unless form_element.to_sym == :associated || form_element.to_sym == :tree || (cancan_enabled? && cannot?(:read, @Klass.to_s.underscore.pluralize.to_sym, attribute)) -%>
26
+ <% unless form_element.to_sym == :associated || form_element.to_sym == :tree || (cancan_enabled? && cannot?(:read, @object, attribute)) -%>
27
27
  <% css_class_id = "attribute_#{attribute}_#{@object.id}" -%>
28
28
  <% if form_element && form_element.to_sym == :header %>
29
29
  <div class="row form_element_header" >
@@ -115,7 +115,7 @@
115
115
  <% end %>
116
116
  <% end %>
117
117
  <% end %>
118
- <% if can? :list_versions, @object.class.name.pluralize.underscore.to_sym %>
118
+ <% if can? :list_versions, @object %>
119
119
  <% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_versions" -%>
120
120
  <div id="<%= css_class_id -%>">
121
121
  <%= render 'versions' %>
@@ -0,0 +1 @@
1
+ $('#<%= @update_span %>').fadeOut("slow")
@@ -10,6 +10,7 @@ gem 'ckeditor', git: 'https://github.com/galetahub/ckeditor'
10
10
  #gem 'bootsnap', require: false
11
11
  gem 'coffee-rails'
12
12
  #gem 'compass-rails'
13
+ gem 'rails-jquery-autocomplete'
13
14
  gem 'devise'
14
15
  gem 'foundation-icons-sass-rails'
15
16
  gem 'foundation-rails', '~> 5.5'
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "6.0.4"
3
+ VERSION = "6.1.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.4
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -10,132 +10,132 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-06-10 00:00:00.000000000 Z
13
+ date: 2020-07-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rvm
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: thor
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - '>='
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: validation_hints
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rails
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: '6.0'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - '>='
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '6.0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rails-i18n
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rspec-rails
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: shoulda
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - '>='
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: bundler
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: jeweler
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - '>='
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  description: Inline Forms aims to ease the setup of forms that provide inline editing.
@@ -149,9 +149,9 @@ executables:
149
149
  extensions: []
150
150
  extra_rdoc_files: []
151
151
  files:
152
- - .document
153
- - .gitignore
154
- - .vscode/settings.json
152
+ - ".document"
153
+ - ".gitignore"
154
+ - ".vscode/settings.json"
155
155
  - Gemfile
156
156
  - LICENSE.txt
157
157
  - README.rdoc
@@ -246,6 +246,7 @@ files:
246
246
  - app/views/inline_forms/extract_translations.erb
247
247
  - app/views/inline_forms/list.js.erb
248
248
  - app/views/inline_forms/new.js.erb
249
+ - app/views/inline_forms/record_destroyed.js.erb
249
250
  - app/views/inline_forms/show.js.erb
250
251
  - app/views/inline_forms/show_element.js.erb
251
252
  - app/views/inline_forms/show_undo.js.erb
@@ -299,17 +300,16 @@ require_paths:
299
300
  - lib
300
301
  required_ruby_version: !ruby/object:Gem::Requirement
301
302
  requirements:
302
- - - '>='
303
+ - - ">="
303
304
  - !ruby/object:Gem::Version
304
305
  version: '0'
305
306
  required_rubygems_version: !ruby/object:Gem::Requirement
306
307
  requirements:
307
- - - '>='
308
+ - - ">="
308
309
  - !ruby/object:Gem::Version
309
310
  version: '0'
310
311
  requirements: []
311
- rubyforge_project: inline_forms
312
- rubygems_version: 2.6.14
312
+ rubygems_version: 3.0.1
313
313
  signing_key:
314
314
  specification_version: 4
315
315
  summary: Inline editing of forms.