Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/assets/stylesheets/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.navigation {
display: flex;
flex-direction: column;
justify-content: space-between;
}
3 changes: 2 additions & 1 deletion app/models/event_procedure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class EventProcedure < ApplicationRecord
acts_as_paranoid

has_enumeration_for :room_type, with: EventProcedures::RoomTypes, create_helpers: true
has_enumeration_for :payment, with: EventProcedures::Payments, create_helpers: true

Expand Down Expand Up @@ -31,4 +30,6 @@ class EventProcedure < ApplicationRecord
validates :room_type, presence: true, if: -> { health_insurance? }
validates :urgency, inclusion: [true, false], if: -> { health_insurance? }
validates :payment, presence: true

validates_with CustomAndUrgencyValidator
end
9 changes: 9 additions & 0 deletions app/validators/custom_and_urgency_validator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class CustomAndUrgencyValidator < ActiveModel::Validator
def validate(record)
return unless record.procedure&.custom && record.urgency

record.errors.add(:base, "EventProcedure cannot have both custom and urgency as true")
end
end
28 changes: 28 additions & 0 deletions app/views/admin/application/_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%#
# Navigation

This partial is used to display the navigation in Administrate.
By default, the navigation contains navigation links
for all resources in the admin dashboard,
as defined by the routes in the `admin/` namespace
%>

<nav class="navigation">
<div>
<%= link_to(t("administrate.navigation.back_to_app"), root_url, class: "button button--alt button--nav") if defined?(root_url) %>

<% Administrate::Namespace.new(namespace).resources_with_index_route.each do |resource| %>
<%= link_to(
display_resource_name(resource),
resource_index_route(resource),
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
) if accessible_action?(model_from_resource(resource), :index) %>
<% end %>
</div>

<div >
<%= link_to "Logout", destroy_user_session_path, method: :delete, class: "button button--danger w-full" %>
</div>
</nav>


41 changes: 41 additions & 0 deletions app/views/layouts/admin/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<%#
# Application Layout

This view template is used as the layout
for every page that Administrate generates.

By default, it renders:
- Navigation
- Content for a search bar
(if provided by a `content_for` block in a nested page)
- Flashes
- Links to stylesheets and JavaScripts
%>

<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
<head>
<meta charset="utf-8">
<meta name="ROBOTS" content="NOODP">
<meta name="viewport" content="initial-scale=1">
<title>
<%= content_for(:title) %> - <%= application_title %>
</title>
<%= render "stylesheet" %>
<%= csrf_meta_tags %>
<%= csp_meta_tag if defined?(csp_meta_tag) %>
</head>
<body>
<%= render "icons" %>
<div class="app-container">
<%= render "navigation" -%>

<main class="main-content">
<%= render "flashes" -%>
<%= yield %>
</main>
</div>

<%= render "javascript" %>
</body>
</html>
1 change: 1 addition & 0 deletions config/initializers/administrate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Administrate::Engine.add_stylesheet("custom.css")
2 changes: 2 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

Rails.application.config.assets.precompile += %w[custom.css]
6 changes: 6 additions & 0 deletions spec/models/event_procedure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@
end

describe "validations" do
let(:event) { build(:event_procedure, urgency: true, procedure_attributes: { custom: true }) }

it { is_expected.to validate_presence_of(:date) }
it { is_expected.to validate_presence_of(:patient_service_number) }
it { is_expected.to validate_presence_of(:room_type) }
it { is_expected.to validate_presence_of(:payment) }

it "is invalid when custom and urgency are both true" do
expect(event).not_to be_valid
end
end

describe ".enumerations" do
Expand Down
Loading