33 changed files with 259 additions and 2 deletions
@ -0,0 +1,14 @@
|
||||
class BaseComponent < ViewComponent::Base |
||||
attr_reader :ability, :current_user |
||||
|
||||
def initialize(current_user:) |
||||
@current_user = current_user |
||||
@ability = Ability.new(current_user) |
||||
end |
||||
|
||||
def can?(action, klass) |
||||
return if action.blank? || klass.blank? |
||||
|
||||
ability.can?(action, klass) |
||||
end |
||||
end |
||||
@ -0,0 +1,5 @@
|
||||
class PaginationComponent < BaseComponent |
||||
def initialize(data:) |
||||
@data = data |
||||
end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
<div class="col col-md-12"> |
||||
<header class="header bg-white b-b clearfix"> |
||||
<div class="row m-t-sm"> |
||||
<div class="col-md-4"> |
||||
<h4 style="color: darkred">Search Results</h4> |
||||
<small style="color: darkred"> |
||||
<%= page_entries_info @data, entry_name: 'records' if @data.present? %> |
||||
</small> |
||||
</div> |
||||
<div class="col-md-8"> |
||||
<div class="text-center paginator pull-right"> |
||||
<%= (paginate @data) if @data.present? %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</header> |
||||
</div> |
||||
@ -0,0 +1,4 @@
|
||||
class SidenavComponent < BaseComponent |
||||
def initialize(current_user:) |
||||
end |
||||
end |
||||
@ -0,0 +1,10 @@
|
||||
<nav class="navbar navbar-light bg-light flex-column align-items-stretch p-3 sidenav"> |
||||
<nav class="nav nav-pills flex-column"> |
||||
<a class="nav-link" href="<%= root_path %>"> Home </a> |
||||
<a class="nav-link" href="#"> Search </a> |
||||
<a class="nav-link" href="<%= decisions_path %>"> Desicions </a> |
||||
<a class="nav-link" href="<%= case_doctrines_path %>"> Case Doctrines </a> |
||||
<a class="nav-link" href="<%= subject_indexes_path %>"> Subject Indexes </a> |
||||
<a class="nav-link" href="#"> Logout </a> |
||||
</nav> |
||||
</nav> |
||||
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class CaseDoctrinesController < ApplicationController |
||||
def index; end |
||||
|
||||
def new; end |
||||
|
||||
def edit; end |
||||
|
||||
def show; end |
||||
|
||||
def create; end |
||||
|
||||
def update; end |
||||
|
||||
def destroy; end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class DecisionsController < ApplicationController |
||||
def index; end |
||||
|
||||
def new; end |
||||
|
||||
def edit; end |
||||
|
||||
def show; end |
||||
|
||||
def create; end |
||||
|
||||
def update; end |
||||
|
||||
def destroy; end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class SubjectIndexesController < ApplicationController |
||||
def index; end |
||||
|
||||
def new; end |
||||
|
||||
def edit; end |
||||
|
||||
def show; end |
||||
|
||||
def create; end |
||||
|
||||
def update; end |
||||
|
||||
def destroy; end |
||||
end |
||||
@ -0,0 +1,9 @@
|
||||
@import "~bootstrap/scss/bootstrap"; |
||||
@import "./application/sidenav"; |
||||
|
||||
.main-layout { |
||||
padding-bottom: 10px !important; |
||||
position: absolute; |
||||
right: 0 !important; |
||||
top: 0 !important; |
||||
} |
||||
@ -0,0 +1,13 @@
|
||||
.sidenav { |
||||
font-feature-settings: 'liga'; |
||||
height: 100%; |
||||
height: -moz-calc(100%); |
||||
left: 0 !important; |
||||
position: fixed; |
||||
padding-top: 120px; |
||||
margin-top: 0; |
||||
overflow: auto; |
||||
text-rendering: optimizeLegibility; |
||||
width: inherit; |
||||
top: 0; |
||||
} |
||||
@ -0,0 +1,25 @@
|
||||
|
||||
class Ability |
||||
include CanCan::Ability |
||||
|
||||
def initialize(user) |
||||
clear_aliased_actions |
||||
|
||||
user ||= User.new |
||||
end |
||||
|
||||
def clear_aliased_actions |
||||
super |
||||
|
||||
# override cancan default aliasing (we don't want to differentiate |
||||
# between read and index) |
||||
alias_action :destroy, to: :delete |
||||
alias_action :edit, to: :update |
||||
alias_action :new, to: :create |
||||
alias_action :show, to: :read |
||||
alias_action :search, to: :index |
||||
alias_action :index, :read, to: :display |
||||
alias_action :create, :update, to: :modify |
||||
alias_action :display, :modify, to: :basic_manage |
||||
end |
||||
end |
||||
@ -0,0 +1,11 @@
|
||||
<%# Link to the "First" page |
||||
- available local variables |
||||
url: url to the first page |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
-%> |
||||
<span class="first"> |
||||
<%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote %> |
||||
</span> |
||||
@ -0,0 +1,8 @@
|
||||
<%# Non-link tag that stands for skipped pages... |
||||
- available local variables |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
-%> |
||||
<span class="page gap"><%= t('views.pagination.truncate').html_safe %></span> |
||||
@ -0,0 +1,11 @@
|
||||
<%# Link to the "Last" page |
||||
- available local variables |
||||
url: url to the last page |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
-%> |
||||
<span class="last"> |
||||
<%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %> |
||||
</span> |
||||
@ -0,0 +1,11 @@
|
||||
<%# Link to the "Next" page |
||||
- available local variables |
||||
url: url to the next page |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
-%> |
||||
<span class="next"> |
||||
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %> |
||||
</span> |
||||
@ -0,0 +1,12 @@
|
||||
<%# Link showing page number |
||||
- available local variables |
||||
page: a page object for "this" page |
||||
url: url to this page |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
-%> |
||||
<span class="page<%= ' current' if page.current? %>"> |
||||
<%= link_to_unless page.current?, page, url, {remote: remote, rel: page.rel} %> |
||||
</span> |
||||
@ -0,0 +1,25 @@
|
||||
<%# The container tag |
||||
- available local variables |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
paginator: the paginator that renders the pagination tags inside |
||||
-%> |
||||
<%= paginator.render do -%> |
||||
<nav class="pagination" role="navigation" aria-label="pager"> |
||||
<%= first_page_tag unless current_page.first? %> |
||||
<%= prev_page_tag unless current_page.first? %> |
||||
<% each_page do |page| -%> |
||||
<% if page.display_tag? -%> |
||||
<%= page_tag page %> |
||||
<% elsif !page.was_truncated? -%> |
||||
<%= gap_tag %> |
||||
<% end -%> |
||||
<% end -%> |
||||
<% unless current_page.out_of_range? %> |
||||
<%= next_page_tag unless current_page.last? %> |
||||
<%= last_page_tag unless current_page.last? %> |
||||
<% end %> |
||||
</nav> |
||||
<% end -%> |
||||
@ -0,0 +1,11 @@
|
||||
<%# Link to the "Previous" page |
||||
- available local variables |
||||
url: url to the previous page |
||||
current_page: a page object for the currently displayed page |
||||
total_pages: total number of pages |
||||
per_page: number of items to fetch per page |
||||
remote: data-remote |
||||
-%> |
||||
<span class="prev"> |
||||
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %> |
||||
</span> |
||||
@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
Kaminari.configure do |config| |
||||
# config.default_per_page = 25 |
||||
# config.max_per_page = nil |
||||
# config.window = 4 |
||||
# config.outer_window = 0 |
||||
# config.left = 0 |
||||
# config.right = 0 |
||||
# config.page_method_name = :page |
||||
# config.param_name = :page |
||||
# config.max_pages = nil |
||||
# config.params_on_first_page = false |
||||
end |
||||
Loading…
Reference in new issue