tranzito_utils 1.1.9 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -39
- data/app/assets/builds/tranzito_utils-compiled.css +15 -11
- data/app/assets/stylesheets/tranzito_utils/_pagination.scss +35 -29
- data/app/assets/stylesheets/tranzito_utils/_period_selection.scss +1 -1
- data/app/views/tranzito_utils/_pagination.html.haml +3 -2
- data/app/views/tranzito_utils/_period_select.html.haml +10 -10
- data/lib/tranzito_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2c631d769babf37c8965014925e310d9f4481e7508c6ec9f311d77ebcefaede
|
4
|
+
data.tar.gz: b8e0aa0336e7adbba8cae83380e6b7a821b8fee699a5383b0e9353a0c34db0d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09712962ee686325cfeb8acffa167d628c20ef7853417cc3bf830ae846713c891f1a82d122fead42ab2c24d9186b80d77dad6b296ed5fe781b2e11eeb773a3aa'
|
7
|
+
data.tar.gz: 9bd61565793edc38e2fe2212322294eb088f8fe54b6ec9343391c182b87fe19cade2c127dc5af32321204982764ffa7912effd194afa5dd34db13627deaf965b
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TranzitoUtils [![CircleCI](https://dl.circleci.com/status-badge/img/gh/Tranzito/tranzito_utils/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/Tranzito/tranzito_utils/tree/main)
|
2
2
|
|
3
|
-
`tranzito_utils` is a ruby gem containing these Rails helpers, concerns and services
|
3
|
+
`tranzito_utils` is a ruby gem containing these Rails helpers, concerns and services:
|
4
4
|
|
5
5
|
| Name | Type | Description |
|
6
6
|
| ---- | ---- | ----------- |
|
@@ -14,9 +14,10 @@
|
|
14
14
|
# Installation
|
15
15
|
|
16
16
|
## tranzito_utils (gem)
|
17
|
+
|
17
18
|
Install the gem by adding this line to your application's Gemfile:
|
18
19
|
|
19
|
-
```
|
20
|
+
```ruby
|
20
21
|
gem "tranzito_utils"
|
21
22
|
```
|
22
23
|
|
@@ -24,56 +25,53 @@ Then run `bundle install`
|
|
24
25
|
|
25
26
|
To include the config file inside your host app run this command.
|
26
27
|
|
27
|
-
```
|
28
|
+
```shell
|
28
29
|
rails g tranzito_utils:install
|
29
30
|
```
|
30
31
|
|
31
32
|
This will add the `tranzito_utils.rb` file in the initializer where you can alter the default behaviour of several variables being used throughout the gem.
|
32
33
|
|
33
|
-
|
34
34
|
# Usage
|
35
35
|
|
36
36
|
#### SortableTable
|
37
37
|
|
38
|
-
To use the SortableTable module
|
38
|
+
To use the SortableTable module, include it in your required controllers:
|
39
39
|
|
40
|
-
```
|
40
|
+
```rb
|
41
41
|
include TranzitoUtils::SortableTable
|
42
42
|
```
|
43
43
|
|
44
|
-
You can use the following methods of `
|
44
|
+
You can use the following methods of `TranzitoUtils::SortableTable` in your controllers. These are also the helper methods.
|
45
45
|
|
46
|
-
```
|
46
|
+
```rb
|
47
47
|
sort_column, sort_direction
|
48
48
|
```
|
49
49
|
|
50
50
|
#### SetPeriod
|
51
51
|
|
52
|
-
Include the `SetPeriod` module
|
52
|
+
Include the `SetPeriod` module in your `ApplicationController` by adding this line:
|
53
53
|
|
54
|
-
```
|
54
|
+
```rb
|
55
55
|
include TranzitoUtils::SetPeriod
|
56
56
|
```
|
57
57
|
|
58
|
-
|
58
|
+
Add this line in the controller where you want to use the `SetPeriod` module:
|
59
59
|
|
60
|
-
```
|
61
|
-
|
60
|
+
```rb
|
61
|
+
before_action :set_period, only: [:index]
|
62
62
|
```
|
63
63
|
|
64
|
-
|
64
|
+
`SetPeriod` depends on a partial file to show the period_select view for filtering. Include in your views with this:
|
65
65
|
|
66
|
+
```erb
|
67
|
+
<%= render partial: "/tranzito_utils/period_select" %>
|
66
68
|
```
|
67
|
-
render partial: "/tranzito_utils/period_select"
|
68
|
-
```
|
69
|
-
|
70
|
-
This will include the period_select view for filtering.
|
71
69
|
|
72
70
|
### Helpers
|
73
71
|
|
74
72
|
For gems helpers, you need to add this into your `application_helper.rb` file.
|
75
73
|
|
76
|
-
```
|
74
|
+
```rb
|
77
75
|
include TranzitoUtils::Helpers
|
78
76
|
```
|
79
77
|
|
@@ -81,57 +79,65 @@ include TranzitoUtils::Helpers
|
|
81
79
|
|
82
80
|
You can include the flash messages into your application by add it's partial in your layouts file.
|
83
81
|
|
82
|
+
```erb
|
83
|
+
<%= render partial: "/tranzito_utils/flash_messages" %>
|
84
84
|
```
|
85
|
-
|
86
|
-
```
|
85
|
+
|
87
86
|
### Assets
|
88
87
|
|
89
88
|
To include the styles from the gem you need to add this into your application.scss, this will include the compiled CSS into your application.
|
90
89
|
|
91
|
-
```
|
90
|
+
```js
|
92
91
|
@import url('/tranzito_utils-compiled.css')
|
93
92
|
```
|
93
|
+
|
94
94
|
## tranzito_utils_js (npm)
|
95
95
|
You also need to add this NPM package in order to use the gem without any issue. You can install it using `yarn` or `npm`.
|
96
96
|
|
97
|
-
For yarn
|
98
|
-
|
97
|
+
For yarn:
|
98
|
+
|
99
|
+
```shell
|
99
100
|
yarn add tranzito_utils_js
|
101
|
+
|
100
102
|
```
|
101
103
|
For npm
|
102
|
-
|
104
|
+
|
105
|
+
```shell
|
103
106
|
npm install tranzito_utils_js
|
104
107
|
```
|
105
108
|
|
106
|
-
Then import it into your application by adding this line in `application.js` or any `.js` file where you need it
|
109
|
+
Then import it into your application by adding this line in `application.js` or any `.js` file where you need it:
|
107
110
|
|
108
|
-
```
|
111
|
+
```js
|
109
112
|
import { PeriodSelector, TimeParser } from "tranzito_utils_js"
|
110
113
|
```
|
111
|
-
Here `TimeParser` and `PeriodSelector` are classes we can use in our app.
|
112
114
|
|
113
|
-
|
115
|
+
Initialize them like this:
|
114
116
|
|
115
|
-
```
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
```js
|
118
|
+
|
119
|
+
document.addEventListener('DOMContentLoaded', function () {
|
120
|
+
if (!window.timeParser) { window.timeParser = new TimeParser() }
|
121
|
+
window.timeParser.localize()
|
119
122
|
|
120
|
-
As for `PeriodSelector`, you can use it by initializing like this
|
121
|
-
```
|
122
123
|
if (document.getElementById('timeSelectionBtnGroup')) {
|
123
124
|
const periodSelector = new PeriodSelector()
|
124
125
|
periodSelector.init()
|
125
126
|
}
|
127
|
+
}
|
126
128
|
```
|
127
|
-
|
129
|
+
|
130
|
+
(if using [turbo](https://github.com/hotwired/turbo-rails), switch `'DOMContentLoaded'` to `'turbo:load'`)
|
131
|
+
|
128
132
|
## License
|
129
|
-
|
133
|
+
|
134
|
+
The gem is available as open source under the terms of the [MIT License](MIT-LICENSE).
|
130
135
|
|
131
136
|
## Development
|
132
137
|
|
133
|
-
|
134
|
-
|
138
|
+
Compile the updated styles:
|
139
|
+
|
140
|
+
```shell
|
135
141
|
cd tranzito_utils_js
|
136
142
|
yarn build:css
|
137
143
|
```
|
@@ -77,39 +77,43 @@ input[type=radio] {
|
|
77
77
|
text-align: center;
|
78
78
|
}
|
79
79
|
|
80
|
-
.pagination-
|
80
|
+
.pagination-container {
|
81
|
+
margin: 1.5rem 1rem;
|
82
|
+
display: flex;
|
83
|
+
flex-wrap: wrap;
|
84
|
+
}
|
85
|
+
.pagination-container .pagination-flex {
|
81
86
|
display: flex;
|
82
87
|
flex-wrap: wrap;
|
83
88
|
opacity: 0.65;
|
84
89
|
}
|
85
|
-
.pagination-flex .pagination {
|
90
|
+
.pagination-container .pagination-flex .pagination {
|
86
91
|
margin: 0.5rem 0.5rem 0 0;
|
87
92
|
}
|
88
|
-
.pagination-flex.pagination-sm a.page-link {
|
93
|
+
.pagination-container .pagination-flex.pagination-sm a.page-link {
|
89
94
|
padding: 0.25rem 0.5rem;
|
90
95
|
font-size: 0.875rem;
|
91
96
|
}
|
92
|
-
.pagination-flex .pagination-number,
|
93
|
-
.pagination-flex .per-page {
|
97
|
+
.pagination-container .pagination-flex .pagination-number,
|
98
|
+
.pagination-container .pagination-flex .per-page {
|
94
99
|
display: flex;
|
95
100
|
flex-basis: 0;
|
96
101
|
flex-grow: 1;
|
97
102
|
margin-top: 0.5rem;
|
98
103
|
}
|
99
|
-
.pagination-flex .per-page {
|
104
|
+
.pagination-container .pagination-flex .per-page {
|
100
105
|
min-width: 9rem;
|
101
106
|
max-width: 9rem;
|
102
107
|
}
|
103
|
-
.pagination-flex .pagination-number {
|
108
|
+
.pagination-container .pagination-flex .pagination-number {
|
104
109
|
margin-left: 0.5rem;
|
105
110
|
}
|
106
|
-
.pagination-flex .per-page-select {
|
111
|
+
.pagination-container .pagination-flex .per-page-select {
|
107
112
|
margin-top: 0.5rem;
|
108
113
|
width: 8rem;
|
109
114
|
display: inline-block;
|
110
115
|
}
|
111
|
-
|
112
|
-
.pagination-number {
|
116
|
+
.pagination-container .pagination-number {
|
113
117
|
margin: 1rem 0 0;
|
114
118
|
}
|
115
119
|
|
@@ -142,7 +146,7 @@ input[type=radio] {
|
|
142
146
|
max-width: 100%;
|
143
147
|
vertical-align: middle;
|
144
148
|
}
|
145
|
-
.custom-time-selection
|
149
|
+
.custom-time-selection #updatePeriodSelectCustom {
|
146
150
|
margin-right: 15px;
|
147
151
|
}
|
148
152
|
.custom-time-selection .end-time-control {
|
@@ -1,36 +1,42 @@
|
|
1
|
-
.pagination-
|
1
|
+
.pagination-container {
|
2
|
+
margin: 1.5rem 1rem;
|
2
3
|
display: flex;
|
3
4
|
flex-wrap: wrap;
|
4
|
-
|
5
|
-
.pagination {
|
6
|
-
margin: 0.5rem 0.5rem 0 0;
|
7
|
-
}
|
8
|
-
&.pagination-sm a.page-link {
|
9
|
-
padding: 0.25rem 0.5rem;
|
10
|
-
font-size: 0.875rem;
|
11
|
-
}
|
12
|
-
.pagination-number,
|
13
|
-
.per-page {
|
5
|
+
|
6
|
+
.pagination-flex {
|
14
7
|
display: flex;
|
15
|
-
flex-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
flex-wrap: wrap;
|
9
|
+
opacity: 0.65; // Make it a little less prominent, it isn't the most important thing on the page
|
10
|
+
.pagination {
|
11
|
+
margin: 0.5rem 0.5rem 0 0;
|
12
|
+
}
|
13
|
+
&.pagination-sm a.page-link {
|
14
|
+
padding: 0.25rem 0.5rem;
|
15
|
+
font-size: 0.875rem;
|
16
|
+
}
|
17
|
+
.pagination-number,
|
18
|
+
.per-page {
|
19
|
+
display: flex;
|
20
|
+
flex-basis: 0;
|
21
|
+
flex-grow: 1;
|
22
|
+
margin-top: 0.5rem;
|
23
|
+
}
|
24
|
+
.per-page {
|
25
|
+
min-width: 9rem;
|
26
|
+
max-width: 9rem;
|
27
|
+
}
|
28
|
+
.pagination-number {
|
29
|
+
margin-left: 0.5rem;
|
30
|
+
}
|
31
|
+
|
32
|
+
.per-page-select {
|
33
|
+
margin-top: 0.5rem; // Align with the pagination part
|
34
|
+
width: 8rem;
|
35
|
+
display: inline-block;
|
36
|
+
}
|
22
37
|
}
|
38
|
+
|
23
39
|
.pagination-number {
|
24
|
-
margin
|
40
|
+
margin: 1rem 0 0;
|
25
41
|
}
|
26
|
-
|
27
|
-
.per-page-select {
|
28
|
-
margin-top: 0.5rem; // Align with the pagination part
|
29
|
-
width: 8rem;
|
30
|
-
display: inline-block;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
.pagination-number {
|
35
|
-
margin: 1rem 0 0;
|
36
42
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
-# Requires locals: collection, name
|
2
|
-
- count
|
2
|
+
-# total_count is pagination method. Handle non-paginated collections, in case this is used to display count and time range
|
3
|
+
- count ||= defined?(collection.total_count) ? collection.total_count : collection.count
|
3
4
|
- skip_total ||= false
|
4
5
|
- skip_pagination ||= false
|
5
6
|
-# override added to convert Created to Imported - for clarity in payroll_times
|
6
7
|
- humanized_time_range_column_override ||= nil
|
7
8
|
|
8
|
-
.
|
9
|
+
.pagination-container
|
9
10
|
- unless skip_total
|
10
11
|
.col-md-5
|
11
12
|
%p.pagination-number
|
@@ -8,30 +8,30 @@
|
|
8
8
|
= prepend_text
|
9
9
|
|
10
10
|
- if include_future
|
11
|
-
%a.btn.btn-
|
11
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "next_week")), class: ("active" if @period == "next_week"), data: { period: "next_week" } }
|
12
12
|
%span.d-none.d-md-inline-block next
|
13
13
|
seven days
|
14
|
-
%a.btn.btn-
|
14
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "next_month")), class: ("active" if @period == "next_month"), data: { period: "next_month" } }
|
15
15
|
%span.d-none.d-md-inline-block next
|
16
16
|
thirty days
|
17
|
-
%a.btn.btn-
|
17
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "hour")), class: ("active" if @period == "hour"), data: { period: "hour" } }
|
18
18
|
%span.d-none.d-md-inline-block past
|
19
19
|
hour
|
20
|
-
%a.btn.btn-
|
20
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "day")), class: ("active" if @period == "day"), data: { period: "day" } }
|
21
21
|
%span.d-none.d-md-inline-block past
|
22
22
|
day
|
23
|
-
%a.btn.btn-
|
23
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "week")), class: ("active" if @period == "week"), data: { period: "week" } }
|
24
24
|
%span.d-none.d-md-inline-block past
|
25
25
|
seven days
|
26
|
-
%a.btn.btn-
|
26
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "month")), class: ("active" if @period == "month"), data: { period: "month" } }
|
27
27
|
%span.d-none.d-md-inline-block past
|
28
28
|
thirty days
|
29
|
-
%a.btn.btn-
|
29
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "year")), class: ("active" if @period == "year"), data: { period: "year" } }
|
30
30
|
%span.d-none.d-md-inline-block past
|
31
31
|
year
|
32
|
-
%a.btn.btn-
|
32
|
+
%a.btn.btn-secondary.btn-sm.period-select-standard{ href: url_for(sortable_search_params.merge(period: "all")), class: ("active" if @period == "all"), data: { period: "all" } }
|
33
33
|
all
|
34
|
-
%button#periodSelectCustom.btn.btn-
|
34
|
+
%button#periodSelectCustom.btn.btn-secondary.btn-sm.ml-2{ class: ("active" if @period == "custom"), data: { period: "custom" } }
|
35
35
|
custom
|
36
36
|
|
37
37
|
%form#timeSelectionCustom.custom-time-selection.row.mt-2.collapse{ class: @period == "custom" ? "in show" : "" }
|
@@ -41,5 +41,5 @@
|
|
41
41
|
.form-group.end-time-control
|
42
42
|
= label_tag :end_time_selector, "to", class: "control-label mr-2 ml-2"
|
43
43
|
= datetime_local_field_tag :end_time_selector, @end_time.strftime("%Y-%m-%dT%H:%M"), step: 60, class: "form-control"
|
44
|
-
%button#updatePeriodSelectCustom.btn.btn-
|
44
|
+
%button#updatePeriodSelectCustom.btn.btn-primary.btn-sm.ml-2
|
45
45
|
update
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tranzito_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willbarrettdev
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|