inline_forms 3.2.11 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTMzMDk1ZGM4Njk1YTFmMDQ3MGQ2MDU4MWQzN2UyMDVhYTJhNDhlZg==
4
+ NzViMjhjYTViNzM4ZjA5MjkyZWY4OGFiMzE2Y2Y2NzQ4MDhmZjA0MA==
5
5
  data.tar.gz: !binary |-
6
- OWU0NjdhNzViYjhmZGQ1MGUwMzIwZjM4OTc4MjNjODRhNTQwZmQ4OQ==
6
+ NjFhMmUwNzI1YTI3NGNmOTkyNjg3ZmQ4YWFiOGMwZDg0ZDY0YjFhNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWJjODU1MTM2NGUwOWZkNDY1NmM5MWRhMDkwYzAxMWM1ZWMxNTQ2Yzg2YWUx
10
- ZDA0ZGVkODBlYTI2Nzc1YzUxODM1ZmIxYWU2YmY3MTY1ZWRkMTE4ODA4Yjgy
11
- MDJjZWFkNzc5ZDNkN2U4Zjc1OWZkNzAwYmI4MjA4MTFmYmVkZjk=
9
+ ZDliMTA0MDkzZWM3MDhiYWU1YTIwNzZlZDczNTNiM2NiYzVhYjY3MzhkZWFi
10
+ MmUxMWFiMGIwMTJmNjY0Njk3NzVkMmM2ZjhmNjQzMDI4YTkxOTFiOGI3NWFm
11
+ MWJjMTUxYmJjNmEzZmZjODc5NzkzMWZkNjM2ZTE4OWM2MmYwNjk=
12
12
  data.tar.gz: !binary |-
13
- OTMxMTM2ZTM1M2VmZjg1ZDNiMTgwMzkwZjk2OGU3ZDU2N2ViZTU4Y2IwOTMw
14
- NDU3NzJhZWExZGZiNTVlYTgwYWExMjUwYjdjNzM4MDViZmJjMWViNDY2MTU3
15
- MjczZWE3ODRhYjZkMGQyYmY4NmYyNzZjOGFkNWUyMDRjNzg5Njg=
13
+ NTNjMzhiYmJhODFhNjhhNjk5ODM4M2Y0MTJhOGU2ODRmMzc0OGU5MmJhNDFj
14
+ ZWVkMTQxNWFkNjk3YjA3OTIwZmNmMzM1ZjIwM2VjYzU1ZTc5MjUwMTUxZTQ0
15
+ Y2JkM2M1NWVjNTc0ZjMzOTkzMzdhMmM1ZjhjNWU3NjZjZWI0MTE=
data/.gitignore CHANGED
@@ -45,5 +45,6 @@ pkg
45
45
  .ruby-gemset
46
46
  .idea
47
47
  bin/LETOVER
48
+ .vscode
48
49
 
49
50
  Gemfile.lock
@@ -4,7 +4,7 @@ create_file 'Gemfile', "# created by inline_forms #{ENV['inline_forms_version']}
4
4
 
5
5
  add_source 'https://rubygems.org'
6
6
 
7
- gem 'rails', '~> 3.2.22.5'
7
+ gem 'rails', '~> 5.0.2'
8
8
  gem 'rake'
9
9
  gem 'jquery-rails'
10
10
  gem 'jquery-ui-sass-rails'
@@ -372,7 +372,7 @@ create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.st
372
372
  protect_from_forgery
373
373
 
374
374
  # Comment next line if you don't want Devise authentication
375
- before_filter :authenticate_user!
375
+ before_action :authenticate_user!
376
376
 
377
377
  # Comment next 6 lines if you do not want CanCan authorization
378
378
  enable_authorization :unless => :devise_controller?
@@ -385,7 +385,7 @@ create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.st
385
385
  ActionView::CompiledTemplates::MODEL_TABS = %w()
386
386
 
387
387
  # Uncomment next line if you want I18n (based on subdomain)
388
- # before_filter :set_locale
388
+ # before_action :set_locale
389
389
 
390
390
  # Uncomment next line and specify default locale
391
391
  # I18n.default_locale = :en
data/inline_forms.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency('rvm')
24
24
  s.add_dependency('thor')
25
25
  s.add_dependency('validation_hints')
