diff --git a/Gemfile.lock b/Gemfile.lock index b59d0063..72dea97d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,7 +80,7 @@ GEM rack ast (2.4.2) aws-eventstream (1.3.0) - aws-partitions (1.1031.0) + aws-partitions (1.1032.0) aws-sdk-core (3.214.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) @@ -524,7 +524,7 @@ CHECKSUMS appsignal (4.3.2) sha256=b1f988815f2f972e9cba49eac6c459b1b2c376638d7c3c17c8c6e872d4d51043 ast (2.4.2) sha256=1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12 aws-eventstream (1.3.0) sha256=f1434cc03ab2248756eb02cfa45e900e59a061d7fbdc4a9fd82a5dd23d796d3f - aws-partitions (1.1031.0) sha256=b29f1e6e9ea047d3272031c1a1ad2ab874157e45a7e705fae8e12c5e2845fa55 + aws-partitions (1.1032.0) sha256=8ae20dbd109e115f52989f2d09fe83bd05b25ea0d1e4c66c4ae0f7c80e95eeac aws-sdk-core (3.214.1) sha256=419b317407d736a19f8b7c422ec134630dc283766a0f9171ceaa2704e82d49fd aws-sdk-lambda (1.144.0) sha256=0299f2e961aa2e4bd6f34cde39ea9b66b2eb43057a8df36eb54d0f022d091d49 aws-sdk-rails (5.1.0) sha256=8cffd3b60142e12a6747c91a7a609f668276b1082fc0c10810d5da3d14b13189 diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 887c60ce..87a1b32f 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -23,6 +23,7 @@ def index def show @account.readonly! + render 'show' end def new @@ -37,7 +38,7 @@ def create authorize(@account) if @account.save - redirect_to(accounts_path, notice: 'Account was successfully created.') + redirect_to(edit_account_path(@account), notice: 'Account was successfully created.') else render(:new) end @@ -45,7 +46,7 @@ def create def update if @account.update(account_params) - redirect_to(accounts_path, notice: 'Account was successfully updated.') + redirect_to(account_path(@account), notice: 'Account was successfully updated.') else render(:edit) end @@ -77,16 +78,11 @@ def account_params params.fetch(:account, {}).permit( :name, :description, - :weblink, - :stakeholder_type_id, - :welcome_message, + :classic_grid_mode, :deactivated, :expires_on, :max_users, :max_scorecards, - :solution_ecosystem_maps, - :allow_transition_cards, - :allow_sustainable_development_goal_alignment_cards, :transition_card_model_name, :transition_card_focus_area_group_model_name, :transition_card_focus_area_model_name, diff --git a/app/helpers/checklist_items_helper.rb b/app/helpers/checklist_items_helper.rb index c142e7a4..0f485b43 100644 --- a/app/helpers/checklist_items_helper.rb +++ b/app/helpers/checklist_items_helper.rb @@ -33,6 +33,14 @@ module ChecklistItemsHelper other: 'bg-gray-200 dark:bg-gray-600' }.freeze + CHECKLIST_LIST_ITEM_COLOR_OPACITY = { + actual: 'FF', + planned: '99', + more_information: '66', + suggestion: '40', + other: '00' + }.freeze + CHECKLIST_LIST_ITEM_RADIO_BUTTON_COLOR_CLASSES = { actual: 'text-sky-600 focus:ring-sky-600', planned: 'text-teal-500 focus:ring-teal-500', @@ -56,16 +64,19 @@ def focus_area_grid_element(focus_area_data) ) end - def checklist_list_item_grid_element(checklist_item_data) - background_color = checklist_list_item_grid_element_color(checklist_item_data[:status]) + def checklist_list_item_grid_element(checklist_item_data:, grid_mode:) + options = checklist_list_item_grid_element_base_options(checklist_item_data) - content_tag( - :div, - '', - class: "p-1.5 h-2 rounded-sm #{background_color}", - title: checklist_item_data[:name], - data: { status: checklist_item_data[:status] } - ) + case grid_mode + when :modern + background_color_class = checklist_list_item_status_color(checklist_item_data[:status]) + options[:class] = "#{options[:class]} #{background_color_class}" + when :classic + background_color_hex = checklist_list_item_focus_area_status_color(checklist_item_data) + options[:style] = "background-color: #{background_color_hex}" + end + + content_tag(:div, '', options) end def current_comment_status_style(checklist_item) @@ -85,14 +96,32 @@ def checklist_item_badge(checklist_item) # rubocop:disable Metrics/MethodLength comments_target: 'badge', toggle: 'tooltip', placement: 'top', - title: checklist_item.status.humanize + title: checklist_item.status.humanizeex } ) end private - def checklist_list_item_grid_element_color(status) + def checklist_list_item_grid_element_base_options(checklist_item_data) + { + class: 'p-1.5 h-2 rounded-sm', + title: checklist_item_data[:name], + data: { + status: checklist_item_data[:status], + focus_area_color: checklist_item_data[:focus_area_color] + } + } + end + + def checklist_list_item_focus_area_status_color(checklist_item_data) + opacity = CHECKLIST_LIST_ITEM_COLOR_OPACITY[checklist_item_data[:status].to_sym].presence || + CHECKLIST_LIST_ITEM_COLOR_OPACITY[:other] + + checklist_item_data[:focus_area_color] + opacity + end + + def checklist_list_item_status_color(status) CHECKLIST_LIST_ITEM_COLOR_CLASSES[status.to_sym].presence || CHECKLIST_LIST_ITEM_COLOR_CLASSES[:other] end diff --git a/app/helpers/custom_form_builder.rb b/app/helpers/custom_form_builder.rb index 59926886..de424c16 100644 --- a/app/helpers/custom_form_builder.rb +++ b/app/helpers/custom_form_builder.rb @@ -220,6 +220,10 @@ def multi_select(method, choices = nil, options = {}, html_options = {}, &block) end end + def number_field(method, options = {}) + wrap_field(method) { super(method, merge_options(method:, options:)) } + end + def password_field(method, options = {}) wrap_field(method) { super(method, merge_options(method:, options:)) } end diff --git a/app/helpers/impact_cards_helper.rb b/app/helpers/impact_cards_helper.rb index b50cc2d5..c4f76a01 100644 --- a/app/helpers/impact_cards_helper.rb +++ b/app/helpers/impact_cards_helper.rb @@ -51,10 +51,25 @@ def multi_select_options_for_labels(labels, selected_labels) # Selected statuses are expected to be an array of strings, e.g. ["actual", "planned", ...] # # The color class is determined by the status name, itself expected to be a symbol, e.g. :actual, :planned, ... - def multi_select_options_for_statuses(statuses, selected_statuses) + def multi_select_options_for_statuses(statuses, selected_statuses, impact_card) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength + focus_area_groups = impact_card.account.focus_area_groups.where(scorecard_type: impact_card.type) + focus_areas = FocusArea.where(focus_area_group: focus_area_groups).order(:scorecard_type, :position) + classic_mode_colors = focus_areas.map(&:actual_color).values_at(0, focus_areas.length / 2, -1).uniq + choices = statuses.map do |status| - color_class = ChecklistItemsHelper::CHECKLIST_LIST_ITEM_COLOR_CLASSES[status[1].to_sym] - icon = { icon: "
 
