Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@

# Ignore master key for decrypting credentials and more.
/config/master.key

# Ignore IDE config files
.idea/
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ group :development, :test do
end

group :development do
gem "hotwire-spark"
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
end
Expand Down
20 changes: 20 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,23 @@ GEM
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
ffi (1.17.1-aarch64-linux-gnu)
ffi (1.17.1-aarch64-linux-musl)
ffi (1.17.1-arm-linux-gnu)
ffi (1.17.1-arm-linux-musl)
ffi (1.17.1-arm64-darwin)
ffi (1.17.1-x86_64-darwin)
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
hotwire-spark (0.1.13)
listen
rails (>= 7.0.0)
zeitwerk
i18n (1.14.7)
concurrent-ruby (~> 1.0)
importmap-rails (2.1.0)
Expand Down Expand Up @@ -148,6 +160,9 @@ GEM
thor (~> 1.3)
zeitwerk (>= 2.6.18, < 3.0)
language_server-protocol (3.17.0.4)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.5)
loofah (2.24.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -253,6 +268,9 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rdoc (6.11.0)
psych (>= 4.0.0)
regexp_parser (2.10.0)
Expand Down Expand Up @@ -378,6 +396,7 @@ PLATFORMS
arm-linux-gnu
arm-linux-musl
arm64-darwin-24
x86_64-darwin-23
x86_64-darwin-24
x86_64-linux
x86_64-linux-gnu
Expand All @@ -390,6 +409,7 @@ DEPENDENCIES
capybara
debug
factory_bot_rails
hotwire-spark
importmap-rails
jbuilder
kamal
Expand Down
65 changes: 65 additions & 0 deletions app/controllers/regions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class RegionsController < ApplicationController
before_action :set_region, only: %i[ show edit update destroy ]

# GET /regions
def index
@regions = Region.all
end

# GET /regions/1
def show
end

# GET /regions/new
def new
@region = Region.new
end

# GET /regions/1/edit
def edit
end

# POST /regions
def create
@region = Region.new(region_params)

respond_to do |format|
if @region.save
format.html { redirect_to @region, notice: "Region was successfully created." }
else
format.html { render :new, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /regions/1
def update
respond_to do |format|
if @region.update(region_params)
format.html { redirect_to @region, notice: "Region was successfully updated." }
else
format.html { render :edit, status: :unprocessable_entity }
end
end
end

# DELETE /regions/1
def destroy
@region.destroy!

respond_to do |format|
format.html { redirect_to regions_path, status: :see_other, notice: "Region was successfully destroyed." }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_region
@region = Region.find(params.expect(:id))
end

# Only allow a list of trusted parameters through.
def region_params
params.expect(region: [ :name ])
end
end
3 changes: 3 additions & 0 deletions app/models/region.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Region < ApplicationRecord
validates :name, presence: true
end
3 changes: 1 addition & 2 deletions app/views/layouts/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@
<li class="sidebar-title">Administration</li>

<li class="sidebar-item ">
<a href="form-layout.html" class='sidebar-link'>
<a href="<%= regions_path %>" class='sidebar-link'>
<i class="bi bi-globe"></i>
<span>Regions</span>
</a>

</li>

<li class="sidebar-item ">
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<link rel="apple-touch-icon" href="/icon.png">

<%# Includes all stylesheet files in app/assets/stylesheets %>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SkillRx</title>
Expand Down
11 changes: 5 additions & 6 deletions app/views/layouts/mazer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>

<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/svg/favicon.svg" type="image/x-icon">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/app.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/app-dark.css">
Expand All @@ -28,13 +27,13 @@
</head>

<body>
<%= render "layouts/sidebar" %>

<%= yield %>

<script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/initTheme.js"></script>
<!-- Start content here -->

<%= render "layouts/sidebar" %>

<div id="main"><%= yield %></div>

<!-- End content -->
<script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/components/dark.js"></script>
<script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/extensions/perfect-scrollbar/perfect-scrollbar.min.js"></script>
Expand All @@ -45,4 +44,4 @@
<script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/extensions/apexcharts/apexcharts.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/pages/dashboard.js"></script>
</body>
</html>
</html>
27 changes: 27 additions & 0 deletions app/views/regions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<%= form_with(model: region) do |form| %>
<% if region.errors.any? %>
<div style="color: red">
<h2><%= pluralize(region.errors.count, "error") %> prohibited this region from being saved:</h2>

<ul>
<% region.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="col-md-4">
<div class="form-group">
<%= form.label :name, style: "display: block" %>
<%= form.text_field :name, id: "basicInput", class: "form-control", autofocus: true %>
</div>
</div>

<div class="mt-4">
<div class="col-12 d-flex justify-content-end">
<%= form.submit "Create Region", class: "btn btn-primary me-1 mb-1" %>
<%= link_to "Cancel", regions_path, class: "btn btn-light-secondary me-1 mb-1" %>
</div>
</div>
<% end %>
3 changes: 3 additions & 0 deletions app/views/regions/_region.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="<%= dom_id region %>">
<h1><%= region.name %></h1>
</div>
10 changes: 10 additions & 0 deletions app/views/regions/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% content_for :title, "Editing region" %>

<h1>Editing region</h1>

<%= render "form", region: @region %>

<div class="mt-4">
<%= link_to "Show this region", @region %> |
<%= link_to "Back to regions", regions_path %>
</div>
58 changes: 58 additions & 0 deletions app/views/regions/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<% content_for :title, "Regions" %>

<section class="section">
<div class="row" id="table-striped">
<div class="col-12 cold-md-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h2>Regions Served</h2>
<%= link_to new_region_path, class: "btn btn-primary" do %>
<i class="bi bi-plus"></i> Add New Region
<% end %>
</div>
<div class="card-content">
<div class="card-body">
<p class="card-text">
Lorem ipsum dolor sit amet, <code>consectetur adipiscing</code> elit. Sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in <code>reprehenderit</code> in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint <code>occaecat cupidatat</code> non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
<!-- table striped -->
<div class="table-responsive">
<table class="table table-lg table-striped mb-0">
<thead>
<tr>
<th>Region</th>
<th>Providers</th>
<th class="text-end">Region Actions</th>
</tr>
</thead>
<tbody>
<% @regions.each do |region| %>
<tr>
<td class="text-bold-500"><%= region.name %></td>
<td>1</td>
<td class="text-end">
<%= link_to region, class: "btn btn-primary btn-sm" do %>
<i class="bi bi-search"></i> View
<% end %>
<%= link_to edit_region_path(region), class: "btn btn-secondary btn-sm" do %>
<i class="bi bi-pencil"></i> Edit
<% end %>
<%= link_to region, method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger btn-sm" do %>
<i class="bi bi-trash"></i> Delete
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>

23 changes: 23 additions & 0 deletions app/views/regions/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<% content_for :title, "New region" %>

<section id="multiple-column-form">
<div class="row match-height">
<div class="col-12">
<div class="card">
<div class="card-header">
<h4>Create New Region</h4>
</div>
<div class="card-content">
<div class="card-body">
<p>Regions should ... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.</p>
<%= render "form", region: @region %>
</div>
</div>
</div>
</div>
</div>
</section>
12 changes: 12 additions & 0 deletions app/views/regions/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div style="color: green"><%= notice %></div>

<%= render @region %>

<div class="mt-4">
<%= link_to "Edit this region", edit_region_path(@region) %> |
<%= link_to "Back to regions", regions_path %>
</div>

<div>
<%= button_to "Destroy this region", @region, method: :delete, class: "btn btn-danger mt-4" %>
</div>
4 changes: 4 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
default: &default
adapter: postgresql
encoding: unicode
username: postgres
password: postgres
host: localhost
port: 5432
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :regions
root "home#index"
get "home/index", as: :home
resource :session
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20250203133408_create_regions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateRegions < ActiveRecord::Migration[8.0]
def change
create_table :regions do |t|
t.string :name

t.timestamps
end
end
end
8 changes: 7 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions spec/factories/regions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :region do
name { "The Region" }
end
end
6 changes: 6 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryBot.define do
factory :user do
email { "john@doe.com" }
password { "password" }
end
end
Loading