Skip to content

Commit 3d7c8b7

Browse files
author
Daniel O'Connor
committed
Merge branch '0.17.x' of github.com:fatfreecrm/fat_free_crm into 0.17.x
2 parents 9235bad + 7cc0961 commit 3d7c8b7

File tree

7 files changed

+41
-23
lines changed

7 files changed

+41
-23
lines changed

.rubocop_todo.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2018-01-07 23:59:28 +0900 using RuboCop version 0.52.1.
3+
# on 2018-01-21 02:52:41 +1030 using RuboCop version 0.52.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -93,7 +93,7 @@ Lint/UselessAssignment:
9393
- 'app/helpers/application_helper.rb'
9494
- 'app/views/home/index.atom.builder'
9595

96-
# Offense count: 133
96+
# Offense count: 132
9797
Metrics/AbcSize:
9898
Max: 57
9999

@@ -102,10 +102,10 @@ Metrics/AbcSize:
102102
Metrics/BlockNesting:
103103
Max: 4
104104

105-
# Offense count: 15
105+
# Offense count: 14
106106
# Configuration parameters: CountComments.
107107
Metrics/ClassLength:
108-
Max: 194
108+
Max: 199
109109

110110
# Offense count: 29
111111
Metrics/CyclomaticComplexity:
@@ -330,12 +330,11 @@ Style/RegexpLiteral:
330330
- 'spec/views/contacts/update.js.haml_spec.rb'
331331
- 'spec/views/opportunities/update.js.haml_spec.rb'
332332

333-
# Offense count: 9
333+
# Offense count: 8
334334
# Cop supports --auto-correct.
335335
# Configuration parameters: AllowAsExpressionSeparator.
336336
Style/Semicolon:
337337
Exclude:
338-
- 'app/controllers/application_controller.rb'
339338
- 'app/controllers/entities/leads_controller.rb'
340339
- 'lib/fat_free_crm/permissions.rb'
341340
- 'lib/tasks/ffcrm/setup.rake'
@@ -351,7 +350,7 @@ Style/TrivialAccessors:
351350
Exclude:
352351
- 'spec/support/auth_macros.rb'
353352

354-
# Offense count: 2140
353+
# Offense count: 1922
355354
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
356355
# URISchemes: http, https
357356
Metrics/LineLength:

app/assets/javascripts/crm_select2.js.coffee

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010
window.crm ||= {}
1111

1212
crm.make_select2 = ->
13-
$(".select2").not(".select2-container, .select2-offscreen").each ->
14-
#$(".select2").each ->
15-
$(this).select2 'width':'resolve'
13+
$(".select2").not(".select2-container, .select2-offscreen, .select2-hidden-accessible").each ->
14+
15+
#$(".select2").each ->
16+
if $(this).data("url")
17+
$(this).select2
18+
'width':'resolve'
19+
placeholder: $(this).attr("placeholder")
20+
ajax:
21+
url: $(this).data("url")
22+
dataType: 'json'
23+
else
24+
$(this).select2
25+
'width':'resolve'
26+
placeholder: $(this).attr("placeholder")
1627

1728
$(".select2_tag").not(".select2-container, .select2-offscreen").each ->
1829
#$(".select2_tag").each ->

app/controllers/admin/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Admin::ApplicationController < ApplicationController
1414
# Autocomplete handler for all admin controllers.
1515
#----------------------------------------------------------------------------
1616
def auto_complete
17-
@query = params[:auto_complete_query]
17+
@query = params[:term]
1818
@auto_complete = klass.text_search(@query).limit(10)
1919
render partial: 'auto_complete'
2020
end

app/controllers/application_controller.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ApplicationController < ActionController::Base
3434
# Common auto_complete handler for all core controllers.
3535
#----------------------------------------------------------------------------
3636
def auto_complete
37-
@query = params[:auto_complete_query] || ''
37+
@query = params[:term] || ''
3838
@auto_complete = hook(:auto_complete, self, query: @query, user: current_user)
3939
if @auto_complete.empty?
4040
exclude_ids = auto_complete_ids_to_exclude(params[:related])
@@ -47,9 +47,15 @@ def auto_complete
4747
respond_to do |format|
4848
format.any(:js, :html) { render partial: 'auto_complete' }
4949
format.json do
50-
render json: @auto_complete.each_with_object({}) { |a, h|
51-
h[a.id] = a.respond_to?(:full_name) ? h(a.full_name) : h(a.name); h
52-
}
50+
results = @auto_complete.map do |a|
51+
{
52+
id: a.id,
53+
text: a.respond_to?(:full_name) ? a.full_name : a.name
54+
}
55+
end
56+
render json: {
57+
results: results
58+
}
5359
end
5460
end
5561
end

app/helpers/accounts_helper.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ def account_select(options = {})
2929
options[:selected] = @account&.id || 0
3030
accounts = ([@account.new_record? ? nil : @account] + Account.my(current_user).order(:name).limit(25)).compact.uniq
3131
collection_select :account, :id, accounts, :id, :name,
32-
{ prompt: t(:select_an_account), include_blank: false },
33-
style: 'width:330px;', class: 'select2'
32+
{ include_blank: true },
33+
style: 'width:330px;', class: 'select2',
34+
placeholder: t(:select_an_account),
35+
"data-url": auto_complete_accounts_path(format: 'json')
3436
end
3537

3638
# Select an existing account or create a new one.
@@ -42,10 +44,10 @@ def account_select_or_create(form, &_block)
4244
content_tag(:div, class: 'label') do
4345
t(:account).html_safe +
4446
content_tag(:span, id: 'account_create_title') do
45-
"(#{t :create_new} #{t :or} <a href='#' onclick='crm.show_select_account(); return false;'>#{t :select_existing}</a>):".html_safe
47+
" (#{t :create_new} #{t :or} <a href='#' onclick='crm.show_select_account(); return false;'>#{t :select_existing}</a>):".html_safe
4648
end +
4749
content_tag(:span, id: 'account_select_title') do
48-
"(<a href='#' onclick='crm.show_create_account(); return false;'>#{t :create_new}</a> #{t :or} #{t :select_existing}):".html_safe
50+
" (<a href='#' onclick='crm.show_create_account(); return false;'>#{t :create_new}</a> #{t :or} #{t :select_existing}):".html_safe
4951
end +
5052
content_tag(:span, ':', id: 'account_disabled_title')
5153
end +

config/initializers/ransack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
config.ajax_options = {
1818
url: '/:controller/auto_complete.json',
1919
type: 'POST',
20-
key: 'auto_complete_query'
20+
key: 'term'
2121
}
2222
end

spec/shared/controllers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
end
1313

1414
it "should do the search and find records that match autocomplete query" do
15-
get :auto_complete, params: { auto_complete_query: @query }
15+
get :auto_complete, params: { term: @query }
1616
expect(assigns[:query]).to eq(@query)
1717
expect(assigns[:auto_complete]).to eq(@auto_complete_matches) # Each controller must define it.
1818
end
1919

2020
it "should save current autocomplete controller in a session" do
21-
get :auto_complete, params: { auto_complete_query: @query }
21+
get :auto_complete, params: { term: @query }
2222

2323
# We don't save Admin/Users autocomplete controller in a session since Users are not
2424
# exposed through the Jumpbox.
@@ -28,7 +28,7 @@
2828
end
2929

3030
it "should render application/_auto_complete template" do
31-
post :auto_complete, params: { auto_complete_query: @query }
31+
post :auto_complete, params: { term: @query }
3232
expect(response).to render_template("application/_auto_complete")
3333
end
3434
end

0 commit comments

Comments
 (0)