".html_safe } # rubocop:disable Rails/OutputSafety + if impact_card.grid_mode.to_sym == :classic + icons = classic_mode_colors.map do |color| + opacity = ChecklistItemsHelper::CHECKLIST_LIST_ITEM_COLOR_OPACITY[status[1].to_sym] + status_color = "#{color}#{opacity}" + + "
 
".html_safe # rubocop:disable Rails/OutputSafety,Layout/LineLength + end + icon = { icon: "
#{icons.join('')}
".html_safe } # rubocop:disable Rails/OutputSafety + else + color_class = ChecklistItemsHelper::CHECKLIST_LIST_ITEM_COLOR_CLASSES[status[1].to_sym] + icon = { icon: "
 
".html_safe } # rubocop:disable Rails/OutputSafety,Layout/LineLength + end + [*status, { data: { hs_select_option: icon.to_json(escape_html_entities: false) } }] end diff --git a/app/javascript/controllers/grid_controller.js b/app/javascript/controllers/grid_controller.js index 31dd289a..cd1c9086 100644 --- a/app/javascript/controllers/grid_controller.js +++ b/app/javascript/controllers/grid_controller.js @@ -31,18 +31,50 @@ export default class extends Controller { const elements = this.gridTarget.querySelectorAll('[data-status]') - elements.forEach(element => { - const status = element.getAttribute('data-status') - const colorClasses = this.statusColorClasses(status) - - if (statuses === undefined || statuses.length == 0 || statuses.includes(status)) { - element.classList.add(...colorClasses) - element.classList.remove('bg-gray-500') - } else { - element.classList.remove(...colorClasses) - element.classList.add('bg-gray-500') - } - }) + if (this.data.get('mode') == 'classic') { + elements.forEach(element => { + const status = element.getAttribute('data-status') + const baseColor = element.getAttribute('data-focus-area-color') + const opacity = this.statusBackgroundColorOpacity(status) + const color = `${baseColor}${opacity}` + + if (statuses === undefined || statuses.length == 0 || statuses.includes(status)) { + element.style.backgroundColor = color + } else { + element.style.backgroundColor = '#00000000' + } + }) + } else { + elements.forEach(element => { + const status = element.getAttribute('data-status') + const colorClasses = this.statusColorClasses(status) + + if (statuses === undefined || statuses.length == 0 || statuses.includes(status)) { + element.classList.add(...colorClasses) + element.classList.remove('bg-gray-500') + } else { + element.classList.remove(...colorClasses) + element.classList.add('bg-gray-500') + } + }) + } + } + + + // NOTE: Duplicated in checklist_items_helper.rb + statusBackgroundColorOpacity(status) { + switch (status) { + case 'actual': + return 'FF' + case 'planned': + return '99' + case 'more_information': + return '66' + case 'suggestion': + return '40' + default: + return '00' + } } statusColorClasses(status) { diff --git a/app/models/account.rb b/app/models/account.rb index dfcaf7ff..af1fea9e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -4,31 +4,31 @@ # # Table name: accounts # -# id :integer not null, primary key -# allow_sustainable_development_goal_alignment_cards :boolean default(FALSE) -# allow_transition_cards :boolean default(TRUE) -# deactivated :boolean -# deleted_at :datetime -# description :string -# expires_on :date -# expiry_warning_sent_on :date -# max_scorecards :integer default(1) -# max_users :integer default(1) -# name :string -# sdgs_alignment_card_characteristic_model_name :string default("Targets") -# sdgs_alignment_card_focus_area_group_model_name :string default("Focus Area Group") -# sdgs_alignment_card_focus_area_model_name :string default("Focus Area") -# sdgs_alignment_card_model_name :string default("SDGs Alignment Card") -# solution_ecosystem_maps :boolean -# transition_card_characteristic_model_name :string default("Characteristic") -# transition_card_focus_area_group_model_name :string default("Focus Area Group") -# transition_card_focus_area_model_name :string default("Focus Area") -# transition_card_model_name :string default("Transition Card") -# weblink :string -# welcome_message :text -# created_at :datetime not null -# updated_at :datetime not null -# stakeholder_type_id :integer +# id :integer not null, primary key +# classic_grid_mode :boolean default(FALSE) +# deactivated :boolean +# deleted_at :datetime +# deprecated_allow_sustainable_development_goal_alignment_cards :boolean default(FALSE) +# deprecated_allow_transition_cards :boolean default(TRUE) +# deprecated_solution_ecosystem_maps :boolean +# deprecated_weblink :string +# deprecated_welcome_message :text +# description :string +# expires_on :date +# expiry_warning_sent_on :date +# max_scorecards :integer default(1) +# max_users :integer default(1) +# name :string +# sdgs_alignment_card_characteristic_model_name :string default("Targets") +# sdgs_alignment_card_focus_area_group_model_name :string default("Focus Area Group") +# sdgs_alignment_card_focus_area_model_name :string default("Focus Area") +# sdgs_alignment_card_model_name :string default("SDGs Alignment Card") +# transition_card_characteristic_model_name :string default("Characteristic") +# transition_card_focus_area_group_model_name :string default("Focus Area Group") +# transition_card_focus_area_model_name :string default("Focus Area") +# transition_card_model_name :string default("Transition Card") +# created_at :datetime not null +# updated_at :datetime not null # class Account < ApplicationRecord include Searchable @@ -38,8 +38,6 @@ class Account < ApplicationRecord EXPIRY_WARNING_PERIOD = 30.days - belongs_to :stakeholder_type, optional: true - # Direct associations has_many :accounts_users, dependent: :destroy has_many :communities, dependent: :destroy @@ -83,22 +81,17 @@ def max_users_reached? users.count >= max_users end - def scorecard_types - @scorecard_types ||= - [].tap do |types| - types << TransitionCard if allow_transition_cards? - types << SustainableDevelopmentGoalAlignmentCard if allow_sustainable_development_goal_alignment_cards? - end - end + SCORECARD_TYPES = [ + TransitionCard, + SustainableDevelopmentGoalAlignmentCard + ].freeze def default_scorecard_type - return scorecard_types.first if scorecard_types.size == 1 - TransitionCard end def custom_stakeholder_types_in_use? - StakeholderType.system_stakeholder_types.order(:name).pluck(:name) != stakeholder_types.order(:name).pluck(:name) + StakeholderType.system_stakeholder_types.order(:name).pluck(:name) != SCORECARD_TYPES.order(:name).pluck(:name) end private diff --git a/app/models/scorecard.rb b/app/models/scorecard.rb index 01867c77..c0e7b78f 100644 --- a/app/models/scorecard.rb +++ b/app/models/scorecard.rb @@ -74,6 +74,10 @@ def set_inverse_linked_scorecard true end + def grid_mode + @grid_mode ||= account.classic_grid_mode? ? :classic : :modern + end + def linked? linked_scorecard_id.present? end diff --git a/app/models/user.rb b/app/models/user.rb index 6a2cbaee..9ef95b15 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,7 +67,7 @@ class User < ApplicationRecord accepts_nested_attributes_for :accounts_users, allow_destroy: true # Virtual attributes used when inviting or updating users - attr_accessor :initial_account_role, :initial_system_role + attr_accessor :initial_account_role, :initial_system_role, :account_role def self.ransackable_attributes(_auth_object = nil) %w[name email] + _ransackers.keys diff --git a/app/policies/scorecard_policy.rb b/app/policies/scorecard_policy.rb index a946fdd2..da1a2b59 100644 --- a/app/policies/scorecard_policy.rb +++ b/app/policies/scorecard_policy.rb @@ -3,13 +3,7 @@ class ScorecardPolicy < ApplicationPolicy # rubocop:disable Style/Documentation class Scope < Scope # rubocop:disable Style/Documentation def resolve - resolve_to_current_account.where(type: current_account_scorecard_types) - end - - private - - def current_account_scorecard_types - current_account&.scorecard_types&.map(&:name).presence || [] + resolve_to_current_account end end diff --git a/app/views/accounts/_account.html.erb b/app/views/accounts/_account.html.erb index 4362d7b1..49df6d0f 100644 --- a/app/views/accounts/_account.html.erb +++ b/app/views/accounts/_account.html.erb @@ -5,9 +5,9 @@ <%= render partial: 'resource_summary', locals: { name: account.name, background_color: 'bg-green-700' } %>
- <%= link_to highlight(account.name, params.dig(:q, :name_or_description_cont)), edit_account_path(account) %> + <%= link_to highlight(account.name, params.dig(:q, :name_or_description_cont)), account_path(account), data: { turbo: false } %>
-
+
<%= highlight(account.description, params.dig(:q, :name_or_description_cont)) %>
diff --git a/app/views/accounts/_form.html.erb b/app/views/accounts/_form.html.erb index 54660a3f..7871acee 100644 --- a/app/views/accounts/_form.html.erb +++ b/app/views/accounts/_form.html.erb @@ -1,81 +1,92 @@ -<%= form_for(@account, role: 'form', html: { class: 'form-horizontal record-form space-y-6' }) do |f| %> - <%#= form_header(@account) %> +
+ <%= form_for(account, html: { role: 'form' }) do |form| %> + <%= render 'form_header', record: account %> + <%= render 'form_body' do %> + <%= render 'section' do %> + <%= render 'section_header', title: 'Overview', subtitle: 'General settings this account.' %> + <%= render 'section_body' do %> +
+ <%= form.label :name %> +
+ <%= + form.text_field(:name, placeholder: 'Account name', autofocus: true, required: true) + %> +
+
-
- <%= f.label :name, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :name %> -
-
+
+ <%= form.label :description %> +
+ <%= form.text_area :description %> +
+
-
- <%= f.label :description, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_area :description %> -
-
+ <% end %> + <% end %> -
- <%= f.label :welcome_message, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_area :welcome_message %> -
-
+ <%= render 'section' do %> + <%= render 'section_header', title: 'Status', subtitle: 'Activation and expiration settings for this account' %> + <%= render 'section_body' do %> + <% if policy(@account).update_protected_attributes? %> +
+ <%= form.label :deactivated %> +
+ <%= form.checkbox :deactivated %> +
+
- <% if policy(@account).update_protected_attributes? %> -
- <%= f.label :expires_on, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :expires_on, class: 'form-input block w-full', data: { behaviour: "datepicker" } %> -
-
+
+ <%= form.label :expires_on %> +
+ <%= form.date_field :expires_on %> +
+
-
- <%= f.label :expiry_warning_sent_on, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :expiry_warning_sent_on, class: 'form-input block w-full', readonly: true %> -
-
+
+ <%= form.label :expiry_warning_sent_on %> +
+ <%= form.date_field :expiry_warning_sent_on, readonly: true, disabled: true %> +
+
+ <% end %> + <% end %> + <% end %> -
- <%= f.label :max_users, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :max_users, class: 'form-input block w-full' %> -
-
+ <%= render 'section' do %> + <%= render 'section_header', title: 'Restrictions', subtitle: 'Limits to number of team members and impact cards' %> + <%= render 'section_body' do %> + <% if policy(@account).update_protected_attributes? %> +
+ <%= form.label :max_users, "Max team members" %> +
+ <%= form.number_field :max_users, min: 0 %> +
+

