common_core_js 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68b5a9a869b6a0f94746461670598d9cb5bedb33990863601ef3ecdf220fbdc9
|
4
|
+
data.tar.gz: 32503cb59ddee608eeae10c6ff8f75c044550c400d28bec85b0b0bb97170eea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e02dc262dc51c695434596729c6fb3521ceb6399446a1ddfb0c3e331c5a34c0f91e533c9e27ce2135e1ccb5da5101ed981873ef26beb97f9b56e88545de8e1
|
7
|
+
data.tar.gz: 21be6527906de8b37ce77b497a10e3c2edbdd1fb5f94aab9ba250820ef58735a4933ae119c2f46aab956ed49724573e84c51c51e9d83e4f3e4434e238796b4db
|
@@ -1,7 +1,13 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module CommonCoreHelper
|
2
|
+
|
3
|
+
def timezonize(tz)
|
4
|
+
tz = tz.to_i
|
5
|
+
(tz >= 0 ? "+" : "-") + sprintf('%02d',tz.abs) + ":00"
|
6
|
+
end
|
7
|
+
|
3
8
|
|
4
9
|
def datetime_field_localized(form_object, field_name, value, label, timezone = nil )
|
10
|
+
|
5
11
|
res = form_object.label(label,
|
6
12
|
field_name,
|
7
13
|
class: 'small form-text text-muted')
|
@@ -10,7 +16,7 @@ module CommonCoreJs
|
|
10
16
|
type: 'datetime-local',
|
11
17
|
value: date_to_current_timezone(value, timezone))
|
12
18
|
|
13
|
-
res <<
|
19
|
+
res << timezonize(timezone)
|
14
20
|
res
|
15
21
|
end
|
16
22
|
|
@@ -36,33 +42,27 @@ module CommonCoreJs
|
|
36
42
|
type: 'time',
|
37
43
|
value: date_to_current_timezone(value, timezone))
|
38
44
|
|
39
|
-
res <<
|
45
|
+
res << timezonize(tz)
|
40
46
|
res
|
41
47
|
end
|
42
48
|
|
43
49
|
def current_timezone
|
44
|
-
if
|
50
|
+
if controller.try(:current_timezone)
|
51
|
+
controller.current_timezone
|
52
|
+
elsif defined?(current_user)
|
45
53
|
if current_user.try(:timezone)
|
46
54
|
Time.now.in_time_zone(current_user.timezone).strftime("%z").to_i/100
|
47
55
|
else
|
48
56
|
Time.now.strftime("%z").to_i/100
|
49
57
|
end
|
50
58
|
else
|
51
|
-
raise "no method current_user is available or it does not implement timezone; please implement/override the method current_timezone"
|
59
|
+
raise "no method current_user is available or it does not implement timezone; please implement/override the method current_timezone IN YOUR CONTROLLER"
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
55
|
-
def human_timezone(time_string, timezone)
|
56
|
-
time = time_string.in_time_zone(timezone)
|
57
|
-
|
58
|
-
if time.zone.match?(/^\w/)
|
59
|
-
time.zone
|
60
|
-
else
|
61
|
-
time.formatted_offset
|
62
|
-
end
|
63
|
-
end
|
64
63
|
|
65
64
|
def date_to_current_timezone(date, timezone = nil)
|
65
|
+
|
66
66
|
# if the timezone is nil, use the server date'
|
67
67
|
if timezone.nil?
|
68
68
|
timezone = Time.now.strftime("%z").to_i/100
|
@@ -76,5 +76,4 @@ module CommonCoreJs
|
|
76
76
|
return nil
|
77
77
|
end
|
78
78
|
end
|
79
|
-
end
|
80
79
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<% if object.errors.any? %>
|
2
2
|
<% pass_through_locals ||= {} %>
|
3
|
-
$(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render
|
3
|
+
$(".<%= singular %>-table tr[data-id=<%= object.id %>][data-edit='true']").html("<%= j render partial: 'edit', locals: {singular.to_sym => object, url: url, colspan: controller.default_colspan}.merge(pass_through_locals || {}) %>")
|
4
|
+
|
4
5
|
$(".flash-notices").html("<%= j render 'layouts/flash_notices' %>");
|
5
6
|
<% else %>
|
6
7
|
$(".<%= singular %>-table tr[data-id=<%= object.id %>]:not([data-edit='true'])").replaceWith("<%= j render partial: 'line', locals: {singular.to_sym => object } %>").fadeIn()
|
data/lib/common_core_js.rb
CHANGED
@@ -8,7 +8,7 @@ module CommonCoreJs
|
|
8
8
|
# Your code goes here...
|
9
9
|
#
|
10
10
|
module ControllerHelpers
|
11
|
-
def modify_date_inputs_on_params(modified_params
|
11
|
+
def modify_date_inputs_on_params(modified_params)
|
12
12
|
use_timezone = authenticated_user.timezone || Time.now.strftime("%z")
|
13
13
|
|
14
14
|
modified_params = modified_params.tap do |params|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_core_js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
@@ -142,7 +142,7 @@ files:
|
|
142
142
|
- app/assets/stylesheets/common_core_js/application.css
|
143
143
|
- app/assets/stylesheets/common_core_js/common_core.scss
|
144
144
|
- app/controllers/common_core_js/application_controller.rb
|
145
|
-
- app/helpers/
|
145
|
+
- app/helpers/common_core_helper.rb
|
146
146
|
- app/jobs/common_core_js/application_job.rb
|
147
147
|
- app/mailers/common_core_js/application_mailer.rb
|
148
148
|
- app/models/common_core_js/application_record.rb
|