tb_core 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/controllers/admin/roles_controller.rb +1 -3
- data/app/controllers/admin/settings_controller.rb +2 -2
- data/app/controllers/admin/setup_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +2 -2
- data/app/controllers/concerns/tb_core/error_handling.rb +4 -4
- data/app/controllers/user_sessions_controller.rb +2 -2
- data/app/models/concerns/tb_core/user_model.rb +1 -3
- data/lib/generators/spud/controller_spec_generator.rb +1 -1
- data/lib/generators/spud/module_generator.rb +1 -1
- data/lib/generators/spud/setup_generator.rb +2 -4
- data/lib/tb_core/belongs_to_app.rb +1 -1
- data/lib/tb_core/engine.rb +1 -3
- data/lib/tb_core/test_files.rb +3 -3
- data/lib/tb_core/test_helper.rb +3 -5
- data/lib/tb_core/version.rb +1 -1
- data/spec/controllers/admin/application_controller_spec.rb +1 -1
- data/spec/models/spud_user_spec.rb +2 -2
- data/spec/rails_helper.rb +1 -1
- data/vendor/assets/rails-validator/rails-validator.js +534 -0
- data/vendor/assets/rails-validator/rails-validator.js.map +1 -0
- data/vendor/assets/rails-validator/rails-validator.min.js +3 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df57df79c7de9d2b469be1b10dbf13768c0618fc
|
4
|
+
data.tar.gz: dcfad21bb4faad94fa53f152d377fe8d894cb9a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c0b426a055515c34d662e6275dc4b24f09ee6caec1d8e12587fd54c51ca360c437b3277daf43eb1422c0f706c017270eeab6ed697579a6760ac4145dca97c40
|
7
|
+
data.tar.gz: 334d22e9f1e97cf378d256b1fa34e28609589c311bba1b952d3aa526801060249830702582aa66a4610b1510418ee3f047203c047ed79c703b33c797e716ef40
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path('
|
17
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
20
|
load 'rails/tasks/statistics.rake'
|
@@ -34,9 +34,7 @@ class Admin::RolesController < Admin::ApplicationController
|
|
34
34
|
|
35
35
|
def update
|
36
36
|
#role_params[:permission_tags] ||= []
|
37
|
-
if @role.
|
38
|
-
flash[:notice] = 'SpudRole updated successfully'
|
39
|
-
end
|
37
|
+
flash[:notice] = 'SpudRole updated successfully' if @role.update(role_params)
|
40
38
|
respond_with @role, location: admin_roles_path
|
41
39
|
end
|
42
40
|
|
@@ -13,14 +13,14 @@ class Admin::SettingsController < Admin::ApplicationController
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def update
|
16
|
-
if check_password && @current_user.
|
16
|
+
if check_password && @current_user.update(user_params)
|
17
17
|
if user_params.include?(:password)
|
18
18
|
SpudUserSession.create(@current_user)
|
19
19
|
end
|
20
20
|
flash[:notice] = 'User settings saved successfully.'
|
21
21
|
respond_with @current_user, location: admin_settings_path
|
22
22
|
else
|
23
|
-
render 'edit', status:
|
23
|
+
render 'edit', status: :unauthorized
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -63,7 +63,7 @@ class Admin::UsersController < Admin::ApplicationController
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def update
|
66
|
-
if @user.
|
66
|
+
if @user.update(user_params)
|
67
67
|
if @user == current_user && user_params[:password].present?
|
68
68
|
SpudUserSession.create(@user)
|
69
69
|
end
|
@@ -75,7 +75,7 @@ class Admin::UsersController < Admin::ApplicationController
|
|
75
75
|
@user.destroy
|
76
76
|
respond_with @user, location: admin_users_path do |format|
|
77
77
|
format.js{
|
78
|
-
render nothing: true, status:
|
78
|
+
render nothing: true, status: :ok
|
79
79
|
}
|
80
80
|
end
|
81
81
|
end
|
@@ -35,8 +35,8 @@ module TbCore
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def handle_record_not_found(
|
39
|
-
error = NotFoundError.new(class_string(
|
38
|
+
def handle_record_not_found(exception)
|
39
|
+
error = NotFoundError.new(class_string(exception.model))
|
40
40
|
handle_request_error(error)
|
41
41
|
end
|
42
42
|
|
@@ -50,8 +50,8 @@ module TbCore
|
|
50
50
|
string
|
51
51
|
end
|
52
52
|
|
53
|
-
def handle_unknown_format_error(
|
54
|
-
error = NotFoundError.new
|
53
|
+
def handle_unknown_format_error(_exception)
|
54
|
+
error = NotFoundError.new
|
55
55
|
handle_request_error(error)
|
56
56
|
end
|
57
57
|
end
|
@@ -14,7 +14,7 @@ class UserSessionsController < ApplicationController
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create
|
17
|
-
@user_session = SpudUserSession.new(user_session_params)
|
17
|
+
@user_session = SpudUserSession.new(user_session_params.to_h)
|
18
18
|
if @user_session.save()
|
19
19
|
respond_with @user_session do |format|
|
20
20
|
format.html{
|
@@ -50,7 +50,7 @@ class UserSessionsController < ApplicationController
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def set_change_password
|
53
|
-
current_user.
|
53
|
+
current_user.update(change_password_params)
|
54
54
|
respond_with current_user do |format|
|
55
55
|
format.html{
|
56
56
|
if current_user.errors.any?
|
@@ -122,9 +122,7 @@ module TbCore
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def unset_requires_password_change
|
125
|
-
if password_changed? && !requires_password_change_changed?(to: true)
|
126
|
-
self.requires_password_change = false
|
127
|
-
end
|
125
|
+
self.requires_password_change = false if password_changed? && !requires_password_change_changed?(to: true)
|
128
126
|
true
|
129
127
|
end
|
130
128
|
end
|
@@ -5,7 +5,7 @@ class Spud::ModuleGenerator < ::Rails::Generators::Base
|
|
5
5
|
argument :module_name, type: :string
|
6
6
|
argument :attributes, type: :array, default: [], banner: 'field[:type][:index] field[:type][:index]'
|
7
7
|
|
8
|
-
source_root File.expand_path('
|
8
|
+
source_root File.expand_path('templates', __dir__)
|
9
9
|
|
10
10
|
def create_module
|
11
11
|
install_templates
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Spud::SetupGenerator < ::Rails::Generators::Base
|
2
2
|
desc 'Base setup for a new TB application'
|
3
|
-
source_root File.expand_path('
|
3
|
+
source_root File.expand_path('templates', __dir__)
|
4
4
|
|
5
5
|
def setup
|
6
6
|
if ask(
|
@@ -16,9 +16,7 @@ class Spud::SetupGenerator < ::Rails::Generators::Base
|
|
16
16
|
environment(spud_core_configs())
|
17
17
|
rake('railties:install:migrations')
|
18
18
|
|
19
|
-
if ask('Migrate the database?', limited_to: ['y', 'n']).downcase == 'y'
|
20
|
-
rake('db:migrate')
|
21
|
-
end
|
19
|
+
rake('db:migrate') if ask('Migrate the database?', limited_to: ['y', 'n']).downcase == 'y'
|
22
20
|
end
|
23
21
|
|
24
22
|
private
|
@@ -18,7 +18,7 @@ module TbCore
|
|
18
18
|
# only: An array of controller actions you want this to apply to (optional)
|
19
19
|
#
|
20
20
|
def belongs_to_app(name, page_title: nil, only: nil)
|
21
|
-
before_action ->
|
21
|
+
before_action ->{
|
22
22
|
act_as_app(name, page_title: page_title)
|
23
23
|
}, only: only
|
24
24
|
end
|
data/lib/tb_core/engine.rb
CHANGED
@@ -49,9 +49,7 @@ module TbCore
|
|
49
49
|
|
50
50
|
initializer 'tb_core.catch_all_route' do |config|
|
51
51
|
# Handle 404 errors if Spud::Cms is not installed
|
52
|
-
unless defined?(Spud::Cms)
|
53
|
-
config.routes_reloader.paths << File.expand_path('../catch_all_route.rb', __FILE__)
|
54
|
-
end
|
52
|
+
config.routes_reloader.paths << File.expand_path('catch_all_route.rb', __dir__) unless defined?(Spud::Cms)
|
55
53
|
end
|
56
54
|
|
57
55
|
initializer 'tb_core.assets' do
|
data/lib/tb_core/test_files.rb
CHANGED
@@ -9,15 +9,15 @@ module Spud
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def load_specs
|
12
|
-
Dir[File.join(File.expand_path('
|
12
|
+
Dir[File.join(File.expand_path('../..', __dir__), 'spec/**/*_spec.rb')].each {|f| require f}
|
13
13
|
end
|
14
14
|
|
15
15
|
def load_factories
|
16
|
-
Dir[File.join(File.expand_path('
|
16
|
+
Dir[File.join(File.expand_path('../..', __dir__), 'factories/*')].each {|f| require f}
|
17
17
|
end
|
18
18
|
|
19
19
|
def load_support
|
20
|
-
Dir[File.join(File.expand_path('
|
20
|
+
Dir[File.join(File.expand_path('../..', __dir__), 'spec/support/**/*.rb')].each {|f| require f}
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/tb_core/test_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'authlogic/test_case'
|
2
|
-
include Authlogic::TestCase
|
3
2
|
|
4
3
|
module TbCore::SessionHelper
|
4
|
+
include Authlogic::TestCase
|
5
5
|
|
6
6
|
# Use this helper in controller specs to establish a login session
|
7
7
|
# - admin: Set to true to create a super_admin
|
@@ -21,7 +21,7 @@ module TbCore::SessionHelper
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# Returns the current user
|
24
|
-
#
|
24
|
+
#
|
25
25
|
def current_user
|
26
26
|
return @user
|
27
27
|
end
|
@@ -37,6 +37,4 @@ end
|
|
37
37
|
|
38
38
|
# Auto load the spud_user factory if FactoryBot is in use
|
39
39
|
#
|
40
|
-
if defined?(FactoryBot)
|
41
|
-
Dir[TbCore::Engine.root.join('spec/factories/spud_user_factories.rb')].each{ |f| require f }
|
42
|
-
end
|
40
|
+
Dir[TbCore::Engine.root.join('spec/factories/spud_user_factories.rb')].each{ |f| require f } if defined?(FactoryBot)
|
data/lib/tb_core/version.rb
CHANGED
@@ -17,7 +17,7 @@ RSpec.describe Admin::ApplicationController, type: :controller do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should respond successfully if the current user is a super admin' do
|
20
|
-
@user.
|
20
|
+
@user.update(super_admin: true)
|
21
21
|
get :index
|
22
22
|
expect(response).to be_success
|
23
23
|
end
|
@@ -66,14 +66,14 @@ describe SpudUser, type: :model do
|
|
66
66
|
it 'should not unset the requires_password_change flag' do
|
67
67
|
u = FactoryBot.create(:spud_user, requires_password_change: true)
|
68
68
|
expect{
|
69
|
-
u.
|
69
|
+
u.update(first_name: 'updated')
|
70
70
|
}.to_not change(u, :requires_password_change)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should unset the requires_password_change flag' do
|
74
74
|
u = FactoryBot.create(:spud_user, requires_password_change: true)
|
75
75
|
expect{
|
76
|
-
u.
|
76
|
+
u.update(password: 'new password', password_confirmation: 'new password')
|
77
77
|
u.reload
|
78
78
|
}.to change(u, :requires_password_change).from(true).to(false)
|
79
79
|
end
|
data/spec/rails_helper.rb
CHANGED
@@ -4,7 +4,7 @@ SimpleCov.start 'rails'
|
|
4
4
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
5
5
|
ENV['RAILS_ENV'] ||= 'test'
|
6
6
|
|
7
|
-
require File.expand_path('
|
7
|
+
require File.expand_path('dummy/config/environment.rb', __dir__)
|
8
8
|
require 'spec_helper'
|
9
9
|
require 'tb_core/test_helper'
|
10
10
|
require 'rails-controller-testing'
|
@@ -0,0 +1,534 @@
|
|
1
|
+
/******/ (function(modules) { // webpackBootstrap
|
2
|
+
/******/ // The module cache
|
3
|
+
/******/ var installedModules = {};
|
4
|
+
/******/
|
5
|
+
/******/ // The require function
|
6
|
+
/******/ function __webpack_require__(moduleId) {
|
7
|
+
/******/
|
8
|
+
/******/ // Check if module is in cache
|
9
|
+
/******/ if(installedModules[moduleId]) {
|
10
|
+
/******/ return installedModules[moduleId].exports;
|
11
|
+
/******/ }
|
12
|
+
/******/ // Create a new module (and put it into the cache)
|
13
|
+
/******/ var module = installedModules[moduleId] = {
|
14
|
+
/******/ i: moduleId,
|
15
|
+
/******/ l: false,
|
16
|
+
/******/ exports: {}
|
17
|
+
/******/ };
|
18
|
+
/******/
|
19
|
+
/******/ // Execute the module function
|
20
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21
|
+
/******/
|
22
|
+
/******/ // Flag the module as loaded
|
23
|
+
/******/ module.l = true;
|
24
|
+
/******/
|
25
|
+
/******/ // Return the exports of the module
|
26
|
+
/******/ return module.exports;
|
27
|
+
/******/ }
|
28
|
+
/******/
|
29
|
+
/******/
|
30
|
+
/******/ // expose the modules object (__webpack_modules__)
|
31
|
+
/******/ __webpack_require__.m = modules;
|
32
|
+
/******/
|
33
|
+
/******/ // expose the module cache
|
34
|
+
/******/ __webpack_require__.c = installedModules;
|
35
|
+
/******/
|
36
|
+
/******/ // define getter function for harmony exports
|
37
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
39
|
+
/******/ Object.defineProperty(exports, name, {
|
40
|
+
/******/ configurable: false,
|
41
|
+
/******/ enumerable: true,
|
42
|
+
/******/ get: getter
|
43
|
+
/******/ });
|
44
|
+
/******/ }
|
45
|
+
/******/ };
|
46
|
+
/******/
|
47
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
48
|
+
/******/ __webpack_require__.n = function(module) {
|
49
|
+
/******/ var getter = module && module.__esModule ?
|
50
|
+
/******/ function getDefault() { return module['default']; } :
|
51
|
+
/******/ function getModuleExports() { return module; };
|
52
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
53
|
+
/******/ return getter;
|
54
|
+
/******/ };
|
55
|
+
/******/
|
56
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
57
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
58
|
+
/******/
|
59
|
+
/******/ // __webpack_public_path__
|
60
|
+
/******/ __webpack_require__.p = "";
|
61
|
+
/******/
|
62
|
+
/******/ // Load entry module and return exports
|
63
|
+
/******/ return __webpack_require__(__webpack_require__.s = 1);
|
64
|
+
/******/ })
|
65
|
+
/************************************************************************/
|
66
|
+
/******/ ([
|
67
|
+
/* 0 */
|
68
|
+
/***/ (function(module, exports, __webpack_require__) {
|
69
|
+
|
70
|
+
"use strict";
|
71
|
+
|
72
|
+
|
73
|
+
Object.defineProperty(exports, "__esModule", {
|
74
|
+
value: true
|
75
|
+
});
|
76
|
+
/*
|
77
|
+
* Build a path for redirection.
|
78
|
+
*
|
79
|
+
* - Adds a timestamp GET param for cache busting
|
80
|
+
* - Inserts an ID attribute if necessary
|
81
|
+
*/
|
82
|
+
var buildSuccessPath = exports.buildSuccessPath = function buildSuccessPath(path, json) {
|
83
|
+
var timestamp = new Date().valueOf();
|
84
|
+
if (path.indexOf('?') > -1) {
|
85
|
+
path += '&t=' + timestamp;
|
86
|
+
} else {
|
87
|
+
path += '?t=' + timestamp;
|
88
|
+
}
|
89
|
+
if (json && json.id) {
|
90
|
+
path = path.replace(':id', json.id);
|
91
|
+
}
|
92
|
+
return path;
|
93
|
+
};
|
94
|
+
|
95
|
+
/*
|
96
|
+
* Remote element
|
97
|
+
*/
|
98
|
+
var removeElement = exports.removeElement = function removeElement(element) {
|
99
|
+
element.parentElement.removeChild(element);
|
100
|
+
};
|
101
|
+
|
102
|
+
/*
|
103
|
+
* Create an error element
|
104
|
+
*/
|
105
|
+
var createErrorParagraph = exports.createErrorParagraph = function createErrorParagraph(text, base) {
|
106
|
+
var p = document.createElement('p');
|
107
|
+
p.classList.add('form-error');
|
108
|
+
p.classList.add(base ? 'form-error-base' : 'form-error-inline');
|
109
|
+
p.innerText = text;
|
110
|
+
return p;
|
111
|
+
};
|
112
|
+
|
113
|
+
/*
|
114
|
+
* Convert a query into an array of elements
|
115
|
+
*/
|
116
|
+
var querySelectorArray = exports.querySelectorArray = function querySelectorArray(parent, selector) {
|
117
|
+
var query = parent.querySelectorAll(selector);
|
118
|
+
var array = Array.prototype.slice.call(query);
|
119
|
+
return array;
|
120
|
+
};
|
121
|
+
|
122
|
+
/*
|
123
|
+
* Take a single error message and format it as if it were
|
124
|
+
* a json error coming from the server
|
125
|
+
*/
|
126
|
+
var formatStringAsErrors = exports.formatStringAsErrors = function formatStringAsErrors(errorString) {
|
127
|
+
return { base: [errorString] };
|
128
|
+
};
|
129
|
+
|
130
|
+
/*
|
131
|
+
* Return true if the element is in view
|
132
|
+
*/
|
133
|
+
var elementIsInView = exports.elementIsInView = function elementIsInView(el) {
|
134
|
+
var rect = el.getBoundingClientRect();
|
135
|
+
var w = window,
|
136
|
+
d = document;
|
137
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (w.innerHeight || d.documentElement.clientHeight) && rect.right <= (w.innerWidth || d.documentElement.clientWidth);
|
138
|
+
};
|
139
|
+
|
140
|
+
/***/ }),
|
141
|
+
/* 1 */
|
142
|
+
/***/ (function(module, exports, __webpack_require__) {
|
143
|
+
|
144
|
+
"use strict";
|
145
|
+
|
146
|
+
|
147
|
+
var _handlers = __webpack_require__(2);
|
148
|
+
|
149
|
+
var handlers = _interopRequireWildcard(_handlers);
|
150
|
+
|
151
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
152
|
+
|
153
|
+
var MODULE_LOADED = '_rails_validator_loaded';
|
154
|
+
|
155
|
+
var init = function init() {
|
156
|
+
window[MODULE_LOADED] = true;
|
157
|
+
addListener('form', 'ajax:before', handlers.onRemoteFormBefore);
|
158
|
+
addListener('form[data-success], a[data-success]', 'ajax:success', handlers.onRemoteFormSuccess);
|
159
|
+
addListener('form[data-errors]', 'ajax:error', handlers.onRemoteFormErrors);
|
160
|
+
};
|
161
|
+
|
162
|
+
var addListener = function addListener(selector, event, fn) {
|
163
|
+
document.addEventListener(event, function (e) {
|
164
|
+
if (e.target.matches(selector)) {
|
165
|
+
e.stopPropagation();
|
166
|
+
fn.call(e.target, e);
|
167
|
+
}
|
168
|
+
});
|
169
|
+
};
|
170
|
+
|
171
|
+
if (!window[MODULE_LOADED]) {
|
172
|
+
init();
|
173
|
+
}
|
174
|
+
|
175
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
176
|
+
if (!Element.prototype.matches) {
|
177
|
+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
178
|
+
}
|
179
|
+
|
180
|
+
/***/ }),
|
181
|
+
/* 2 */
|
182
|
+
/***/ (function(module, exports, __webpack_require__) {
|
183
|
+
|
184
|
+
"use strict";
|
185
|
+
|
186
|
+
|
187
|
+
Object.defineProperty(exports, "__esModule", {
|
188
|
+
value: true
|
189
|
+
});
|
190
|
+
exports.onRemoteFormErrors = exports.onRemoteFormSuccess = exports.onRemoteFormBefore = undefined;
|
191
|
+
|
192
|
+
var _errors = __webpack_require__(3);
|
193
|
+
|
194
|
+
var errors = _interopRequireWildcard(_errors);
|
195
|
+
|
196
|
+
var _helpers = __webpack_require__(0);
|
197
|
+
|
198
|
+
var helpers = _interopRequireWildcard(_helpers);
|
199
|
+
|
200
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
201
|
+
|
202
|
+
/*
|
203
|
+
* Tell the server we want a json response
|
204
|
+
*/
|
205
|
+
var onRemoteFormBefore = exports.onRemoteFormBefore = function onRemoteFormBefore(event) {
|
206
|
+
var form = event.target;
|
207
|
+
if (form.getAttribute('data-type') === null) {
|
208
|
+
form.setAttribute('data-type', 'json');
|
209
|
+
}
|
210
|
+
};
|
211
|
+
|
212
|
+
/*
|
213
|
+
* Called when a remote form is submitted with a data-success configured
|
214
|
+
* Redirects to the configured path, or reloads the page if "reload" is passed
|
215
|
+
*
|
216
|
+
* ie:
|
217
|
+
* <form action="..." data-remote="true" data-success="/path/for/success/:id">
|
218
|
+
*/
|
219
|
+
var onRemoteFormSuccess = exports.onRemoteFormSuccess = function onRemoteFormSuccess(event) {
|
220
|
+
var form = event.target;
|
221
|
+
var successPath = form.getAttribute('data-success');
|
222
|
+
if (successPath === 'reload') {
|
223
|
+
window.location.reload(true);
|
224
|
+
} else {
|
225
|
+
var json = event.detail[0];
|
226
|
+
window.location = helpers.buildSuccessPath(successPath, json);
|
227
|
+
}
|
228
|
+
};
|
229
|
+
|
230
|
+
/*
|
231
|
+
* Called when a remote form is submitted and the server has returned an
|
232
|
+
* error, only if the form has a data-errors attribute
|
233
|
+
*
|
234
|
+
* ie:
|
235
|
+
* <form action="..." data-remote="true" data-errors="inline">
|
236
|
+
* - OR -
|
237
|
+
* <form action="..." data-remote="true" data-errors="alert">
|
238
|
+
*/
|
239
|
+
var onRemoteFormErrors = exports.onRemoteFormErrors = function onRemoteFormErrors(event) {
|
240
|
+
var json = event.detail[0];
|
241
|
+
var xhr = event.detail[2];
|
242
|
+
var form = event.target;
|
243
|
+
var errorType = form.getAttribute('data-errors');
|
244
|
+
|
245
|
+
if (xhr.status === 422) {
|
246
|
+
if (errorType === 'inline') {
|
247
|
+
errors.displayErrorsInline(form, json);
|
248
|
+
} else {
|
249
|
+
errors.displayErrorsAlert(json);
|
250
|
+
}
|
251
|
+
} else if (xhr.status === 401 || xhr.status === 403) {
|
252
|
+
window.alert('Error: Access denied.');
|
253
|
+
} else {
|
254
|
+
var errorThrown = event.detail[1];
|
255
|
+
window.alert('An unexpected error occurred: ' + errorThrown);
|
256
|
+
}
|
257
|
+
};
|
258
|
+
|
259
|
+
/***/ }),
|
260
|
+
/* 3 */
|
261
|
+
/***/ (function(module, exports, __webpack_require__) {
|
262
|
+
|
263
|
+
"use strict";
|
264
|
+
|
265
|
+
|
266
|
+
Object.defineProperty(exports, "__esModule", {
|
267
|
+
value: true
|
268
|
+
});
|
269
|
+
exports.displayErrorsAlert = exports.displayErrorsInline = exports.clearErrors = undefined;
|
270
|
+
|
271
|
+
var _helpers = __webpack_require__(0);
|
272
|
+
|
273
|
+
var helpers = _interopRequireWildcard(_helpers);
|
274
|
+
|
275
|
+
var _case = __webpack_require__(4);
|
276
|
+
|
277
|
+
var _case2 = _interopRequireDefault(_case);
|
278
|
+
|
279
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
280
|
+
|
281
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
282
|
+
|
283
|
+
/*
|
284
|
+
* Remove inline error messages
|
285
|
+
*/
|
286
|
+
var clearErrors = exports.clearErrors = function clearErrors(form) {
|
287
|
+
helpers.querySelectorArray(form, '.form-error-inline, .form-error-base').forEach(helpers.removeElement);
|
288
|
+
};
|
289
|
+
|
290
|
+
/*
|
291
|
+
* Append error text to form input fields and scroll to the first error
|
292
|
+
*/
|
293
|
+
var displayErrorsInline = exports.displayErrorsInline = function displayErrorsInline(form, json) {
|
294
|
+
if (typeof json === 'string') {
|
295
|
+
json = helpers.formatStringAsErrors(json);
|
296
|
+
}
|
297
|
+
|
298
|
+
clearErrors(form);
|
299
|
+
var errors = json.errors;
|
300
|
+
|
301
|
+
for (var key in errors) {
|
302
|
+
var messages = errors[key];
|
303
|
+
if (key === 'base') {
|
304
|
+
for (var i = 0; i < messages.length; i++) {
|
305
|
+
var p = helpers.createErrorParagraph(messages[i], true);
|
306
|
+
form.insertBefore(p, form.firstChild);
|
307
|
+
}
|
308
|
+
} else {
|
309
|
+
var input = void 0,
|
310
|
+
keyArr = void 0;
|
311
|
+
keyArr = key.split('.');
|
312
|
+
|
313
|
+
if (keyArr.length === 2) {
|
314
|
+
keyArr[0] += '_attributes';
|
315
|
+
input = form.querySelector('[name$=\'[' + keyArr.join('][') + ']\']');
|
316
|
+
} else {
|
317
|
+
var array = helpers.querySelectorArray(form, '[name$=\'[' + key + ']\']');
|
318
|
+
input = array.filter(function (input) {
|
319
|
+
// Filter out nested attribute inputs ie model[a][b]
|
320
|
+
return !input.name.match(/\]\[/);
|
321
|
+
})[0];
|
322
|
+
if (input === null && !key.match(/_id$/)) {
|
323
|
+
input = form.querySelector('[name$=\'[' + key + '_id]\']');
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
var message = messages[0];
|
328
|
+
if (input) {
|
329
|
+
input.parentNode.appendChild(helpers.createErrorParagraph(message));
|
330
|
+
} else {
|
331
|
+
// eslint-disable-next-line no-console
|
332
|
+
console.warn('Missing input field for key:', key);
|
333
|
+
form.insertBefore(helpers.createErrorParagraph(_case2.default.title(key) + ' ' + message), form.firstChild);
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}
|
337
|
+
|
338
|
+
var firstError = form.querySelector('.form-error-inline, .form-error-base');
|
339
|
+
if (firstError && !helpers.elementIsInView(firstError) && typeof firstError.scrollIntoView === 'function') {
|
340
|
+
firstError.parentElement.scrollIntoView();
|
341
|
+
}
|
342
|
+
};
|
343
|
+
|
344
|
+
/*
|
345
|
+
* Display errors in a standard window.alert dialog
|
346
|
+
*/
|
347
|
+
var displayErrorsAlert = exports.displayErrorsAlert = function displayErrorsAlert(json) {
|
348
|
+
if (typeof json === 'string') {
|
349
|
+
json = helpers.formatStringAsErrors(json);
|
350
|
+
}
|
351
|
+
var text = 'Please correct the following errors:\n';
|
352
|
+
var message = void 0,
|
353
|
+
errors = json.errors;
|
354
|
+
for (var key in errors) {
|
355
|
+
message = errors[key][0];
|
356
|
+
if (key === 'base') {
|
357
|
+
text += ' - ' + message + '\n';
|
358
|
+
} else {
|
359
|
+
text += ' - ' + _case2.default.title(key) + ' ' + message + '\n';
|
360
|
+
}
|
361
|
+
}
|
362
|
+
window.alert(text);
|
363
|
+
};
|
364
|
+
|
365
|
+
/***/ }),
|
366
|
+
/* 4 */
|
367
|
+
/***/ (function(module, exports) {
|
368
|
+
|
369
|
+
/*! Case - v1.5.3 - 2017-07-11
|
370
|
+
* Copyright (c) 2017 Nathan Bubna; Licensed MIT, GPL */
|
371
|
+
(function() {
|
372
|
+
"use strict";
|
373
|
+
var unicodes = function(s, prefix) {
|
374
|
+
prefix = prefix || '';
|
375
|
+
return s.replace(/(^|-)/g, '$1\\u'+prefix).replace(/,/g, '\\u'+prefix);
|
376
|
+
},
|
377
|
+
basicSymbols = unicodes('20-26,28-2F,3A-40,5B-60,7B-7E,A0-BF,D7,F7', '00'),
|
378
|
+
baseLowerCase = 'a-z'+unicodes('DF-F6,F8-FF', '00'),
|
379
|
+
baseUpperCase = 'A-Z'+unicodes('C0-D6,D8-DE', '00'),
|
380
|
+
improperInTitle = 'A|An|And|As|At|But|By|En|For|If|In|Of|On|Or|The|To|Vs?\\.?|Via',
|
381
|
+
regexps = function(symbols, lowers, uppers, impropers) {
|
382
|
+
symbols = symbols || basicSymbols;
|
383
|
+
lowers = lowers || baseLowerCase;
|
384
|
+
uppers = uppers || baseUpperCase;
|
385
|
+
impropers = impropers || improperInTitle;
|
386
|
+
return {
|
387
|
+
capitalize: new RegExp('(^|['+symbols+'])(['+lowers+'])', 'g'),
|
388
|
+
pascal: new RegExp('(^|['+symbols+'])+(['+lowers+uppers+'])', 'g'),
|
389
|
+
fill: new RegExp('['+symbols+']+(.|$)','g'),
|
390
|
+
sentence: new RegExp('(^\\s*|[\\?\\!\\.]+"?\\s+"?|,\\s+")(['+lowers+'])', 'g'),
|
391
|
+
improper: new RegExp('\\b('+impropers+')\\b', 'g'),
|
392
|
+
relax: new RegExp('([^'+uppers+'])(['+uppers+']*)(['+uppers+'])(?=['+lowers+']|$)', 'g'),
|
393
|
+
upper: new RegExp('^[^'+lowers+']+$'),
|
394
|
+
hole: /[^\s]\s[^\s]/,
|
395
|
+
apostrophe: /'/g,
|
396
|
+
room: new RegExp('['+symbols+']')
|
397
|
+
};
|
398
|
+
},
|
399
|
+
re = regexps(),
|
400
|
+
_ = {
|
401
|
+
re: re,
|
402
|
+
unicodes: unicodes,
|
403
|
+
regexps: regexps,
|
404
|
+
types: [],
|
405
|
+
up: String.prototype.toUpperCase,
|
406
|
+
low: String.prototype.toLowerCase,
|
407
|
+
cap: function(s) {
|
408
|
+
return _.up.call(s.charAt(0))+s.slice(1);
|
409
|
+
},
|
410
|
+
decap: function(s) {
|
411
|
+
return _.low.call(s.charAt(0))+s.slice(1);
|
412
|
+
},
|
413
|
+
deapostrophe: function(s) {
|
414
|
+
return s.replace(re.apostrophe, '');
|
415
|
+
},
|
416
|
+
fill: function(s, fill, deapostrophe) {
|
417
|
+
if (fill != null) {
|
418
|
+
s = s.replace(re.fill, function(m, next) {
|
419
|
+
return next ? fill + next : '';
|
420
|
+
});
|
421
|
+
}
|
422
|
+
if (deapostrophe) {
|
423
|
+
s = _.deapostrophe(s);
|
424
|
+
}
|
425
|
+
return s;
|
426
|
+
},
|
427
|
+
prep: function(s, fill, pascal, upper) {
|
428
|
+
s = s == null ? '' : s + '';// force to string
|
429
|
+
if (!upper && re.upper.test(s)) {
|
430
|
+
s = _.low.call(s);
|
431
|
+
}
|
432
|
+
if (!fill && !re.hole.test(s)) {
|
433
|
+
var holey = _.fill(s, ' ');
|
434
|
+
if (re.hole.test(holey)) {
|
435
|
+
s = holey;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
if (!pascal && !re.room.test(s)) {
|
439
|
+
s = s.replace(re.relax, _.relax);
|
440
|
+
}
|
441
|
+
return s;
|
442
|
+
},
|
443
|
+
relax: function(m, before, acronym, caps) {
|
444
|
+
return before + ' ' + (acronym ? acronym+' ' : '') + caps;
|
445
|
+
}
|
446
|
+
},
|
447
|
+
Case = {
|
448
|
+
_: _,
|
449
|
+
of: function(s) {
|
450
|
+
for (var i=0,m=_.types.length; i<m; i++) {
|
451
|
+
if (Case[_.types[i]].apply(Case, arguments) === s){ return _.types[i]; }
|
452
|
+
}
|
453
|
+
},
|
454
|
+
flip: function(s) {
|
455
|
+
return s.replace(/\w/g, function(l) {
|
456
|
+
return (l == _.up.call(l) ? _.low : _.up).call(l);
|
457
|
+
});
|
458
|
+
},
|
459
|
+
random: function(s) {
|
460
|
+
return s.replace(/\w/g, function(l) {
|
461
|
+
return (Math.round(Math.random()) ? _.up : _.low).call(l);
|
462
|
+
});
|
463
|
+
},
|
464
|
+
type: function(type, fn) {
|
465
|
+
Case[type] = fn;
|
466
|
+
_.types.push(type);
|
467
|
+
}
|
468
|
+
},
|
469
|
+
types = {
|
470
|
+
lower: function(s, fill, deapostrophe) {
|
471
|
+
return _.fill(_.low.call(_.prep(s, fill)), fill, deapostrophe);
|
472
|
+
},
|
473
|
+
snake: function(s) {
|
474
|
+
return Case.lower(s, '_', true);
|
475
|
+
},
|
476
|
+
constant: function(s) {
|
477
|
+
return Case.upper(s, '_', true);
|
478
|
+
},
|
479
|
+
camel: function(s) {
|
480
|
+
return _.decap(Case.pascal(s));
|
481
|
+
},
|
482
|
+
kebab: function(s) {
|
483
|
+
return Case.lower(s, '-', true);
|
484
|
+
},
|
485
|
+
header: function(s) {
|
486
|
+
return Case.capital(s, '-', true);
|
487
|
+
},
|
488
|
+
upper: function(s, fill, deapostrophe) {
|
489
|
+
return _.fill(_.up.call(_.prep(s, fill, false, true)), fill, deapostrophe);
|
490
|
+
},
|
491
|
+
capital: function(s, fill, deapostrophe) {
|
492
|
+
return _.fill(_.prep(s).replace(re.capitalize, function(m, border, letter) {
|
493
|
+
return border+_.up.call(letter);
|
494
|
+
}), fill, deapostrophe);
|
495
|
+
},
|
496
|
+
pascal: function(s) {
|
497
|
+
return _.fill(_.prep(s, false, true).replace(re.pascal, function(m, border, letter) {
|
498
|
+
return _.up.call(letter);
|
499
|
+
}), '', true);
|
500
|
+
},
|
501
|
+
title: function(s) {
|
502
|
+
return Case.capital(s).replace(re.improper, function(small, p, i, s) {
|
503
|
+
return i > 0 && i < s.lastIndexOf(' ') ? _.low.call(small) : small;
|
504
|
+
});
|
505
|
+
},
|
506
|
+
sentence: function(s, names) {
|
507
|
+
s = Case.lower(s).replace(re.sentence, function(m, prelude, letter) {
|
508
|
+
return prelude + _.up.call(letter);
|
509
|
+
});
|
510
|
+
if (names) {
|
511
|
+
names.forEach(function(name) {
|
512
|
+
s = s.replace(new RegExp('\\b'+Case.lower(name)+'\\b', "g"), _.cap);
|
513
|
+
});
|
514
|
+
}
|
515
|
+
return s;
|
516
|
+
}
|
517
|
+
};
|
518
|
+
|
519
|
+
// TODO: Remove "squish" in a future breaking release.
|
520
|
+
types.squish = types.pascal;
|
521
|
+
|
522
|
+
for (var type in types) {
|
523
|
+
Case.type(type, types[type]);
|
524
|
+
}
|
525
|
+
// export Case (AMD, commonjs, or global)
|
526
|
+
var define = typeof define === "function" ? define : function(){};
|
527
|
+
define(typeof module === "object" && module.exports ? module.exports = Case : this.Case = Case);
|
528
|
+
|
529
|
+
}).call(this);
|
530
|
+
|
531
|
+
|
532
|
+
/***/ })
|
533
|
+
/******/ ]);
|
534
|
+
//# sourceMappingURL=rails-validator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap 54e2b37c7c9a37ac7b21","webpack:///./lib/helpers.js","webpack:///./lib/index.js","webpack:///./lib/handlers.js","webpack:///./lib/errors.js","webpack:///./node_modules/case/dist/Case.js"],"names":["buildSuccessPath","path","json","timestamp","Date","valueOf","indexOf","id","replace","removeElement","element","parentElement","removeChild","createErrorParagraph","text","base","p","document","createElement","classList","add","innerText","querySelectorArray","parent","selector","query","querySelectorAll","array","Array","prototype","slice","call","formatStringAsErrors","errorString","elementIsInView","el","rect","getBoundingClientRect","w","window","d","top","left","bottom","innerHeight","documentElement","clientHeight","right","innerWidth","clientWidth","handlers","MODULE_LOADED","init","addListener","onRemoteFormBefore","onRemoteFormSuccess","onRemoteFormErrors","event","fn","addEventListener","e","target","matches","stopPropagation","errors","helpers","form","getAttribute","setAttribute","successPath","location","reload","detail","xhr","errorType","status","displayErrorsInline","displayErrorsAlert","alert","errorThrown","clearErrors","forEach","key","messages","i","length","insertBefore","firstChild","input","keyArr","split","querySelector","join","filter","name","match","message","parentNode","appendChild","console","warn","title","firstError","scrollIntoView"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;AC7DA;;;;;;AAMO,IAAMA,8CAAmB,SAAnBA,gBAAmB,CAACC,IAAD,EAAOC,IAAP,EAAgB;AAC9C,MAAIC,YAAa,IAAIC,IAAJ,EAAD,CAAaC,OAAb,EAAhB;AACA,MAAGJ,KAAKK,OAAL,CAAa,GAAb,IAAoB,CAAC,CAAxB,EAA0B;AACxBL,YAAS,QAAQE,SAAjB;AACD,GAFD,MAGI;AACFF,YAAS,QAAQE,SAAjB;AACD;AACD,MAAGD,QAAQA,KAAKK,EAAhB,EAAmB;AACjBN,WAAOA,KAAKO,OAAL,CAAa,KAAb,EAAoBN,KAAKK,EAAzB,CAAP;AACD;AACD,SAAON,IAAP;AACD,CAZM;;AAcP;;;AAGO,IAAMQ,wCAAgB,SAAhBA,aAAgB,CAACC,OAAD,EAAa;AACxCA,UAAQC,aAAR,CAAsBC,WAAtB,CAAkCF,OAAlC;AACD,CAFM;;AAIP;;;AAGO,IAAMG,sDAAuB,SAAvBA,oBAAuB,CAACC,IAAD,EAAOC,IAAP,EAAgB;AAClD,MAAIC,IAAIC,SAASC,aAAT,CAAuB,GAAvB,CAAR;AACAF,IA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AAK;AACL;AACA;AACA;AACA,0CAA0C,KAAK;AAC/C,mEAAmE,mBAAmB;AACtF;AACA,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC","file":"rails-validator.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 54e2b37c7c9a37ac7b21","/*\n* Build a path for redirection.\n*\n* - Adds a timestamp GET param for cache busting\n* - Inserts an ID attribute if necessary\n*/\nexport const buildSuccessPath = (path, json) => {\n let timestamp = (new Date()).valueOf();\n if(path.indexOf('?') > -1){\n path += ('&t=' + timestamp);\n }\n else{\n path += ('?t=' + timestamp);\n }\n if(json && json.id){\n path = path.replace(':id', json.id);\n }\n return path;\n};\n\n/*\n* Remote element\n*/\nexport const removeElement = (element) => {\n element.parentElement.removeChild(element);\n};\n\n/*\n* Create an error element\n*/\nexport const createErrorParagraph = (text, base) => {\n let p = document.createElement('p');\n p.classList.add('form-error');\n p.classList.add(base ? 'form-error-base' : 'form-error-inline');\n p.innerText = text;\n return p;\n};\n\n/*\n* Convert a query into an array of elements\n*/\nexport const querySelectorArray = (parent, selector) => {\n let query = parent.querySelectorAll(selector);\n let array = Array.prototype.slice.call(query);\n return array;\n};\n\n/*\n* Take a single error message and format it as if it were\n* a json error coming from the server\n*/\nexport const formatStringAsErrors = (errorString) => {\n return { base: [errorString] };\n};\n\n/*\n* Return true if the element is in view\n*/\nexport const elementIsInView = (el) => {\n let rect = el.getBoundingClientRect();\n let w = window, d = document;\n return (\n rect.top >= 0 &&\n rect.left >= 0 &&\n rect.bottom <= (w.innerHeight || d.documentElement.clientHeight) &&\n rect.right <= (w.innerWidth || d.documentElement.clientWidth)\n );\n};\n\n\n\n// WEBPACK FOOTER //\n// ./lib/helpers.js","import * as handlers from './handlers';\n\nconst MODULE_LOADED='_rails_validator_loaded';\n\nconst init = () => {\n window[MODULE_LOADED] = true;\n addListener('form',\n 'ajax:before',\n handlers.onRemoteFormBefore);\n addListener('form[data-success], a[data-success]',\n 'ajax:success',\n handlers.onRemoteFormSuccess);\n addListener('form[data-errors]',\n 'ajax:error',\n handlers.onRemoteFormErrors);\n};\n\nconst addListener = (selector, event, fn) => {\n document.addEventListener(event, (e) => {\n if(e.target.matches(selector)){\n e.stopPropagation();\n fn.call(e.target, e);\n }\n });\n};\n\nif(!window[MODULE_LOADED]) {\n init();\n}\n\n\n\n// WEBPACK FOOTER //\n// ./lib/index.js","import * as errors from './errors';\nimport * as helpers from './helpers';\n\n/*\n* Tell the server we want a json response\n*/\nexport const onRemoteFormBefore = (event) => {\n let form = event.target;\n if(form.getAttribute('data-type') === null){\n form.setAttribute('data-type', 'json');\n }\n};\n\n/*\n* Called when a remote form is submitted with a data-success configured\n* Redirects to the configured path, or reloads the page if \"reload\" is passed\n*\n* ie:\n* <form action=\"...\" data-remote=\"true\" data-success=\"/path/for/success/:id\">\n*/\nexport const onRemoteFormSuccess = (event) => {\n let form = event.target;\n let successPath = form.getAttribute('data-success');\n if(successPath === 'reload'){\n window.location.reload(true);\n }\n else{\n let json = event.detail[0];\n window.location = helpers.buildSuccessPath(successPath, json);\n }\n};\n\n/*\n* Called when a remote form is submitted and the server has returned an\n* error, only if the form has a data-errors attribute\n*\n* ie:\n* <form action=\"...\" data-remote=\"true\" data-errors=\"inline\">\n* - OR -\n* <form action=\"...\" data-remote=\"true\" data-errors=\"alert\">\n*/\nexport const onRemoteFormErrors = (event) => {\n let json = event.detail[0];\n let xhr = event.detail[2];\n let form = event.target;\n let errorType = form.getAttribute('data-errors');\n\n if(xhr.status === 422){\n if(errorType === 'inline'){\n errors.displayErrorsInline(form, json);\n }\n else{\n errors.displayErrorsAlert(json);\n }\n }\n else if(xhr.status === 401 || xhr.status === 403){\n window.alert('Error: Access denied.');\n }\n else{\n let errorThrown = event.detail[1];\n window.alert('An unexpected error occurred: ' + errorThrown);\n }\n};\n\n\n\n// WEBPACK FOOTER //\n// ./lib/handlers.js","import * as helpers from './helpers';\nimport Case from 'case';\n\n/*\n* Remove inline error messages\n*/\nexport const clearErrors = function(form) {\n helpers.querySelectorArray(form,\n '.form-error-inline, .form-error-base').forEach(helpers.removeElement);\n};\n\n/*\n* Append error text to form input fields and scroll to the first error\n*/\nexport const displayErrorsInline = function(form, json){\n if(typeof json === 'string') {\n json = helpers.formatStringAsErrors(json);\n }\n\n clearErrors(form);\n let errors = json.errors;\n\n for(let key in errors){\n let messages = errors[key];\n if(key === 'base'){\n for(let i=0; i<messages.length; i++){\n let p = helpers.createErrorParagraph(messages[i], true);\n form.insertBefore(p, form.firstChild);\n }\n }\n else{\n let input, keyArr;\n keyArr = key.split('.');\n\n if(keyArr.length === 2){\n keyArr[0] += '_attributes';\n input = form.querySelector(`[name$='[${keyArr.join('][')}]']`);\n }\n else{\n let array = helpers.querySelectorArray(form, `[name$='[${key}]']`);\n input = array.filter(function(input){\n // Filter out nested attribute inputs ie model[a][b]\n return !input.name.match(/\\]\\[/);\n })[0];\n if(input === null && !key.match(/_id$/)){\n input = form.querySelector(`[name$='[${key}_id]']`);\n }\n }\n\n let message = messages[0];\n if(input){\n input.parentNode.appendChild(helpers.createErrorParagraph(message));\n }\n else{\n // eslint-disable-next-line no-console\n console.warn('Missing input field for key:', key);\n form.insertBefore(\n helpers.createErrorParagraph(`${Case.title(key)} ${message}`),\n form.firstChild\n );\n }\n }\n }\n\n let firstError = form.querySelector('.form-error-inline, .form-error-base');\n if(firstError &&\n !helpers.elementIsInView(firstError) &&\n typeof(firstError.scrollIntoView) === 'function'){\n firstError.parentElement.scrollIntoView();\n }\n};\n\n/*\n* Display errors in a standard window.alert dialog\n*/\nexport const displayErrorsAlert = function(json){\n if(typeof json === 'string') {\n json = helpers.formatStringAsErrors(json);\n }\n let text = 'Please correct the following errors:\\n';\n let message, errors = json.errors;\n for(let key in errors){\n message = errors[key][0];\n if(key === 'base'){\n text += ` - ${message}\\n`;\n }\n else{\n text += ` - ${Case.title(key)} ${message}\\n`;\n }\n }\n window.alert(text);\n};\n\n\n\n// WEBPACK FOOTER //\n// ./lib/errors.js","/*! Case - v1.5.3 - 2017-07-11\n* Copyright (c) 2017 Nathan Bubna; Licensed MIT, GPL */\n(function() {\n \"use strict\";\n var unicodes = function(s, prefix) {\n prefix = prefix || '';\n return s.replace(/(^|-)/g, '$1\\\\u'+prefix).replace(/,/g, '\\\\u'+prefix);\n },\n basicSymbols = unicodes('20-26,28-2F,3A-40,5B-60,7B-7E,A0-BF,D7,F7', '00'),\n baseLowerCase = 'a-z'+unicodes('DF-F6,F8-FF', '00'),\n baseUpperCase = 'A-Z'+unicodes('C0-D6,D8-DE', '00'),\n improperInTitle = 'A|An|And|As|At|But|By|En|For|If|In|Of|On|Or|The|To|Vs?\\\\.?|Via',\n regexps = function(symbols, lowers, uppers, impropers) {\n symbols = symbols || basicSymbols;\n lowers = lowers || baseLowerCase;\n uppers = uppers || baseUpperCase;\n impropers = impropers || improperInTitle;\n return {\n capitalize: new RegExp('(^|['+symbols+'])(['+lowers+'])', 'g'),\n pascal: new RegExp('(^|['+symbols+'])+(['+lowers+uppers+'])', 'g'),\n fill: new RegExp('['+symbols+']+(.|$)','g'),\n sentence: new RegExp('(^\\\\s*|[\\\\?\\\\!\\\\.]+\"?\\\\s+\"?|,\\\\s+\")(['+lowers+'])', 'g'),\n improper: new RegExp('\\\\b('+impropers+')\\\\b', 'g'),\n relax: new RegExp('([^'+uppers+'])(['+uppers+']*)(['+uppers+'])(?=['+lowers+']|$)', 'g'),\n upper: new RegExp('^[^'+lowers+']+$'),\n hole: /[^\\s]\\s[^\\s]/,\n apostrophe: /'/g,\n room: new RegExp('['+symbols+']')\n };\n },\n re = regexps(),\n _ = {\n re: re,\n unicodes: unicodes,\n regexps: regexps,\n types: [],\n up: String.prototype.toUpperCase,\n low: String.prototype.toLowerCase,\n cap: function(s) {\n return _.up.call(s.charAt(0))+s.slice(1);\n },\n decap: function(s) {\n return _.low.call(s.charAt(0))+s.slice(1);\n },\n deapostrophe: function(s) {\n return s.replace(re.apostrophe, '');\n },\n fill: function(s, fill, deapostrophe) {\n if (fill != null) {\n s = s.replace(re.fill, function(m, next) {\n return next ? fill + next : '';\n });\n }\n if (deapostrophe) {\n s = _.deapostrophe(s);\n }\n return s;\n },\n prep: function(s, fill, pascal, upper) {\n s = s == null ? '' : s + '';// force to string\n if (!upper && re.upper.test(s)) {\n s = _.low.call(s);\n }\n if (!fill && !re.hole.test(s)) {\n var holey = _.fill(s, ' ');\n if (re.hole.test(holey)) {\n s = holey;\n }\n }\n if (!pascal && !re.room.test(s)) {\n s = s.replace(re.relax, _.relax);\n }\n return s;\n },\n relax: function(m, before, acronym, caps) {\n return before + ' ' + (acronym ? acronym+' ' : '') + caps;\n }\n },\n Case = {\n _: _,\n of: function(s) {\n for (var i=0,m=_.types.length; i<m; i++) {\n if (Case[_.types[i]].apply(Case, arguments) === s){ return _.types[i]; }\n }\n },\n flip: function(s) {\n return s.replace(/\\w/g, function(l) {\n return (l == _.up.call(l) ? _.low : _.up).call(l);\n });\n },\n random: function(s) {\n return s.replace(/\\w/g, function(l) {\n return (Math.round(Math.random()) ? _.up : _.low).call(l);\n });\n },\n type: function(type, fn) {\n Case[type] = fn;\n _.types.push(type);\n }\n },\n types = {\n lower: function(s, fill, deapostrophe) {\n return _.fill(_.low.call(_.prep(s, fill)), fill, deapostrophe);\n },\n snake: function(s) {\n return Case.lower(s, '_', true);\n },\n constant: function(s) {\n return Case.upper(s, '_', true);\n },\n camel: function(s) {\n return _.decap(Case.pascal(s));\n },\n kebab: function(s) {\n return Case.lower(s, '-', true);\n },\n header: function(s) {\n return Case.capital(s, '-', true);\n },\n upper: function(s, fill, deapostrophe) {\n return _.fill(_.up.call(_.prep(s, fill, false, true)), fill, deapostrophe);\n },\n capital: function(s, fill, deapostrophe) {\n return _.fill(_.prep(s).replace(re.capitalize, function(m, border, letter) {\n return border+_.up.call(letter);\n }), fill, deapostrophe);\n },\n pascal: function(s) {\n return _.fill(_.prep(s, false, true).replace(re.pascal, function(m, border, letter) {\n return _.up.call(letter);\n }), '', true);\n },\n title: function(s) {\n return Case.capital(s).replace(re.improper, function(small, p, i, s) {\n return i > 0 && i < s.lastIndexOf(' ') ? _.low.call(small) : small;\n });\n },\n sentence: function(s, names) {\n s = Case.lower(s).replace(re.sentence, function(m, prelude, letter) {\n return prelude + _.up.call(letter);\n });\n if (names) {\n names.forEach(function(name) {\n s = s.replace(new RegExp('\\\\b'+Case.lower(name)+'\\\\b', \"g\"), _.cap);\n });\n }\n return s;\n }\n };\n\n // TODO: Remove \"squish\" in a future breaking release.\n types.squish = types.pascal;\n\n for (var type in types) {\n Case.type(type, types[type]);\n }\n // export Case (AMD, commonjs, or global)\n var define = typeof define === \"function\" ? define : function(){};\n define(typeof module === \"object\" && module.exports ? module.exports = Case : this.Case = Case);\n\n}).call(this);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/case/dist/Case.js\n// module id = 4\n// module chunks = 0 1"],"sourceRoot":""}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var t={};r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=1)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.buildSuccessPath=function(e,r){var t=(new Date).valueOf();return e.indexOf("?")>-1?e+="&t="+t:e+="?t="+t,r&&r.id&&(e=e.replace(":id",r.id)),e},r.removeElement=function(e){e.parentElement.removeChild(e)},r.createErrorParagraph=function(e,r){var t=document.createElement("p");return t.classList.add("form-error"),t.classList.add(r?"form-error-base":"form-error-inline"),t.innerText=e,t},r.querySelectorArray=function(e,r){var t=e.querySelectorAll(r);return Array.prototype.slice.call(t)},r.formatStringAsErrors=function(e){return{base:[e]}},r.elementIsInView=function(e){var r=e.getBoundingClientRect(),t=window,n=document;return r.top>=0&&r.left>=0&&r.bottom<=(t.innerHeight||n.documentElement.clientHeight)&&r.right<=(t.innerWidth||n.documentElement.clientWidth)}},function(e,r,t){"use strict";var n=t(2),o=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(n),a=function(e,r,t){document.addEventListener(r,function(r){r.target.matches(e)&&(r.stopPropagation(),t.call(r.target,r))})};window._rails_validator_loaded||function(){window._rails_validator_loaded=!0,a("form","ajax:before",o.onRemoteFormBefore),a("form[data-success], a[data-success]","ajax:success",o.onRemoteFormSuccess),a("form[data-errors]","ajax:error",o.onRemoteFormErrors)}(),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector)},function(e,r,t){"use strict";function n(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}Object.defineProperty(r,"__esModule",{value:!0}),r.onRemoteFormErrors=r.onRemoteFormSuccess=r.onRemoteFormBefore=void 0;var o=t(3),a=n(o),l=t(0),i=n(l);r.onRemoteFormBefore=function(e){var r=e.target;null===r.getAttribute("data-type")&&r.setAttribute("data-type","json")},r.onRemoteFormSuccess=function(e){var r=e.target,t=r.getAttribute("data-success");if("reload"===t)window.location.reload(!0);else{var n=e.detail[0];window.location=i.buildSuccessPath(t,n)}},r.onRemoteFormErrors=function(e){var r=e.detail[0],t=e.detail[2],n=e.target,o=n.getAttribute("data-errors");if(422===t.status)"inline"===o?a.displayErrorsInline(n,r):a.displayErrorsAlert(r);else if(401===t.status||403===t.status)window.alert("Error: Access denied.");else{var l=e.detail[1];window.alert("An unexpected error occurred: "+l)}}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.displayErrorsAlert=r.displayErrorsInline=r.clearErrors=void 0;var n=t(0),o=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(n),a=t(4),l=function(e){return e&&e.__esModule?e:{default:e}}(a),i=r.clearErrors=function(e){o.querySelectorArray(e,".form-error-inline, .form-error-base").forEach(o.removeElement)};r.displayErrorsInline=function(e,r){"string"==typeof r&&(r=o.formatStringAsErrors(r)),i(e);var t=r.errors;for(var n in t){var a=t[n];if("base"===n)for(var c=0;c<a.length;c++){var u=o.createErrorParagraph(a[c],!0);e.insertBefore(u,e.firstChild)}else{var s=void 0,p=void 0;if(p=n.split("."),2===p.length)p[0]+="_attributes",s=e.querySelector("[name$='["+p.join("][")+"]']");else{s=o.querySelectorArray(e,"[name$='["+n+"]']").filter(function(e){return!e.name.match(/\]\[/)})[0],null!==s||n.match(/_id$/)||(s=e.querySelector("[name$='["+n+"_id]']"))}var f=a[0];s?s.parentNode.appendChild(o.createErrorParagraph(f)):(console.warn("Missing input field for key:",n),e.insertBefore(o.createErrorParagraph(l.default.title(n)+" "+f),e.firstChild))}}var d=e.querySelector(".form-error-inline, .form-error-base");d&&!o.elementIsInView(d)&&"function"==typeof d.scrollIntoView&&d.parentElement.scrollIntoView()},r.displayErrorsAlert=function(e){"string"==typeof e&&(e=o.formatStringAsErrors(e));var r="Please correct the following errors:\n",t=void 0,n=e.errors;for(var a in n)t=n[a][0],r+="base"===a?" - "+t+"\n":" - "+l.default.title(a)+" "+t+"\n";window.alert(r)}},function(e,r){/*! Case - v1.5.3 - 2017-07-11
|
2
|
+
* Copyright (c) 2017 Nathan Bubna; Licensed MIT, GPL */
|
3
|
+
(function(){"use strict";var r=function(e,r){return r=r||"",e.replace(/(^|-)/g,"$1\\u"+r).replace(/,/g,"\\u"+r)},t=r("20-26,28-2F,3A-40,5B-60,7B-7E,A0-BF,D7,F7","00"),n="a-z"+r("DF-F6,F8-FF","00"),o="A-Z"+r("C0-D6,D8-DE","00"),a=function(e,r,a,l){return e=e||t,r=r||n,a=a||o,l=l||"A|An|And|As|At|But|By|En|For|If|In|Of|On|Or|The|To|Vs?\\.?|Via",{capitalize:new RegExp("(^|["+e+"])(["+r+"])","g"),pascal:new RegExp("(^|["+e+"])+(["+r+a+"])","g"),fill:new RegExp("["+e+"]+(.|$)","g"),sentence:new RegExp('(^\\s*|[\\?\\!\\.]+"?\\s+"?|,\\s+")(['+r+"])","g"),improper:new RegExp("\\b("+l+")\\b","g"),relax:new RegExp("([^"+a+"])(["+a+"]*)(["+a+"])(?=["+r+"]|$)","g"),upper:new RegExp("^[^"+r+"]+$"),hole:/[^\s]\s[^\s]/,apostrophe:/'/g,room:new RegExp("["+e+"]")}},l=a(),i={re:l,unicodes:r,regexps:a,types:[],up:String.prototype.toUpperCase,low:String.prototype.toLowerCase,cap:function(e){return i.up.call(e.charAt(0))+e.slice(1)},decap:function(e){return i.low.call(e.charAt(0))+e.slice(1)},deapostrophe:function(e){return e.replace(l.apostrophe,"")},fill:function(e,r,t){return null!=r&&(e=e.replace(l.fill,function(e,t){return t?r+t:""})),t&&(e=i.deapostrophe(e)),e},prep:function(e,r,t,n){if(e=null==e?"":e+"",!n&&l.upper.test(e)&&(e=i.low.call(e)),!r&&!l.hole.test(e)){var o=i.fill(e," ");l.hole.test(o)&&(e=o)}return t||l.room.test(e)||(e=e.replace(l.relax,i.relax)),e},relax:function(e,r,t,n){return r+" "+(t?t+" ":"")+n}},c={_:i,of:function(e){for(var r=0,t=i.types.length;r<t;r++)if(c[i.types[r]].apply(c,arguments)===e)return i.types[r]},flip:function(e){return e.replace(/\w/g,function(e){return(e==i.up.call(e)?i.low:i.up).call(e)})},random:function(e){return e.replace(/\w/g,function(e){return(Math.round(Math.random())?i.up:i.low).call(e)})},type:function(e,r){c[e]=r,i.types.push(e)}},u={lower:function(e,r,t){return i.fill(i.low.call(i.prep(e,r)),r,t)},snake:function(e){return c.lower(e,"_",!0)},constant:function(e){return c.upper(e,"_",!0)},camel:function(e){return i.decap(c.pascal(e))},kebab:function(e){return c.lower(e,"-",!0)},header:function(e){return c.capital(e,"-",!0)},upper:function(e,r,t){return i.fill(i.up.call(i.prep(e,r,!1,!0)),r,t)},capital:function(e,r,t){return i.fill(i.prep(e).replace(l.capitalize,function(e,r,t){return r+i.up.call(t)}),r,t)},pascal:function(e){return i.fill(i.prep(e,!1,!0).replace(l.pascal,function(e,r,t){return i.up.call(t)}),"",!0)},title:function(e){return c.capital(e).replace(l.improper,function(e,r,t,n){return t>0&&t<n.lastIndexOf(" ")?i.low.call(e):e})},sentence:function(e,r){return e=c.lower(e).replace(l.sentence,function(e,r,t){return r+i.up.call(t)}),r&&r.forEach(function(r){e=e.replace(new RegExp("\\b"+c.lower(r)+"\\b","g"),i.cap)}),e}};u.squish=u.pascal;for(var s in u)c.type(s,u[s]);var p="function"==typeof p?p:function(){};p("object"==typeof e&&e.exports?e.exports=c:this.Case=c)}).call(this)}]);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Woods
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: authlogic
|
@@ -475,6 +475,9 @@ files:
|
|
475
475
|
- spec/models/spud_user_spec.rb
|
476
476
|
- spec/rails_helper.rb
|
477
477
|
- spec/spec_helper.rb
|
478
|
+
- vendor/assets/rails-validator/rails-validator.js
|
479
|
+
- vendor/assets/rails-validator/rails-validator.js.map
|
480
|
+
- vendor/assets/rails-validator/rails-validator.min.js
|
478
481
|
homepage: http://bitbucket.org/moser-inc/tb_core
|
479
482
|
licenses: []
|
480
483
|
metadata: {}
|
@@ -486,7 +489,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
486
489
|
requirements:
|
487
490
|
- - ">="
|
488
491
|
- !ruby/object:Gem::Version
|
489
|
-
version:
|
492
|
+
version: 2.4.2
|
490
493
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
491
494
|
requirements:
|
492
495
|
- - ">="
|
@@ -494,7 +497,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
494
497
|
version: '0'
|
495
498
|
requirements: []
|
496
499
|
rubyforge_project:
|
497
|
-
rubygems_version: 2.
|
500
|
+
rubygems_version: 2.6.14
|
498
501
|
signing_key:
|
499
502
|
specification_version: 4
|
500
503
|
summary: Twice Baked Core Engine
|