Skip to content
Merged
3 changes: 3 additions & 0 deletions app/assets/images/announcement-disable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/announcement.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/assets/images/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/details.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/star-disable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/ticket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@layer components {
.site-header {
@apply sticky z-10 top-0 flex justify-between items-center py-4 px-32 bg-primary p-5 drop-shadow-[5px_5px_20px_rgba(51,102,40,0.4)] min-h-20;
@apply fixed z-10 top-0 w-screen flex justify-between items-center py-4 px-32 bg-primary p-5 drop-shadow-[5px_5px_20px_rgba(51,102,40,0.4)] min-h-20;
}

.site-main {
Expand Down Expand Up @@ -56,7 +56,7 @@
}

.notice {
@apply p-5 bg-success text-textPrimary rounded-3xl font-bold absolute top-[90px] right-32 left-32;
@apply p-5 bg-success text-textPrimary rounded-3xl font-bold mx-32;
}

.alert {
Expand Down Expand Up @@ -114,4 +114,12 @@
.filter_button {
@apply bg-primary text-white;
}

.sidebar-item-div {
@apply flex relative justify-center items-center p-2 min-h-[50px];
}

.sidebar-tooltip {
@apply absolute px-4 py-2 rounded-full left-24 bg-[#C2CFDE] hidden;
}
}
6 changes: 3 additions & 3 deletions app/controllers/announcements_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AnnouncementsController < ApplicationController
layout "dashboard"
layout "dashboard_with_sidebar"
before_action :authenticate_user!
before_action :set_event
before_action :check_if_published
Expand All @@ -24,9 +24,9 @@ def create
@announcement.user = current_user
@announcement.event = @event
if @announcement.save
redirect_to event_announcements_path(@event), notice: t(".success")
redirect_to event_announcements_path(@event)
else
@announcements = @event.announcements
@announcements = @event.announcements.order(created_at: :desc)
flash.now[:alert] = t(".failure")
render :index, status: :unprocessable_entity
end
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern

helper_method :current_event

def after_sign_in_path_for(resource)
dashboard_path
end

protected

def current_event
@event ||= Event.find_by(id: params[:event_id]) || Event.find_by(id: params[:id])
end

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [ :name, :family_name, :registration_number ])
end
Expand Down
10 changes: 9 additions & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class EventsController < ApplicationController
layout "dashboard"
layout :determine_layout
before_action :authenticate_user!
before_action :check_if_admin, only: [ :history ]
before_action :authorize_event_access, only: [ :show, :publish, :destroy, :edit, :update ]
Expand Down Expand Up @@ -76,6 +76,14 @@ def history

private

def determine_layout
if [ "index", "new", "create", "history" ].include?(action_name)
"dashboard"
else
"dashboard_with_sidebar"
end
end

def event_params
params.require(:event).permit(:name, :address, :event_type, :participants_limit, :url, :logo, :banner, :description, :start_date, :end_date, category_ids: [])
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/feedbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class FeedbacksController < ApplicationController
layout "dashboard"
layout "dashboard_with_sidebar"
before_action :authenticate_user!
before_action :authorize_event_access
before_action :check_if_event_ended
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/schedules_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SchedulesController < ApplicationController
layout "dashboard"
layout "dashboard_with_sidebar"
before_action :authenticate_user!
before_action :authorize_schedule_access, only: [ :show ]
before_action :find_event, only: [ :show ]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ticket_batches_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class TicketBatchesController < ApplicationController
layout "dashboard"
layout "dashboard_with_sidebar"
before_action :authenticate_user!
before_action :authorize_event_access
before_action :set_ticket_batch, only: [ :edit, :update ]
Expand Down
14 changes: 14 additions & 0 deletions app/javascript/controllers/flash_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
static targets = ["message"];
connect() {
setTimeout(() => {
this.close();
}, 7000);
}

close() {
this.messageTarget.remove();
}
}
3 changes: 3 additions & 0 deletions app/models/ticket_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def sold_tickets_count
rescue Faraday::Error => error
Rails.logger.error(error)
[]
rescue Rack::Timeout::RequestTimeoutException => error
Rails.logger.error(error)
[]
end

