Files
PMS/app/views/tasks/index.html.erb
2026-01-28 09:53:14 +06:30

95 lines
3.2 KiB
Plaintext

<div class="dashboard-header">
<h1>Task Management</h1>
<% if current_user %>
<div class="user-info">
<span class="user-role">
<%= current_user.name %> - <%= current_user.role.humanize %>
<% if current_user.department %>
( <%= current_user.department.name %> )
<% end %>
</span>
</div>
<% end %>
</div>
<% if flash[:notice] %>
<div class="notice"><%= flash[:notice] %></div>
<% end %>
<div class="content-layout">
<div class="sidebar">
<div class="filter-section">
<h3>Filters</h3>
<% if accessible_departments.count > 1 %>
<div class="filter-group">
<label>Department</label>
<%= form_with(url: tasks_path, method: :get, local: true, class: "filter-form") do |f| %>
<%= f.select :department_id,
options_for_select([[ "All Departments", "" ]] + accessible_departments.map { |d| [d.name, d.id] },
params[:department_id]),
{ onchange: "this.form.submit();" },
{ class: "filter-select" } %>
<% end %>
</div>
<% end %>
<div class="filter-group">
<label>Priority</label>
<%= form_with(url: tasks_path, method: :get, local: true, class: "filter-form") do |f| %>
<%= f.select :priority,
options_for_select([[ "All Priorities", "" ]] + Task.priorities.keys.map { |p| [p.humanize, p] },
params[:priority]),
{ onchange: "this.form.submit();" },
{ class: "filter-select" } %>
<% end %>
</div>
<div class="filter-group">
<label>Status</label>
<%= form_with(url: tasks_path, method: :get, local: true, class: "filter-form") do |f| %>
<%= f.select :status,
options_for_select([[ "All Statuses", "" ]] + Task.statuses.keys.map { |s| [s.humanize, s] },
params[:status]),
{ onchange: "this.form.submit();" },
{ class: "filter-select" } %>
<% end %>
</div>
</div>
<div class="actions-section">
<h3>Actions</h3>
<%= link_to 'Dashboard', dashboard_path, class: 'action-btn' %>
<%= link_to 'My Tasks', my_tasks_path, class: 'action-btn' if current_user.employee? %>
<%= link_to 'Departments', departments_path, class: 'action-btn' if current_user.admin? || current_user.manager? %>
<% if current_user.admin? %>
<%= link_to 'New User', new_user_registration_path, class: 'action-btn' %>
<% end %>
</div>
</div>
<div class="main-content">
<div class="new-task-section">
<h2>Create New Task</h2>
<%= form_with(model: @task, local: true, class: "task-form") do |form| %>
<%= render 'form', task: @task, form: form %>
<% end %>
</div>
<div class="tasks-section">
<h2>Tasks (<%= @tasks.count %>)</h2>
<% if @tasks.empty? %>
<p class="empty-state">No tasks found with current filters.</p>
<% else %>
<div class="tasks-list">
<% @tasks.each do |task| %>
<%= render 'task', task: task %>
<% end %>
</div>
<% end %>
</div>
</div>
</div>