From 19127a29cc28f89831727a547be0a600244cd533 Mon Sep 17 00:00:00 2001 From: "Marco (Polo) Ornelas" Date: Wed, 18 Feb 2026 17:14:45 -0500 Subject: [PATCH 01/17] first try --- .browserslistrc | 1 - .ruby-version | 2 +- Gemfile | 35 +++-- app/controllers/new/templates_controller.rb | 2 +- app/controllers/templates_controller.rb | 2 +- app/entities/blocks/block.rb | 1 + app/entities/bodies/body.rb | 1 + app/entities/sections/section.rb | 2 +- app/entities/templates/template.rb | 2 +- .../pre_audit_report_generation_subscriber.rb | 1 - .../pre_audit_report_processor_subscriber.rb | 1 - app/helpers/application_helper.rb | 21 ++- app/javascript/packs/application.js | 39 ++++-- app/javascript/packs/application.scss | 1 - app/javascript/stylesheets/application.scss | 3 + app/javascript/stylesheets/signin.scss | 55 -------- app/javascript/stylesheets/site.scss | 21 --- app/liquid/tags/gist_tag.rb | 1 - app/liquid/tags/render_section.rb | 2 +- app/models/account.rb | 1 + .../effective/datatables/notices_datatable.rb | 12 +- app/models/entities/templates/main.rb | 1 + app/models/notice_builder.rb | 12 +- app/models/notice_kind.rb | 4 +- app/models/pdf_report.rb | 4 +- app/models/services/token_builder.rb | 8 +- app/models/templates/template_model.rb | 6 +- app/operations/documents/upload.rb | 48 ++++++- .../reports/generate_rcno_report.rb | 2 +- app/views/layouts/application.html.erb | 12 +- app/views/layouts/single_column.html.erb | 4 +- app/views/new/sections/_form.html.erb | 32 ++--- app/views/new/sections/edit.html.erb | 32 ++--- app/views/new/templates/_new_form.html.erb | 28 ++-- app/views/new/templates/_templates.html.erb | 16 +-- app/views/new/templates/edit.html.erb | 117 +++++++++-------- app/views/new/templates/index.html.erb | 24 ++-- app/views/shared/_nav_bar.html.erb | 2 +- app/views/templates/_form.html.erb | 62 ++++----- bin/docker-entrypoint | 9 ++ bin/rubocop | 8 ++ bin/shakapacker | 13 ++ bin/shakapacker-dev-server | 13 ++ bin/webpack | 20 --- bin/webpack-dev-server | 18 --- config/application.rb | 29 +++-- config/boot.rb | 6 +- config/deploy/production.rb | 1 + config/deploy/staging.rb | 1 + config/environment.rb | 2 +- config/environments/development.rb | 2 + config/environments/production.rb | 16 ++- config/environments/test.rb | 13 +- config/initializers/assets.rb | 6 +- config/initializers/event_source.rb | 4 +- .../initializers/filter_parameter_logging.rb | 5 +- config/initializers/liquid.rb | 2 +- .../new_framework_defaults_7_2.rb | 72 ++++++++++ config/mongoid.yml | 4 +- config/puma.rb | 18 +++ config/shakapacker.yml | 123 ++++++++++++++++++ config/webpack/development.js | 5 - config/webpack/environment.js | 61 --------- config/webpack/production.js | 5 - config/webpack/test.js | 5 - config/webpack/webpack.config.js | 14 ++ public/406-unsupported-browser.html | 66 ++++++++++ public/icon.png | Bin 0 -> 5599 bytes public/icon.svg | 3 + public/icons.png | Bin 0 -> 12421 bytes public/icons_hidpi.png | Bin 0 -> 40265 bytes scripts/code_event_mappings_report.rb | 5 +- scripts/rcno_metric_report.rb | 28 ++-- .../document_meta_data_publisher_spec.rb | 2 +- spec/helpers/application_helper_spec.rb | 5 +- spec/operations/documents/create_spec.rb | 97 +++++++++----- spec/operations/documents/upload_spec.rb | 12 +- .../generate_and_publish_documents_spec.rb | 3 +- ...generate_and_publish_tax_documents_spec.rb | 3 +- spec/rails_helper.rb | 5 +- .../features/enroll_app/enroll_app.yml | 9 +- 81 files changed, 793 insertions(+), 540 deletions(-) delete mode 100644 .browserslistrc delete mode 100644 app/javascript/packs/application.scss create mode 100644 app/javascript/stylesheets/application.scss delete mode 100644 app/javascript/stylesheets/signin.scss delete mode 100644 app/javascript/stylesheets/site.scss create mode 100755 bin/docker-entrypoint create mode 100755 bin/rubocop create mode 100755 bin/shakapacker create mode 100755 bin/shakapacker-dev-server delete mode 100755 bin/webpack delete mode 100755 bin/webpack-dev-server create mode 100644 config/initializers/new_framework_defaults_7_2.rb create mode 100644 config/shakapacker.yml delete mode 100644 config/webpack/development.js delete mode 100644 config/webpack/environment.js delete mode 100644 config/webpack/production.js delete mode 100644 config/webpack/test.js create mode 100644 config/webpack/webpack.config.js create mode 100644 public/406-unsupported-browser.html create mode 100644 public/icon.png create mode 100644 public/icon.svg create mode 100644 public/icons.png create mode 100644 public/icons_hidpi.png diff --git a/.browserslistrc b/.browserslistrc deleted file mode 100644 index e94f8140..00000000 --- a/.browserslistrc +++ /dev/null @@ -1 +0,0 @@ -defaults diff --git a/.ruby-version b/.ruby-version index 6a81b4c8..4d9d11cf 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.8 +3.4.2 diff --git a/Gemfile b/Gemfile index d730d327..5acb4efd 100644 --- a/Gemfile +++ b/Gemfile @@ -3,15 +3,16 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.7.8' +ruby '3.4.2' gem 'aca_entities', git: 'https://github.com/ideacrew/aca_entities.git', branch: 'trunk' # Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.4.4', require: false +gem 'bootsnap', '>= 1.10.3', require: false gem 'ckeditor', '~> 4.2.4' gem 'combine_pdf', '~> 1.0' -gem 'config', '~> 2.0' # Deprecate for Resource Registry +gem 'config', '~> 5.1' # Deprecate for Resource Registry +gem 'csv' gem 'devise', '~> 4.8' # for account locking @@ -33,7 +34,7 @@ gem 'event_source', gem 'sneakers', '~> 2.12' -gem 'httparty', '~> 0.16' +gem 'httparty', '~> 0.21.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' @@ -43,7 +44,7 @@ gem 'jquery-ui-rails' # Had to clone to make nested search work in where filter gem 'liquid', path: './project_gems/liquid-5.0.1' -gem 'mongoid', '~> 7.3.3' +gem 'mongoid', '~> 8.1.0' gem 'mongoid-locker' gem 'prawn', '~> 2.2' @@ -51,10 +52,10 @@ gem 'prawn-templates', '~> 0.1.2' gem 'pundit', '~> 2.1.0' -gem 'puma', '~> 5.0' +gem 'puma', '~> 6.0' # Use SCSS for stylesheets -gem 'rails', '~> 6.1.4' +gem 'rails', '~> 7.2' # Use Puma as the app server gem 'resource_registry', @@ -62,16 +63,12 @@ gem 'resource_registry', branch: 'trunk' # gem 'resource_registry', path: '../resource_registry' -gem 'roo', '~> 2.7.0' +gem 'roo', '~> 2.10.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'sass-rails', '>= 6' +gem 'sass-rails', '>= 6' # This is required for ckeditor-4 gem. -# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker -# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks -gem 'turbolinks', '~> 5' - -gem 'webpacker', '~> 5.0' +gem 'shakapacker', '~> 7.0' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password @@ -89,9 +86,9 @@ group :development, :test do gem 'database_cleaner-mongoid' gem 'factory_bot_rails' gem 'pry-byebug', require: false - gem 'rspec-rails', '~> 5.0' + gem 'rspec-rails', '~> 7.0' gem 'shoulda-matchers', '~> 3' - gem 'yard' + gem 'yard', '0.9.36' gem 'rubocop-git' end @@ -105,13 +102,13 @@ group :development do # Display performance information such as SQL time and flame graphs for each request in your browser. # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md gem 'rack-mini-profiler', '~> 2.0', require: false - gem 'rubocop', require: false + gem 'rubocop', '~> 1.69.0' gem 'rubocop-rails', require: false gem 'rubocop-rake' gem 'rubocop-rspec' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' + gem 'spring', '~> 4.2.1' # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 4.1.0' @@ -119,7 +116,7 @@ end group :production do gem 'eye', '0.10.0' - gem 'unicorn', '~> 4.8' + gem 'unicorn', '~> 6.1' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/app/controllers/new/templates_controller.rb b/app/controllers/new/templates_controller.rb index f2272136..5eed48df 100644 --- a/app/controllers/new/templates_controller.rb +++ b/app/controllers/new/templates_controller.rb @@ -158,7 +158,7 @@ def upload_notices @notice_kinds = Templates::TemplateModel.all @datatable = Effective::Datatables::NoticesDatatable.new - render action: 'index' + redirect_to action: :index end def fetch_tokens diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 933bc0a8..d58ec7a0 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # TemplatesController -class TemplatesController < ::ApplicationController +class TemplatesController < ApplicationController include ::DataTablesAdapter # include ::DataTablesSearch # before_action :check_hbx_staff_role diff --git a/app/entities/blocks/block.rb b/app/entities/blocks/block.rb index a3c65a28..f8b366f8 100644 --- a/app/entities/blocks/block.rb +++ b/app/entities/blocks/block.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module Blocks + # block class Block < Dry::Struct attribute :key, Types::String attribute :type, Types::String diff --git a/app/entities/bodies/body.rb b/app/entities/bodies/body.rb index 09c23857..72da012c 100644 --- a/app/entities/bodies/body.rb +++ b/app/entities/bodies/body.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module Bodies + # body class Body < Dry::Struct attribute :markup, Types::Any.meta(omittable: false) attribute :encoding_type, Types::String.optional.meta(omittable: true) diff --git a/app/entities/sections/section.rb b/app/entities/sections/section.rb index 264da401..cc233bf5 100644 --- a/app/entities/sections/section.rb +++ b/app/entities/sections/section.rb @@ -85,7 +85,7 @@ def flatten_map # Strip any Mondoid-managed attributes from hash def sanitize_attributes(params) - params.reject { |k, _v| Polypress::Types::MONGOID_PRIVATE_KEYS.include?(k) } + params.except(*Polypress::Types::MONGOID_PRIVATE_KEYS) end end end diff --git a/app/entities/templates/template.rb b/app/entities/templates/template.rb index 8cc8495e..7a21a39d 100644 --- a/app/entities/templates/template.rb +++ b/app/entities/templates/template.rb @@ -115,7 +115,7 @@ def update_model(record_id) # Strip any Mondoid-managed attributes from hash def sanitize_attributes - to_h.reject { |k, _v| Polypress::Types::MONGOID_PRIVATE_KEYS.include?(k) } + to_h.except(*Polypress::Types::MONGOID_PRIVATE_KEYS) end end end diff --git a/app/event_source/subscribers/reports/pre_audit_report_generation_subscriber.rb b/app/event_source/subscribers/reports/pre_audit_report_generation_subscriber.rb index b3207e17..1133c3a8 100644 --- a/app/event_source/subscribers/reports/pre_audit_report_generation_subscriber.rb +++ b/app/event_source/subscribers/reports/pre_audit_report_generation_subscriber.rb @@ -31,7 +31,6 @@ class PreAuditReportGenerationSubscriber ) nack(delivery_info.delivery_tag) end - rescue Exception => e logger.error( "Exception: :on_receive_report_generation_event\n Exception: #{e.inspect}" + diff --git a/app/event_source/subscribers/reports/pre_audit_report_processor_subscriber.rb b/app/event_source/subscribers/reports/pre_audit_report_processor_subscriber.rb index 8ef68da0..dc5e3287 100644 --- a/app/event_source/subscribers/reports/pre_audit_report_processor_subscriber.rb +++ b/app/event_source/subscribers/reports/pre_audit_report_processor_subscriber.rb @@ -26,7 +26,6 @@ class PreAuditReportProcessorSubscriber ) nack(delivery_info.delivery_tag) end - rescue Exception => e logger.error( "Exception: :on_generate_recon_preaudit_report\n Exception: #{e.inspect}" + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 02bbd458..dc33a481 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,20 +4,15 @@ module ApplicationHelper def format_flash(name, msg) return unless msg.is_a?(String) + alert_type = name.to_s == 'notice' ? 'alert-success' : 'alert-danger' - content_tag( - :div, - "#{msg} \n" + - tag.button( - nil, - type: 'button', - class: 'btn-close', - 'data-bs-dismiss': 'alert', - 'aria-label': 'Close' - ), - class: %W[alert #{alert_type} alert-dismissible fade show], - role: 'alert' - ) + + content_tag(:div, class: ['alert', alert_type, 'alert-dismissible', 'fade', 'show'], role: 'alert') do + safe_join([ + msg, + tag.button('', type: 'button', class: 'btn-close', 'data-bs-dismiss': 'alert', 'aria-label': 'Close') + ]) + end end def prepend_glyph_to_text(template) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 5b691c0d..38c18190 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -3,10 +3,12 @@ // a relevant structure within app/javascript and only use these pack files to reference // that code so it'll be compiled. -import Rails from "rails-ujs"; -import Turbolinks from "turbolinks"; +import Rails from "@rails/ujs"; +import "@hotwired/turbo-rails"; import "channels"; +import * as bootstrap from "bootstrap"; + // JS import "../js/bootstrap_js_files"; @@ -14,18 +16,27 @@ import "../js/bootstrap_js_files"; const images = require.context("../images", true); const imagePath = (name) => images(name, true); -import "jquery"; -import "jquery-ui"; -import "popper.js"; - +import $ from "jquery"; window.jQuery = $; window.$ = $; + Rails.start(); -Turbolinks.start(); - -// import "css/polypress"; -// import "css/datatable_custom_filter"; -// import "css/effective_datatable"; -// import "datatables/datatable_custom_filter.js"; -// import "bootstrap"; -import "@fortawesome/fontawesome-free/css/all"; \ No newline at end of file + +import "@fortawesome/fontawesome-free/css/all.css"; +import "../stylesheets/application.scss"; + +$.fn.tab = function (action) { + return this.each(function () { + const tabInstance = bootstrap.Tab.getOrCreateInstance(this); + if (action === "show") tabInstance.show(); + }); +}; + +$.fn.modal = function (action) { + return this.each(function () { + const modalInstance = bootstrap.Modal.getOrCreateInstance(this); + if (action === "show") modalInstance.show(); + else if (action === "hide") modalInstance.hide(); + else if (action === "toggle") modalInstance.toggle(); + }); +}; diff --git a/app/javascript/packs/application.scss b/app/javascript/packs/application.scss deleted file mode 100644 index fefc1f11..00000000 --- a/app/javascript/packs/application.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../stylesheets/site"; \ No newline at end of file diff --git a/app/javascript/stylesheets/application.scss b/app/javascript/stylesheets/application.scss new file mode 100644 index 00000000..8f0e6d7c --- /dev/null +++ b/app/javascript/stylesheets/application.scss @@ -0,0 +1,3 @@ +@import "variables/colors"; +@import "~bootstrap/scss/bootstrap"; +@import "datatable_custom_filter"; diff --git a/app/javascript/stylesheets/signin.scss b/app/javascript/stylesheets/signin.scss deleted file mode 100644 index 38b98a9b..00000000 --- a/app/javascript/stylesheets/signin.scss +++ /dev/null @@ -1,55 +0,0 @@ -// html, -// body { -// height: 100%; -// } - -// body { -// display: flex; -// align-items: center; -// padding-top: 40px; -// padding-bottom: 40px; -// background-color: #f5f5f5; -// } - -// .form-login, -// .form-signup { -// width: 100%; -// max-width: 330px; -// padding: 15px; -// margin: auto; -// } - -// .form-login, -// .form-signup .checkbox { -// font-weight: 400; -// } - -// .form-login, -// .form-signup .form-floating:focus-within { -// z-index: 2; -// } - -// .form-login, -// .form-signup input[type="email"] { -// margin-bottom: -1px; -// border-bottom-right-radius: 0; -// border-bottom-left-radius: 0; -// } - -// .form-login input[type="password"] { -// margin-bottom: 10px; -// border-top-left-radius: 0; -// border-top-right-radius: 0; -// } - -// .form-signup input[type="password"] { -// margin-bottom: -1px; -// border-top-left-radius: 0; -// border-top-right-radius: 0; -// } - -// .form-signup #floating_password_confirm { -// margin-bottom: 10px; -// border-top-left-radius: 0; -// border-top-right-radius: 0; -// } diff --git a/app/javascript/stylesheets/site.scss b/app/javascript/stylesheets/site.scss deleted file mode 100644 index a8045def..00000000 --- a/app/javascript/stylesheets/site.scss +++ /dev/null @@ -1,21 +0,0 @@ -@import "variables/colors"; -// @import "signin"; -// inside app/frontend/packs/application.scss -// Import all Bootstrap v5 -@import "~bootstrap/scss/bootstrap"; -@import "datatable_custom_filter"; -// Include parts of Bootstrap -// // 1. Include functions first (so you can manipulate colors, SVGs, calc, etc) -// @import "~/bootstrap/scss/functions"; -// // 3. Include remainder of required Bootstrap stylesheets -// @import "~/bootstrap/scss/variables"; -// @import "~/bootstrap/scss/mixins"; -// // 4. Include any optional Bootstrap components as you like -// @import "~/bootstrap/scss/root"; -// @import "~/bootstrap/scss/reboot"; -// @import "~/bootstrap/scss/type"; -// @import "~/bootstrap/scss/images"; -// @import "~/bootstrap/scss/containers"; -// @import "~/bootstrap/scss/grid"; -// // 5. Add additional custom code here -// @import "../stylesheets/signin"; \ No newline at end of file diff --git a/app/liquid/tags/gist_tag.rb b/app/liquid/tags/gist_tag.rb index b415d288..a31e48d0 100644 --- a/app/liquid/tags/gist_tag.rb +++ b/app/liquid/tags/gist_tag.rb @@ -5,7 +5,6 @@ module Tags class GistTag < Tags::LiquidTagBase PARTIAL = 'liquids/gist' VALID_LINK_REGEXP = %r{\Ahttps://gist\.github\.com/([a-zA-Z0-9](-?[a-zA-Z0-9]){0,38})/([a-zA-Z0-9]){1,32}(/[a-zA-Z0-9]+)?\Z} - .freeze def initialize(_tag_name, link, _parse_context) super diff --git a/app/liquid/tags/render_section.rb b/app/liquid/tags/render_section.rb index 8626e822..8ef2c5dc 100644 --- a/app/liquid/tags/render_section.rb +++ b/app/liquid/tags/render_section.rb @@ -4,7 +4,7 @@ module Tags # RenderSection class RenderSection < Tags::LiquidTagBase FOR = 'for' - SYNTAX = /(#{Liquid::QuotedString}+)(\s+(with|#{FOR})\s+(#{Liquid::QuotedFragment}+))?(\s+(?:as)\s+(#{Liquid::VariableSegment}+))?/o.freeze + SYNTAX = /(#{Liquid::QuotedString}+)(\s+(with|#{FOR})\s+(#{Liquid::QuotedFragment}+))?(\s+(?:as)\s+(#{Liquid::VariableSegment}+))?/o disable_tags 'include' diff --git a/app/models/account.rb b/app/models/account.rb index 618b8b80..e3995a89 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# Account class Account include Mongoid::Document # Include default devise modules. Others available are: diff --git a/app/models/effective/datatables/notices_datatable.rb b/app/models/effective/datatables/notices_datatable.rb index 62f3e403..dbe1f00e 100644 --- a/app/models/effective/datatables/notices_datatable.rb +++ b/app/models/effective/datatables/notices_datatable.rb @@ -20,18 +20,12 @@ class NoticesDatatable < Effective::MongoidDatatable table_column :title, :proc => proc { |row| link_to row.title, preview_template_path(row), target: '_blank' }, :filter => false, :sortable => false - table_column :doc_type, :proc => proc { |row| - row.doc_type - }, :filter => false, :sortable => false - table_column :description, :proc => proc { |row| - row.description - }, :filter => false, :sortable => false + table_column :doc_type, :proc => proc(&:doc_type), :filter => false, :sortable => false + table_column :description, :proc => proc(&:description), :filter => false, :sortable => false table_column :recipient, :proc => proc { |row| row.recipient_klass_name.to_s.titleize }, :filter => false, :sortable => false - table_column :key, :proc => proc { |row| - row.key - }, :filter => false, :sortable => true + table_column :key, :proc => proc(&:key), :filter => false, :sortable => true table_column :last_updated_at, :proc => proc { |row| row.updated_at.in_time_zone('Eastern Time (US & Canada)').strftime('%m/%d/%Y %H:%M') }, :filter => false, :sortable => false diff --git a/app/models/entities/templates/main.rb b/app/models/entities/templates/main.rb index 45f278d0..974c64be 100644 --- a/app/models/entities/templates/main.rb +++ b/app/models/entities/templates/main.rb @@ -2,6 +2,7 @@ module Entities module Templates + # main class Main < Dry::Struct # @!attribute [r] sections diff --git a/app/models/notice_builder.rb b/app/models/notice_builder.rb index bc98f3b1..ff0c41d5 100644 --- a/app/models/notice_builder.rb +++ b/app/models/notice_builder.rb @@ -266,13 +266,13 @@ def employee_appeal_rights def ivl_taglines join_pdfs [ notice_path, - Rails.root.join('lib/pdf_templates', 'taglines.pdf') + Rails.root.join("lib/pdf_templates/#{Settings.site.key}", 'taglines.pdf') ] end def attach_blank_page(template_path = nil) path = template_path.nil? ? notice_path : template_path - blank_page = Rails.root.join('lib/pdf_templates', 'blank.pdf') + blank_page = Rails.root.join("lib/pdf_templates/#{Settings.site.key}", 'blank.pdf') page_count = Prawn::Document.new(template: path).page_count join_pdfs([path, blank_page], path) if page_count.odd? end @@ -524,14 +524,12 @@ def notice_type end def valid_resource? - (employee? || consumer? || employer?) + employee? || consumer? || employer? end def sub_resource? - ( - resource.is_a?(EmployeeRole) || resource.is_a?(BrokerRole) || - resource.is_a?(ConsumerRole) - ) + resource.is_a?(EmployeeRole) || resource.is_a?(BrokerRole) || + resource.is_a?(ConsumerRole) end def envelope diff --git a/app/models/notice_kind.rb b/app/models/notice_kind.rb index 3ede19b0..86b81c38 100644 --- a/app/models/notice_kind.rb +++ b/app/models/notice_kind.rb @@ -51,7 +51,7 @@ class NoticeKind attr_accessor :resource, :payload def tokens - template.raw_body.scan(/\#\{([\w|.\s+\-]*)\}/).flatten.reject {|element| element.scan(/Settings/).any?}.uniq.map(&:strip) + template.raw_body.scan(/\#\{([\w|.\s+\-]*)\}/).flatten.reject {|element| element.scan('Settings').any?}.uniq.map(&:strip) end def conditional_tokens @@ -70,7 +70,7 @@ def set_data_elements iterator_subloop_tokens = [] loop_tokens = [] loop_iterators = conditional_tokens.inject([]) do |iterators, conditional_token| - iterators unless conditional_token.match(/(.+)\.each/i) + return iterators unless conditional_token.match(/(.+)\.each/i) loop_match = conditional_token.match(/\|(.+)\|/i) if loop_match.present? loop_token = conditional_token.match(/(.+)\.each/i)[1] diff --git a/app/models/pdf_report.rb b/app/models/pdf_report.rb index f7811079..3f64e804 100644 --- a/app/models/pdf_report.rb +++ b/app/models/pdf_report.rb @@ -7,7 +7,7 @@ class PdfReport < Prawn::Document def initialize(options = {}) options.merge!(:margin => [50, 70]) if options[:margin].nil? - super(options) + super font "Times-Roman" font_size 12 @@ -23,7 +23,7 @@ def footer def text(text, options = {}) options.merge!({ :align => :justify }) unless options.key?(:align) - super text, options + super end def subheading(sub_heading) diff --git a/app/models/services/token_builder.rb b/app/models/services/token_builder.rb index 18c4f797..ab9b6606 100644 --- a/app/models/services/token_builder.rb +++ b/app/models/services/token_builder.rb @@ -44,16 +44,12 @@ def sections end def placeholders - placeholders = [] - - [:if, :iterator, :tablerow, :comment].each do |type| - placeholders << { + [:if, :iterator, :tablerow, :comment].map do |type| + { title: type.to_s.titleize, type: type } end - - placeholders end def editor_tokens diff --git a/app/models/templates/template_model.rb b/app/models/templates/template_model.rb index 9be8e4b4..5b7ccbc8 100644 --- a/app/models/templates/template_model.rb +++ b/app/models/templates/template_model.rb @@ -161,13 +161,13 @@ def conditional_tokens body.scan(/\[\[([\s|\w.?]*)/).flatten.map(&:strip).collect do |ele| ele.gsub(/\w+/) { |m| keywords.fetch(m, m) } end.map(&:strip) - .reject(&:blank?) - .uniq + .reject(&:blank?) + .uniq end def tokens body.scan(/\#\{([\w|.\s+\-]*)\}/).flatten.reject do |element| - element.scan(/Settings/).any? + element.scan('Settings').any? end.uniq.map(&:strip) end diff --git a/app/operations/documents/upload.rb b/app/operations/documents/upload.rb index 664a2d8c..168f65b3 100644 --- a/app/operations/documents/upload.rb +++ b/app/operations/documents/upload.rb @@ -4,7 +4,6 @@ module Documents # Uploads documents to doc storage via cartafact class Upload send(:include, Dry::Monads[:result, :do, :try]) - include CartafactHelpers def call(resource_id:, title:, file:, user_id:, subjects: nil) _validate = yield validate(resource_id, file) @@ -24,10 +23,42 @@ def validate(resource_id, file) Success(true) end + def encoded_payload(payload) + Base64.strict_encode64(payload.to_json) + end + def fetch_file(file) file.tempfile end + def fetch_secret_key + PolypressRegistry[:secret_key_base].item + end + + def fetch_url + Rails.application.config.cartafact_document_base_url + end + + def construct_headers(resource_id, user_id) + payload_to_encode = { + authorized_identity: { user_id: user_id.to_s, system: 'polypress' }, + authorized_subjects: [{ type: "notice", id: resource_id.to_s }] + } + + Success( + { + 'X-REQUESTINGIDENTITY' => encoded_payload(payload_to_encode), + 'X-REQUESTINGIDENTITYSIGNATURE' => Base64.strict_encode64( + OpenSSL::HMAC.digest( + "SHA256", + fetch_secret_key, + encoded_payload(payload_to_encode) + ) + ) + } + ) + end + def construct_body(resource_id, file, subjects) document_body = { subjects: [{ id: resource_id.to_s, type: 'Person' }], @@ -73,5 +104,20 @@ def validate_response(params) result.success? ? Success(params) : Failure(result.errors.to_h) end + + def test_env_response(resource_id) + { + :title => 'untitled', + :language => 'en', + :format => 'application/octet-stream', + :source => 'polypress', + :document_type => 'notice', + :subjects => [{ :id => resource_id.to_s, :type => nil }], + :id => BSON::ObjectId.new.to_s, + :extension => 'pdf', + :file_name => 'Test.pdf', + :file_content_type => 'application/pdf' + } + end end end diff --git a/app/operations/reports/generate_rcno_report.rb b/app/operations/reports/generate_rcno_report.rb index b1e39f22..582445a6 100644 --- a/app/operations/reports/generate_rcno_report.rb +++ b/app/operations/reports/generate_rcno_report.rb @@ -981,7 +981,7 @@ def insert_data # rubocop:enable Metrics/MethodLength def insert_total_record_data - ["02", @rcni_row[1], "----------".gsub(/-/, " "), + ["02", @rcni_row[1], "----------".gsub('-', " "), @rcni_row[3], @rcni_row[4], @rcni_row[5], @rcni_row[6], @total_number_of_issuer_records, @total_subscribers, @total_dependents, format('%.2f', @total_premium_amount), diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6ef78fd9..df89c71e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,11 +6,11 @@ <%= favicon_link_tag Settings.site.tab_icon, :rel => 'shortcut icon', :type => 'image/vnd.microsoft.icon' %> - Polypress - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> + Polypress + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbo-track': 'reload' %> + <%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %> @@ -20,7 +20,7 @@
-
+
<%= render 'layouts/flash' %>
diff --git a/app/views/layouts/single_column.html.erb b/app/views/layouts/single_column.html.erb index 0a535643..8873c34e 100644 --- a/app/views/layouts/single_column.html.erb +++ b/app/views/layouts/single_column.html.erb @@ -8,8 +8,8 @@ <%= content_for?(:title) ? yield(:title) : "Welcome to DC HealthLink" %> - <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_pack_tag "application", 'data-turbolinks-track': 'reload' %> + <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbo-track': 'reload' %> + <%= javascript_pack_tag "application", 'data-turbo-track': 'reload' %> <%= csrf_meta_tags %> diff --git a/app/views/new/sections/_form.html.erb b/app/views/new/sections/_form.html.erb index 0d84eafa..c503dc49 100644 --- a/app/views/new/sections/_form.html.erb +++ b/app/views/new/sections/_form.html.erb @@ -1,7 +1,7 @@

