ns_settings_ui 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +14 -0
- data/.rubocop_u2i.yml +54 -0
- data/Appraisals +5 -0
- data/Gemfile +16 -0
- data/Guardfile +79 -0
- data/MIT-LICENSE +20 -0
- data/README.md +65 -0
- data/Rakefile +28 -0
- data/app/assets/images/ns_settings_ui/.keep +0 -0
- data/app/assets/javascripts/ns_settings_ui/application.js +13 -0
- data/app/assets/javascripts/ns_settings_ui/jquery.liveFilter.js +50 -0
- data/app/assets/stylesheets/ns_settings_ui/application.css +15 -0
- data/app/assets/stylesheets/ns_settings_ui/settings.css.scss +21 -0
- data/app/controllers/ns_settings_ui/application_controller.rb +4 -0
- data/app/controllers/ns_settings_ui/settings_controller.rb +29 -0
- data/app/helpers/ns_settings_ui/application_helper.rb +17 -0
- data/app/helpers/ns_settings_ui/settings_helper.rb +15 -0
- data/app/models/ns_settings_ui/setting.rb +26 -0
- data/app/views/ns_settings_ui/settings/_edit.html.erb +12 -0
- data/app/views/ns_settings_ui/settings/_setting_row.html.erb +6 -0
- data/app/views/ns_settings_ui/settings/_update.js.erb +3 -0
- data/app/views/ns_settings_ui/settings/index.html.erb +21 -0
- data/bin/rails +13 -0
- data/bin/rspec +15 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20151210214903_create_ns_settings_ui_settings.rb +15 -0
- data/db/migrate/20151215081718_add_value_type_to_ns_settings_ui_settings.rb +5 -0
- data/gemfiles/rails_3.2.gemfile +7 -0
- data/gemfiles/rails_4.2.gemfile +7 -0
- data/lib/ns_settings_ui/engine.rb +9 -0
- data/lib/ns_settings_ui/version.rb +3 -0
- data/lib/ns_settings_ui.rb +6 -0
- data/lib/tasks/ns_settings_ui_tasks.rake +4 -0
- data/ns_settings_ui.gemspec +37 -0
- data/spec/controllers/ns_settings_ui/settings_controller_spec.rb +61 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +55 -0
- data/spec/dummy/config/application.rb~ +64 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +34 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/ns_settings_ui.rb +4 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +25 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/log/development.log +17213 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/helpers/ns_settings_ui/settings_helper_spec.rb +27 -0
- data/spec/models/ns_settings_ui/setting_spec.rb +114 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/spec_helper.rb~ +37 -0
- data/spec/support/blueprints.rb +3 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +22 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +9 -0
- data/test/ns_settings_ui_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +424 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 620d3d4a37036756b288e67585ce6e0438dd3755
|
4
|
+
data.tar.gz: d2ac6935cc37e0bf72b7427e5bef7859033b454a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa7c499bd852dfb1f66bdc3e079fc5f0499a8b282ee5a9f5a9fa4b3ee53c2bc50fa1c347efc4cb461bd63b6e3c4321bde508786e8d39facb98361d76a920c66b
|
7
|
+
data.tar.gz: a2f0cfb55baefacd78f29004d242a6da74f2f33c20be924c9872836c5dd733ed7d18c793b3f66eaeab3d160d3f87cae35716334467e3846b943feabacf4ddac9
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_u2i.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- '**/Rakefile'
|
4
|
+
- '**/config.ru'
|
5
|
+
Exclude:
|
6
|
+
- bin/**/*
|
7
|
+
- db/**/*
|
8
|
+
- config/**/*
|
9
|
+
- script/**/*
|
10
|
+
- db/schema.rb
|
11
|
+
- bundle/**/*
|
12
|
+
|
13
|
+
Style/MultilineOperationIndentation:
|
14
|
+
EnforcedStyle: indented
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/WhileUntilModifier:
|
20
|
+
MaxLineLength: 120
|
21
|
+
Exclude:
|
22
|
+
- spec/**/*
|
23
|
+
|
24
|
+
Style/SpaceInsideHashLiteralBraces:
|
25
|
+
EnforcedStyle: no_space
|
26
|
+
EnforcedStyleForEmptyBraces: no_space
|
27
|
+
|
28
|
+
Style/MultilineBlockChain:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
Style/DotPosition:
|
32
|
+
EnforcedStyle: trailing
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Style/SingleLineMethods:
|
36
|
+
AllowIfMethodIsEmpty: false
|
37
|
+
|
38
|
+
Style/NumericLiterals:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
#Style/TrailingComma:
|
42
|
+
# # If EnforcedStyleForMultiline is comma, the cop allows a comma after the
|
43
|
+
# # last item of a list, but only for lists where each item is on its own line.
|
44
|
+
# EnforcedStyleForMultiline: comma
|
45
|
+
|
46
|
+
Metrics/LineLength:
|
47
|
+
Max: 120
|
48
|
+
Enabled: true
|
49
|
+
Exclude:
|
50
|
+
- spec/**/*
|
51
|
+
|
52
|
+
Metrics/MethodLength:
|
53
|
+
CountComments: false # count full line comments?
|
54
|
+
Max: 30
|
data/Appraisals
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in ns_settings_ui.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
15
|
+
|
16
|
+
gem 'rails', '~> 3.2' # assuming Rails 3.2 for jenkins jobs and top level rake tasks
|
data/Guardfile
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
# This group allows to skip running RuboCop if RSpec.
|
27
|
+
|
28
|
+
group :red_green_refactor, halt_on_fail: true do
|
29
|
+
guard :rspec, cmd: "bin/rspec" do
|
30
|
+
require "guard/rspec/dsl"
|
31
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
32
|
+
|
33
|
+
# Feel free to open issues for suggestions and improvements
|
34
|
+
|
35
|
+
# RSpec files
|
36
|
+
rspec = dsl.rspec
|
37
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
38
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
39
|
+
watch(rspec.spec_files)
|
40
|
+
|
41
|
+
# Ruby files
|
42
|
+
ruby = dsl.ruby
|
43
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
44
|
+
|
45
|
+
# Rails files
|
46
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
47
|
+
dsl.watch_spec_files_for(rails.app_files)
|
48
|
+
dsl.watch_spec_files_for(rails.views)
|
49
|
+
|
50
|
+
watch(rails.controllers) do |m|
|
51
|
+
[
|
52
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
53
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
54
|
+
rspec.spec.("acceptance/#{m[1]}")
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
# Rails config changes
|
59
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
60
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
61
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
62
|
+
|
63
|
+
# Capybara features specs
|
64
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
65
|
+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
|
66
|
+
|
67
|
+
# Turnip features and steps
|
68
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
69
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
70
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
guard :rubocop, all_on_start: false, cli: %w(--format fuubar --rails) do
|
75
|
+
watch(%r{.+\.rb$})
|
76
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
[![Build Status](http://jenkins.nielsensocial.u2i.eu/buildStatus/icon?job=(master) ns_settings_ui)](http://jenkins.nielsensocial.u2i.eu/job/(master) ns_settings_ui)
|
2
|
+
|
3
|
+
# NsSettingsUi
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ns_settings_ui'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ns_settings_ui
|
18
|
+
|
19
|
+
Install migrations:
|
20
|
+
|
21
|
+
$ rake ns_settings_ui:install:migrations
|
22
|
+
|
23
|
+
And run db:migrate in your application
|
24
|
+
|
25
|
+
$ rake db:migate
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
Add ns_setting_ui initializer to config/initializers/ns_settings_ui.rb
|
30
|
+
|
31
|
+
```
|
32
|
+
if defined?(NsSettingsUi)
|
33
|
+
NsSettingsUi.layout = nil
|
34
|
+
NsSettingsUi.parent_controller = ActionController::Base
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
You can modify NsSettingsUi variables in order to:
|
39
|
+
* `NsSettingsUi.layout` - set a layout from your application
|
40
|
+
* `NsSettingsUi.parent_controller` - choose a controller that NsSettingUi controllers will inherit from
|
41
|
+
|
42
|
+
## Testing
|
43
|
+
|
44
|
+
This engine is used by NTTR and socialguide, thereby needs to be compatible with both Rails 3.2 and 4.2.
|
45
|
+
It uses [Appraisal](https://github.com/thoughtbot/appraisal) gem with a set up similar to [permitters gem](https://github.com/permitters/permitters) to give you an easy way of testing the code under multiple Rails versions.
|
46
|
+
|
47
|
+
To bundle install for each appraisal defined:
|
48
|
+
|
49
|
+
`appraisal install`
|
50
|
+
|
51
|
+
And then to run specs for all the appraisals:
|
52
|
+
|
53
|
+
`appraisal bundle exec rspec spec`
|
54
|
+
|
55
|
+
Or a specific one:
|
56
|
+
|
57
|
+
`appraisal rails_4.2 bundle exec rspec spec`
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it ( http://github.com/<my-github-username>/ns_settings_ui/fork )
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'NsSettingsUi'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rspec/core'
|
23
|
+
require 'rspec/core/rake_task'
|
24
|
+
|
25
|
+
desc 'Run all specs in spec directory (excluding plugin specs)'
|
26
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
27
|
+
|
28
|
+
task default: :spec
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery.liveFilter
|
3
|
+
*
|
4
|
+
* Copyright (c) 2009 Mike Merritt
|
5
|
+
*
|
6
|
+
* Forked by Lim Chee Aun (cheeaun.com)
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function($){
|
11
|
+
$.fn.liveFilter = function(inputEl, filterEl, options){
|
12
|
+
var defaults = {
|
13
|
+
filterChildSelector: null,
|
14
|
+
filter: function(el, val){
|
15
|
+
return $(el).text().toUpperCase().match(val.toUpperCase()) !== null;
|
16
|
+
},
|
17
|
+
before: function(){},
|
18
|
+
after: function(){}
|
19
|
+
};
|
20
|
+
var options = $.extend(defaults, options);
|
21
|
+
|
22
|
+
var el = $(this).find(filterEl);
|
23
|
+
if (options.filterChildSelector) el = el.find(options.filterChildSelector);
|
24
|
+
|
25
|
+
var filter = options.filter;
|
26
|
+
$(inputEl).keyup(function(){
|
27
|
+
var val = $(this).val();
|
28
|
+
var contains = el.filter(function(){
|
29
|
+
return filter(this, val);
|
30
|
+
});
|
31
|
+
var containsNot = el.not(contains);
|
32
|
+
if (options.filterChildSelector){
|
33
|
+
contains = contains.parents(filterEl);
|
34
|
+
containsNot = containsNot.parents(filterEl).hide();
|
35
|
+
}
|
36
|
+
|
37
|
+
options.before.call(this, contains, containsNot);
|
38
|
+
|
39
|
+
contains.show();
|
40
|
+
containsNot.hide();
|
41
|
+
|
42
|
+
if (val === '') {
|
43
|
+
contains.show();
|
44
|
+
containsNot.show();
|
45
|
+
}
|
46
|
+
|
47
|
+
options.after.call(this, contains, containsNot);
|
48
|
+
});
|
49
|
+
}
|
50
|
+
})(jQuery);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// Place all the styles related to the Settings controller here.
|
2
|
+
// They will automatically be included in application.css.
|
3
|
+
// You can use Sass (SCSS) here: http://sass-lang.com/
|
4
|
+
|
5
|
+
#ns_settings_ui {
|
6
|
+
ul {
|
7
|
+
list-style-type: none;
|
8
|
+
}
|
9
|
+
form {
|
10
|
+
display: inline;
|
11
|
+
}
|
12
|
+
input[type=text] {
|
13
|
+
width: 130px;
|
14
|
+
display: inline;
|
15
|
+
}
|
16
|
+
table {
|
17
|
+
td {
|
18
|
+
padding: 2px;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module NsSettingsUi
|
2
|
+
class SettingsController < NsSettingsUi::ApplicationController
|
3
|
+
layout NsSettingsUi.layout
|
4
|
+
before_filter :setting_from_id_param, only: [:update, :reset]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@settings = Setting.order('`key`').all
|
8
|
+
end
|
9
|
+
|
10
|
+
def update
|
11
|
+
@setting.value = params[:setting][:value]
|
12
|
+
@setting.default_value = params[:setting][:default_value]
|
13
|
+
@setting.save!
|
14
|
+
render partial: 'update'
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset
|
18
|
+
@setting.value = @setting.default_value
|
19
|
+
@setting.save!
|
20
|
+
render partial: 'update'
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def setting_from_id_param
|
26
|
+
@setting = Setting.find(params[:id])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module NsSettingsUi
|
2
|
+
module ApplicationHelper
|
3
|
+
def url_for(options)
|
4
|
+
super(options)
|
5
|
+
rescue ActionController::RoutingError
|
6
|
+
main_app.url_for(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(method, *args, &block)
|
10
|
+
if main_app.respond_to?(method)
|
11
|
+
main_app.send(method, *args)
|
12
|
+
else
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module NsSettingsUi
|
2
|
+
module SettingsHelper
|
3
|
+
def setting_value_class(setting)
|
4
|
+
return 'alert-danger' if setting.value.nil? || setting.value.empty?
|
5
|
+
return 'alert-warning' if setting.value != setting.default_value
|
6
|
+
''
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def recursive_hash
|
12
|
+
Hash.new { |hash, key| hash[key] = recursive_hash }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module NsSettingsUi
|
2
|
+
class Setting < ActiveRecord::Base
|
3
|
+
TYPES = {
|
4
|
+
string: 1,
|
5
|
+
integer: 2
|
6
|
+
}.freeze
|
7
|
+
|
8
|
+
def self.get(*keys)
|
9
|
+
where(key: keys.join('.')).first_or_create
|
10
|
+
end
|
11
|
+
|
12
|
+
def keys
|
13
|
+
key.split('.').map(&:to_sym)
|
14
|
+
end
|
15
|
+
|
16
|
+
def formatted_value
|
17
|
+
return nil if value.nil?
|
18
|
+
case value_type
|
19
|
+
when TYPES[:string] then value.to_s
|
20
|
+
when TYPES[:integer] then value.to_i
|
21
|
+
else
|
22
|
+
value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div id="setting_<%= setting.id -%>">
|
2
|
+
<%= form_for(setting, url: ns_settings_ui.setting_path(setting), method: :put, remote: true, html: {class: 'form-inline'}) do |f| %>
|
3
|
+
<%= f.label(:value) %>
|
4
|
+
<%= f.text_field(:value, size: 10, class: "form-control #{setting_value_class(setting)}" ) %>
|
5
|
+
<%= f.label(:default_value) %>
|
6
|
+
<%= f.text_field(:default_value, size: 10, class: 'form-control') %>
|
7
|
+
<%= f.submit('Update', class: 'btn btn-default') %>
|
8
|
+
<% end %>
|
9
|
+
<%= form_for(setting, url: ns_settings_ui.reset_setting_path(setting), method: :put, remote: true) do |f| %>
|
10
|
+
<%= f.submit('Reset to default', class: 'btn btn-default') %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
$("#ns_settings_ui #setting_<%= @setting.id -%>").replaceWith("<%= escape_javascript(render partial: 'edit', locals: {setting: @setting}) %>");
|
2
|
+
$("#ns_settings_ui #setting_<%= @setting.id -%>").append('<span class="notice text-success">Updated</span>');
|
3
|
+
$("#ns_settings_ui #setting_<%= @setting.id -%> .notice").delay(1000).fadeOut('slow');
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= content_for :head do %>
|
2
|
+
<%= stylesheet_link_tag 'ns_settings_ui/settings' -%>
|
3
|
+
<%= javascript_include_tag 'ns_settings_ui/application' -%>
|
4
|
+
<% end %>
|
5
|
+
<div id="ns_settings_ui">
|
6
|
+
<div class="panel panel-default">
|
7
|
+
<div class="panel-heading">
|
8
|
+
<span>Filter: </span>
|
9
|
+
<input class="form-control" id="filter-input" type="text" value=""> (regular expressions are available)
|
10
|
+
</div>
|
11
|
+
<div class="panel-body">
|
12
|
+
<table class="table table-striped table-bordered">
|
13
|
+
<%= render partial: 'setting_row', collection: @settings, as: 'setting' -%>
|
14
|
+
</table>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<%= javascript_tag do -%>
|
20
|
+
$('#ns_settings_ui').liveFilter('#ns_settings_ui #filter-input', 'tr', {filterChildSelector: '.setting_key'});
|
21
|
+
<% end %>
|
data/bin/rails
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails"
|
3
|
+
# with Rails 4 gems installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
6
|
+
ENGINE_PATH = File.expand_path('../../lib/ns_settings_ui/engine', __FILE__)
|
7
|
+
|
8
|
+
# Set up gems listed in the Gemfile.
|
9
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
10
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
11
|
+
|
12
|
+
require 'rails/all'
|
13
|
+
require 'rails/engine/commands'
|
data/bin/rspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'bundler/setup'
|
14
|
+
|
15
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateNsSettingsUiSettings < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
create_table :ns_settings_ui_settings do |t|
|
4
|
+
t.string :key, null: false
|
5
|
+
t.string :value
|
6
|
+
t.string :default_value
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :ns_settings_ui_settings, :key
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
drop_table :ns_settings_ui_settings
|
14
|
+
end
|
15
|
+
end
|