renalware-core 2.0.164 → 2.0.165

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: de3ed99a5d8710a68b891a50ee0a575b1d3b141c169eb3788b05aee36b5a6db2
4
- data.tar.gz: dfb9b199413bccd4f215afe49dc7fe6e9f3a9ff6b1c15ba2dff18ad7a7f3aec7
3
+ metadata.gz: 700d5b2079008a4d7003114ffc54c354e66ccc522b264cf8be06f7affef1b608
4
+ data.tar.gz: 9bbb9f90eda8d067104d6bbb88d3abd47a9c31c7cd31c4913f4fe400f4d13405
5
5
  SHA512:
6
- metadata.gz: d88f8b264a43ae6d9907fba7492fdef6a7980d852ce765f7449964aaaceab5545eae2ccbe705aab9379513522dbe09396161959a72621f089ab0689f4173ca5f
7
- data.tar.gz: c5450e7a0a13c2ae617c300fc65c9c509e0d9da36ba2479a8064c6653436298b16eee9d08fd57da31648193699f1500cbe3c782fc8ce2f386febbf750f568a1a
6
+ metadata.gz: 34ccd19919e8e560fd814a94faaa1529ba058780b8c08afca122f737668a738ddd7865af63f8fb93446a3f18c85dfec56aaccb59429a12354c39b3f44b9779a6
7
+ data.tar.gz: 03a28eee3622a1b1e856a4d36549e85bdff271cc74f1e1f0db492dfbba1f07a8fa67fd7206919b7406fac404456cb65aa36d9da17c887e3eb886578aa737232e
@@ -409,6 +409,12 @@ table {
409
409
  }
410
410
  }
411
411
 
