-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd60827
commit 33ca337
Showing
10 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<nav class="nav nav-pills nav-fill" role="tablist"> | ||
<% @weekdays.each do |day| %> | ||
<%= button_tag day.strftime("%A"), class: ["nav-link", ("active" if day.today?)], data: { bs_toggle: :tab, bs_target: "##{day}" } %> | ||
<% end %> | ||
</nav> | ||
|
||
<hr> | ||
|
||
<div class="tab-content"> | ||
<% @grouped_events.each_pair do |day, events| %> | ||
<%= tag.div id: day, class: ["tab-pane", ("active" if day.today?)], role: :tabpanel do %> | ||
<ul class="list-group"> | ||
<% events.each do |event| %> | ||
<li class="list-group-item d-flex justify-content-between lh-lg align-items-center"> | ||
<%= event.activity_name %> | ||
|
||
<small><%= event.start_time %> - <%= event.end_time %></small> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module App | ||
class AgendaComponent < ViewComponent::Base | ||
def initialize(events:) | ||
@grouped_events = events.group_by { |event| event.starts_at.to_date } | ||
@weekdays = Time.zone.today.all_week | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module App | ||
class AgendasController < BaseController | ||
def show | ||
authorize :agenda, :show? | ||
|
||
activities = policy_scope(Current.company.activities).includes(:schedule) | ||
week = Time.zone.today.all_week | ||
|
||
@events = EventDecorator.decorate_collection( | ||
Event.from_activities(activities, from: week.begin, to: week.end) | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module App | ||
class AgendaPolicy < ApplicationPolicy | ||
def show? | ||
customer? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%= turbo_frame_tag :remote_modal, target: :_top do %> | ||
<div class="modal" data-controller="modal" data-bs-backdrop="static"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title"><%= t '.title' %></h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<%= render App::AgendaComponent.new(events: @events) %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe App::AgendaComponent, type: :component do | ||
let(:activity) { build(:activity) } | ||
let(:event1) { build(:event, activity:, starts_at: Time.current.beginning_of_week).decorate } | ||
let(:event2) { build(:event, activity:, starts_at: Time.current.end_of_week).decorate } | ||
|
||
subject { render_inline(described_class.new(events: [ event1, event2 ])).to_html } | ||
|
||
Time.zone.today.all_week.each do |date| | ||
it { is_expected.to include(date.strftime("%A")) } | ||
end | ||
|
||
it { is_expected.to include(activity.name) } | ||
it { is_expected.to include(event1.start_time) } | ||
it { is_expected.to include(event1.end_time) } | ||
it { is_expected.to include(event2.start_time) } | ||
it { is_expected.to include(event2.end_time) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe App::AgendaPolicy, type: :policy do | ||
let(:customer) { create(:customer) } | ||
|
||
subject { described_class } | ||
|
||
before { Current.customer = customer } | ||
|
||
permissions :show? do | ||
it_behaves_like "a customer resource" do | ||
let(:resource) { :agenda } | ||
end | ||
end | ||
end |