Skip to content

Commit

Permalink
delegate footer and header to components, implemented notification pa…
Browse files Browse the repository at this point in the history
…ge, invoices page, offers page, delegate boiler code to the components
  • Loading branch information
OlegPhenomenon committed Aug 17, 2023
1 parent 4a93368 commit 41ca969
Show file tree
Hide file tree
Showing 26 changed files with 844 additions and 1,073 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ group :development do
gem 'listen', '>= 3.0.5', '< 3.9'
gem 'web-console', '>= 3.3.0'
gem 'htmlbeautifier'
gem "ruby-lsp-rails"
end

group :test do
Expand Down Expand Up @@ -80,3 +81,4 @@ gem 'pagy', '~> 6.0'
gem 'faker'

gem 'noticed', '~> 1.6'
gem "freezolite", require: false
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ GEM
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
freezolite (0.3.0)
require-hooks (~> 0.1)
globalid (1.1.0)
activesupport (>= 5.0)
hashdiff (1.0.1)
Expand Down Expand Up @@ -269,6 +271,7 @@ GEM
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
prettier_print (1.2.1)
propshaft (0.7.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
Expand Down Expand Up @@ -337,6 +340,7 @@ GEM
regexp_parser (2.8.1)
request_store (1.5.1)
rack (>= 1.4)
require-hooks (0.1.0)
responders (3.1.0)
actionpack (>= 5.2)
railties (>= 5.2)
Expand All @@ -357,6 +361,14 @@ GEM
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-lsp (0.7.6)
language_server-protocol (~> 3.17.0)
sorbet-runtime
syntax_tree (>= 6.1.1, < 7)
ruby-lsp-rails (0.2.2)
rails (>= 6.0)
ruby-lsp (>= 0.6.2, < 0.8.0)
sorbet-runtime (>= 0.5.9897)
ruby-openai (4.2.0)
faraday (>= 1)
faraday-multipart (>= 1)
Expand All @@ -379,13 +391,16 @@ GEM
unf (~> 0.1.4)
skylight (5.3.4)
activesupport (>= 5.2.0)
sorbet-runtime (0.5.10972)
spy (1.0.5)
stimulus-rails (1.2.1)
railties (>= 6.0.0)
swd (1.3.0)
activesupport (>= 3)
attr_required (>= 0.0.5)
httpclient (>= 2.4)
syntax_tree (6.1.1)
prettier_print (>= 1.2.0)
thor (1.2.2)
timeout (0.4.0)
turbo-rails (1.4.0)
Expand Down Expand Up @@ -458,6 +473,7 @@ DEPENDENCIES
directo!
faker
faraday
freezolite
hotwire-rails (~> 0.1.3)
htmlbeautifier
i18n-debug
Expand All @@ -484,6 +500,7 @@ DEPENDENCIES
recaptcha
redis (~> 5.0)
rubocop-performance
ruby-lsp-rails
ruby-openai
scenic
simplecov (~> 0.10, < 0.18)
Expand Down
26 changes: 26 additions & 0 deletions app/assets/builds/application.js

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

6 changes: 3 additions & 3 deletions app/assets/builds/application.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/components/common/auction_type_icon/component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if english? %>
<span class="o-io-icon auction_platform"></span><span class="u-hidden">IO</span>
<% else %>
<span class="o-po-icon auction_platform"></span><span class="u-hidden">PO</span>
<% end %>
17 changes: 17 additions & 0 deletions app/components/common/auction_type_icon/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Common
module AuctionTypeIcon
class Component < ApplicationViewComponent
attr_reader :auction

def initialize(auction:)
@auction = auction

super
end

def english?
auction.english?
end
end
end
end
157 changes: 157 additions & 0 deletions app/components/common/footer/component.html.erb

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/components/common/footer/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Common
module Footer
class Component < ApplicationViewComponent; end
end
end
140 changes: 140 additions & 0 deletions app/components/common/header/component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<header class="c-header">
<div class="c-header__menu">
<button class="c-header__toggle u-bg-blue-gradient js-nav-toggle hamburger hamburger--collapse">
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
<span>Avalik portaal</span>
</button>
</div>
<div class="c-toolbar js-toolbar">
<div class="c-toolbar__grid">
<div class="c-toolbar__nav">
<ul class="s-toolbar-nav">
<li>
<a href="#">Avalik portaal</a>
<span class="o-arrow js-submenu-toggle"></span>
<ul class="submenu">
<li>
<a href="#">Info</a>
<span class="o-arrow o-arrow--visible-on-desktop js-submenu-toggle"></span>
<ul class="submenu">
<li>
<a href="#">hell</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="is-active">
<a href="#">Oksjonikeskkond</a>
<span class="o-arrow js-submenu-toggle"></span>

<ul class="submenu">
<li>
<%= link_to 'OKSJONID', root_path %>
</li>
<li>
<a href="#">KASUTAJA KONTO</a>
</li>
<li>
<%= link_to 'MINU ARVED', invoices_path %>
</li>
<li>
<%= link_to 'MINU PAKKUMISED', offers_path %>
</li>
<li>
<a href="#">Minu SOOVIDE NIMEKIRI</a>
</li>
<li class="c-toolbar__search js-search-toolbar">
<%= link_to notifications_path, class: 'c-toolbar__notice' do %>
<svg width="12" height="16" viewBox="0 0 12 16" fill="white"
xmlns="http://www.w3.org/2000/svg">
<path d="M5.99986 15.3333C6.35348 15.3333 6.69262 15.1928 6.94267 14.9428C7.19272 14.6927 7.33319 14.3536 7.33319 14H4.66652C4.66652 14.3536 4.807 14.6927 5.05705 14.9428C5.3071 15.1928 5.64624 15.3333 5.99986 15.3333ZM0.666525 12.6666H11.3332C11.465 12.6666 11.5939 12.6275 11.7035 12.5542C11.8131 12.481 11.8985 12.3769 11.949 12.2551C11.9994 12.1333 12.0126 11.9992 11.9869 11.8699C11.9612 11.7406 11.8977 11.6219 11.8045 11.5286L10.6665 10.3906V6.66663C10.6644 5.54563 10.2591 4.46279 9.52477 3.61582C8.7904 2.76885 7.77591 2.21426 6.66652 2.05329V1.33329C6.66652 1.15648 6.59629 0.986912 6.47126 0.861888C6.34624 0.736864 6.17667 0.666626 5.99986 0.666626C5.82305 0.666626 5.65348 0.736864 5.52845 0.861888C5.40343 0.986912 5.33319 1.15648 5.33319 1.33329V2.05329C4.2238 2.21426 3.20932 2.76885 2.47495 3.61582C1.74059 4.46279 1.33534 5.54563 1.33319 6.66663V10.3906L0.195191 11.5286C0.101985 11.6219 0.038514 11.7406 0.0128023 11.8699C-0.0129094 11.9992 0.000292634 12.1333 0.0507393 12.2551C0.101186 12.3769 0.186612 12.481 0.296219 12.5542C0.405825 12.6275 0.534691 12.6666 0.666525 12.6666ZM2.47119 11.138C2.59622 11.013 2.66649 10.8434 2.66652 10.6666V6.66663C2.66652 5.78257 3.01771 4.93472 3.64284 4.3096C4.26796 3.68448 5.1158 3.33329 5.99986 3.33329C6.88391 3.33329 7.73176 3.68448 8.35688 4.3096C8.982 4.93472 9.33319 5.78257 9.33319 6.66663V10.6666C9.33323 10.8434 9.40349 11.013 9.52852 11.138L9.72386 11.3333H2.27586L2.47119 11.138Z"/>
</svg>
<span>
Teavitused<sup>(2)</sup>
</span>
<% end %>
</li>
</ul>

</li>
<li>
<a href="#">Registripidaja portaal</a>
<span class="o-arrow js-submenu-toggle"></span>
<ul class="submenu">
<li>
<ul class="submenu">
<li>
<a href="#">Hello</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#">Registreerija portaal</a>
<span class="o-arrow js-submenu-toggle"></span>
<ul class="submenu">
<li>
<ul class="submenu">
<li>
<a href="#">Submenu</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#">eeIDc-hero</a>
<span class="o-arrow js-submenu-toggle"></span>
<ul class="submenu">
<li>
<ul class="submenu">
<li>
<a href="#">Submenu</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="c-toolbar__socials">
<% if user_signed_in? %>
<%= link_to destroy_user_session_path, class: "c-header__user", method: :delete, data: { 'turbo-method': 'delete' } do %>
<svg width="10" height="12" viewBox="0 0 10 12" fill="white" xmlns="http://www.w3.org/2000/svg">
<path d="M6.85524 6.35494C7.34544 5.96927 7.70324 5.4404 7.87886 4.84191C8.05449 4.24342 8.0392 3.60507 7.83514 3.01567C7.63107 2.42628 7.24837 1.91514 6.74028 1.55337C6.23219 1.1916 5.62397 0.997192 5.00024 0.997192C4.37652 0.997192 3.7683 1.1916 3.26021 1.55337C2.75212 1.91514 2.36941 2.42628 2.16535 3.01567C1.96128 3.60507 1.946 4.24342 2.12162 4.84191C2.29725 5.4404 2.65505 5.96927 3.14524 6.35494C2.30528 6.69146 1.57239 7.24961 1.02469 7.9699C0.476991 8.69018 0.135024 9.54559 0.0352425 10.4449C0.0280198 10.5106 0.0338008 10.577 0.0522552 10.6405C0.0707096 10.7039 0.101476 10.7631 0.142798 10.8146C0.226252 10.9187 0.347634 10.9854 0.480243 10.9999C0.612851 11.0145 0.745822 10.9758 0.849905 10.8924C0.953988 10.8089 1.02066 10.6875 1.03524 10.5549C1.14503 9.57754 1.61109 8.67485 2.34435 8.01934C3.07762 7.36383 4.02669 7.00145 5.01024 7.00145C5.99379 7.00145 6.94287 7.36383 7.67613 8.01934C8.4094 8.67485 8.87545 9.57754 8.98524 10.5549C8.99884 10.6778 9.05746 10.7913 9.1498 10.8734C9.24213 10.9556 9.36163 11.0007 9.48524 10.9999H9.54024C9.67131 10.9849 9.79111 10.9186 9.87352 10.8156C9.95594 10.7125 9.9943 10.5811 9.98024 10.4499C9.87999 9.54804 9.53618 8.69043 8.98567 7.96904C8.43515 7.24765 7.6987 6.68968 6.85524 6.35494ZM5.00024 5.99994C4.60468 5.99994 4.218 5.88264 3.8891 5.66288C3.5602 5.44312 3.30386 5.13076 3.15248 4.76531C3.00111 4.39986 2.9615 3.99772 3.03867 3.60976C3.11584 3.2218 3.30632 2.86543 3.58603 2.58573C3.86573 2.30602 4.2221 2.11554 4.61006 2.03837C4.99802 1.9612 5.40016 2.00081 5.76561 2.15218C6.13106 2.30356 6.44342 2.5599 6.66318 2.8888C6.88294 3.2177 7.00024 3.60438 7.00024 3.99994C7.00024 4.53037 6.78953 5.03908 6.41446 5.41415C6.03938 5.78923 5.53068 5.99994 5.00024 5.99994Z"/>
</svg>
<%= t(:sign_out) %>
<% end %>
<% else %>
<%= link_to new_user_session_path, class: "c-header__user" do %>
<svg width="10" height="12" viewBox="0 0 10 12" fill="white" xmlns="http://www.w3.org/2000/svg">
<path d="M6.85524 6.35494C7.34544 5.96927 7.70324 5.4404 7.87886 4.84191C8.05449 4.24342 8.0392 3.60507 7.83514 3.01567C7.63107 2.42628 7.24837 1.91514 6.74028 1.55337C6.23219 1.1916 5.62397 0.997192 5.00024 0.997192C4.37652 0.997192 3.7683 1.1916 3.26021 1.55337C2.75212 1.91514 2.36941 2.42628 2.16535 3.01567C1.96128 3.60507 1.946 4.24342 2.12162 4.84191C2.29725 5.4404 2.65505 5.96927 3.14524 6.35494C2.30528 6.69146 1.57239 7.24961 1.02469 7.9699C0.476991 8.69018 0.135024 9.54559 0.0352425 10.4449C0.0280198 10.5106 0.0338008 10.577 0.0522552 10.6405C0.0707096 10.7039 0.101476 10.7631 0.142798 10.8146C0.226252 10.9187 0.347634 10.9854 0.480243 10.9999C0.612851 11.0145 0.745822 10.9758 0.849905 10.8924C0.953988 10.8089 1.02066 10.6875 1.03524 10.5549C1.14503 9.57754 1.61109 8.67485 2.34435 8.01934C3.07762 7.36383 4.02669 7.00145 5.01024 7.00145C5.99379 7.00145 6.94287 7.36383 7.67613 8.01934C8.4094 8.67485 8.87545 9.57754 8.98524 10.5549C8.99884 10.6778 9.05746 10.7913 9.1498 10.8734C9.24213 10.9556 9.36163 11.0007 9.48524 10.9999H9.54024C9.67131 10.9849 9.79111 10.9186 9.87352 10.8156C9.95594 10.7125 9.9943 10.5811 9.98024 10.4499C9.87999 9.54804 9.53618 8.69043 8.98567 7.96904C8.43515 7.24765 7.6987 6.68968 6.85524 6.35494ZM5.00024 5.99994C4.60468 5.99994 4.218 5.88264 3.8891 5.66288C3.5602 5.44312 3.30386 5.13076 3.15248 4.76531C3.00111 4.39986 2.9615 3.99772 3.03867 3.60976C3.11584 3.2218 3.30632 2.86543 3.58603 2.58573C3.86573 2.30602 4.2221 2.11554 4.61006 2.03837C4.99802 1.9612 5.40016 2.00081 5.76561 2.15218C6.13106 2.30356 6.44342 2.5599 6.66318 2.8888C6.88294 3.2177 7.00024 3.60438 7.00024 3.99994C7.00024 4.53037 6.78953 5.03908 6.41446 5.41415C6.03938 5.78923 5.53068 5.99994 5.00024 5.99994Z"/>
</svg>
<%= t(:sign_in) %>
<% end %>
<% end %>
</div>
<div class="c-toolbar__lang">
</div>
</div>
</div>
<div class="c-header__lang">
<div class="c-dropdown">
<span class="c-dropdown__label" onclick="this.parentNode.classList.toggle('is-open')">
<span class="c-dropdown__label__lang">
EST
</span>
<svg width="10" height="7" viewBox="0 0 10 7" fill="white" xmlns="http://www.w3.org/2000/svg">
<path d="M4.50581 5.82828L0.505807 1.82828C0.232439 1.55491 0.232439 1.11169 0.505807 0.838326C0.779174 0.564959 1.22239 0.564959 1.49576 0.838326L5.00078 4.34335L8.50581 0.838326C8.77917 0.564959 9.22239 0.564959 9.49576 0.838326C9.76912 1.11169 9.76912 1.55491 9.49576 1.82828L5.49576 5.82828C5.22239 6.10164 4.77917 6.10164 4.50581 5.82828Z"/>
</svg>
</span>
<ul class="c-dropdown__list s-dropdown-list">
<%= languages %>
</ul>
</div>
</div>
</header>
17 changes: 17 additions & 0 deletions app/components/common/header/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Common
module Header
class Component < ApplicationViewComponent
include Devise::Controllers::Helpers

def languages
l = %w[Est Eng].map do |lang|
content_tag('li') do
content_tag('a', lang, href: '#')
end
end

safe_join(l)
end
end
end
end
7 changes: 7 additions & 0 deletions app/components/common/pagy/component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="u-text-center u-mt-40">
<% if @pagy.pages > 1 %>
<div class="dataTables_filter">
<%== pagy_nav(@pagy) %>
</div>
<% end %>
</div>
15 changes: 15 additions & 0 deletions app/components/common/pagy/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Common
module Pagy
class Component < ApplicationViewComponent
include PagyHelper

attr_reader :pagy

def initialize(pagy:)
@pagy = pagy

super
end
end
end
end
4 changes: 2 additions & 2 deletions app/components/common/table/component.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<table class="js-table-dt dataTable no-footer">
<%= tag.table **@options do %>
<thead>
<tr>
<%= table_header_generator %>
</tr>
</thead>

<%= content %>
</table>
<% end %>
6 changes: 4 additions & 2 deletions app/components/common/table/component.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module Common
module Table
class Component < ApplicationViewComponent
attr_reader :header_collection
attr_reader :header_collection, :options

def initialize(header_collection:, **options)
def initialize(header_collection:, options: {})
@header_collection = header_collection
@options = options

super
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def show; end
# GET /invoices
def index
@issued_invoices = invoices_list_by_status(Invoice.statuses[:issued])
@paid_invoices = invoices_list_by_status(Invoice.statuses[:paid])
@cancelled_payable_invoices = invoices_list_by_status(Invoice.statuses[:cancelled]).with_ban
@cancelled_expired_invoices = invoices_list_by_status(Invoice.statuses[:cancelled]).without_ban

@paid_invoices = invoices_list_by_status(Invoice.statuses[:paid])
@deposit_paid = current_user.domain_participate_auctions.order(created_at: :desc)

return unless params[:state] == 'payment'
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class NotificationsController < ApplicationController
def index
@notifications = current_user&.notifications&.limit(6)
@notifications = current_user&.notifications

@unread_notifications = @notifications&.unread
@read_notifications = @notifications&.read
end
end
3 changes: 3 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ application.register("form--autobider-submit", Form__AutobiderSubmitController);
import Table__OrdeableController from "./table/ordeable_controller";
application.register("table--ordeable", Table__OrdeableController);

import Table__TabController from "./table/tab_controller";
application.register("table--tab", Table__TabController);

import AutotaxCounter from "./autotax_counter_controller";
application.register("autotax-counter", AutotaxCounter);

Expand Down
Loading

0 comments on commit 41ca969

Please sign in to comment.