Set to zero (0) to indicate unlimited team members.

+
-
- <%= f.label :max_scorecards, "Max #{Scorecard.model_name.human.pluralize.downcase}", class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :max_scorecards, class: 'form-input block w-full' %> -
-
+
+ <%= form.label :max_scorecards, 'Max impact ards' %> +
+ <%= form.number_field :max_scorecards, min: 0 %> +
+

Set to zero (0) to indicate unlimited impact cards.

+
+ <% end %> + <% end %> + <% end %> -
-
- <%= label :solution_ecosystem_maps, 'Solution Ecosystem Map?' %> -
-
- <%= f.check_box :solution_ecosystem_maps, class: 'form-checkbox' %> -
-
- -
-
- -
-
- <%= f.check_box :allow_transition_cards, class: 'form-checkbox' %> -
-
- -
-
- -
-
- <%= f.check_box :allow_sustainable_development_goal_alignment_cards, class: 'form-checkbox' %> -
-
+ <%= render 'section' do %> + <%= render 'section_header', title: 'Other Settings' %> + <%= render 'section_body' do %> +
+ <%= form.label :classic_grid_mode %> +
+ <%= form.checkbox :classic_grid_mode %> +
+
+ <% end %> + <% end %> + <%= render 'form_buttons', form:, cancel_path: account.persisted? ? account_path(account) : accounts_path %> + <% end %> <% end %> -<% end %> +
diff --git a/app/views/accounts/_form.html.erb.old b/app/views/accounts/_form.html.erb.old new file mode 100644 index 00000000..74b2a268 --- /dev/null +++ b/app/views/accounts/_form.html.erb.old @@ -0,0 +1,74 @@ +<%= form_for(@account, role: 'form', html: { class: 'form-horizontal record-form space-y-6' }) do |f| %> + <%#= form_header(@account) %> + +
+ <%= f.label :name, class: 'w-1/3 text-right pr-4' %> +
+ <%= f.text_field :name %> +
+
+ +
+ <%= f.label :description, class: 'w-1/3 text-right pr-4' %> +
+ <%= f.text_area :description %> +
+
+ + <% if policy(@account).update_protected_attributes? %> +
+ <%= f.label :expires_on, class: 'w-1/3 text-right pr-4' %> +
+ <%= f.text_field :expires_on, class: 'form-input block w-full', data: { behaviour: "datepicker" } %> +
+
+ +
+ <%= f.label :expiry_warning_sent_on, class: 'w-1/3 text-right pr-4' %> +
+ <%= f.text_field :expiry_warning_sent_on, class: 'form-input block w-full', readonly: true %> +
+
+ +
+ <%= f.label :max_accounts, class: 'w-1/3 text-right pr-4' %> +
+ <%= f.text_field :max_accounts, class: 'form-input block w-full' %> +
+
+ +
+ <%= f.label :max_scorecards, "Max #{Scorecard.model_name.human.pluralize.downcase}", class: 'w-1/3 text-right pr-4' %> +
+ <%= f.text_field :max_scorecards, class: 'form-input block w-full' %> +
+
+ +
+
+ <%= label :solution_ecosystem_maps, 'Solution Ecosystem Map?' %> +
+
+ <%= f.check_box :solution_ecosystem_maps, class: 'form-checkbox' %> +
+
+ +
+
+ +
+
+ <%= f.check_box :allow_transition_cards, class: 'form-checkbox' %> +
+
+ +
+
+ +
+
+ <%= f.check_box :allow_sustainable_development_goal_alignment_cards, class: 'form-checkbox' %> +
+
+ <% end %> +<% end %> diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index 100d5fa4..68034694 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -1,70 +1,46 @@ -<%= form_for(@account, html: { class: 'space-y-6' }) do |f| %> - <%= form_header(@account) %> +
+
+
+ <%= page_header_tag 'Account Details' %> +
+
+ <%= render partial: 'resource_summary', locals: { name: @account.name, background_color: 'bg-green-700' } %> +
+
+ <%= @account.name %> +
+
+ <%= @account.description %> +
+
+
+
+
+ <%= link_to_primary 'Edit', edit_account_path(@account), class: 'inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500' %> +
+
+
+
+
+ + <%= render 'section' do %> + <%= render 'section_header', title: 'Account Status' %> + <%= render 'section_body' do %> +
+ +
+
+
Expires On
<%= @account.expires_on %>
+
Event
Bear Hug: Live in Concert
+
Amount
$150.00 USD
+
Amount after exchange rate
US$150.00 → CA$199.79
+
Fee
$4.79 USD
+
Net
$1,955.00
+
+
+
+ + <% end %> + <% end %> +
-
- <%= f.label :name, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :name, class: 'form-input block w-full', readonly: true %> -
-
- -
- <%= f.label :description, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_area :description, class: 'form-textarea block w-full', readonly: true %> -
-
- -
- <%= f.label :welcome_message, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_area :welcome_message, class: 'form-textarea block w-full', readonly: true %> -
-
- -
- <%= f.label :expires_on, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :expires_on, class: 'form-input block w-full', readonly: true %> -
-
- -
- <%= f.label :expiry_warning_sent_on, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :expiry_warning_sent_on, class: 'form-input block w-full', readonly: true %> -
-
- -
- <%= f.label :max_users, class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :max_users, class: 'form-input block w-full', readonly: true %> -
-
- -
- <%= f.label :max_scorecards, "Max #{Scorecard.model_name.human.pluralize.downcase}", class: 'w-1/3 text-right pr-4' %> -
- <%= f.text_field :max_scorecards, class: 'form-input block w-full', readonly: true %> -
-
- -
-
- -
-
- <%= f.check_box :solution_ecosystem_maps, class: 'form-checkbox', onclick: "return false;" %> -
-
- -
-
- -
-
- <%= f.check_box :allow_transition_cards, class: 'form-checkbox', onclick: "return false;" %> -
-
-<% end %> diff --git a/app/views/application/_form_header.html.erb b/app/views/application/_form_header.html.erb index 97f6c143..f12188ef 100644 --- a/app/views/application/_form_header.html.erb +++ b/app/views/application/_form_header.html.erb @@ -1,4 +1,4 @@

