Skip to content

Admin Dashboard - #274

Open
jasonsouza wants to merge 12 commits into
qafrom
admin-dashboard
Open

Admin Dashboard#274
jasonsouza wants to merge 12 commits into
qafrom
admin-dashboard

Conversation

@jasonsouza

@jasonsouza jasonsouza commented Mar 13, 2018

Copy link
Copy Markdown
Contributor

This pull request will add the admin page for employees and admins to have access to the following dashboards:

  • Employees (admin only)
    • List all employees
    • Create new employees
    • Delete employees
  • Customers
    • List all customers
    • Attributes can be editable
    • sort and filter by name
    • searchable by email, first name, last name
  • Wholesalers
    • List all wholesalers
      • Add status
      • Filter by status
    • View wholesaler
    • Approve/deny wholesaler
  • Menu
    • Edit/Upgrade Menu
  • Coupons
    • List of available coupons
    • Search/Filter by expiration date, status

Other Tasks:

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use %i or %I for an array of symbols.

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.


# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use %i or %I for an array of symbols.

:customer,
:id,
:business_name,
:contact_name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.


# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use %i or %I for an array of symbols.

:category,
:id,
:name,
:description,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use %i or %I for an array of symbols.

description: Field::Text,
price: Field::String.with_options(searchable: false),
created_at: Field::DateTime,
updated_at: Field::DateTime,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of a hash.

@@ -0,0 +1,60 @@
require "administrate/base_dashboard"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

misternu
misternu previously approved these changes Mar 15, 2018
@jasonsouza jasonsouza added the WIP label Mar 15, 2018
@misternu
misternu dismissed their stale review March 15, 2018 01:33

mistake

visit '/admin'
expect(current_path).to eq(admin_root_path)
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

end at 14, 4 is not aligned with RSpec.feature "Admin dashboard" do at 3, 0.

Comment thread spec/features/admin_features_spec.rb Outdated
# customer = create(:customer)
end
it 'logs in as admin' do
visit '/admin'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use 2 (not 4) spaces for indentation.

Comment thread spec/features/admin_features_spec.rb Outdated
# employee = create(:employee)
# customer = create(:customer)
end
it 'logs in as admin' do

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

Comment thread spec/features/admin_features_spec.rb Outdated
before :each do
admin = create(:admin)
# employee = create(:employee)
# customer = create(:customer)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect indentation detected (column 12 instead of 10).

Comment thread spec/features/admin_features_spec.rb Outdated
RSpec.feature "Admin dashboard" do
context 'visit admin page before logging in'
before :each do
admin = create(:admin)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use 2 (not 4) spaces for indentation.
Useless assignment to variable - admin.

Comment thread spec/features/admin_features_spec.rb Outdated
@@ -0,0 +1,14 @@
require "rails_helper"

RSpec.feature "Admin dashboard" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

Comment thread spec/features/admin_features_spec.rb Outdated
@@ -0,0 +1,14 @@
require "rails_helper"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

password_confirmation '12345678'
end
factory :admin, :class => 'Employee' do
sequence(:email){ |n| "employeedoe1#{n}@example.com" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Space missing to the left of {.

password '12345678'
password_confirmation '12345678'
end
factory :admin, :class => 'Employee' do

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

Comment thread spec/features/admin_features_spec.rb Outdated
# it 'logs in as admin' do
# visit '/admin'
# expect(current_path).to eq(admin_root_path)
# end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect indentation detected (column 8 instead of 2).

Comment thread spec/features/admin_features_spec.rb Outdated
# end
# it 'not logged in' do
# visit '/admin'
# end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect indentation detected (column 4 instead of 8).

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

Comment thread spec/features/admin_features_spec.rb Outdated
# it 'logs in as admin' do
# visit '/admin'
# expect(current_path).to eq(admin_root_path)
# end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect indentation detected (column 8 instead of 2).

Comment thread spec/features/admin_features_spec.rb Outdated
# end
# it 'not logged in' do
# visit '/admin'
# end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Incorrect indentation detected (column 4 instead of 8).

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

Comment thread app/models/customer.rb
@@ -1,5 +1,5 @@
class Customer < ApplicationRecord

has_many :orders

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Specify a :dependent option.

before_action :authenticate_admin

def authenticate_admin
redirect_to "/employees/sign_in" unless current_employee

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

plan_opts.map{|sub| "#{sub.metadata.frequency} / #{number_to_currency(sub.amount.to_f / 100)} per bag" }

plans.sort!{|a,b| freq[a.metadata.frequency] <=> freq[b.metadata.frequency] }
plans.map{|sub| "#{sub.metadata.frequency} / #{number_to_currency(sub.amount.to_f / 100)} per bag" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Space missing to the left of {.
Space between { and | missing.

plan_opts.sort!{|a,b| freq[a.metadata.frequency] <=> freq[b.metadata.frequency] }
plan_opts.map{|sub| "#{sub.metadata.frequency} / #{number_to_currency(sub.amount.to_f / 100)} per bag" }

plans.sort!{|a,b| freq[a.metadata.frequency] <=> freq[b.metadata.frequency] }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Space missing to the left of {.
Space between { and | missing.
Space missing after comma.

Comment thread app/dashboards/wholesaler_dashboard.rb Outdated
:recieving_hours,
:days_closed,
:is_approved,
:is_rejected,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid comma after the last item of an array.

password_confirmation '12345678'
end
factory :admin, :class => 'Employee' do
sequence(:email){ |n| "employeedoe1#{n}@example.com" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Layout/SpaceBeforeBlockBraces: Space missing to the left of {.

password '12345678'
password_confirmation '12345678'
end
factory :admin, :class => 'Employee' do

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.

:category,
:name,
:description,
:price,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/TrailingCommaInArrayLiteral: Avoid comma after the last item of an array.

# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/SymbolArray: Use %i or %I for an array of symbols.

:description,
:price,
:created_at,
:updated_at,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/TrailingCommaInArrayLiteral: Avoid comma after the last item of an array.

# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/SymbolArray: Use %i or %I for an array of symbols.

:grind_id,
:sku,
:name,
:price,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/TrailingCommaInArrayLiteral: Avoid comma after the last item of an array.


# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/SymbolArray: Use %i or %I for an array of symbols.

:customer,
:order,
:id,
:created_at,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/TrailingCommaInArrayLiteral: Avoid comma after the last item of an array.

#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Style/SymbolArray: Use %i or %I for an array of symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants