Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Remove Flatpicker (#132)
Browse files Browse the repository at this point in the history
* Add head to CORS

* Credit balances report

* Gemfile change

* Removed flatpicker and upgrades stimulus/turbo

* Some UI changes

* Fix for new customer report

* Change app tier
  • Loading branch information
jmadkins authored Jan 27, 2022
1 parent 1d0e36f commit bc6c378
Show file tree
Hide file tree
Showing 45 changed files with 1,236 additions and 1,208 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#### 2102.11 - January 27, 2022

- Admin Portal Improvements
- Credit Balances report
- Removed custom datetime picker infavor of pickers offered by the users browser
- Technical features and improvements
- Updates to system dependencies

#### 2102.10 - January 16, 2022

- Changes
Expand Down
19 changes: 11 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
GEM
remote: https://rubygems.org/
remote: https://rubygems.pkg.github.com/mythcoders/
specs:
aasm (5.2.0)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -202,13 +201,6 @@ GEM
html2haml (>= 1.0.1)
railties (>= 5.1)
hashie (4.1.0)
hermes (0.4.1)
activesupport (>= 4.2.2)
faraday (>= 1.0)
faraday_middleware
hashie (>= 3.4.0)
mail (>= 2.5.4)
mime-types
hotwire-rails (0.1.3)
rails (>= 6.0.0)
stimulus-rails
Expand Down Expand Up @@ -514,6 +506,17 @@ GEM
nokogiri (~> 1.8)
zeitwerk (2.4.2)

GEM
remote: https://rubygems.pkg.github.com/mythcoders/
specs:
hermes (0.4.1)
activesupport (>= 4.2.2)
faraday (>= 1.0)
faraday_middleware
hashie (>= 3.4.0)
mail (>= 2.5.4)
mime-types

PLATFORMS
ruby

Expand Down
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2102.10
2102.11
1 change: 0 additions & 1 deletion app/assets/stylesheets/apollo/_admin_portal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Styles specific to the Admin Portal
//

@import "flatpickr/dist/flatpickr.css";
@import "trix/dist/trix.css";
@import "actiontext";

Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/dashkit/_vendors.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@import "vendors/dropzone";
@import "vendors/flatpickr";
@import "vendors/list";
5 changes: 1 addition & 4 deletions app/controllers/admin/announcements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ def destroy
private

def announcement_params
parameters = params.require(:announcement).permit(:title, :content, :start_at, :end_at)
parameters[:start_at] = convert_datetime(parameters[:start_at])
parameters[:end_at] = convert_datetime(parameters[:end_at])
parameters
params.require(:announcement).permit(:title, :content, :start_at, :end_at)
end

def set_announcement
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/admin/customer_credits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,12 @@ def set_credit

def create_params
parameters = params.require(:customer_credit).permit(:user_id, :starting_amount, :expiration_date)
parameters[:expiration_date] = convert_date(parameters[:expiration_date])
parameters[:balance] = parameters[:starting_amount]
parameters
end

def update_params
parameters = params.require(:customer_credit).permit(:user_id, :expiration_date)
parameters[:expiration_date] = convert_date(parameters[:expiration_date])
parameters
params.require(:customer_credit).permit(:user_id, :expiration_date)
end
end
end
19 changes: 17 additions & 2 deletions app/controllers/admin/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def guest_list
end
end

def credit_balances
@report = CreditBalancesReport.new(credit_balances_params) if request.post?

respond_to do |format|
format.turbo_stream { render "credit_balances", locals: {report: @report} }
format.html
end
end

private

def sales_tax_params
Expand All @@ -44,8 +53,8 @@ def sales_tax_params

def new_customers_params
{
start_date: convert_datetime(params[:start_date]),
end_date: convert_datetime(params[:end_date])
start_date: params[:start_date],
end_date: params[:end_date]
}
end

Expand All @@ -55,6 +64,12 @@ def guest_list_params
}
end

def credit_balances_params
{
include_zero_balances: ActiveModel::Type::Boolean.new.cast(params[:include_zero_balances])
}
end

def tax_periods
@tax_periods ||= TaxPeriod.all
end
Expand Down
12 changes: 2 additions & 10 deletions app/controllers/admin/tax_periods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def new
end

def create
@tax_period = TaxPeriod.new(filtered_params)
@tax_period = TaxPeriod.new(tax_period_params)

if @tax_period.save
flash[:success] = t("create.success")
Expand All @@ -26,7 +26,7 @@ def create
end

