tranzito_utils 1.0.3 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,73 @@
1
+ .admin-header {
2
+ @extend .clearfix;
3
+ margin-bottom: 1rem;
4
+ padding-bottom: 1.5rem;
5
+ border-bottom: 1px solid #bdbdbd;
6
+
7
+ .btn {
8
+ @extend .header-sublink;
9
+ }
10
+
11
+ h1 {
12
+ font-size: 2rem;
13
+ @include media-breakpoint-up(md) {
14
+ .btn {
15
+ line-height: 2; // align floating buttons with the h1 tag
16
+ }
17
+ }
18
+ }
19
+ h1,
20
+ h2,
21
+ h3 {
22
+ @include media-breakpoint-down(sm) {
23
+ font-size: 1.5rem;
24
+ }
25
+ }
26
+ ul {
27
+ @extend .nav;
28
+ @extend .nav-pills;
29
+ @extend .justify-content-end;
30
+
31
+ // On small screens, make nav links align left
32
+ @include media-breakpoint-down(sm) {
33
+ justify-content: normal !important;
34
+ }
35
+ }
36
+ .nav-item {
37
+ @extend .small;
38
+ margin-left: 0.25rem;
39
+ a,
40
+ .button_to .btn {
41
+ padding: 0.25rem 0.5rem;
42
+ }
43
+ }
44
+ .subtitle {
45
+ @extend .mt-4;
46
+ @extend .col-12;
47
+ }
48
+ }
49
+
50
+ .header-link {
51
+ color: $text-color;
52
+ text-decoration: underline;
53
+ }
54
+
55
+ // Because we want it to break on small screens
56
+ .header-sublink {
57
+ @extend .float-md-right !optional;
58
+ }
59
+
60
+ // Because otherwise they overflow the right side of the screen
61
+ .right-dropdown-overflown {
62
+ .dropdown-menu.show {
63
+ left: -75% !important;
64
+ }
65
+ }
66
+
67
+ .right-dropdown-overflown-lg {
68
+ @include media-breakpoint-up(lg) {
69
+ .dropdown-menu.show {
70
+ left: -75%;
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,42 @@
1
+ // Bootstrap alerts for flash message types
2
+ .alert-error {
3
+ @extend .alert-danger;
4
+ }
5
+ .alert-alert {
6
+ @extend .alert-warning;
7
+ }
8
+ .alert-notice {
9
+ @extend .alert-info;
10
+ }
11
+
12
+ .flash-alert-container {
13
+ position: fixed;
14
+ z-index: 1049; // Modal z-index minus 1
15
+ width: 90%;
16
+ max-width: 500px;
17
+ top: 48px;
18
+ right: 48px;
19
+ .alert {
20
+ box-shadow: 1px 1px 2px rgba(black, 0.1);
21
+ margin-bottom: 0;
22
+ margin-top: 10px;
23
+ &:first-of-type {
24
+ margin-top: 0;
25
+ }
26
+ }
27
+ // When extra small, 48px over is too far!
28
+ @include media-breakpoint-down(xs) {
29
+ right: 3%;
30
+ }
31
+ }
32
+
33
+ .valet-interface .flash-alert-container {
34
+ position: relative;
35
+ z-index: 1;
36
+ width: 100%;
37
+ top: 0;
38
+ left: 0;
39
+ .alert {
40
+ margin-bottom: 0.5rem;
41
+ }
42
+ }
@@ -0,0 +1,36 @@
1
+ .pagination-flex {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ opacity: 0.65; // Make it a little less prominent, it isn't the most important thing on the page
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 {
14
+ display: flex;
15
+ flex-basis: 0;
16
+ flex-grow: 1;
17
+ margin-top: 0.5rem;
18
+ }
19
+ .per-page {
20
+ min-width: 9rem;
21
+ max-width: 9rem;
22
+ }
23
+ .pagination-number {
24
+ margin-left: 0.5rem;
25
+ }
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
+ }
@@ -0,0 +1,175 @@
1
+ // Some tables have skip-user as an option. Because of caching, we always want the same columns
2
+ // So include the user and hide it the class is enabled
3
+ .skip-user .user-cell,
4
+ .skip-parking-location .parking-location-cell {
5
+ display: none;
6
+ }
7
+
8
+ // ^ is bikehub unique styles, the following is shared with Bike Index
9
+
10
+ // Full screen table stuff
11
+ @mixin full-screen-table-overflown {
12
+ // Enable scrolling and make it edge to edge
13
+ // separate class so it can be applied via js if applicable
14
+ overflow-x: scroll;
15
+ margin-left: -15px;
16
+ margin-right: -15px;
17
+ }
18
+
19
+ .full-screen-table-overflown {
20
+ @include full-screen-table-overflown;
21
+ }
22
+
23
+ .full-screen-table {
24
+ @include media-breakpoint-down(sm) {
25
+ @include full-screen-table-overflown;
26
+ }
27
+
28
+ td ul {
29
+ padding: 0 0 0 1.5rem;
30
+ margin: 0.5rem 0 0.5rem;
31
+ }
32
+
33
+ // Dropdown headers
34
+ .dropdown-toggle {
35
+ font-weight: normal;
36
+ &:active,
37
+ &.active {
38
+ font-weight: bold;
39
+ text-decoration: underline;
40
+ }
41
+ }
42
+ }
43
+
44
+ .table-list {
45
+ @extend .table;
46
+ @extend .table-striped;
47
+ @extend .table-bordered;
48
+ @extend .table-sm;
49
+ tr td {
50
+ line-height: 1.5;
51
+ &:first-child {
52
+ font-size: 75%;
53
+ font-style: italic;
54
+ text-align: right;
55
+ padding: 9px 4px 4px;
56
+ line-height: 1.25;
57
+ }
58
+ &:first-child.full-width-data {
59
+ font-size: 100%;
60
+ font-style: normal;
61
+ text-align: left;
62
+ }
63
+ // use last, rather than first, to enable full width single rows
64
+ &:last-child {
65
+ width: 85%; // This is effectively min-width for tables
66
+ }
67
+ }
68
+ tr.active-row {
69
+ background-color: #ebf5fb !important;
70
+ a {
71
+ text-decoration: underline;
72
+ }
73
+ }
74
+ &.wide-definition tr td {
75
+ &:last-child {
76
+ width: 70%;
77
+ }
78
+ }
79
+ .inline-images img {
80
+ display: inline-block;
81
+ width: 31%;
82
+ max-width: 150px;
83
+ margin-right: 3%;
84
+ }
85
+ }
86
+
87
+ table thead.sortable {
88
+ th {
89
+ font-weight: normal;
90
+ a.sortable-link {
91
+ display: block;
92
+ position: relative;
93
+ // To give a spot for the sortable direction
94
+ &.active {
95
+ padding-right: 1.5rem;
96
+ }
97
+ span.sortable-direction {
98
+ display: block;
99
+ position: absolute;
100
+ right: 0;
101
+ top: 0;
102
+ }
103
+ &.active {
104
+ font-weight: strong;
105
+ text-decoration: underline;
106
+ }
107
+ }
108
+ }
109
+ }
110
+ .code-small {
111
+ pre {
112
+ margin-bottom: 0;
113
+ padding: 0;
114
+ border: none;
115
+ }
116
+ code {
117
+ position: relative;
118
+ }
119
+ }
120
+
121
+ // Random special formatting bits
122
+ table {
123
+ .table-cell-check {
124
+ font-family: Courier;
125
+ text-align: center;
126
+ font-weight: bold;
127
+ }
128
+
129
+ code {
130
+ word-break: break-all;
131
+ }
132
+
133
+ .data-cell {
134
+ pre {
135
+ padding: 0.25rem 0.5rem;
136
+ margin: 0 0 0.5rem;
137
+ }
138
+ &.only-data {
139
+ padding: 0;
140
+ @extend .code-small;
141
+ pre {
142
+ background: none;
143
+ }
144
+ }
145
+ &.small {
146
+ padding: 0;
147
+ pre {
148
+ border: none;
149
+ font-size: 80%;
150
+ margin: 0;
151
+ }
152
+ }
153
+ }
154
+
155
+ .less-strong-hold {
156
+ position: relative;
157
+ min-height: 1.25em;
158
+ }
159
+
160
+ .less-strong-right {
161
+ position: absolute;
162
+ right: -0.3em;
163
+ line-height: 1;
164
+ bottom: -0.2em;
165
+ font-size: 0.8em;
166
+ @extend .less-strong;
167
+ }
168
+
169
+ .photo-cell {
170
+ text-align: center;
171
+ img {
172
+ max-width: 150px;
173
+ }
174
+ }
175
+ }
@@ -0,0 +1,83 @@
1
+ // Handy helper classes
2
+ .less-strong {
3
+ opacity: 0.65;
4
+ // Couldn't get & + input to work, so manually specifying the applicable element classes
5
+ a:hover,
6
+ & + a:hover,
7
+ .btn:hover,
8
+ &.btn:hover,
9
+ .btn:focus,
10
+ &.btn:focus,
11
+ .form-control:hover,
12
+ &.form-control:hover,
13
+ .form-control:focus,
14
+ &.form-control:focus {
15
+ opacity: 1;
16
+ }
17
+ }
18
+
19
+ .less-less-strong {
20
+ @extend .less-strong;
21
+ opacity: 0.3;
22
+ }
23
+
24
+ .gray-link {
25
+ a,
26
+ & {
27
+ color: $gray-600 !important;
28
+ opacity: 0.65;
29
+ text-decoration: underline;
30
+ }
31
+ &:hover,
32
+ &:active,
33
+ &.active {
34
+ opacity: 0.9;
35
+ }
36
+ }
37
+
38
+ label,
39
+ input[type="checkbox"],
40
+ input[type="radio"] {
41
+ cursor: pointer;
42
+ }
43
+
44
+ .em {
45
+ font-style: italic;
46
+ }
47
+
48
+ .hidden-sm-down {
49
+ @include media-breakpoint-down(sm) {
50
+ display: none;
51
+ }
52
+ }
53
+
54
+ .hidden-xs-down {
55
+ @include media-breakpoint-down(xs) {
56
+ display: none;
57
+ }
58
+ }
59
+
60
+ .convertedTime {
61
+ white-space: nowrap;
62
+ }
63
+
64
+ .text-underline {
65
+ text-decoration: underline;
66
+ }
67
+
68
+ .uuid-display {
69
+ white-space: nowrap;
70
+ }
71
+
72
+ .overflow-scroll {
73
+ overflow: scroll;
74
+ }
75
+
76
+ .text-color-link {
77
+ color: $text-color;
78
+ text-decoration: underline;
79
+ }
80
+
81
+ .center {
82
+ text-align: center;
83
+ }
@@ -0,0 +1,2 @@
1
+ $text-color: #212529;
2
+
@@ -0,0 +1,13 @@
1
+ @import 'bootstrap/scss/bootstrap';
2
+
3
+ // Variables
4
+ @import "tranzito_utils/variables";
5
+
6
+ // Utilities
7
+ @import "tranzito_utils/utils";
8
+ @import "tranzito_utils/pagination";
9
+ @import "tranzito_utils/table_extensions";
10
+
11
+ // Sections
12
+ @import "tranzito_utils/admin_header";
13
+ @import "tranzito_utils/alerts";
@@ -0,0 +1,10 @@
1
+ .flash-alert-container
2
+ - if flash.present?
3
+ - flash.each do |type, message|
4
+ - next unless message.present?
5
+ .alert{ class: "alert-#{type}" }
6
+ %button.close{ 'data-dismiss' => 'alert' } ×
7
+ = message
8
+ - if flash[:link]
9
+ %br
10
+ link: #{link_to flash[:link], flash[:link]}
@@ -5,6 +5,14 @@ module TranzitoUtils
5
5
  extend ActiveSupport::Concern
6
6
  PERIOD_TYPES = %w[hour day month year week all next_week next_month].freeze
7
7
 
8
+ included do
9
+ helper_method :controller_namespace
10
+ end
11
+
12
+ def controller_namespace
13
+ @controller_namespace ||= self.class.module_parent.name != "Object" ? self.class.module_parent.name.downcase : nil
14
+ end
15
+
8
16
  # For setting periods, particularly for graphing
9
17
  def set_period
10
18
  set_timezone
@@ -3,6 +3,9 @@ module TranzitoUtils
3
3
  initializer "tranzito_utils.config", before: :load_config_initializers do |app|
4
4
  # Setting the default timezone for timeparser service from host application configuration
5
5
  TranzitoUtils::DEFAULT[:time_zone] = ActiveSupport::TimeZone[Rails.application.config.time_zone]
6
+
7
+ # Setting the default application display name
8
+ TranzitoUtils::DEFAULT[:application_display_name] = Rails.application.class.module_parent.to_s
6
9
  end
7
10
  end
8
11
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TranzitoUtils
4
+ module AdminHelper
5
+ def admin_number_display(number)
6
+ content_tag(:span, number_with_delimiter(number), class: (number == 0 ? "less-less-strong" : ""))
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TranzitoUtils
4
+ module Helpers
5
+ include TranzitoUtils::AdminHelper
6
+ include TranzitoUtils::GraphingHelper
7
+ include TranzitoUtils::SortableHelper
8
+
9
+ def in_admin?
10
+ controller_namespace == "admin"
11
+ end
12
+
13
+ def page_title
14
+ return @page_title if defined?(@page_title)
15
+ prefix = (in_admin? ? "🧰" : TranzitoUtils::DEFAULT[:application_display_name])
16
+ return "#{prefix} #{@prefixed_page_title}" if @prefixed_page_title.present?
17
+ [
18
+ prefix,
19
+ default_action_name_title,
20
+ controller_title_for_action
21
+ ].compact.join(" ")
22
+ end
23
+
24
+ def active_link(link_text, link_path, html_options = {})
25
+ match_controller = html_options.delete(:match_controller)
26
+ html_options[:class] ||= ""
27
+ html_options[:class] += " active" if current_page_active?(link_path, match_controller)
28
+ link_to(raw(link_text), link_path, html_options).html_safe
29
+ end
30
+
31
+ def current_page_active?(link_path, match_controller = false)
32
+ link_path = Rails.application.routes.recognize_path(link_path)
33
+ active_path = Rails.application.routes.recognize_path(request.url)
34
+ matches_controller = active_path[:controller] == link_path[:controller]
35
+ return true if match_controller && matches_controller
36
+ current_page?(link_path) || matches_controller && active_path[:action] == link_path[:action]
37
+ rescue # This mainly fails in testing - but why not rescue always
38
+ false
39
+ end
40
+
41
+ def current_user_time_preference_script
42
+ time_preference = current_user&.time_preference || User.time_preferences.first
43
+ scrpt = ""
44
+ if %w[single_format_local single_format_event].include?(time_preference)
45
+ scrpt += "window.timeParserSingleFormat=true;"
46
+ end
47
+ if %w[single_format_event variable_format_event].include?(time_preference)
48
+ scrpt += 'window.localTimezone="America/Los_Angeles";'
49
+ end
50
+ scrpt
51
+ end
52
+
53
+ def pretty_print_json(data)
54
+ require "coderay"
55
+ CodeRay.scan(JSON.pretty_generate(data), :json).div.html_safe
56
+ end
57
+
58
+ private
59
+
60
+ def default_action_name_title
61
+ if action_name == "show"
62
+ # Take up less space for admin
63
+ return in_admin? ? nil : "Display"
64
+ end
65
+ action_name == "index" ? nil : action_name.titleize
66
+ end
67
+
68
+ def controller_title_for_action
69
+ return @controller_display_name if defined?(@controller_display_name)
70
+ # No need to include parking
71
+ c_name = controller_name.gsub("parking_location", "location")
72
+ return c_name.titleize if %(index).include?(action_name)
73
+ c_name.singularize.titleize
74
+ end
75
+ end
76
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TranzitoUtils
4
- VERSION = "1.0.3"
4
+ VERSION = "1.1.1"
5
5
  end
@@ -8,14 +8,17 @@ module TranzitoUtils
8
8
  earliest_year: 1900,
9
9
  latest_year: (Time.current.year + 100),
10
10
  additional_search_keys: [],
11
- time_zone: ""
11
+ time_zone: "",
12
+ application_display_name: ""
12
13
  }
13
14
  end
14
15
 
15
16
  require "tranzito_utils/concerns/set_period"
16
17
  require "tranzito_utils/concerns/sortable_table"
18
+ require "tranzito_utils/helpers/admin_helper"
17
19
  require "tranzito_utils/helpers/graphing_helper"
18
20
  require "tranzito_utils/helpers/sortable_helper"
21
+ require "tranzito_utils/helpers/helpers"
19
22
  require "tranzito_utils/services/time_parser"
20
23
  require "tranzito_utils/services/normalize"
21
24
  require "tranzito_utils/gem"
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.0.3
4
+ version: 1.1.1
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: 2022-09-29 00:00:00.000000000 Z
13
+ date: 2022-10-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -26,6 +26,20 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '6.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: coderay
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
29
43
  description: Ruby gem contain several modules mainly containing the helpers, concerns
30
44
  and services for personal use by Tranzito
31
45
  email:
@@ -37,6 +51,15 @@ files:
37
51
  - MIT-LICENSE
38
52
  - README.md
39
53
  - Rakefile
54
+ - app/assets/builds/tranzito_utils-compiled.css
55
+ - app/assets/stylesheets/tranzito_utils.scss
56
+ - app/assets/stylesheets/tranzito_utils/_admin_header.scss
57
+ - app/assets/stylesheets/tranzito_utils/_alerts.scss
58
+ - app/assets/stylesheets/tranzito_utils/_pagination.scss
59
+ - app/assets/stylesheets/tranzito_utils/_table_extensions.scss
60
+ - app/assets/stylesheets/tranzito_utils/_utils.scss
61
+ - app/assets/stylesheets/tranzito_utils/_variables.scss
62
+ - app/views/tranzito_utils/_flash_messages.haml
40
63
  - app/views/tranzito_utils/_period_select.html.haml
41
64
  - config/locales/en.yml
42
65
  - lib/generators/tranzito_utils/install_generator.rb
@@ -45,7 +68,9 @@ files:
45
68
  - lib/tranzito_utils/concerns/set_period.rb
46
69
  - lib/tranzito_utils/concerns/sortable_table.rb
47
70
  - lib/tranzito_utils/gem.rb
71
+ - lib/tranzito_utils/helpers/admin_helper.rb
48
72
  - lib/tranzito_utils/helpers/graphing_helper.rb
73
+ - lib/tranzito_utils/helpers/helpers.rb
49
74
  - lib/tranzito_utils/helpers/sortable_helper.rb
50
75
  - lib/tranzito_utils/services/normalize.rb
51
76
  - lib/tranzito_utils/services/time_parser.rb