ndr_ui 2.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6f096a99d6497432a68a4d9f0b8b136e18b032d4492a9db7f68b6f599e23659
4
- data.tar.gz: afa294bc04877c1e805baf95a04fae23107c07c33fe2015302d2004264d47735
3
+ metadata.gz: 948171552053d8201249a7ad4d0b1aff5743a844c01339dfac66f7458307e03f
4
+ data.tar.gz: 27d8fa3cc83c56584f3c5a2caf786216143794b3632d867f1cb8fd25412b76fc
5
5
  SHA512:
6
- metadata.gz: 76bf0eec7211d4c0aa55321495cdb54fa19897e1cdcfd7194c2acbd87afccbf6c0b2bd31abf1199e4791083d11e41eef35dd60cebbc16430f851ddea321da328
7
- data.tar.gz: 4cd0dcd9fb8b8bca3035c8a52956a49bf3ed4a29212e2169ca2b29f7bc7b9d1ec7776c75ecdefbf69df062beddb1a6cdf19fd270e987acbfb06f9d75f9f020d4
6
+ metadata.gz: d3c9dd26dc4dec27e06208b20f8c606466dd0fff4570e32874b76fd44a9a9b65eba252449f66aeb322f0cb6f00584dd4b7650f8780897b157c2c809a95131c7f
7
+ data.tar.gz: 32d327a35c5656866922cdcf7c0f2a9badcfa47ca53f5a064b85eed5f507ec6c3b76ae1a247072cea612dcc5c2695480130d4ad27a7ffa2cb511e368c13eaaa0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # NdrUi [![Build Status](https://travis-ci.org/PublicHealthEngland/ndr_ui.svg)](https://travis-ci.org/PublicHealthEngland/ndr_ui) [![Gem Version](https://badge.fury.io/rb/ndr_ui.svg)](https://badge.fury.io/rb/ndr_ui) [![Documentation](https://img.shields.io/badge/ndr_ui-docs-blue.svg)](https://www.rubydoc.info/gems/ndr_ui)
1
+ # NdrUi [![Build Status](https://github.com/publichealthengland/ndr_ui/workflows/Test/badge.svg)](https://github.com/publichealthengland/ndr_ui/actions?query=workflow%3Atest) [![Gem Version](https://badge.fury.io/rb/ndr_ui.svg)](https://rubygems.org/gems/ndr_ui) [![Documentation](https://img.shields.io/badge/ndr_ui-docs-blue.svg)](https://www.rubydoc.info/gems/ndr_ui)
2
2
 
3
3
  This is the Public Health England (PHE) National Disease Registration (NDR) User Interface rubygem,
4
4
  providing a set of core features:
@@ -1 +1 @@
1
- //= require bootstrap-datepicker-1.6.0-dist/js/bootstrap-datepicker
1
+ //= require js/bootstrap-datepicker
@@ -1,4 +1,4 @@
1
- //= require jquery-timeago-1.5.3/jquery.timeago.js
1
+ //= require jquery.timeago.js
2
2
 
3
3
  jQuery(document).ready(function() {
4
4
  jQuery("time.timeago,abbr.timeago").timeago();
@@ -1,4 +1,4 @@
1
- @import "bootstrap-datepicker.scss";
1
+ @import 'bootstrap-datepicker-scss-fix.scss';
2
2
 
3
3
  // Ensure date picker renders over the static nav
4
4
  .datepicker {
@@ -13,7 +13,17 @@ module NdrUi
13
13
  # See the source code for ActionView::Helpers::Tags::Label for more.
14
14
  #
15
15
  # QUESTION: Parameterise the tooltip so we're not just bound to a question_tooltip ?
16
- def label(method, text = nil, **options, &block)
16
+ def label(method, content_or_options = nil, options = nil, &block)
17
+ options ||= {}
18
+
19
+ content_is_options = content_or_options.is_a?(Hash)
20
+ if content_is_options
21
+ options.merge! content_or_options
22
+ text = nil
23
+ else
24
+ text = content_or_options
25
+ end
26
+
17
27
  tooltip_text = options.delete(:tooltip)
18
28
 
19
29
  super(method, text, options) do |builder|
@@ -227,9 +227,15 @@ module NdrUi
227
227
  if horizontal = options.delete(:horizontal)
228
228
  # set the form html class for horizontal bootstrap forms
229
229
  options[:html][:class] ||= ''
230
- options[:html][:class] = (options[:html][:class].split(' ') << 'form-horizontal').uniq.join(' ')
230
+ classes = (options[:html][:class].split(' ') << 'form-horizontal').uniq.join(' ')
231
+ options[:html][:class] = classes
231
232
  end
232
233
 
234
+ # stimuls controller, default `form_controller`
235
+ options[:html][:'data-controller'] ||= ''
236
+ controllers = (options[:html][:'data-controller'].split(' ') << 'form').uniq.join(' ')
237
+ options[:html][:'data-controller'] = controllers
238
+
233
239
  # We switch autocomplete off by default
234
240
  raise 'autocomplete should be defined an html option' if options[:autocomplete]
235
241
  options[:html][:autocomplete] ||= 'off'
@@ -258,6 +264,11 @@ module NdrUi
258
264
  options[:html][:class] = classes
259
265
  end
260
266
 
267
+ # stimuls controller, default `form_controller`
268
+ options[:html][:'data-controller'] ||= ''
269
+ controllers = (options[:html][:'data-controller'].split(' ') << 'form').uniq.join(' ')
270
+ options[:html][:'data-controller'] = controllers
271
+
261
272
  # We switch autocomplete off by default
262
273
  raise 'autocomplete should be defined an html option' if options[:autocomplete]
263
274
  options[:html][:autocomplete] ||= 'off'
@@ -434,6 +445,36 @@ module NdrUi
434
445
  content_tag(:div, capture(&block), class: 'btn-group')
435
446
  end
436
447
 
448
+ # Creates a Boostrap 'New' link.
449
+ #
450
+ # ==== Signatures
451
+ #
452
+ # new_link(path, options = {})
453
+ #
454
+ # ==== Examples
455
+ #
456
+ # <%= new_link('#') %>
457
+ # # => <a title="New" class="btn btn-primary btn-xs" href="#">
458
+ # <span class="glyphicon glyphicon-plus-sign"></span>
459
+ # </a>
460
+ #
461
+ # <%= new_link(Post.new) %>
462
+ # # => <a title="New" class="btn btn-primary btn-xs" href="/posts/new">
463
+ # <span class="glyphicon glyphicon-plus-sign"></span>
464
+ # </a>
465
+ #
466
+ def new_link(path, options = {})
467
+ return unless options.delete(:skip_authorization) || ndr_can?(:new, path)
468
+
469
+ path = new_polymorphic_path(path) if can_generate_polymorphic_path?(path)
470
+
471
+ defaults = {
472
+ icon: 'plus-sign', title: 'New', path: path, class: 'btn btn-primary btn-xs'
473
+ }
474
+
475
+ link_to_with_icon(defaults.merge(options))
476
+ end
477
+
437
478
  # Creates a Boostrap 'Details' link.
438
479
  #
439
480
  # ==== Signatures
@@ -448,7 +489,7 @@ module NdrUi
448
489
  # </a>
449
490
  #
450
491
  def details_link(path, options = {})
451
- return unless ndr_can?(:read, path)
492
+ return unless options.delete(:skip_authorization) || ndr_can?(:read, path)
452
493
 
453
494
  link_to_with_icon({ icon: 'share-alt', title: 'Details', path: path }.merge(options))
454
495
  end
@@ -467,7 +508,7 @@ module NdrUi
467
508
  # </a>
468
509
  #
469
510
  def edit_link(path, options = {})
470
- return unless ndr_can?(:edit, path)
511
+ return unless options.delete(:skip_authorization) || ndr_can?(:edit, path)
471
512
 
472
513
  path = edit_polymorphic_path(path) if path.is_a?(ActiveRecord::Base)
473
514
 
@@ -488,7 +529,7 @@ module NdrUi
488
529
  # <span class="glyphicon glyphicon-trash icon-white"></span>
489
530
  # </a>'
490
531
  def delete_link(path, options = {})
491
- return unless ndr_can?(:delete, path)
532
+ return unless options.delete(:skip_authorization) || ndr_can?(:delete, path)
492
533
 
493
534
  defaults = {
494
535
  icon: 'trash icon-white', title: 'Delete', path: path,
@@ -563,5 +604,12 @@ module NdrUi
563
604
 
564
605
  can?(action, subject, *extra_args)
565
606
  end
607
+
608
+ def can_generate_polymorphic_path?(path)
609
+ case path
610
+ when Array, ActiveRecord::Base then true
611
+ else false
612
+ end
613
+ end
566
614
  end
567
615
  end
@@ -3,7 +3,7 @@ module NdrUi
3
3
  module CssHelper
4
4
  # This method merges the specified css_classes into the options hash
5
5
  def css_class_options_merge(options, css_classes = [], &block)
6
- options.symbolize_keys!
6
+ options = options.symbolize_keys
7
7
  css_classes += options[:class].split(' ') if options.include?(:class)
8
8
  yield(css_classes) if block_given?
9
9
  options[:class] = css_classes.join(' ') unless css_classes.empty?
data/config/routes.rb CHANGED
@@ -1,2 +1,5 @@
1
1
  Rails.application.routes.draw do
2
+ resources :posts do
3
+ resources :comments
4
+ end
2
5
  end
data/lib/ndr_ui/engine.rb CHANGED
@@ -6,7 +6,13 @@ module NdrUi
6
6
  class Engine < ::Rails::Engine
7
7
  isolate_namespace NdrUi
8
8
 
9
- config.assets.paths << File.expand_path('../../../vendor/assets', __FILE__)
9
+ # Hook into host app's asset pipeline, allowing all the gem's assets
10
+ # to be complied alongside. This allows the gem's assets to be referenced
11
+ # directly by templates without issue, rather than needing to go via
12
+ # an asset manifest in the host.
13
+ initializer 'ndr_ui.assets.precompile' do |app|
14
+ app.config.assets.precompile += %w(*.scss *.js *.gif)
15
+ end
10
16
 
11
17
  # We configure the generator of the host app
12
18
  config.app_generators do |g|
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This stores the current version of the NdrUi gem. Use semantic versioning http://semver.org
4
4
  module NdrUi
5
- VERSION = '2.1.1'.freeze
5
+ VERSION = '3.2.0'.freeze
6
6
  end
@@ -0,0 +1 @@
1
+ ./../bootstrap-datepicker-1.6.0-dist/css/bootstrap-datepicker3.css
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndr_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NDR Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -31,33 +31,33 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7.0'
33
33
  - !ruby/object:Gem::Dependency
34
- name: bootstrap-sass
34
+ name: sprockets
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 3.4.1
39
+ version: '4.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 3.4.1
46
+ version: '4.0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: sass-rails
48
+ name: bootstrap-sass
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '3.2'
53
+ version: 3.4.1
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '3.2'
60
+ version: 3.4.1
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: jquery-rails
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -118,22 +118,16 @@ dependencies:
118
118
  name: ndr_dev_support
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '3.1'
124
121
  - - ">="
125
122
  - !ruby/object:Gem::Version
126
- version: 3.1.3
123
+ version: 5.10.2
127
124
  type: :development
128
125
  prerelease: false
129
126
  version_requirements: !ruby/object:Gem::Requirement
130
127
  requirements:
131
- - - "~>"
132
- - !ruby/object:Gem::Version
133
- version: '3.1'
134
128
  - - ">="
135
129
  - !ruby/object:Gem::Version
136
- version: 3.1.3
130
+ version: 5.10.2
137
131
  - !ruby/object:Gem::Dependency
138
132
  name: simplecov
139
133
  requirement: !ruby/object:Gem::Requirement
@@ -162,6 +156,20 @@ dependencies:
162
156
  - - "~>"
163
157
  - !ruby/object:Gem::Version
164
158
  version: 1.1.0
159
+ - !ruby/object:Gem::Dependency
160
+ name: puma
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
165
173
  description: Provides Rails applications with additional support for the Twitter Bootstrap
166
174
  UI framework
167
175
  email: []
@@ -287,7 +295,7 @@ files:
287
295
  - vendor/assets/bootstrap-datepicker-1.6.0-dist/locales/bootstrap-datepicker.vi.min.js
288
296
  - vendor/assets/bootstrap-datepicker-1.6.0-dist/locales/bootstrap-datepicker.zh-CN.min.js
289
297
  - vendor/assets/bootstrap-datepicker-1.6.0-dist/locales/bootstrap-datepicker.zh-TW.min.js
290
- - vendor/assets/bootstrap-datepicker.scss
298
+ - vendor/assets/datepicker-scss-fix/bootstrap-datepicker-scss-fix.scss
291
299
  - vendor/assets/jquery-timeago-1.5.3/jquery.timeago.js
292
300
  - vendor/assets/jquery-timeago-1.5.3/locales/README.md
293
301
  - vendor/assets/jquery-timeago-1.5.3/locales/jquery.timeago.af.js
@@ -367,14 +375,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
367
375
  requirements:
368
376
  - - ">="
369
377
  - !ruby/object:Gem::Version
370
- version: 2.4.0
378
+ version: 2.6.0
371
379
  required_rubygems_version: !ruby/object:Gem::Requirement
372
380
  requirements:
373
381
  - - ">="
374
382
  - !ruby/object:Gem::Version
375
383
  version: '0'
376
384
  requirements: []
377
- rubygems_version: 3.0.3
385
+ rubygems_version: 3.1.6
378
386
  signing_key:
379
387
  specification_version: 4
380
388
  summary: NDR UI Rails Engine
@@ -1 +0,0 @@
1
- ./bootstrap-datepicker-1.6.0-dist/css/bootstrap-datepicker3.css