def update
if @tax_period.update(filtered_params)
if @tax_period.update(tax_period_params)
flash[:success] = t("update.success")
redirect_to admin_tax_periods_path
else
Expand All @@ -53,13 +53,5 @@ def set_tax_period
def tax_period_params
params.require(:tax_period).permit(:start_date, :due_date, :amount_paid)
end

def filtered_params
parameters = tax_period_params
parameters[:start_date] = convert_datetime(parameters[:start_date])
parameters[:due_date] = convert_datetime(parameters[:due_date])

parameters
end
end
end
2 changes: 0 additions & 2 deletions app/controllers/admin/tax_rates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def tax_rate_params
def filtered_params
parameters = tax_rate_params
parameters[:rate] = (parameters[:rate].to_d / 100).to_s
parameters[:effective_date] = convert_datetime(parameters[:effective_date])

parameters
end

Expand Down
4 changes: 0 additions & 4 deletions app/controllers/admin/workshops_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ def set_workshop_types
def filtered_params
parameters = workshop_params
parameters[:project_ids]&.reject!(&:blank?)
parameters[:purchase_start_date] = convert_datetime(parameters[:purchase_start_date])
parameters[:purchase_end_date] = convert_datetime(parameters[:purchase_end_date])
parameters[:start_date] = convert_datetime(parameters[:start_date])
parameters[:end_date] = convert_datetime(parameters[:end_date])
parameters
end
end
Expand Down
12 changes: 0 additions & 12 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ def set_permitted_parameters
devise_parameter_sanitizer.permit(:account_update, keys: [:role])
end

def convert_datetime(value)
return nil if value.blank?

Time.zone.strptime(value, t("time.formats.default"))
end

def convert_date(value)
return nil if value.blank?

Date.strptime(value, "%m-%d-%Y")
end

def render_404
respond_to do |format|
format.html { render file: "public/404.html", status: 404 }
Expand Down
3 changes: 0 additions & 3 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ application.load(
)
)

import Flatpickr from 'stimulus-flatpickr'
application.register('flatpickr', Flatpickr)

import 'bootstrap/dist/js/bootstrap.bundle.min'
import 'helpers/sentry_helpers'
20 changes: 20 additions & 0 deletions app/reports/credit_balances_report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class CreditBalancesReport
def initialize(params)
@include_zero_balances = params[:include_zero_balances]
end

def raw_data
@raw_data ||= customer_credits
end

private

def customer_credits
scope = CustomerCredit.includes(:customer).order("users.last_name")
return scope.all if @include_zero_balances

scope.where("balance > 0")
end
end
4 changes: 2 additions & 2 deletions app/reports/new_customers_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class NewCustomersReport
def initialize(params)
@start_date = params[:start_date]
@end_date = params[:end_date] ||= Time.zone.now
@start_date = Date.parse params[:start_date]
@end_date = Date.parse params[:end_date] ||= Time.zone.now
end

attr_reader :start_date, :end_date
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/addons/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

= form_for @addon, url: admin_addon_path(@addon), method: :patch do |f|
.card
.card-header
%h3.card-header-title Edit Add-on
.card-body
= error_messages_for 'addon'
= render partial: 'admin/addons/form', locals: { f: f }
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/addons/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

= form_for @addon, url: admin_addons_path do |f|
.card
.card-header
%h3.card-header-title Information
.card-body
= error_messages_for 'addon'
= render partial: 'admin/addons/form', locals: { f: f }
Expand Down
12 changes: 2 additions & 10 deletions app/views/admin/announcements/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@
.form-row
.form-group.col
= f.label :start_at, class: 'col-form-label'
.input-group.date
= f.text_field :start_at, value: lifp(@announcement.start_at), class: 'form-control', data: { controller: "flatpickr", flatpickr_date_format: t('time.formats.default'), flatpickr_enable_time: true }
.input-group-append{"data-target": "#startpicker", "data-toggle": "datetimepicker"}
.input-group-text
= fa_regular 'calendar'
= f.datetime_field :start_at, class: 'form-control'
.form-group.col
= f.label :end_at, class: 'col-form-label'
.input-group.date
= f.text_field :end_at, value: lifp(@announcement.end_at), class: 'form-control', data: { controller: "flatpickr", flatpickr_date_format: t('time.formats.default'), flatpickr_enable_time: true }
.input-group-append
.input-group-text
= fa_regular 'calendar'
= f.datetime_field :end_at, class: 'form-control'
.form-group
= f.rich_text_area :content
8 changes: 1 addition & 7 deletions app/views/admin/customer_credits/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