- <%= record.persisted? ? "Edit #{record.name}" : "New #{record.model_name.human}" %> + <%= record.persisted? ? "Edit #{record.name.presence || record.model_name.human }" : "New #{record.model_name.human}" %>

diff --git a/app/views/checklist_items/_link.html.erb b/app/views/checklist_items/_link.html.erb index a7d2faa9..fb4fec6e 100644 --- a/app/views/checklist_items/_link.html.erb +++ b/app/views/checklist_items/_link.html.erb @@ -1,5 +1,5 @@
- + <%= link_to( edit_checklist_item_path(checklist_item), diff --git a/app/views/checklist_items/edit.html.erb b/app/views/checklist_items/edit.html.erb index fd9c86b6..2929988a 100644 --- a/app/views/checklist_items/edit.html.erb +++ b/app/views/checklist_items/edit.html.erb @@ -1,5 +1,5 @@ <%= turbo_frame_tag dom_id(@checklist_item) do %> - + <%= @checklist_item.characteristic.name %>
diff --git a/app/views/impact_cards/_grid.html.erb b/app/views/impact_cards/_grid.html.erb index fffa8b4a..b8ce25eb 100644 --- a/app/views/impact_cards/_grid.html.erb +++ b/app/views/impact_cards/_grid.html.erb @@ -1,6 +1,6 @@ <%= render 'labels/stylesheet', labels: @subsystem_tags %> -
+
<%= form_with url: impact_card_path(@scorecard), method: :get, data: { grid_target: 'filterForm' } do |form| %> @@ -26,7 +26,7 @@ <%= form.multi_select( :statuses, - multi_select_options_for_statuses(@statuses, @selected_statuses), + multi_select_options_for_statuses(@statuses, @selected_statuses, @scorecard), { placeholder: 'Select statuses...' }, { include_hidden: false, data: { grid_target: "statuses" } } ) @@ -53,7 +53,7 @@ <%# TODO Move the lookup of the focus area details to @scorecard_grid %> <%= focus_area_grid_element(grouped_checklist_item_data.first) %> <%- grouped_checklist_item_data.each do |checklist_item_data| %> - <%= checklist_list_item_grid_element(checklist_item_data) %> + <%= checklist_list_item_grid_element(checklist_item_data:, grid_mode: @scorecard.grid_mode) %> <% end %>
<% end %> diff --git a/app/views/organisations/_form.html.erb b/app/views/organisations/_form.html.erb index a97c9bea..4d824f97 100644 --- a/app/views/organisations/_form.html.erb +++ b/app/views/organisations/_form.html.erb @@ -7,8 +7,9 @@ <%= render 'section_body' do %>
<%= form.label :name %> -
<%= form.text_field(:name, placeholder: 'Stakeholder name', autofocus: true, required: true) %> -
+
+ <%= form.text_field(:name, placeholder: 'Stakeholder name', autofocus: true, required: true) %> +
diff --git a/db/data/20250107075016_set_classic_grid_mode_for_existing_accounts.rb b/db/data/20250107075016_set_classic_grid_mode_for_existing_accounts.rb new file mode 100644 index 00000000..2c808b21 --- /dev/null +++ b/db/data/20250107075016_set_classic_grid_mode_for_existing_accounts.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class SetClassicGridModeForExistingAccounts < ActiveRecord::Migration[8.0] + def up + Account.update_all(classic_grid_mode: true) + end + + def down + Account.update_all(classic_grid_mode: false) + end +end diff --git a/db/data_schema.rb b/db/data_schema.rb index fbd0a10c..c2309bde 100644 --- a/db/data_schema.rb +++ b/db/data_schema.rb @@ -1 +1 @@ -DataMigrate::Data.define(version: 20241029104713) +DataMigrate::Data.define(version: 20250107075016) diff --git a/db/migrate/20250106064920_add_classic_grid_mode_to_accounts.rb b/db/migrate/20250106064920_add_classic_grid_mode_to_accounts.rb new file mode 100644 index 00000000..f8043982 --- /dev/null +++ b/db/migrate/20250106064920_add_classic_grid_mode_to_accounts.rb @@ -0,0 +1,5 @@ +class AddClassicGridModeToAccounts < ActiveRecord::Migration[8.0] + def change + add_column :accounts, :classic_grid_mode, :boolean, default: false + end +end diff --git a/db/migrate/20250106070451_remove_stakeholder_type_id_from_accounts.rb b/db/migrate/20250106070451_remove_stakeholder_type_id_from_accounts.rb new file mode 100644 index 00000000..4dea7459 --- /dev/null +++ b/db/migrate/20250106070451_remove_stakeholder_type_id_from_accounts.rb @@ -0,0 +1,5 @@ +class RemoveStakeholderTypeIdFromAccounts < ActiveRecord::Migration[8.0] + def change + remove_column :accounts, :stakeholder_type_id, :integer + end +end diff --git a/db/migrate/20250107024008_deprecate_unused_account_columns.rb b/db/migrate/20250107024008_deprecate_unused_account_columns.rb new file mode 100644 index 00000000..baa2d30c --- /dev/null +++ b/db/migrate/20250107024008_deprecate_unused_account_columns.rb @@ -0,0 +1,9 @@ +class DeprecateUnusedAccountColumns < ActiveRecord::Migration[8.0] + def change + rename_column :accounts, :welcome_message, :deprecated_welcome_message + rename_column :accounts, :weblink, :deprecated_weblink + rename_column :accounts, :allow_sustainable_development_goal_alignment_cards, :deprecated_allow_sustainable_development_goal_alignment_cards + rename_column :accounts, :allow_transition_cards, :deprecated_allow_transition_cards + rename_column :accounts, :solution_ecosystem_maps, :deprecated_solution_ecosystem_maps + end +end diff --git a/db/schema.rb b/db/schema.rb index 8ad259f3..543e0137 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_12_30_085214) do +ActiveRecord::Schema[8.0].define(version: 2025_01_07_024008) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "pg_stat_statements" @@ -19,9 +19,8 @@ create_table "accounts", id: :serial, force: :cascade do |t| t.string "name" t.string "description" - t.string "weblink" - t.integer "stakeholder_type_id" - t.text "welcome_message" + t.string "deprecated_weblink" + t.text "deprecated_welcome_message" t.boolean "deactivated" t.datetime "deleted_at", precision: nil t.datetime "created_at", precision: nil, null: false @@ -29,9 +28,9 @@ t.date "expires_on" t.integer "max_users", default: 1 t.integer "max_scorecards", default: 1 - t.boolean "solution_ecosystem_maps" - t.boolean "allow_transition_cards", default: true - t.boolean "allow_sustainable_development_goal_alignment_cards", default: false + t.boolean "deprecated_solution_ecosystem_maps" + t.boolean "deprecated_allow_transition_cards", default: true + t.boolean "deprecated_allow_sustainable_development_goal_alignment_cards", default: false t.date "expiry_warning_sent_on" t.string "transition_card_model_name", default: "Transition Card" t.string "transition_card_focus_area_group_model_name", default: "Focus Area Group" @@ -41,6 +40,7 @@ t.string "sdgs_alignment_card_focus_area_group_model_name", default: "Focus Area Group" t.string "sdgs_alignment_card_focus_area_model_name", default: "Focus Area" t.string "sdgs_alignment_card_characteristic_model_name", default: "Targets" + t.boolean "classic_grid_mode", default: false end create_table "accounts_users", id: :serial, force: :cascade do |t| diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb index a23a8ea7..c7221991 100644 --- a/spec/factories/accounts.rb +++ b/spec/factories/accounts.rb @@ -4,31 +4,31 @@ # # Table name: accounts # -# id :integer not null, primary key -# allow_sustainable_development_goal_alignment_cards :boolean default(FALSE) -# allow_transition_cards :boolean default(TRUE) -# deactivated :boolean -# deleted_at :datetime -# description :string -# expires_on :date -# expiry_warning_sent_on :date -# max_scorecards :integer default(1) -# max_users :integer default(1) -# name :string -# sdgs_alignment_card_characteristic_model_name :string default("Targets") -# sdgs_alignment_card_focus_area_group_model_name :string default("Focus Area Group") -# sdgs_alignment_card_focus_area_model_name :string default("Focus Area") -# sdgs_alignment_card_model_name :string default("SDGs Alignment Card") -# solution_ecosystem_maps :boolean -# transition_card_characteristic_model_name :string default("Characteristic") -# transition_card_focus_area_group_model_name :string default("Focus Area Group") -# transition_card_focus_area_model_name :string default("Focus Area") -# transition_card_model_name :string default("Transition Card") -# weblink :string -# welcome_message :text -# created_at :datetime not null -# updated_at :datetime not null -# stakeholder_type_id :integer +# id :integer not null, primary key +# classic_grid_mode :boolean default(FALSE) +# deactivated :boolean +# deleted_at :datetime +# deprecated_allow_sustainable_development_goal_alignment_cards :boolean default(FALSE) +# deprecated_allow_transition_cards :boolean default(TRUE) +# deprecated_solution_ecosystem_maps :boolean +# deprecated_weblink :string +# deprecated_welcome_message :text +# description :string +# expires_on :date +# expiry_warning_sent_on :date +# max_scorecards :integer default(1) +# max_users :integer default(1) +# name :string +# sdgs_alignment_card_characteristic_model_name :string default("Targets") +# sdgs_alignment_card_focus_area_group_model_name :string default("Focus Area Group") +# sdgs_alignment_card_focus_area_model_name :string default("Focus Area") +# sdgs_alignment_card_model_name :string default("SDGs Alignment Card") +# transition_card_characteristic_model_name :string default("Characteristic") +# transition_card_focus_area_group_model_name :string default("Focus Area Group") +# transition_card_focus_area_model_name :string default("Focus Area") +# transition_card_model_name :string default("Transition Card") +# created_at :datetime not null +# updated_at :datetime not null # FactoryBot.define do factory :account do diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 27a53524..267561cb 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -4,31 +4,31 @@ # # Table name: accounts # -# id :integer not null, primary key -# allow_sustainable_development_goal_alignment_cards :boolean default(FALSE) -# allow_transition_cards :boolean default(TRUE) -# deactivated :boolean -# deleted_at :datetime -# description :string -# expires_on :date -# expiry_warning_sent_on :date -# max_scorecards :integer default(1) -# max_users :integer default(1) -# name :string -# sdgs_alignment_card_characteristic_model_name :string default("Targets") -# sdgs_alignment_card_focus_area_group_model_name :string default("Focus Area Group") -# sdgs_alignment_card_focus_area_model_name :string default("Focus Area") -# sdgs_alignment_card_model_name :string default("SDGs Alignment Card") -# solution_ecosystem_maps :boolean -# transition_card_characteristic_model_name :string default("Characteristic") -# transition_card_focus_area_group_model_name :string default("Focus Area Group") -# transition_card_focus_area_model_name :string default("Focus Area") -# transition_card_model_name :string default("Transition Card") -# weblink :string -# welcome_message :text -# created_at :datetime not null -# updated_at :datetime not null -# stakeholder_type_id :integer +# id :integer not null, primary key +# classic_grid_mode :boolean default(FALSE) +# deactivated :boolean +# deleted_at :datetime +# deprecated_allow_sustainable_development_goal_alignment_cards :boolean default(FALSE) +# deprecated_allow_transition_cards :boolean default(TRUE) +# deprecated_solution_ecosystem_maps :boolean +# deprecated_weblink :string +# deprecated_welcome_message :text +# description :string +# expires_on :date +# expiry_warning_sent_on :date +# max_scorecards :integer default(1) +# max_users :integer default(1) +# name :string +# sdgs_alignment_card_characteristic_model_name :string default("Targets") +# sdgs_alignment_card_focus_area_group_model_name :string default("Focus Area Group") +# sdgs_alignment_card_focus_area_model_name :string default("Focus Area") +# sdgs_alignment_card_model_name :string default("SDGs Alignment Card") +# transition_card_characteristic_model_name :string default("Characteristic") +# transition_card_focus_area_group_model_name :string default("Focus Area Group") +# transition_card_focus_area_model_name :string default("Focus Area") +# transition_card_model_name :string default("Transition Card") +# created_at :datetime not null +# updated_at :datetime not null # require 'rails_helper'