<%= section.persisted? ? 'Edit' : 'Create' %> Section

- <%= form_with scope: :section, url: new_sections_path(section.id), method: :post do |f| %> + <%= form_with scope: :section, url: new_sections_path(section.id), method: :post, data: { turbo: false, remote: false } do |f| %> - <%= form_with scope: :section, url: "/new/sections/#{@section.id}", method: :put do |f| %> + <%= form_with scope: :section, url: "/new/sections/#{@section.id}", method: :put, data: { turbo: false, remote: false } do |f| %>
<%= render(:partial => 'edit_form', :locals => { section: @section, f: f }) %> @@ -36,10 +36,10 @@
<% end %>
-
+
- <%= link_to 'Cancel', new_templates_path, class: "btn btn-secondary" %> + <%= link_to 'Cancel', new_templates_path, class: "btn btn-secondary", data: { turbo: false } %>
@@ -130,19 +130,21 @@ }); } - $('#instant_preview').click(function(e) { - $.ajax({ - type:"POST", - url: "/new/sections/instant_preview", - // dataType: 'json', - data: { body: CKEDITOR.instances.section_body_markup.getData(), key: $('#section_key').val(), title: $('#section_title').val(), marketplace: $('#section_marketplace').val()}, - success: function(result){ - } + document.addEventListener('turbo:load', function() { + $('#instant_preview').click(function(e) { + $.ajax({ + type:"POST", + url: "/new/sections/instant_preview", + // dataType: 'json', + data: { body: CKEDITOR.instances.section_body_markup.getData(), key: $('#section_key').val(), title: $('#section_title').val(), marketplace: $('#section_marketplace').val()}, + success: function(result){ + } + }) }) - }) - $(document).ready(function() { - updateCkEditor(); - }); + $(document).ready(function() { + updateCkEditor(); + }); + }) \ No newline at end of file diff --git a/app/views/new/templates/_new_form.html.erb b/app/views/new/templates/_new_form.html.erb index fe5c857b..89cbde4b 100644 --- a/app/views/new/templates/_new_form.html.erb +++ b/app/views/new/templates/_new_form.html.erb @@ -1,21 +1,19 @@
-

- <%= template.persisted? ? 'Edit' : 'Create' %> Template

+

<%= template.persisted? ? 'Edit' : 'Create' %> Template

- <%#= form_for [:new, template], as: :template do |f| %> - <%= form_with scope: :template, url: new_templates_path(template.id), method: :post do |f| %> - + <%= form_with scope: :template, url: new_templates_path(template.id), method: :post, data: {turbo: false, remote: false} do |f| %> + - <%= render(:partial => 'form', :locals => { template: template, f: f }) %> + <%= render(:partial => 'form', :locals => { template: template, f: f }) %> -
- - <%= link_to 'Cancel', new_templates_path, class: "btn btn-secondary" %> -
- <% end %> +
+ + <%= link_to 'Cancel', new_templates_path, class: "btn btn-secondary" %> +
+ <% end %>
-
\ No newline at end of file +
diff --git a/app/views/new/templates/_templates.html.erb b/app/views/new/templates/_templates.html.erb index a239814d..faefab80 100644 --- a/app/views/new/templates/_templates.html.erb +++ b/app/views/new/templates/_templates.html.erb @@ -66,15 +66,15 @@
<%= form_tag(upload_notices_new_templates_path, multipart: true, method: :post) do %> - + - + <% end %>
-
\ No newline at end of file + diff --git a/app/views/new/templates/edit.html.erb b/app/views/new/templates/edit.html.erb index 7c44ff7b..5ccfb488 100644 --- a/app/views/new/templates/edit.html.erb +++ b/app/views/new/templates/edit.html.erb @@ -18,38 +18,39 @@ - <%= form_with scope: :template, url: "/new/templates/#{@template.id}", method: :put do |f| %> -
+ <%= form_with scope: :template, url: "/new/templates/#{@template.id}", method: :put, data: { turbo: false, remote: false } do |f| %> +
<%= render(:partial => 'form', :locals => { template: @template, f: f }) %>
+ <%= f.fields_for :body do |body_form| %> -
+
-
-
- <%= body_form.cktext_area :markup, value: @template.body.markup, class: 'notice_template form-control' %> -
+
+
+ <%= body_form.cktext_area :markup, value: @template.body.markup, class: 'notice_template form-control' %>
+
-
+
<% end %> -
+
-
-
- - <%= link_to 'Cancel', new_templates_path, class: "btn btn-secondary" %> - -
+
+
+ + <%= link_to 'Cancel', new_templates_path, class: "btn btn-secondary", data: { turbo: false } %> +
+
-
@@ -136,48 +137,50 @@ }); } - $('#instant_preview').click(function(e) { - $.ajax({ - type:"POST", - url: "/new/templates/instant_preview", - // dataType: 'json', - data: { - body: CKEDITOR.instances.template_body_markup.getData(), - subject: $('#print_code').val(), - key: $('#key').val(), - title: $('#title').val(), - marketplace: $('#template_marketplace').val(), - recipient: $('#template_recipient').val() - }, - success: function(result){ - } + document.addEventListener('turbo:load', function() { + $('#instant_preview').click(function(e) { + $.ajax({ + type:"POST", + url: "/new/templates/instant_preview", + // dataType: 'json', + data: { + body: CKEDITOR.instances.template_body_markup.getData(), + subject: $('#print_code').val(), + key: $('#key').val(), + title: $('#title').val(), + marketplace: $('#template_marketplace').val(), + recipient: $('#template_recipient').val() + }, + success: function(result){ + } + }) }) - }) - $('#template_marketplace').change(function() { - $.ajax({ - type:"GET", - url:"/new/templates/fetch_recipients", - dataType:"json", - data: {market_kind: $('#template_marketplace').val()}, - complete:function(result){ - var select = $('#template_recipient'); - select.empty(); - - $.each( result.responseJSON.recipients, function( key, value ) { - select.append(""); - }); - updateCkEditor(); - } + $('#template_marketplace').change(function() { + $.ajax({ + type:"GET", + url:"/new/templates/fetch_recipients", + dataType:"json", + data: {market_kind: $('#template_marketplace').val()}, + complete:function(result){ + var select = $('#template_recipient'); + select.empty(); + + $.each( result.responseJSON.recipients, function( key, value ) { + select.append(""); + }); + updateCkEditor(); + } + }) }) - }) - $('#template_recipient').change(function() { - updateCkEditor(); - }) + $('#template_recipient').change(function() { + updateCkEditor(); + }) - $(document).ready(function() { - updateCkEditor(); + $(document).ready(function() { + updateCkEditor(); + }); }); diff --git a/app/views/new/templates/index.html.erb b/app/views/new/templates/index.html.erb index ba61dd2f..faa83fd6 100644 --- a/app/views/new/templates/index.html.erb +++ b/app/views/new/templates/index.html.erb @@ -38,18 +38,20 @@ \ No newline at end of file diff --git a/app/views/shared/_nav_bar.html.erb b/app/views/shared/_nav_bar.html.erb index 75825e64..2d80c290 100644 --- a/app/views/shared/_nav_bar.html.erb +++ b/app/views/shared/_nav_bar.html.erb @@ -1,6 +1,6 @@