tranzito_utils 1.1.9 → 1.1.10
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 +1 -1
- data/app/assets/stylesheets/tranzito_utils/_period_selection.scss +1 -1
- data/app/views/tranzito_utils/_pagination.html.haml +2 -1
- data/app/views/tranzito_utils/_period_select.html.haml +10 -10
- data/lib/tranzito_utils/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 423402f724633bc8cd7c907d5d80633a6bf7efbd14a7d77c5738b9735cb673db
|
4
|
+
data.tar.gz: 5468281cde4f1db9bff2d0cdcba731c13820da9cfba94502c216d0e9c7d4107a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b313dead21a726851031c188a4926569757dc61e1e69347da97afa562b1c286b6f93bc2a0b4f2ba4bc697caf968e3e7f47a4b0c4169e6911b1f66444a5bdbbe
|
7
|
+
data.tar.gz: f561ff9e50a3fd773b31893def71a6637d7d81eafd101c882110477e85f71b80c229a8024d1301a4aad97c37d9d206c920f3f0d38ccd91476854b439be24d366
|
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
|
```
|
@@ -1,5 +1,6 @@
|
|
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
|
@@ -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,16 +1,16 @@
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willbarrettdev
|
8
8
|
- sethherr
|
9
9
|
- hafiz-ahmed
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -103,7 +103,7 @@ licenses:
|
|
103
103
|
metadata:
|
104
104
|
homepage_uri: https://github.com/Tranzito/tranzito_utils
|
105
105
|
source_code_uri: https://github.com/Tranzito/tranzito_utils
|
106
|
-
post_install_message:
|
106
|
+
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|
@@ -118,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.1.
|
122
|
-
signing_key:
|
121
|
+
rubygems_version: 3.1.6
|
122
|
+
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Ruby gem contain several modules mainly containing the helpers, concerns
|
125
125
|
and services for personal use by Tranzito
|