Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developed Projects listing page #105

Merged
merged 8 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class ProjectsController < ApplicationController
def index
if params["query"]
@projects = Project.where("name LIKE ?", "%#{params['query']}%")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be really nice if we could use Ransack gem for the search part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keshavbiswa, I have added the Ransack gem. Can you review it once again?

else
@projects = Project.all
judis007 marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
72 changes: 72 additions & 0 deletions app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<div class="" id="root-page">
<div class="max-w-6xl mx-auto px-2 md:px-11 font-manrope" x-data="{ 'isDialogOpen': false }" @keydown.escape="isDialogOpen = false">
<div class="px-5">
<div class="">

<div class="sm:flex sm:items-center sm:justify-between mt-6 mb-3">
<div class="flex-1 min-w-0">
<h2 class="text-3xl font-extrabold leading-7 text-gray-900 sm:text-4xl py-1">
Projects
</h2>
</div>
<div class="mt-6 flex sm:mt-0 md:ml-4 items-center sm:w-4/6">
<div class="mt-1 relative rounded-md shadow-sm md:ml-10">
<%= form_with url: projects_path, method: :get do |form| %>
<%= form.text_field :query, class: 'rounded tracking-wider appearance-none border border-gray-100 block w-72 sm:w-96 px-3 py-2 bg-miru-gray-100 h-8 shadow-sm font-semibold text-xs text-miru-dark-purple-1000 focus:outline-none focus:ring-miru-gray-1000 focus:border-miru-gray-1000 sm:text-sm', placeholder: 'Search' %>
<%= image_submit_tag 'search_icon.svg', class: "h-3 text-miru-gray-400 absolute inset-y-2 right-0 pr-3 flex items-center cursor-pointer" %>
<% end %>
</div>
</div>
<div class="mt-6 flex sm:mt-0 md:ml-4">
<button @click="isDialogOpen = true" type="button" class="ml-2 tracking-widest inline-flex items-center h-10 w-full flex justify-center py-1 px-4 border-2 border-miru-han-purple-1000 shadow-sm bg-transparent hover:border-miru-han-purple-600 focus:outline-none rounded text-base font-sans font-medium text-miru-han-purple-1000 bg-transparent hover:text-miru-han-purple-600 cursor-pointer">
<img src="<%= image_url 'plus_icon.svg' %>" class="-ml-0.5 mr-2 h-4 w-4 ">
NEW PROJECT
</button>
</div>
</div>

<!-- team table -->
<div class="flex flex-col">
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8 ">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="overflow-hidden border-b-2 border-miru-gray-200 ">
<table class="min-w-full divide-y divide-gray-200 mt-4">
<thead class="">
<tr>
<th scope="col" class="px-6 py-5 text-left text-sm font-semibold text-miru-dark-purple-600 tracking-wider">
PROJECT/CLIENT
judis007 marked this conversation as resolved.
Show resolved Hide resolved
</th>
<th scope="col" class="px-6 py-5 text-left text-sm font-semibold text-miru-dark-purple-600 tracking-wider">
HOURS LOGGED
</th>
<th scope="col" class="px-6 py-5 text-left text-sm font-semibold text-miru-dark-purple-600 tracking-wider">

</th>
<th scope="col" class="relative px-6 py-5">
<span class="sr-only">Edit</span>
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @projects.each do |project| %>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-miru-dark-purple-1000">
<%= project.name.capitalize %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-miru-dark-purple-1000">
<%= project.timesheet_entries.collect(&:duration).first %>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
</td>
</tr>
<% end %>

</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
judis007 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def draw(routes_name)
resources :time_tracking, only: [:index], path: "time-tracking"
resources :clients, only: [:index]
resources :team, only: [:index, :update, :destroy]
resources :projects, only: [:index]

devise_scope :user do
get "profile", to: "users/registrations#edit"
Expand Down