inline_forms 6.0.5 → 6.1.1

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
2
  SHA1:
3
- metadata.gz: b7294976b3ac09b7775c3a0a36925ce4ccb4f73f
4
- data.tar.gz: 945113c29e712687c341ef479de35d5242096fca
3
+ metadata.gz: 7699a366575cf2f80d88f82690e4fa35a745ab62
4
+ data.tar.gz: 2302ad5c8577598ab406f600c4e58da9767557ee
5
5
  SHA512:
6
- metadata.gz: 68737c524ed39ab962da6e43b95ba051e453795dd7f03add546a1145eb44cbda13a7204c786649313fdcec04de70b96001b06f729e34aec55518d2fccef8fe04
7
- data.tar.gz: 2df74e31c2ee0b47e6d0d38c565cf889812e58c60ed851661db018b2140bb8955f2d084157c0c707a9b8086a8529953a691cc5098aa933c04e22f6a4e0d15a64
6
+ metadata.gz: a57adab713ef09d53421d2bb3252518eaee1945652f5f5c8698b830cb3d218c9754d3c3039588b272800b2f59a1f791af50181969bfcd93e532d75d358f46b9e
7
+ data.tar.gz: 99c0ca10e136ab2242836488d20ead84b3fc04f327a8c344d6b90b62f10b5ccefdcda8ee5f7a92d45b6fe6f97e2e65cc07853cb149c3f165892ac85b5b29df4c
@@ -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,
@@ -14,21 +14,21 @@ module InlineForms::SoftDeletable
14
14
  # end
15
15
  # end
16
16
 
17
- def self.soft_deletable?
17
+ def soft_deletable?
18
18
  true
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' %>
@@ -44,11 +44,14 @@
44
44
  <div class="small-1 column">
45
45
  <%= version.event -%>
46
46
  </div>
47
+ <div class="small-2 column">
48
+ <%= version.created_at -%>
49
+ </div>
47
50
  <div class="small-2 column">
48
51
  <%= version_modified_by version.whodunnit -%>
49
52
  </div>
50
- <div class="small-8 column">
51
- <% if version.changeset.empty? %>
53
+ <div class="small-6 column">
54
+ <% if version.changeset.nil? || version.changeset.empty? %>
52
55
  <em>empty</em>
53
56
  <% else %>
54
57
  <% version.changeset.each do |attribute, value| %>
@@ -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.5"
3
+ VERSION = "6.1.1"
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.5
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-06-10 00:00:00.000000000 Z
13
+ date: 2021-01-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rvm
@@ -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