26
- s.add_dependency('rails', '3.2.22.5')
26
+ s.add_dependency('rails', '5.0.2')
27
27
  s.add_dependency('rails-i18n')
28
28
 
29
29
  s.add_development_dependency(%q<rspec-rails>)
@@ -17,16 +17,16 @@
17
17
  # and @Klass will be set to Example by the getKlass before filter.
18
18
  #
19
19
  # === How it works
20
- # The getKlass before_filter extracts the class and puts it in @Klass
20
+ # The getKlass before_action extracts the class and puts it in @Klass
21
21
  #
22
22
  # @Klass is used in the InlineFormsHelper
23
23
  #
24
24
  class InlineFormsController < ApplicationController
25
- before_filter :getKlass
25
+ before_action :getKlass
26
26
 
27
27
  def self.cancan_enabled?
28
28
  begin
29
- ::Ability && true
29
+ CanCan::Ability && true
30
30
  rescue NameError
31
31
  false
32
32
  end
@@ -63,9 +63,7 @@ class InlineFormsController < ApplicationController
63
63
  @objects ||= @Klass.accessible_by(current_ability) if cancan_enabled?
64
64
  @objects ||= @Klass
65
65
  @objects = @objects.order(@Klass.table_name + "." + @Klass.order_by_clause) if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?
66
- @objects = @objects.paginate(
67
- :page => params[:page],
68
- :conditions => conditions )
66
+ @objects = @objects.where(conditions).paginate(:page => params[:page])
69
67
  respond_to do |format|
70
68
  format.html { render 'inline_forms/_list', :layout => 'inline_forms' } unless @Klass.not_accessible_through_html?
71
69
  format.js { render :list }
@@ -87,19 +85,20 @@ class InlineFormsController < ApplicationController
87
85
 
88
86
  @object.inline_forms_attribute_list = @inline_forms_attribute_list if @inline_forms_attribute_list
89
87
  respond_to do |format|
88
+ format.html { render 'inline_forms/_new', :layout => 'inline_forms' } unless @Klass.not_accessible_through_html?
90
89
  format.js { }
91
90
  end
92
91
  end
93
92
 
94
93
  # :edit presents a form to edit one specific attribute from an object
95
94
  def edit
96
- @object = @Klass.find(params[:id])
95
+ @object = referenced_object
97
96
  @attribute = params[:attribute]
98
97
  @form_element = params[:form_element]
99
98
  @sub_id = params[:sub_id]
100
99
  @update_span = params[:update]
101
100
  respond_to do |format|
102
- #format.html { } unless @Klass.not_accessible_through_html?
101
+ format.html { } unless @Klass.not_accessible_through_html?
103
102
  format.js { }
104
103
  end
105
104
  end
@@ -124,11 +123,13 @@ class InlineFormsController < ApplicationController
124
123
  conditions = [ "#{foreign_key} = ?", @parent_id ]
125
124
  @object[foreign_key] = @parent_id
126
125
  end
126
+
127
127
  if @object.save
128
128
  flash.now[:success] = t('success', :message => @object.class.model_name.human)
129
- @objects = @Klass.where(id: @object.id)
130
- @objects = @objects.accessible_by(current_ability) if cancan_enabled?
131
- @objects = @objects.paginate :page => params[:page], :conditions => conditions
129
+ @objects = @Klass
130
+ @objects = @Klass.accessible_by(current_ability) if cancan_enabled?
131
+ @objects = @objects.order(@Klass.table_name + "." + @Klass.order_by_clause) if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?
132
+ @objects = @objects.where(conditions).paginate(:page => params[:page])
132
133
  @object = nil
133
134
  respond_to do |format|
134
135
  format.js { render :list}
@@ -145,7 +146,7 @@ class InlineFormsController < ApplicationController
145
146
 
146
147
  # :update updates a specific attribute from an object.
147
148
  def update
148
- @object = @Klass.find(params[:id])
149
+ @object = referenced_object
149
150
  @attribute = params[:attribute]
150
151
  @form_element = params[:form_element]
151
152
  @sub_id = params[:sub_id]
@@ -153,6 +154,7 @@ class InlineFormsController < ApplicationController
153
154
  send("#{@form_element.to_s}_update", @object, @attribute)
154
155
  @object.save
155
156
  respond_to do |format|
