-
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.
Add Quick Links and user projects table
Each division now has a Quick Links section that should be only editable by division administrators. I also added a table that shows the current projects for the user.
- Loading branch information
Showing
9 changed files
with
164 additions
and
53 deletions.
There are no files selected for viewing
48 changes: 26 additions & 22 deletions
48
app/assets/stylesheets/admin/dashboard_beta/_dashboard.scss
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 |
---|---|---|
@@ -1,7 +1,39 @@ | ||
class Admin::DashboardBetaController < Admin::AdminController | ||
def dashboard | ||
authorize :dashboard | ||
@person = Person.find(current_user.profile_id) | ||
end | ||
class Admin::DashboardBetaController < Admin::AdminController | ||
|
||
STATUS_FILTERS = %w(all active completed) | ||
|
||
def dashboard | ||
authorize :dashboard | ||
@person = Person.find(current_user.profile_id) | ||
@division = selected_division_or_root | ||
|
||
prep_projects_grid_for_current_user | ||
end | ||
|
||
private | ||
|
||
def prep_projects_grid_for_current_user | ||
# Projects belonging to the current user | ||
# 15 most recent projects, sorted by created date, then updated date | ||
@recent_projects = @person.active_agent_projects | ||
|
||
@recent_projects_grid = initialize_wice_grid(@recent_projects, @person.id) | ||
|
||
@status_filter_options = STATUS_FILTERS.map { |f| [I18n.t("dashboard.status_options.#{f}"), f] } | ||
end | ||
|
||
private | ||
|
||
def initialize_wice_grid(projects, person_id) | ||
initialize_grid( | ||
projects, | ||
include: [:primary_agent, :secondary_agent], | ||
order: "projects.order_by_agent", | ||
custom_order: { | ||
"projects.order_by_agent" => ->(_col) { Arel.sql(Project.dashboard_order(person_id)) }, | ||
}, | ||
name: "projects_person_#{person_id}", | ||
enable_export_to_csv: false | ||
) | ||
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
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 @@ | ||
class DashboardBetaPolicy < ApplicationPolicy | ||
class Scope < DivisionOwnedScope | ||
end | ||
|
||
def dashboard? | ||
true | ||
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,24 @@ | ||
= simple_form_for([:admin, @division], | ||
html: { \ | ||
class: 'form-horizontal organization-record', | ||
}, | ||
wrapper: :horizontal_form_condensed, | ||
defaults: { \ | ||
input_html: {class: 'form-element form-control'}, | ||
}, | ||
) do |f| | ||
|
||
- form_identifier = 'division_quicklinks' | ||
- popover_options = {placement: 'left'} | ||
|
||
= error_notification(f) | ||
|
||
|
||
= f.input :quick_links, label: false, hint: false, as: :summernote | ||
.view-element = sanitize(@division.quick_links) | ||
= f.input_field :quick_links, label: false, hint: false, as: :summernote | ||
|
||
.actions.form-element | ||
= f.submit class: 'update-action btn btn-primary' | ||
= "Update Notes" | ||
.clearfix |
39 changes: 39 additions & 0 deletions
39
app/views/admin/dashboard_beta/_recent_projects_grid_definition.html.slim
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,39 @@ | ||
= define_grid(grid, hide_csv_button: true, | ||
html: {class: 'rowlink table-hover', data: {link: @csv_mode ? nil : 'row'}}) do |g| | ||
|
||
- g.row_attributes do |project| | ||
- if project.primary_agent_id == person.id | ||
- {class: 'bold'} | ||
|
||
- g.blank_slate { grid.no_records_at_all = true; "" } | ||
|
||
- g.column name: 'LID', attribute: 'id', filter: false, in_csv: false, | ||
ordering: false do |project| | ||
- if project.type == 'BasicProject' | ||
- link_to(project.id, admin_basic_project_path(project.id)) | ||
- else | ||
- link_to(project.id, admin_loan_path(project.id)) | ||
|
||
- g.column name: 'Project Name', attribute: 'name', filter: false, in_csv: false, | ||
ordering: false do |project| | ||
- project.name | ||
|
||
- g.column name: t('common.role'), attribute: 'primary_agent_id', filter: false, | ||
ordering: false do |project| | ||
- if project.primary_agent_id == person.id | ||
- t('common.first') | ||
- else | ||
- t('common.second') | ||
|
||
- g.column name: t('activerecord.attributes.project.status'), attribute: 'status_value', | ||
filter: false, ordering: false do |project| | ||
- content_tag(:span, project.status, | ||
class: "project-status #{project.status_value == 'completed' ? 'completed' : 'active'}") | ||
|
||
- g.column name: 'Percentage of memo complete', attribute: 'name', filter: false, in_csv: false, | ||
ordering: false do |project| | ||
- "Sample percentage" | ||
|
||
- g.column name: 'Next steps', attribute: 'name', filter: false, in_csv: false, | ||
ordering: false do |project| | ||
- "Sample steps" |
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,5 @@ | ||
class AddQuicklinksToDivisions < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :divisions, :quick_links, :string | ||
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