egov_utils 0.3.12 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/egov_utils/application.js +1 -1
- data/app/assets/javascripts/egov_utils/eGovUtilities.coffee.erb +14 -14
- data/app/assets/stylesheets/egov_utils/egov_utils.scss +2 -0
- data/app/views/common/_grid.html.coffee +1 -1
- data/app/views/egov_utils/users/_users_tab.html.haml +1 -1
- data/lib/bootstrap_form/check_box_patch.rb +1 -31
- data/lib/bootstrap_form/datetimepicker.rb +36 -7
- data/lib/bootstrap_form/fileuid.rb +1 -1
- data/lib/bootstrap_form/helpers/bootstrap4.rb +15 -0
- data/lib/bootstrap_form/select2.rb +4 -14
- data/lib/egov_utils.rb +2 -0
- data/lib/egov_utils/engine.rb +1 -1
- data/lib/egov_utils/helpers/tags/datetime_field_patch.rb +0 -16
- data/lib/egov_utils/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2290ad2369d8330daa5b454e76bc5f042931f191e10697178b86bc08c5412fb5
|
4
|
+
data.tar.gz: cd4db6767c26c648c93bb6f70038ce294b0f8f215fb684cb7177a14af3ccbe50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b89e4897982f5c62154dfacf26addab9ddffa031ff19c9425998a42c36d39f440ec1dbac5d2de30cd199b707983df3ed2f68bb3ca5770e738ca76de4934fa5
|
7
|
+
data.tar.gz: 55905eab4a285b84c1f1dc47f2d31cc4fa5ea2a92d612018695314227c949364295cc7895038d2dd76cdb5976d4554d8aa5453ec80e26f583d90829c8595f1a3
|
@@ -13,17 +13,17 @@ window.eGovUtilities =
|
|
13
13
|
$.fn.select2.defaults.set( "theme", "bootstrap" )
|
14
14
|
|
15
15
|
# datepicker defaults
|
16
|
-
$.extend $.fn.datetimepicker.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
16
|
+
# $.extend $.fn.datetimepicker.Constructor.Default.icons, {
|
17
|
+
# time: 'fa fa-clock-o',
|
18
|
+
# date: 'fa fa-calendar',
|
19
|
+
# up: 'fa fa-chevron-up',
|
20
|
+
# down: 'fa fa-chevron-down',
|
21
|
+
# previous: 'fa fa-chevron-left',
|
22
|
+
# next: 'fa fa-chevron-right',
|
23
|
+
# today: 'fa fa-calendar-check-o',
|
24
|
+
# clear: 'fa fa-trash-o',
|
25
|
+
# close: 'fa fa-close'
|
26
|
+
# }
|
27
27
|
|
28
28
|
$(document).on 'change', '.custom-file-input:file', ()->
|
29
29
|
$input = $(this)
|
@@ -54,13 +54,13 @@ window.eGovUtilities =
|
|
54
54
|
$container ||= $(document)
|
55
55
|
if !Modernizr.inputtypes.date
|
56
56
|
pickers = $('[type="date"][data-provide="datepicker"]', $container)
|
57
|
-
pickers.
|
57
|
+
pickers.addClass('datetimepicker-input').parents().datetimepicker({allowInputToggle: true})
|
58
58
|
if !Modernizr.inputtypes.datetime
|
59
59
|
pickers = $('[type="datetime"][data-provide="datepicker"]', $container)
|
60
|
-
pickers.
|
60
|
+
pickers.addClass('datetimepicker-input').parents().datetimepicker({allowInputToggle: true})
|
61
61
|
if !Modernizr.inputtypes['datetime-local']
|
62
62
|
pickers = $('[type="datetime-local"][data-provide="datepicker"]', $container)
|
63
|
-
pickers.
|
63
|
+
pickers.addClass('datetimepicker-input').parents().datetimepicker({allowInputToggle: true})
|
64
64
|
|
65
65
|
initPeople: ($container)->
|
66
66
|
$container ||= $(document)
|
@@ -109,7 +109,7 @@ $ ->
|
|
109
109
|
<% schema.columns.each do |col| %>
|
110
110
|
<%= raw column_for_grid(grid, col) %>
|
111
111
|
<% end %>
|
112
|
-
<% if can?(:update, schema.model) || can?(:destroy, schema.model) %>
|
112
|
+
<% if can?(:update, schema.model) || (local_assigns.fetch(:allow_delete, false) && can?(:destroy, schema.model)) %>
|
113
113
|
{
|
114
114
|
width: 150
|
115
115
|
title: "<%= t('label_actions') %>"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
%table.table#users
|
2
2
|
%thead
|
3
3
|
%tr
|
4
|
-
%th=
|
4
|
+
%th= EgovUtils::User.human_attribute_name('fullname')
|
5
5
|
%th= EgovUtils::User.human_attribute_name('provider')
|
6
6
|
%th= EgovUtils::User.human_attribute_name('roles')
|
7
7
|
%th= EgovUtils::User.human_attribute_name('groups')
|
@@ -12,37 +12,7 @@ module BootstrapForm
|
|
12
12
|
end
|
13
13
|
options[:label_class] = label_classes.compact.join(' ')
|
14
14
|
|
15
|
-
|
16
|
-
check_box_options[:class] = ['form-check-input', check_box_options[:class]].compact.join(' ')
|
17
|
-
|
18
|
-
|
19
|
-
html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value)
|
20
|
-
label_content = block_given? ? capture(&block) : options[:label]
|
21
|
-
html.concat(' ').concat(label_content || (object && object.class.human_attribute_name(name)) || name.to_s.humanize)
|
22
|
-
|
23
|
-
label_name = name
|
24
|
-
# label's `for` attribute needs to match checkbox tag's id,
|
25
|
-
# IE sanitized value, IE
|
26
|
-
# https://github.com/rails/rails/blob/c57e7239a8b82957bcb07534cb7c1a3dcef71864/actionview/lib/action_view/helpers/tags/base.rb#L116-L118
|
27
|
-
if options[:multiple]
|
28
|
-
label_name =
|
29
|
-
"#{name}_#{checked_value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase}"
|
30
|
-
end
|
31
|
-
|
32
|
-
disabled_class = " disabled" if options[:disabled]
|
33
|
-
label_class = options[:label_class]
|
34
|
-
|
35
|
-
if options[:inline]
|
36
|
-
label_class = " #{label_class}" if label_class
|
37
|
-
label(label_name, html, class: "checkbox-inline#{disabled_class}#{label_class}")
|
38
|
-
else
|
39
|
-
wrapper_class = ['form-check', options[:wrapper_class]]
|
40
|
-
wrapper_class << error_class if has_error?(name)
|
41
|
-
wrapper_class = wrapper_class.compact.join(' ')
|
42
|
-
content_tag(:div, class: "#{wrapper_class}#{disabled_class}") do
|
43
|
-
label(label_name, html, class: label_class).concat(generate_help(name, options[:help]))
|
44
|
-
end
|
45
|
-
end
|
15
|
+
super
|
46
16
|
end
|
47
17
|
|
48
18
|
end
|
@@ -2,9 +2,9 @@ module BootstrapForm
|
|
2
2
|
module Datetimepicker
|
3
3
|
def date_field(name, *args)
|
4
4
|
options = args.extract_options!.symbolize_keys!
|
5
|
-
options
|
6
|
-
options[:data]
|
7
|
-
options
|
5
|
+
prepare_options(name, options)
|
6
|
+
options[:input_group][:data].merge!({'date-format' => 'L', 'date-extra-formats' => [BootstrapForm::DATE_FORMAT_JS]}.merge(options[:data] || {}))
|
7
|
+
append_min_max(BootstrapForm::DATE_FORMAT_RUBY, options)
|
8
8
|
args << options
|
9
9
|
super
|
10
10
|
end
|
@@ -19,9 +19,9 @@ module BootstrapForm
|
|
19
19
|
|
20
20
|
def datetime_local_field(name, *args)
|
21
21
|
options = args.extract_options!.symbolize_keys!
|
22
|
-
options
|
23
|
-
options[:data]
|
24
|
-
options
|
22
|
+
prepare_options(name, options)
|
23
|
+
options[:input_group][:data].merge!({'date-extra-formats' => [BootstrapForm::DATE_FORMAT_JS+"THH:mm"+(options[:include_seconds] ? ':ss' : '')]}.merge(options[:data] || {}))
|
24
|
+
append_min_max(BootstrapForm::DATE_FORMAT_RUBY+"T%T", options)
|
25
25
|
args << options
|
26
26
|
super
|
27
27
|
end
|
@@ -30,8 +30,37 @@ module BootstrapForm
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
+
def prepare_options(name, options)
|
34
|
+
input_group_id = default_group_id(name)
|
35
|
+
options[:datetimepicker] = true
|
36
|
+
options[:append] = calendar_addon
|
37
|
+
options[:input_group_class] = 'date'
|
38
|
+
options[:input_group] ||= {}
|
39
|
+
options[:input_group][:id] = input_group_id
|
40
|
+
options[:input_group][:data] = {'target-input' => 'nearest'}
|
41
|
+
options[:append_tag] = {data: {toggle: 'datetimepicker', target: '#' + input_group_id}}
|
42
|
+
options[:data] ||= {}
|
43
|
+
options[:data][:target] = '#' + input_group_id
|
44
|
+
end
|
45
|
+
|
46
|
+
def append_min_max(format, options)
|
47
|
+
options[:input_group][:data].merge!('date-min-date' => options[:min].try(:strftime, format), 'date-max-date' => options[:max].try(:strftime, format))
|
48
|
+
end
|
49
|
+
|
33
50
|
def calendar_addon
|
34
|
-
content_tag('i', '', class: '
|
51
|
+
content_tag('i', '', class: 'fa fa-calendar')
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_group_id(method_name)
|
55
|
+
"#{sanitized_object_name}_#{sanitized_method_name(method_name)}_group"
|
56
|
+
end
|
57
|
+
|
58
|
+
def sanitized_object_name
|
59
|
+
@object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
|
60
|
+
end
|
61
|
+
|
62
|
+
def sanitized_method_name(method_name)
|
63
|
+
method_name.to_s.sub(/\?$/, "")
|
35
64
|
end
|
36
65
|
end
|
37
66
|
end
|
@@ -5,7 +5,7 @@ module BootstrapForm
|
|
5
5
|
|
6
6
|
def fileuid_field(method, options={})
|
7
7
|
form_group_builder(method, options) do
|
8
|
-
prepend_and_append_input(options) do
|
8
|
+
prepend_and_append_input(method, options) do
|
9
9
|
@template.fileuid_field(@object_name, method, objectify_options(options))
|
10
10
|
end
|
11
11
|
end
|
@@ -7,6 +7,21 @@ module BootstrapForm
|
|
7
7
|
super(name, options)
|
8
8
|
end
|
9
9
|
|
10
|
+
|
11
|
+
# TODO check upstream - append tag options
|
12
|
+
def prepend_and_append_input(name, options, &block)
|
13
|
+
options = options.extract!(:prepend, :append, :input_group_class, :append_tag, :input_group)
|
14
|
+
input_group_class = ["input-group", options[:input_group_class]].compact.join(' ')
|
15
|
+
|
16
|
+
input = capture(&block) || "".html_safe
|
17
|
+
|
18
|
+
input = content_tag(:div, input_group_content(options[:prepend]), class: 'input-group-prepend') + input if options[:prepend]
|
19
|
+
input << content_tag(:div, input_group_content(options[:append]), (options[:append_tag] || {}).merge(class: 'input-group-append')) if options[:append]
|
20
|
+
input << generate_error(name)
|
21
|
+
input = content_tag(:div, input, (options[:input_group] || {}).merge(class: input_group_class)) unless options.empty?
|
22
|
+
input
|
23
|
+
end
|
24
|
+
|
10
25
|
end
|
11
26
|
end
|
12
27
|
end
|
@@ -1,20 +1,10 @@
|
|
1
1
|
module BootstrapForm
|
2
2
|
module Select2
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@template.select2(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options), &block)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
else
|
13
|
-
def select2(method, choices, options = {}, html_options = {}, &block)
|
14
|
-
form_group_builder(method, options, html_options) do
|
15
|
-
prepend_and_append_input(options) do
|
16
|
-
@template.select2(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options))
|
17
|
-
end
|
4
|
+
def select2(method, choices = nil, options = {}, html_options = {}, &block)
|
5
|
+
form_group_builder(method, options, html_options) do
|
6
|
+
prepend_and_append_input(method, options) do
|
7
|
+
@template.select2(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options), &block)
|
18
8
|
end
|
19
9
|
end
|
20
10
|
end
|
data/lib/egov_utils.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'jquery-rails'
|
2
2
|
require 'jquery-ui-rails'
|
3
|
+
require 'font-awesome-sass'
|
3
4
|
require 'bootstrap'
|
4
5
|
require 'bootstrap_form'
|
5
6
|
require 'momentjs-rails'
|
7
|
+
require 'bootstrap4-datetime-picker-rails'
|
6
8
|
|
7
9
|
require 'egov_utils/fileuid'
|
8
10
|
require 'egov_utils/model_permissions'
|
data/lib/egov_utils/engine.rb
CHANGED
@@ -108,8 +108,8 @@ module EgovUtils
|
|
108
108
|
require 'bootstrap_form/check_box_patch'
|
109
109
|
BootstrapForm::FormBuilder.__send__(:prepend, BootstrapForm::CheckBoxPatch)
|
110
110
|
|
111
|
+
#TODO: same as redefine method down?
|
111
112
|
require 'egov_utils/helpers/tags/datetime_field_patch'
|
112
|
-
ActionView::Helpers::Tags::DatetimeField.prepend(EgovUtils::Helpers::Tags::DatetimeFieldPatch)
|
113
113
|
ActionView::Helpers::Tags::DatetimeLocalField.prepend(EgovUtils::Helpers::Tags::DatetimeLocalFieldPatch)
|
114
114
|
|
115
115
|
ActionView::Helpers::Tags::DateField.redefine_method(:format_date) do |value|
|
@@ -1,22 +1,6 @@
|
|
1
1
|
module EgovUtils
|
2
2
|
module Helpers
|
3
3
|
module Tags
|
4
|
-
module DatetimeFieldPatch
|
5
|
-
|
6
|
-
def render
|
7
|
-
pickerize_options! if @options.stringify_keys['datetimepicker']
|
8
|
-
super
|
9
|
-
end
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def pickerize_options!
|
14
|
-
options = @options.stringify_keys
|
15
|
-
picker_data = {'provide' => 'datepicker', 'date-min-date' => format_date(datetime_value(options["min"])), 'date-max-date' => format_date(datetime_value(options["max"])) }
|
16
|
-
@options[:data] = picker_data.merge(options['data'] || {})
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
4
|
|
21
5
|
module DatetimeLocalFieldPatch
|
22
6
|
private
|
data/lib/egov_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egov_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 4.0
|
229
|
+
version: '4.0'
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: 4.0
|
236
|
+
version: '4.0'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: sass-rails
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,14 +268,28 @@ dependencies:
|
|
268
268
|
requirements:
|
269
269
|
- - "~>"
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version:
|
271
|
+
version: 4.0.0.dev
|
272
272
|
type: :runtime
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
276
|
- - "~>"
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
278
|
+
version: 4.0.0.dev
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: bootstrap4-datetime-picker-rails
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - "~>"
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0.1'
|
286
|
+
type: :runtime
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - "~>"
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '0.1'
|
279
293
|
- !ruby/object:Gem::Dependency
|
280
294
|
name: momentjs-rails
|
281
295
|
requirement: !ruby/object:Gem::Requirement
|