157
+ format.html { } unless @Klass.not_accessible_through_html?
156
158
  format.js { }
157
159
  end
158
160
  end
@@ -160,7 +162,7 @@ class InlineFormsController < ApplicationController
160
162
  # :show shows one attribute (attribute) from a record (object).
161
163
  # It includes the link to 'edit'
162
164
  def show
163
- @object = @Klass.find(params[:id])
165
+ @object = referenced_object
164
166
  @attribute = params[:attribute]
165
167
  @form_element = params[:form_element]
166
168
  close = params[:close] || false
@@ -187,6 +189,7 @@ class InlineFormsController < ApplicationController
187
189
  end
188
190
  else
189
191
  respond_to do |format|
192
+ format.html { } unless @Klass.not_accessible_through_html?
190
193
  format.js { render :show_element }
191
194
  end
192
195
  end
@@ -195,15 +198,17 @@ class InlineFormsController < ApplicationController
195
198
  # :destroy destroys the record, but also shows an undo link (with paper_trail)
196
199
  def destroy
197
200
  @update_span = params[:update]
198
- @object = @Klass.find(params[:id])
201
+ @object = referenced_object
199
202
  if current_user.role? :superadmin
200
203
  @object.destroy
201
204
  respond_to do |format|
205
+ format.html { } unless @Klass.not_accessible_through_html?
202
206
  format.js { render :show_undo }
203
207
  end
204
208
  elsif (@Klass.safe_deletable? rescue false)
205
209
  @object.safe_delete(current_user)
206
210
  respond_to do |format|
211
+ format.html { } unless @Klass.not_accessible_through_html?
207
212
  format.js { render :close }
208
213
  end
209
214
  end
@@ -219,12 +224,14 @@ class InlineFormsController < ApplicationController
219
224
  @object = @Klass.find(@version.item_id)
220
225
  authorize!(:revert, @object) if cancan_enabled?
221
226
  respond_to do |format|
227
+ format.html { } unless @Klass.not_accessible_through_html?
222
228
  format.js { render :close }
223
229
  end
224
230
  elsif (@Klass.safe_deletable? rescue false)
225
- @object = @Klass.find(params[:id])
231
+ @object = referenced_object
226
232
  @object.safe_restore
227
233
  respond_to do |format|
234
+ format.html { } unless @Klass.not_accessible_through_html?
228
235
  format.js { render :close }
229
236
  end
230
237
  end
@@ -248,6 +255,15 @@ class InlineFormsController < ApplicationController
248
255
  # TODO think about this a bit more.
249
256
  def getKlass #:doc:
250
257
  @Klass = self.controller_name.classify.constantize
258
+ @Klass
259
+ end
260
+
261
+ def referenced_object
262
+ @Klass.find(object_id_params)
263
+ end
264
+
265
+ def object_id_params
266
+ params.require(:id)
251
267
  end
252
268
 
253
269
  def deep_hashify(ary)
@@ -270,4 +286,8 @@ class InlineFormsController < ApplicationController
270
286
  a
271
287
  end
272
288
 
289
+ def revert_params
290
+ params.require(:id).permit(:update)
291
+ end
292
+
273
293
  end
@@ -10,7 +10,7 @@ end
10
10
  def chicas_dropdown_with_family_members_edit(object, attribute)
11
11
  o = object.send(attribute) # the client
12
12
  values = o.family.clients
13
- values.sort_by! &:_dropdown_presentation
13
+ values.sort_by(&:_dropdown_presentation)
14
14
  # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
15
15
  collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '_dropdown_presentation', :selected => object.send(attribute).id)
16
16
  end
@@ -25,7 +25,7 @@ def dropdown_edit(object, attribute)
25
25
  if klass.method_defined? :disabled_for_dropdown?
26
26
  options_disabled = values.map{|v| v.id if v.disabled_for_dropdown?}.compact
27
27
  end
28
- values.sort_by! {|v|v.send presentation}
28
+ values.sort_by {|v|v.send presentation}
29
29
  # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
30
30
  collection_select( ('_' + object.class.to_s.underscore).to_sym,
31
31
  attribute.to_s.foreign_key.to_sym,
@@ -24,7 +24,7 @@ def dropdown_with_other_edit(object, attribute)
24
24
  values.each do |v|
25
25
  v.name = v._presentation
26
26
  end
27
- # values.sort_by! &:name
27
+ # values.sort_by(&:name)
28
28
 
29
29
  collection = values.map {|v|[v.name, v.id]}
30
30
  collection << [object[attribute + '_other'], 0] unless object[attribute + '_other'].nil? || object[attribute + '_other'].empty?
@@ -17,17 +17,17 @@ def pdf_link_update(object, attribute)
17
17
  # do absolutely nothing
18
18
  end
19
19
 
20
- module ActionView::Helpers::DateHelper
21
-
22
- def distance_of_time_in_words_to_now_with_future(from_time, include_seconds = false)
23
- if from_time > Time.now()
24
- 'in ' + distance_of_time_in_words_to_now_without_future(from_time, include_seconds)
25
- else
26
- distance_of_time_in_words_to_now_without_future(from_time, include_seconds) + ' ago'
27
- end
28
- end
29
-
30
- alias_method_chain :distance_of_time_in_words_to_now, :future
31
-
32
- end
33
-
20
+ #module ActionView::Helpers::DateHelper
21
+ #
22
+ # def distance_of_time_in_words_to_now_with_future(from_time, include_seconds = false)
23
+ # if from_time > Time.now()
24
+ # 'in ' + distance_of_time_in_words_to_now_without_future(from_time, include_seconds)
25
+ # else
26
+ # distance_of_time_in_words_to_now_without_future(from_time, include_seconds) + ' ago'
27
+ # end
28
+ # end
29
+ #
30
+ # alias_method_chain :distance_of_time_in_words_to_now, :future
31
+ #
32
+ #end
33
+ #
@@ -3,17 +3,17 @@ class GeoCodeCuracao
3
3
  attr_accessor :street, :neighbourhood, :zone
4
4
 
5
5
  class Zone < ActiveRecord::Base
6
- set_table_name "Zones"
6
+ self.table_name = "Zones"
7
7
  alias_attribute :name, :NAME
8
8
  end
9
9
 
10
10
  class Neighbourhood < ActiveRecord::Base
11
- set_table_name "Buurten"
11
+ self.table_name = "Buurten"
12
12
  alias_attribute :name, :NAME
13
13
  end
14
14
 
15
15
  class Street < ActiveRecord::Base
16
- set_table_name "Straatcode"
16
+ self.table_name = "Straatcode"
17
17
  alias_attribute :name, :NAME
18
18
  end
19
19
 
@@ -2,7 +2,7 @@
2
2
  <nav id='inline_forms_application_top_bar' class="top-bar" data-topbar>
3
3
  <ul class="title-area">
4
4
  <li class="name">
5
- <h1><a href="/"><%= application_name %> v<%= inline_forms_version %></a></h1>
5
+ <h1><a href="/"><%= application_name %> v<%= inline_forms_version %> <%= current_user.name %></a></h1>
6
6
  </li>
7
7
  <li class="toggle-topbar menu-icon">
8
8
  <a href="#"><span></span></a>
@@ -37,7 +37,7 @@
37
37
  <% objects = parent_class.find(parent_id).send(attribute) %>
38
38
  <% objects = parent_class.find(parent_id).send(attribute).accessible_by(current_ability) if cancan_enabled? %>
39
39
  <% objects = objects.order(attribute.to_s.singularize.camelcase.constantize.order_by_clause) if attribute.to_s.singularize.camelcase.constantize.respond_to?(:order_by_clause) && ! attribute.to_s.singularize.camelcase.constantize.order_by_clause.nil? %>
40
- <% objects = objects.paginate :page => params[:page], :conditions => conditions %>
40
+ <% objects = objects.where(conditions).paginate(:page => params[:page]) %>
41
41
  <% end %>
42
42
  <% end %>
43
43
 
@@ -3,11 +3,9 @@
3
3
  <% flash.each do |key, value| %>
4
4
  <div class="flash <%= key %>">
5
5
  <ul>
6
- <% value.each do |m| %>
7
6
  <li>
8
- <%= m %>
7
+ <%= value %>
9
8
  </li>
10
- <% end %>
11
9
  </ul>
12
10
  </div>
13
11
  <% end %>
@@ -27,16 +25,16 @@
27
25
  <% attributes.each do | attribute, name, form_element | -%>
28
26
  <% unless form_element.to_sym == :associated || form_element.to_sym == :tree || (cancan_enabled? && cannot?(:read, @Klass.to_s.underscore.pluralize.to_sym, attribute)) -%>
29
27
  <% css_class_id = "attribute_#{attribute}_#{@object.id}" -%>
30
- <% if form_element == :header %>
28
+ <% if form_element && form_element.to_sym == :header %>
31
29
  <div class="row form_element_header" >
32
30
  <div class='large-12 column<%= " attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
33
- <%= @object.class.human_attribute_name(attribute) -%>
31
+ <%= @object.human_attribute_name(attribute) -%>
34
32
  </div>
35
33
  </div>
36
34
  <% else %>
37
35
  <div class="row <%= cycle('odd', 'even') %>">
38
36
  <div class='medium-5 large-5 column' >
39
- <%= @object.class.human_attribute_name(attribute) -%>
37
+ <%= @object.human_attribute_name(attribute) -%>
40
38
  </div>
41
39
  <div class='medium-7 large-7 column' >
42
40
  <span id="<%= css_class_id -%>" > <%= send("#{form_element}_edit", @object, attribute) -%> </span>
@@ -19,7 +19,6 @@
19
19
  <% end %>
20
20
  <% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
21
21
  <% attributes.each do | attribute, name, form_element | -%>
22
- <% puts "LOG: #{attribute}, #{form_element}" if Rails.env.development? %>
23
22
  <% if cancan_disabled? || can?(:read, @object, attribute) %>
24
23
  <% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_#{attribute}" -%>
25
24
  <% if form_element == :header %>
@@ -1 +1 @@
1
- $('#<%= @update_span %>').html('<%= escape_javascript(link_to t('inline_forms.view.undo'), send('revert_' + @object.class.to_s.underscore + "_path", @object.versions.scoped.last, :update => @update_span), :remote => true, :method => :post)%>')
1
+ $('#<%= @update_span %>').html('<%= escape_javascript(link_to t('inline_forms.view.undo'), send('revert_' + @object.class.to_s.underscore + "_path", @object.versions.scope.last, :update => @update_span), :remote => true, :method => :post)%>')
@@ -0,0 +1,7 @@
1
+ class HumanAttributeNameGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path("../templates", __FILE__)
3
+
4
+ def copy_initializer_file
5
+ copy_file "model_instance_human_attribute_name.rb", "config/initializers/human_attribute_name.rb"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # Wrapper for @model.human_attribute_name -> Model.human_attribute_name
2
+ #
3
+ class ActiveRecord::Base
4
+ def human_attribute_name(*args)
5
+ self.class.human_attribute_name(*args)
6
+ end
7
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "3.2.11"
3
+ VERSION = "5.0.0"
4
4
  end
@@ -35,4 +35,4 @@ en:
35
35
  attributes:
36
36
  client:
37
37
  first_name: first name
38
- last_name: last name
38
+ last_name: last name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.11
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2017-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rvm
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.2.22.5
61
+ version: 5.0.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 3.2.22.5
68
+ version: 5.0.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rails-i18n
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -149,6 +149,7 @@ extra_rdoc_files: []
149
149
  files:
150
150
  - .document
151
151
  - .gitignore
152
+ - .vscode/settings.json
152
153
  - Gemfile
153
154
  - LICENSE.txt
154
155
  - README.rdoc
@@ -248,6 +249,7 @@ files:
248
249
  - lib/generators/assets/stylesheets/devise.scss
249
250
  - lib/generators/assets/stylesheets/foundation_and_overrides.scss
250
251
  - lib/generators/assets/stylesheets/inline_forms.scss
252
+ - lib/generators/human_attribute_name_generator.rb
251
253
  - lib/generators/inline_forms_generator.rb
252
254
  - lib/generators/templates/_inline_forms_tabs.html.erb
253
255
  - lib/generators/templates/abstract_mysql2_adapter.rb
@@ -255,6 +257,7 @@ files:
255
257
  - lib/generators/templates/deploy.rb
256
258
  - lib/generators/templates/migration.erb
257
259
  - lib/generators/templates/model.erb
260
+ - lib/generators/templates/model_instance_human_attribute_name.rb
258
261
  - lib/generators/templates/test.erb
259
262
  - lib/generators/templates/unicorn.rb
260
263
  - lib/inline_forms.rb