= form_for @credit, url: admin_customer_credit_path(@credit), method: :patch do |f|
.card
.card-header
%h5.card-header-title Information
.card-body
= error_messages_for 'credit'
= f.hidden_field :id
Expand All @@ -27,11 +25,7 @@
.form-control-plaintext= number_to_currency @credit.starting_amount
.form-group.col-12.col-md-6
= f.label :expiration_date, class: 'col-form-label'
#expirationpicker.input-group.date{"data-target-input": "nearest", 'data-date-picker': ''}
= f.text_field :expiration_date, value: lifp(@credit.expiration_date), class: 'form-control datepicker-input', 'data-target': '#expirationpicker'
.input-group-append{"data-target": "#expirationpicker", "data-toggle": "datetimepicker"}
.input-group-text
= fa_regular 'calendar'
= f.date_field :expiration_date, class: 'form-control'
.card-footer
= link_to 'Cancel', admin_customer_path(@credit.customer), class: 'btn btn-outline-secondary'
= f.submit 'Save Changes', class: 'btn btn-success'
Expand Down
8 changes: 1 addition & 7 deletions app/views/admin/customer_credits/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

= form_for @credit, url: admin_customer_credits_path do |f|
.card
.card-header
%h5.card-header-title Information
.card-body
= error_messages_for 'credit'
= f.hidden_field :user_id
Expand All @@ -27,11 +25,7 @@
%small.text-muted This amount can not be changed after creation
.form-group.col-12.col-md-6
= f.label :expiration_date, class: 'col-form-label'
#expirationpicker.input-group.date{"data-target-input": "nearest", 'data-date-picker': ''}
= f.text_field :expiration_date, value: lifp(@credit.expiration_date), class: 'form-control datepicker-input', 'data-target': '#expirationpicker'
.input-group-append{"data-target": "#expirationpicker", "data-toggle": "datetimepicker"}
.input-group-text
= fa_regular 'calendar'
= f.date_field :expiration_date, class: 'form-control'
.card-footer
= link_to 'Cancel', admin_customer_path(@credit.customer), class: 'btn btn-outline-secondary'
= f.submit 'Create', class: 'btn btn-success'
6 changes: 1 addition & 5 deletions app/views/admin/customers/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
.form-row
.form-group.col
= f.label :locked_at, class: 'col-form-label'
.input-group.date
= f.text_field :locked_at, value: lifp(@customer.locked_at), class: 'form-control', data: { controller: "flatpickr", flatpickr_date_format: t('time.formats.default'), flatpickr_enable_time: true }
.input-group-append
.input-group-text
= fa_regular 'calendar'
= f.datetime_field :locked_at, class: 'form-control'
.form-group.col
= f.label :failed_attempts, class: 'col-form-label'
= f.text_field :failed_attempts, class: 'form-control'
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/customers/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
= link_to "Delete", admin_customer_path(@customer), method: :delete, class: 'btn btn-outline-danger',
data: {confirm: 'Are you sure want to delete this customer? This can not be undone!'}
.card
.card-header
%h3.card-header-title Information
.card-body
= error_messages_for 'customer'
= render partial: 'admin/customers/form', locals: { f: f }
2 changes: 0 additions & 2 deletions app/views/admin/customers/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

= form_for @customer, url: admin_customers_path do |f|
.card
.card-header
%h3.card-header-title Information
.card-body
= error_messages_for 'customer'
= render partial: 'admin/customers/form', locals: { f: f }
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/employees/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

= form_for @employee, url: admin_employee_path(@employee), method: :patch do |f|
.card
.card-header
%h2.card-header-title Information
.card-body
= error_messages_for 'employee'
= render partial: 'admin/employees/form', locals: { f: f }
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/employees/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

= form_for @employee, url: admin_employees_path do |f|
.card
.card-header
%h2.card-header-title Information
.card-body
= error_messages_for 'employee'
= render partial: 'admin/employees/form', locals: { f: f }
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/employees/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
.col-auto

.card
.card-header
%h2.card-header-title Information
.card-body
.form-group
%label
Expand Down
2 changes: 0 additions & 2 deletions app/views/admin/projects/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
.row
.col-12.col-md-5
.card
.card-header
%h3.card-header-title Information
.card-body
= error_messages_for 'project'
= render partial: 'admin/projects/form', locals: { f: f }
Expand Down
Loading

0 comments on commit bc6c378

Please sign in to comment.