Skip to content

Commit

Permalink
user is able to add collaborator
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonela-Johannes committed Mar 21, 2023
2 parents 5a83212 + 30476b3 commit aec762d
Show file tree
Hide file tree
Showing 34 changed files with 471 additions and 109 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ gem "cloudinary"
gem "groupdate", "~> 6.2"
gem "faker"
gem "pg_search"

gem 'acts-as-taggable-on', '~> 9.0'
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
acts-as-taggable-on (9.0.1)
activerecord (>= 6.0, < 7.1)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
autoprefixer-rails (10.4.13.0)
Expand Down Expand Up @@ -285,6 +287,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
acts-as-taggable-on (~> 9.0)
autoprefixer-rails
bootsnap
capybara
Expand Down
Binary file added app/assets/images/soiree_colour_logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/soiree_logo_colour.png
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/stylesheets/components/_container.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.application_container {
padding-top: 130px;
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/components/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
@import "icon";
@import "input";
@import "kanban";
@import "container";
22 changes: 19 additions & 3 deletions app/assets/stylesheets/components/_navbar.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@

nav{
padding-bottom: 80px;
padding-bottom: 0px;
}
.navbar{
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
background: #ffffff;
border-bottom: #64c0ae 2px solid;
border-bottom: $light-gray 1px solid;
position: fixed;
height: 70px;
height: 100px;
padding: 5px;
.nav-link {
color: $secondary-color-alt;
margin-left: 30px;
margin-right: 30px;
margin-top: 5px;
}
.nav-link:hover {
color: $secondary-color-hover;
}
.btn-action {
width: 150px;
font-family: $headers-font;
font-size: 16px;
margin-top: 10px;
}
// a.logo{
// font-size: 25px;
// letter-spacing: 2px;
Expand Down
13 changes: 8 additions & 5 deletions app/assets/stylesheets/components/_table.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
table, th {
border: 2px solid #BA937C;
padding: 10px;
table,th {
border: 2px solid #BA937C;
padding: 10px;

}

tr:nth-child(even) {
background-color: $light-gray;
}

table, td {
border: 2px dotted #CCCCCC;
padding: 10px;

}
}

.text-table-std, th {
text-align: left;
Expand All @@ -27,5 +31,4 @@ table, td {

.text-table-status, td {
text-align: center;

}
9 changes: 8 additions & 1 deletion app/controllers/expenses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ def index
@event = Event.find(params[:event_id])
@expense.event = @event
@expenses = @event.expenses

categories = ["Catering", "Bar", "Entertainment", "Decor", "Venue", "Services", "Transport", "Other"]

@pie_chart_expenses = []
categories.each do |category|
@pie_chart_expenses << [ category, @expenses.tagged_with(category).sum(:amount_spent) ] if @expenses.tagged_with(category).sum(:amount_spent).positive?
end
end

def show
Expand Down Expand Up @@ -43,6 +50,6 @@ def set_expense
end

def expense_params
params.require(:expense).permit(:name, :amount_spent)
params.require(:expense).permit(:name, :amount_spent, :status, :category_list)
end
end
23 changes: 21 additions & 2 deletions app/controllers/guests_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class GuestsController < ApplicationController
def index
@event = Event.find(params[:event_id])
@guests = @event.guests
@guests = @event.guests.order(updated_at: :desc)
@guest = Guest.new
end

def create
@guest = Guest.new(guest_params)
@event = Event.find(params[:event_id])
@guest = Guest.new(guest_params)
@guest.event = @event
if @guest.save
redirect_to event_guests_path(@event), notice: "Guest was successfully added to the list."
Expand All @@ -16,7 +16,26 @@ def create
end
end

def update
@event = Event.find(params[:event_id])
guest = Guest.find(params[:id])
guest.update!(guest_params)
if guest.save
redirect_to event_guests_path(@event), notice: "Guest was successfully updated."
else
redirect_to event_guests_path(@event), status: :unprocessable_entity, notice: "Guest was not successfully updated."
end
end

def destroy
@event = Event.find(params[:event_id])
guest = Guest.find(params[:id])
guest.destroy
redirect_to event_guests_path(@event), notice: "Guest was successfully removed"
end

private

def guest_params
params.require(:guest).permit(:first_name, :last_name, :email_address, :phone_number)
end
Expand Down
30 changes: 26 additions & 4 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class TasksController < ApplicationController
before_action :set_task, only: [ :update, :destroy ]
before_action :set_event, only: [ :create, :index, :update, :destroy ]
def create
@task = Task.new(task_params)
@event = Event.find(params[:event_id])
@task.event = @event
if @task.save
redirect_to event_tasks_path(@event), notice: "Task was successfully created."
else
redirect_to event_tasks_path(@event), status: :unprocessable_entity, notice: "Event was not successfully created."
redirect_to event_tasks_path(@event), status: :unprocessable_entity, notice: "Task was not successfully created."
end
end

def index
@task = Task.new
@event = Event.find(params[:event_id])
@task.event = @event
@tasks = @event.tasks

Expand All @@ -24,9 +24,31 @@ def index
@incomplete_tasks = @tasks.where(status: [:to_do, :doing])
end

def update
@task.event = @event
@task.update(task_params)
respond_to do |format|
format.html { redirect_to event_tasks_path(@event) }
format.text { render partial: 'tasks/task_infos', locals: { task: @task }, formats: [:html] }
end
end

def destroy
@task.destroy
redirect_to event_tasks_path(@event), notice: "Task was successfully deleted"
end

private

def task_params
params.require(:task).permit(:name, :description, :due_date, :status)
params.require(:task).permit(:name, :description, :due_date, :status, :category_list)
end

def set_task
@task = Task.find(params[:id])
end

def set_event
@event = Event.find(params[:event_id])
end
end
1 change: 1 addition & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Entry point for the build script in your package.json
import "@hotwired/turbo-rails"
import "./controllers"
import "@popperjs/core"
import "bootstrap"
import "chartkick/chart.js"
33 changes: 33 additions & 0 deletions app/javascript/controllers/edit_task_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Controller } from "@hotwired/stimulus"

// Connects to data-controller="edit-task"
export default class extends Controller {
static targets = ["infos", "form", "task"]

connect() {
console.log(this.infosTarget);
console.log(this.formTarget);
console.log(this.taskTarget);
}

displayForm() {
this.infosTarget.classList.add('d-none');
this.formTarget.classList.remove('d-none');
}

// update(event) {
// event.preventDefault();
// const url = this.formTarget.action

// fetch(url, {
// method: 'PATCH',
// headers: { 'Accept': 'text/html' },
// body: new FormData(this.formTarget)
// })
// .then(response => response.text())
// .then((data) => {
// this.taskTarget.outerHTML = data;
// })
// }

}
3 changes: 3 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ application.register("hello", HelloController)

import PhotoPreviewController from "./photo_preview_controller"
application.register("photo-preview", PhotoPreviewController)

import EditTaskController from "./edit_task_controller"
application.register("edit-task", EditTaskController)
1 change: 1 addition & 0 deletions app/models/expense.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Expense < ApplicationRecord
belongs_to :event
enum :status, [:paid, :unpaid]
acts_as_taggable_on :categories
end
3 changes: 2 additions & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Task < ApplicationRecord
belongs_to :event
has_many :assignments, dependent: :destroy

acts_as_taggable_on :categories
enum :status, %i[to_do doing done]

end
23 changes: 18 additions & 5 deletions app/views/expenses/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<%= simple_form_for [ @event, @expense] do |f| %>
<%= f.input :name %>
<%= f.input :amount_spent %>
<%= f.input :category_list, collection: [:Catering, :Bar, :Entertainment, :Decor, :Venue, :Services, :Transport, :Other], label: "Category" %>
<%= f.button :button, "Add expense", class:"btn-action" %>
<% end %>
</div>
Expand All @@ -36,10 +37,10 @@
<table>
<thead>
<tr>

<th>Name</th>
<th>Amount Spent</th>
<th>Status</th>
<th>Category</th>
<th>Status</th>
<th>Date</th>
</tr>
</thead>
Expand All @@ -48,6 +49,7 @@
<tr>
<td><%= e.name %></td>
<td><%= e.amount_spent %></td>
<td><%= e.category_list %></td>
<td>
<% if e.status == "paid" %>
<p class="text-primary"> Paid </p>
Expand All @@ -58,14 +60,25 @@
</tr>
<% end %>
<tr>
<td>Total Expenses:</td>
<td><%= total_expenses %></td>
<td><strong>Total Expenses:</strong></td>
<td><strong><%= total_expenses %></strong></td>
</tr>
</tbody>
</table>

<h5>Total Budget:</h5>
<%= @event.total_budget %>

</div>
<div class="col-md-6">
<%= pie_chart @expenses.group(:name ).sum(:amount_spent), donut: true %>
<%= pie_chart(@pie_chart_expenses, donut: true) %>
</div>

<div>
<%= bar_chart [
{name: "Total Expenses", data: [["R",@expenses.sum(:amount_spent)]]},
{name: "Remaining Budget", data: [["R",@event.total_budget - @expenses.sum(:amount_spent)]]}],
stacked: true %>
</div>

</div>
Loading

0 comments on commit aec762d

Please sign in to comment.