412
+ tr.deleted {
413
+ td {
414
+ background-color: lighten($nhs-red, 53);
415
+ }
416
+ }
417
+
412
418
  table.report {
413
419
  table-layout: auto;
414
420
 
@@ -24,6 +24,7 @@ ul.side-nav.side-nav--admin
24
24
  = super_admin_menu_item "Print batches", renalware.letters_batches_path, %r{letters/batches}
25
25
  = super_admin_menu_item "OBX", renalware.pathology_observation_descriptions_path, %r{admin/pathology_observation_descriptions}
26
26
  = super_admin_menu_item "Pathology Code Groups", renalware.pathology_code_groups_path, %r{pathology/code_groups}
27
+ = super_admin_menu_item "Virology Vaccination Types", renalware.virology_vaccination_types_path, %r{virology/vaccination_types}
27
28
  = admin_menu_item "Mailshots", renalware.letters_mailshots_path, %r{letters/mailshots}
28
29
  = super_admin_menu_item "Playground", renalware.admin_playground_path, %r{admin/playground}
29
30
  = developer_menu_item "HL7 Test", renalware.new_feeds_hl7_test_message_path, %r{admin/123}
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/virology"
4
+
5
+ module Renalware
6
+ module Virology
7
+ class VaccinationTypesController < BaseController
8
+ def index
9
+ types = VaccinationType.with_deleted.ordered
10
+ authorize types
11
+ render locals: { types: types }
12
+ end
13
+
14
+ def edit
15
+ type = find_and_authorise_type
16
+ render locals: { type: type }
17
+ end
18
+
19
+ def update
20
+ type = find_and_authorise_type
21
+ if type.update(type_params)
22
+ redirect_to virology_vaccination_types_path
23
+ else
24
+ render :edit, locals: { type: type }
25
+ end
26
+ end
27
+
28
+ def new
29
+ type = VaccinationType.new
30
+ authorize type
31
+ render locals: { type: type }
32
+ end
33
+
34
+ def create
35
+ type = VaccinationType.new(type_params)
36
+ authorize type
37
+ if type.save
38
+ redirect_to virology_vaccination_types_path
39
+ else
40
+ render :new, locals: { type: type }
41
+ end
42
+ end
43
+
44
+ def destroy
45
+ find_and_authorise_type.destroy!
46
+ redirect_to virology_vaccination_types_path
47
+ end
48
+
49
+ def sort
50
+ authorize VaccinationType, :sort?
51
+ ids = params[:virology_vaccination_type]
52
+ VaccinationType.sort(ids)
53
+ render json: ids
54
+ end
55
+
56
+ private
57
+
58
+ def find_and_authorise_type
59
+ VaccinationType.find(params[:id]).tap { |type| authorize type }
60
+ end
61
+
62
+ def type_params
63
+ params
64
+ .require("virology_vaccination_type")
65
+ .permit(:name, :code, :position)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -5,12 +5,34 @@ require_dependency "renalware/virology"
5
5
  module Renalware
6
6
  module Virology
7
7
  class VaccinationType < ApplicationRecord
8
- validates :name, presence: true, uniqueness: true
9
- validates :code, presence: true, uniqueness: true
8
+ include Sortable
9
+
10
+ class UniquenessIncludingDeletedValidator < ActiveModel::EachValidator
11
+ def validate_each(record, attribute, value)
12
+ return unless record.send(:"#{attribute}_changed?")
13
+
14
+ if record.class.with_deleted.exists?(attribute => value)
15
+ record.errors.add attribute, (options[:message] || "already used")
16
+ end
17
+ end
18
+ end
19
+ validates :name, presence: true, uniqueness_including_deleted: true
20
+ validates :code, presence: true, uniqueness_including_deleted: true
21
+ before_create :underscore_code
10
22
 
11
23
  acts_as_paranoid
12
24
 
13
- scope :ordered, -> { order(position: :asc, name: :asc) }
25
+ scope :ordered, -> { order(deleted_at: :desc, position: :asc, name: :asc) }
26
+
27
+ def self.policy_class
28
+ BasePolicy
29
+ end
30
+
31
+ def underscore_code
32
+ return if code.blank?
33
+
34
+ self.code = code.downcase.tr(" ", " ").tr(" ", "_")
35
+ end
14
36
  end
15
37
  end
16
38
  end
@@ -0,0 +1,10 @@
1
+ = simple_form_for type do |f|
2
+ = f.input :name
3
+ - if type.new_record?
4
+ = f.input :code, hint: "Will be converted to lower case with underscores"
5
+ - else
6
+ p.px-0.mb-5
7
+ ' Code:
8
+ code= type.code
9
+
10
+ = f.submit class: :button
@@ -0,0 +1,3 @@
1
+ = within_new_admin_layout(title: "Edit",
2
+ breadcrumbs: breadcrumb_for("Virology Vaccination Types", virology_vaccination_types_path)) do
3
+ = render "form", type: type
@@ -0,0 +1,42 @@
1
+ = content_for(:actions) do
2
+ = link_to t("new_record.link_title"),
3
+ new_virology_vaccination_type_path,
4
+ class: "button"
5
+
6
+ = within_new_admin_layout(title: "Virology Vaccination Types") do
7
+ .rounded-md.bg-blue-100.px-3.py-2.flex.items-start.shadow.mb-5
8
+ i.fas.fa-info-circle.mr-2.mt-1.text-blue-500
9
+ ' Deleting a type sets the 'deleted at' date, preventing the type from
10
+ ' being used prospectively.
11
+ br
12
+ ' The type's code cannot be edited once set, just in case it has already been used.
13
+ br
14
+ ' Drag and drop the icon to change the sort order.
15
+
16
+ table.vaccination_types
17
+ thead
18
+ tr
19
+ th.actions.col-width-small
20
+ th Name
21
+ th Code
22
+ th.text-center Sort order
23
+ th.col-width-date-time Created at
24
+ th.col-width-date-time Deleted at
25
+ tbody.sortables(data-rel=sort_virology_vaccination_types_path)
26
+ - types.each do |type|
27
+ = content_tag_for(:tr, type, class: "sortable #{type.deleted? ? 'deleted' : ''}") do
28
+ td.actions
29
+ - unless type.deleted?
30
+ =link_to "Edit", edit_virology_vaccination_type_path(type)
31
+ =link_to "Delete",
32
+ virology_vaccination_type_path(type),
33
+ method: :delete,
34
+ data: { confirm: "Are you sure you want to delete this type? Doing so will prevent it from being used prospectively."}
35
+
36
+ td= type.name
37
+ td= type.code
38
+ td.handle
39
+ - unless type.deleted?
40
+ i.fas.fa-bars
41
+ td= l(type.created_at)
42
+ td= l(type.deleted_at)
@@ -0,0 +1,3 @@
1
+ = within_new_admin_layout(title: "New",
2
+ breadcrumbs: breadcrumb_for("Virology Vaccination Types", virology_vaccination_types_path)) do
3
+ = render "form", type: type
@@ -8,6 +8,7 @@ super_admin:
8
8
  - Renalware::HD::CannulationType
9
9
  - Renalware::System::Download
10
10
  - Renalware::Pathology::ObservationDescription
11
+ - Renalware::Virology::VaccinationType
11
12
  admin:
12
13
  - Renalware::User
13
14
  - Renalware::BagType
@@ -10,3 +10,9 @@ resources :patients, only: [] do
10
10
  defaults: { slug: :vaccinations }
11
11
  end
12
12
  end
13
+
14
+ namespace :virology do
15
+ resources :vaccination_types do
16
+ post :sort, on: :collection
17
+ end
18
+ end
@@ -5,6 +5,6 @@ module Renalware
5
5
  # to creat that class even though its not used. If we don't do this zeitwerk
6
6
  # complains that version.rb does export a constant called Version.
7
7
  class VersionNumber
8
- VERSION = "2.0.164"
8
+ VERSION = "2.0.165"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.164
4
+ version: 2.0.165
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-18 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-import
@@ -1455,6 +1455,7 @@ files:
1455
1455
  - app/controllers/renalware/virology/base_controller.rb
1456
1456
  - app/controllers/renalware/virology/dashboards_controller.rb
1457
1457
  - app/controllers/renalware/virology/profiles_controller.rb
1458
+ - app/controllers/renalware/virology/vaccination_types_controller.rb
1458
1459
  - app/controllers/renalware/virology/vaccinations_controller.rb
1459
1460
  - app/documents/document/attribute_initializer.rb
1460
1461
  - app/documents/document/attribute_initializer/active_model.rb
@@ -3330,6 +3331,10 @@ files:
3330
3331
  - app/views/renalware/virology/dashboards/show.html.slim
3331
3332
  - app/views/renalware/virology/profiles/_summary.html.slim
3332
3333
  - app/views/renalware/virology/profiles/edit.html.slim
3334
+ - app/views/renalware/virology/vaccination_types/_form.html.slim
3335
+ - app/views/renalware/virology/vaccination_types/edit.html.slim
3336
+ - app/views/renalware/virology/vaccination_types/index.html.slim
3337
+ - app/views/renalware/virology/vaccination_types/new.html.slim
3333
3338
  - app/views/renalware/virology/vaccinations/_alert.html.slim
3334
3339
  - app/views/renalware/virology/vaccinations/_cell.html.slim
3335
3340
  - app/views/renalware/virology/vaccinations/_inputs.html.slim