private
Expand Down
7 changes: 1 addition & 6 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
<% if @event.draft? %>
<%= button_to 'Publicar', publish_event_path(@event), method: :patch, class: 'outline_button' %>
<% end %>
<%= link_to 'Comunicados', event_announcements_path(@event), class: 'outline_button' %>
<%= link_to 'Lotes', event_ticket_batches_path(@event), class: 'outline_button' %>
<% if @event.ended?%>
<%= link_to 'Feedbacks', event_feedbacks_path(@event), class: 'outline_button'%>
<% end %>
<%= link_to 'Editar', edit_event_path(@event), class: 'outline_button' %>
<%= button_to 'Excluir', event_path(@event), method: :delete, class: 'danger_button h-full w-full', data: { turbo_method: :delete, turbo_confirm: "Tem certeza que deseja deletar o evento:\n#{@event.name}", test_id: "delete-#{@event.id}" } %>
</div>
Expand Down Expand Up @@ -80,7 +75,7 @@
</div>
</article>

<aside class="flex flex-col gap-4 items-end pl-10 min-w-fit">
<aside class="flex flex-col gap-4 items-end pl-10 min-w-fit" data-shedule-items>
<h2 class="text-right">Agendas do Evento</h2>
<% @event.schedules.order(date: :asc).each do |schedule| %>
<%= link_to event_schedule_path(@event, schedule), class: "text-right justify-end underline underline-offset-4 decoration-primary hover:bg-textPrimary/15 p-3 rounded-md transition duration-150 font-bold hover:brightness-90" do %>
Expand Down
2 changes: 0 additions & 2 deletions app/views/feedbacks/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div class="max-w-[50vw] min-w-[50vw] mx-auto">
<turbo-frame id="feedbacks">
<section class="bg-white w-full rounded shadow-md mb-10 min-h-[20vh] p-10">
<h1 class="mb-4">Feedbacks</h1>
<% if @feedbacks.any?%>
Expand Down Expand Up @@ -58,5 +57,4 @@
</div>
<% end %>
</section>
</turbo-frame>
</div>
7 changes: 1 addition & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@
<% end %>
</header>

<% if flash[:notice] %>
<p class="notice"><%= notice %></p>
<% end %>
<% if flash[:alert] %>
<p class="alert"><%= alert %></p>
<% end %>
<%= render 'shared/flash_messages'%>

<main class="site-main">
<%= yield %>
Expand Down
17 changes: 6 additions & 11 deletions app/views/layouts/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,11 @@
<%= render 'shared/navbar' %>
</header>

<% if flash[:notice] %>
<p class="notice"><%= notice %></p>
<% end %>
<% if flash[:alert] %>
<p class="alert"><%= alert %></p>
<% end %>

<main class="site-main">
<%= render 'shared/breadcrumbs' %>
<%= yield %>
</main>
<%= render 'shared/flash_messages'%>

<main class="site-main">
<%= render 'shared/breadcrumbs' %>
<%= yield %>
</main>
</body>
</html>
42 changes: 42 additions & 0 deletions app/views/layouts/dashboard_with_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) || "E-Ventos" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= yield :head %>
<%# 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) %>
<%= favicon_link_tag asset_path('wind.svg') %>
<link rel="apple-touch-icon" href="/icon.png">
<%# Includes all stylesheet files in app/assets/stylesheets %>
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head>
<body class="relative bg-backgroundWhite min-h-screen text-textPrimary font-sans" data-controller="sidebar">
<header class="site-header">
<%= link_to dashboard_path do %>
<span class="w-20 lg:w-auto user-select-none"><%= image_tag "Logo.svg"%></span>
<% end %>

<%= render 'shared/navbar' %>
</header>



<%= render 'shared/flash_messages'%>


<%= render 'shared/sidebar'%>
<main class="site-main">
<%= render 'shared/breadcrumbs' %>
<%= yield %>
</main>


</body>
</html>
2 changes: 1 addition & 1 deletion app/views/shared/_breadcrumbs.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav id="breadcrumbs" class="flex gap-2 py-2 mb-10 border-y border-primary">
<nav id="breadcrumbs" class="flex gap-2 py-2 mb-10">
<% breadcrumbs.each_with_index do |breadcrumb, index| %>
<% if index == breadcrumbs.length - 1 %>
<span class="breadcrumb_active_route"><%= breadcrumb.name %></span>
Expand Down
14 changes: 14 additions & 0 deletions app/views/shared/_flash_messages.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="mt-[90px]" data-controller="flash">
<% if flash[:notice] %>
<div class="notice flex justify-between" data-flash-target="message">
<p><%= notice %></p>
<button data-action="flash#close"><img src="<%= asset_path('close.svg')%>" alt="close" class="w-4"></button>
</div>
<% end %>
<% if flash[:alert] %>
<div class="alert flex justify-between" data-flash-target="message">
<p><%= alert %></p>
<button data-action="flash#close"><img src="<%= asset_path('close.svg')%>" alt="close" class="w-4"></button>
</div>
<% end %>
</div>
46 changes: 46 additions & 0 deletions app/views/shared/_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<aside class="z-50 rounded-full fixed w-20 left-5 top-1/2 transform -translate-y-1/2 h-1/2 bg-[#DDEAF8] text-primary" data-sidebar-target="menu">
<nav class="flex h-full justify-center w-full">
<ul class="flex flex-col justify-around h-full w-full py-5">
<div class="sidebar-item-div group hover:bg-[#C2CFDE] <%= 'bg-[#C2CFDE]' if controller_name == 'events'%>">
<div class='rounded-xl'>
<%= link_to event_path(current_event) do%>
<img src="<%=asset_path('details.svg')%>" alt="detalhes" class="w-10">
<% end %>
</div>
<div class="sidebar-tooltip group-hover:block">Detalhes</div>
</div>
<div class="sidebar-item-div group hover:bg-[#C2CFDE] <%= 'bg-[#C2CFDE]' if controller_name == 'ticket_batches'%>">
<div class=''>
<%= link_to event_ticket_batches_path(current_event) do%>
<img src="<%=asset_path('ticket.svg')%>" alt="lotes" class="w-10">
<% end %>
</div>
<div class="sidebar-tooltip group-hover:block">Lotes</div>
</div>
<div class="sidebar-item-div group <%="hover:bg-[#C2CFDE]" if @event.published?%> <%= 'bg-[#C2CFDE]' if controller_name == 'announcements'%>">
<div class=''>
<% if @event.published?%>
<%= link_to event_announcements_path(current_event) do%>
<img src="<%=asset_path('announcement.svg')%>" alt="close" class="w-10">
<% end %>
<% else %>
<img src="<%=asset_path('announcement-disable.svg')%>" alt="close" class="w-10">
<% end %>
</div>
<div class="sidebar-tooltip group-hover:block">Comunicados</div>
</div>
<div class="sidebar-item-div group <%="hover:bg-[#C2CFDE]" if @event.ended?%> <%= 'bg-[#C2CFDE]' if controller_name == 'feedbacks'%>">
<div class='rounded-xl'>
<% if @event.ended?%>
<%= link_to event_feedbacks_path(current_event) do%>
<img src="<%=asset_path('star.svg')%>" alt="close" class="w-10">
<% end %>
<% else %>
<img src="<%=asset_path('star-disable.svg')%>" alt="close" class="w-10">
<% end %>
</div>
<div class="sidebar-tooltip group-hover:block">Feedbacks</div>
</div>
</ul>
</nav>
</aside>
2 changes: 1 addition & 1 deletion config/initializers/timeout.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Rails.application.config.middleware.insert_before Rack::Runtime, Rack::Timeout, service_timeout: 8
Rails.application.config.middleware.insert_before Rack::Runtime, Rack::Timeout, service_timeout: 5
12 changes: 8 additions & 4 deletions spec/system/announcement/user_create_annoucement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,33 @@
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'
find('a[href*="announcements"]').click
fill_in 'announcement[title]', with: 'Palestra x foi cancelada'
find('trix-editor').click.set('Por conta de y Evento')
click_on 'Enviar'

expect(page).to have_content 'Palestra x foi cancelada'
expect(page).to have_content 'Por conta de y Evento'
expect(page).to have_content "Comunicado adicionado com sucesso."
end

it 'e falha por não preencher campos obrigatórios' do
event_manager = create(:user)
create(:event, user: event_manager, status: :published)
event = create(:event, name: 'ccxp', status: :published, user: event_manager)
create(:announcement, title: 'Distribuição de cartas One Piece', user: event_manager, event: event)
create(:announcement, title: 'Transporte da estação Luz', user: event_manager, event: event)


login_as event_manager
visit root_path
within "nav#navbar" do
click_on 'Meus Eventos'
end
click_on 'Gerenciar'
click_on 'Comunicados'
find('a[href*="announcements"]').click
click_on 'Enviar'

announcements = all('[data-announcement-title]')
expect(announcements.map(&:text)).to eq [ 'Transporte da estação Luz', 'Distribuição de cartas One Piece' ]
expect(page).to have_content "Comunicado não foi adicionado."
end
end
Loading