Skip to content

Commit

Permalink
Merge pull request #959 from paloesg/enhance/add-settings-to-turn-on-…
Browse files Browse the repository at this point in the history
…off-features

Add settings to turn on off features and fix JSONB error for admin page
  • Loading branch information
Jonathanlau92 authored Mar 16, 2021
2 parents 406934f + 05bff8e commit 2def3e3
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 42 deletions.
7 changes: 5 additions & 2 deletions app/dashboards/company_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class CompanyDashboard < Administrate::BaseDashboard
expires_at: Field::Number,
account_type: EnumField,
before_deadline_reminder_days: Field::Number,
settings: Field::JSONB,
products: Field::JSONB,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}
Expand All @@ -47,8 +49,7 @@ class CompanyDashboard < Administrate::BaseDashboard
:workflows,
:templates,
:documents,
:batches,
:invoices,
:products,
:company_type
]

Expand Down Expand Up @@ -77,6 +78,8 @@ class CompanyDashboard < Administrate::BaseDashboard
:expires_at,
:account_type,
:before_deadline_reminder_days,
:settings,
:products
]

# Overwrite this method to customize how profiles are displayed
Expand Down
10 changes: 10 additions & 0 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def find_franchisors
self.users.includes(:roles).where(roles: { name: "franchisor" })
end

# To change the settings of overture feature, we need to parse it in JSON for the admin page as the gem doesn't provide it for now
def settings=(value)
self[:settings] = value.is_a?(String) ? JSON.parse(value) : value
end

# To add or remove products in the admin page, we need to parse the product value for the admin page as the gem doesn't provide it for now
def products=(value)
self[:products] = value.is_a?(String) ? JSON.parse(value) : value
end

private

def generate_mailbox_token
Expand Down
88 changes: 49 additions & 39 deletions app/views/layouts/overture/_overture_sidebar.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,61 @@
i.material-icons-outlined.mr-5 dashboard
.ml-5.sidebar-font Dashboard
- if current_user.company.startup?
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_contacts_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 search
.ml-5.sidebar-font Search Investor
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_contact_statuses_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 view_agenda
.ml-5.sidebar-font Buyer's Progress
- if current_user.company.settings[0]["search_feature"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_contacts_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 search
.ml-5.sidebar-font Search Investor
- if current_user.company.settings[0]["kanban_board"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_contact_statuses_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 view_agenda
.ml-5.sidebar-font Buyer's Progress
- else
- if current_user.company.settings[0]["search_feature"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_profiles_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 search
.ml-5.sidebar-font Search Startup
- if current_user.company.settings[0]["dataroom"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_profiles_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 search
.ml-5.sidebar-font Search Startup
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to (current_user.company.startup? ? overture_startups_documents_path : overture_companies_path), class: 'col-sm-12 d-flex align-items-center' do
= image_pack_tag 'media/src/images/overture/dataroom-lock-icon.png', alt: "dataroom-lock-icon", class: 'mr-6'
.ml-5.sidebar-font Dataroom
= link_to (current_user.company.startup? ? overture_startups_documents_path : overture_companies_path), class: 'col-sm-12 d-flex align-items-center' do
= image_pack_tag 'media/src/images/overture/dataroom-lock-icon.png', alt: "dataroom-lock-icon", class: 'mr-6'
.ml-5.sidebar-font Dataroom
hr.m-1.text-dark
ul.nav.flex-column
- if current_user.company.startup?
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_investments_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 supervised_user_circle
.ml-5.sidebar-font Our Investors
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_capitalization_table_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 table_chart
.ml-5.sidebar-font Capitalization Table
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_financial_performance_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 timeline
.ml-5.sidebar-font Performance Report
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to Folder.find_by(company: current_user.company, name: "Shared Drive").present? ? overture_folder_path(id: Folder.find_by(company: current_user.company, name: "Shared Drive").id) : overture_startups_documents_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 folder
.ml-5.sidebar-font Shared Files
- if current_user.company.settings[0]["our_investor_or_startup"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_investments_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 supervised_user_circle
.ml-5.sidebar-font Our Investors
- if current_user.company.settings[0]["cap_table"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_capitalization_table_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 table_chart
.ml-5.sidebar-font Capitalization Table
- if current_user.company.settings[0]["performance_report"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_financial_performance_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 timeline
.ml-5.sidebar-font Performance Report
- if current_user.company.settings[0]["shared_file"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to Folder.find_by(company: current_user.company, name: "Shared Drive").present? ? overture_folder_path(id: Folder.find_by(company: current_user.company, name: "Shared Drive").id) : overture_startups_documents_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 folder
.ml-5.sidebar-font Shared Files
- else
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_investments_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 domain
.ml-5.sidebar-font My Startups
- if current_user.company.settings[0]["our_investor_or_startup"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to overture_investments_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 domain
.ml-5.sidebar-font My Startups
hr.m-1.text-dark
ul.nav.flex-column
- if current_user.company.startup?
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to Folder.find_by(company: current_user.company, name: "Resource Portal").present? ? overture_folder_path(id: Folder.find_by(company: current_user.company, name: "Resource Portal").id) : overture_startups_documents_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 book
.ml-5.sidebar-font Resource Portal
- if current_user.company.settings[0]["resource_portal"] == "true"
li.nav-item.hover-blue.py-1.m-4.cursor-pointer
= link_to Folder.find_by(company: current_user.company, name: "Resource Portal").present? ? overture_folder_path(id: Folder.find_by(company: current_user.company, name: "Resource Portal").id) : overture_startups_documents_path, class: 'col-sm-12 d-flex align-items-center' do
i.material-icons-outlined.mr-5 book
.ml-5.sidebar-font Resource Portal
5 changes: 5 additions & 0 deletions db/migrate/20210316060147_add_settings_to_companies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSettingsToCompanies < ActiveRecord::Migration[6.1]
def change
add_column :companies, :settings, :json, default: [{search_feature: 'true', kanban_board: 'true', dataroom: 'true', our_investor_or_startup: 'true', cap_table: 'true', performance_report: 'true', shared_file: 'true', resource_portal: 'true' }]
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_03_05_024013) do
ActiveRecord::Schema.define(version: 2021_03_16_060147) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
Expand Down Expand Up @@ -217,6 +217,7 @@
t.integer "storage_limit"
t.integer "storage_used"
t.string "cap_table_url"
t.json "settings", default: [{"search_feature"=>"true", "kanban_board"=>"true", "dataroom"=>"true", "our_investor_or_startup"=>"true", "cap_table"=>"true", "performance_report"=>"true", "shared_file"=>"true", "resource_portal"=>"true"}]
t.index ["ancestry"], name: "index_companies_on_ancestry"
t.index ["associate_id"], name: "index_companies_on_associate_id"
t.index ["consultant_id"], name: "index_companies_on_consultant_id"
Expand Down

0 comments on commit 2def3e3

Please sign in to comment.