From 82fe7a29e443c9abc2842a1d8b8c67f442bd58be Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Wed, 3 Jul 2024 14:56:47 -0400 Subject: [PATCH 1/9] added archived field to common attributes table --- app/models/common_attribute.rb | 1 + .../20240703185321_add_archived_to_common_attributes.rb | 5 +++++ db/schema.rb | 3 ++- spec/factories/common_attributes.rb | 1 + spec/models/common_attribute_spec.rb | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20240703185321_add_archived_to_common_attributes.rb diff --git a/app/models/common_attribute.rb b/app/models/common_attribute.rb index a6db6ec1..22b16874 100644 --- a/app/models/common_attribute.rb +++ b/app/models/common_attribute.rb @@ -8,6 +8,7 @@ # need_quantity_box :boolean # created_at :datetime not null # updated_at :datetime not null +# archived :boolean default(FALSE) # class CommonAttribute < ApplicationRecord has_many :common_attribute_states diff --git a/db/migrate/20240703185321_add_archived_to_common_attributes.rb b/db/migrate/20240703185321_add_archived_to_common_attributes.rb new file mode 100644 index 00000000..ba5bb3d3 --- /dev/null +++ b/db/migrate/20240703185321_add_archived_to_common_attributes.rb @@ -0,0 +1,5 @@ +class AddArchivedToCommonAttributes < ActiveRecord::Migration[7.1] + def change + add_column :common_attributes, :archived, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 40708726..d3532f8c 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[7.1].define(version: 2024_07_03_042628) do +ActiveRecord::Schema[7.1].define(version: 2024_07_03_185321) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -99,6 +99,7 @@ t.boolean "need_quantity_box" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "archived", default: false end create_table "floors", force: :cascade do |t| diff --git a/spec/factories/common_attributes.rb b/spec/factories/common_attributes.rb index cc97ce9f..01e1bbfb 100644 --- a/spec/factories/common_attributes.rb +++ b/spec/factories/common_attributes.rb @@ -8,6 +8,7 @@ # need_quantity_box :boolean # created_at :datetime not null # updated_at :datetime not null +# archived :boolean default(FALSE) # FactoryBot.define do factory :common_attribute do diff --git a/spec/models/common_attribute_spec.rb b/spec/models/common_attribute_spec.rb index 197f2425..185c753c 100644 --- a/spec/models/common_attribute_spec.rb +++ b/spec/models/common_attribute_spec.rb @@ -8,6 +8,7 @@ # need_quantity_box :boolean # created_at :datetime not null # updated_at :datetime not null +# archived :boolean default(FALSE) # require 'rails_helper' From 9e9cb6cf8e1ee03d5958c0fb479b2ea32e64a893 Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Wed, 3 Jul 2024 16:23:10 -0400 Subject: [PATCH 2/9] archive/unarchive common attributes process finshed --- .../common_attributes_controller.rb | 25 ++++++++++++++++--- app/models/common_attribute.rb | 7 ++++++ app/policies/common_attribute_policy.rb | 4 +++ .../_common_attribute.html.erb | 10 ++++++-- app/views/common_attributes/index.html.erb | 9 ++++++- config/routes.rb | 1 + 6 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/controllers/common_attributes_controller.rb b/app/controllers/common_attributes_controller.rb index 1c97baae..5b501a18 100644 --- a/app/controllers/common_attributes_controller.rb +++ b/app/controllers/common_attributes_controller.rb @@ -4,7 +4,14 @@ class CommonAttributesController < ApplicationController # GET /common_attributes or /common_attributes.json def index - @common_attributes = CommonAttribute.all + @show_archived = params[:show_archived] == "1" + if @show_archived + @common_attributes = CommonAttribute.archived + @option_header = "Unarchive" + else + @common_attributes = CommonAttribute.active + @option_header = "Delete" + end @new_common_attribute = CommonAttribute.new authorize @common_attributes end @@ -53,10 +60,16 @@ def update # DELETE /common_attributes/1 or /common_attributes/1.json def destroy - @common_attribute.destroy! + + if @common_attribute.has_state? + @common_attribute.update(archived: true) + notice = "Common attribute was successfully archived." + else + @common_attribute.destroy! + notice = "Common attribute was successfully deleted." + end respond_to do |format| - notice = "Common attribute was successfully deleted." format.turbo_stream do flash.now[:notice] = notice end @@ -64,6 +77,12 @@ def destroy end end + def unarchive + authorize :common_attribute, :unarchive? + CommonAttribute.find(params[:id]).update(archived: false) + redirect_to common_attributes_path, notice: "Common attribute was successfully unarchived." + end + private # Use callbacks to share common setup or constraints between actions. def set_common_attribute diff --git a/app/models/common_attribute.rb b/app/models/common_attribute.rb index 22b16874..d3070c68 100644 --- a/app/models/common_attribute.rb +++ b/app/models/common_attribute.rb @@ -16,6 +16,13 @@ class CommonAttribute < ApplicationRecord validates :description, presence: true, uniqueness: true validate :needs_either_checkbox_or_quantity_box + scope :active, -> { where(archived: false) } + scope :archived, -> { where(archived: true) } + + def has_state? + self.common_attribute_states.present? + end + private def needs_either_checkbox_or_quantity_box diff --git a/app/policies/common_attribute_policy.rb b/app/policies/common_attribute_policy.rb index 555ae6a2..e8b9eaf7 100644 --- a/app/policies/common_attribute_policy.rb +++ b/app/policies/common_attribute_policy.rb @@ -22,4 +22,8 @@ def edit? def destroy? is_admin? end + + def unarchive? + is_admin? + end end diff --git a/app/views/common_attributes/_common_attribute.html.erb b/app/views/common_attributes/_common_attribute.html.erb index 41c475c3..975fd969 100644 --- a/app/views/common_attributes/_common_attribute.html.erb +++ b/app/views/common_attributes/_common_attribute.html.erb @@ -16,8 +16,14 @@ <% end %> - <%= link_to common_attribute_path(common_attribute), 'aria-label': "delete_#{common_attribute.id}", data: { turbo_confirm: "Are you sure you want to delete this common attribute?" , turbo_method: :delete } do %> - + <% if common_attribute.archived %> + <%= link_to unarchive_common_attribute_path(common_attribute), 'aria-label': "unarchive_#{common_attribute.id}" do %> + + <% end %> + <% else %> + <%= link_to common_attribute_path(common_attribute), 'aria-label': "delete_#{common_attribute.id}", data: { turbo_confirm: "Are you sure you want to delete this common attribute?" , turbo_method: :delete } do %> + + <% end %> <% end %> diff --git a/app/views/common_attributes/index.html.erb b/app/views/common_attributes/index.html.erb index 11742d61..e621da63 100644 --- a/app/views/common_attributes/index.html.erb +++ b/app/views/common_attributes/index.html.erb @@ -5,6 +5,13 @@ <%= render 'form', common_attribute: @new_common_attribute %> <% end %> + <%= form_with(url: common_attributes_path, html: { class: 'mb-3' }, method: :get, data: { controller: "autosubmit", autosubmit_target: "form" }) do |form| %> +
+ <%= form.check_box :show_archived, class: "form-check-input", checked: @show_archived, data: { action: "input->autosubmit#search" } %> + <%= form.label :show_archived, "Show Archived Common Attributes" %> +
+ <% end %> + @@ -12,7 +19,7 @@ - + diff --git a/config/routes.rb b/config/routes.rb index 1247deba..aecc38ef 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,7 @@ post '/common_attribute_states/update_common_attribute_states/:id', to: 'common_attribute_states#update_common_attribute_states', as: :update_common_attribute_states resources :common_attributes, except: [:show] + get 'unarchive_common_attribute/:id', to: 'common_attributes#unarchive', as: :unarchive_common_attribute resources :rovers resources :zones do From 5885cea1de4a6a892727c6da1fecc2a9c15941c7 Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Fri, 5 Jul 2024 12:40:54 -0400 Subject: [PATCH 3/9] UI updates to archive --- app/controllers/common_attributes_controller.rb | 2 +- .../common_attributes/_common_attribute.html.erb | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/common_attributes_controller.rb b/app/controllers/common_attributes_controller.rb index 5b501a18..1abc39e9 100644 --- a/app/controllers/common_attributes_controller.rb +++ b/app/controllers/common_attributes_controller.rb @@ -10,7 +10,7 @@ def index @option_header = "Unarchive" else @common_attributes = CommonAttribute.active - @option_header = "Delete" + @option_header = "Delete/Archive" end @new_common_attribute = CommonAttribute.new authorize @common_attributes diff --git a/app/views/common_attributes/_common_attribute.html.erb b/app/views/common_attributes/_common_attribute.html.erb index 975fd969..be325746 100644 --- a/app/views/common_attributes/_common_attribute.html.erb +++ b/app/views/common_attributes/_common_attribute.html.erb @@ -18,11 +18,17 @@ From d95b7b4231899ffcb70cb31555a9ca9d7c64e683 Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Fri, 5 Jul 2024 12:51:31 -0400 Subject: [PATCH 4/9] attempt to add turbo --- app/controllers/common_attributes_controller.rb | 8 ++++++++ .../common_attributes/_common_attributes_list.html.erb | 5 +++++ app/views/common_attributes/index.html.erb | 8 +++----- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 app/views/common_attributes/_common_attributes_list.html.erb diff --git a/app/controllers/common_attributes_controller.rb b/app/controllers/common_attributes_controller.rb index 1abc39e9..13bb31f4 100644 --- a/app/controllers/common_attributes_controller.rb +++ b/app/controllers/common_attributes_controller.rb @@ -12,6 +12,14 @@ def index @common_attributes = CommonAttribute.active @option_header = "Delete/Archive" end + + respond_to do |format| + format.html + format.turbo_stream do + render turbo_stream: turbo_stream.replace('common_attributes_list', partial: 'common_attributes_list', locals: { common_attributes: @common_attributes }) + end + end + @new_common_attribute = CommonAttribute.new authorize @common_attributes end diff --git a/app/views/common_attributes/_common_attributes_list.html.erb b/app/views/common_attributes/_common_attributes_list.html.erb new file mode 100644 index 00000000..92604e68 --- /dev/null +++ b/app/views/common_attributes/_common_attributes_list.html.erb @@ -0,0 +1,5 @@ + + <% @common_attributes.each do |common_attribute| %> + <%= render common_attribute %> + <% end %> + \ No newline at end of file diff --git a/app/views/common_attributes/index.html.erb b/app/views/common_attributes/index.html.erb index e621da63..3d47fb75 100644 --- a/app/views/common_attributes/index.html.erb +++ b/app/views/common_attributes/index.html.erb @@ -22,10 +22,8 @@ - - <% @common_attributes.each do |common_attribute| %> - <%= render common_attribute %> - <% end %> - + <%= turbo_frame_tag 'common_attributes_list' do %> + <%= render 'common_attributes_list' %> + <% end %>
Needs Checkbox? Needs Quantity Box? EditDelete<%= @option_header %>
<% if common_attribute.archived %> <%= link_to unarchive_common_attribute_path(common_attribute), 'aria-label': "unarchive_#{common_attribute.id}" do %> - + <% end %> <% else %> - <%= link_to common_attribute_path(common_attribute), 'aria-label': "delete_#{common_attribute.id}", data: { turbo_confirm: "Are you sure you want to delete this common attribute?" , turbo_method: :delete } do %> - + <% if common_attribute.has_state? %> + <%= link_to common_attribute_path(common_attribute), 'aria-label': "delete_#{common_attribute.id}", data: { turbo_confirm: "Are you sure you want to archive this common attribute?" , turbo_method: :delete } do %> + + <% end %> + <% else %> + <%= link_to common_attribute_path(common_attribute), 'aria-label': "delete_#{common_attribute.id}", data: { turbo_confirm: "Are you sure you want to delete this common attribute?" , turbo_method: :delete } do %> + + <% end %> <% end %> <% end %>
<%= @option_header %>
From b5dad2cf90bc476b13ee4417f5311b3752bded1a Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Mon, 8 Jul 2024 12:36:56 -0400 Subject: [PATCH 5/9] changed turbo stream format --- app/views/common_attributes/destroy.turbo_stream.erb | 2 +- app/views/common_attributes/index.html.erb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/common_attributes/destroy.turbo_stream.erb b/app/views/common_attributes/destroy.turbo_stream.erb index 5db17576..f0e84b18 100644 --- a/app/views/common_attributes/destroy.turbo_stream.erb +++ b/app/views/common_attributes/destroy.turbo_stream.erb @@ -1,2 +1,2 @@ -<%= turbo_stream.remove @common_attribute %> +<%= turbo_stream.update @common_attribute %> <%= turbo_stream.update "flash", partial: 'layouts/flash' %> diff --git a/app/views/common_attributes/index.html.erb b/app/views/common_attributes/index.html.erb index 3d47fb75..1b40ac38 100644 --- a/app/views/common_attributes/index.html.erb +++ b/app/views/common_attributes/index.html.erb @@ -22,8 +22,6 @@ <%= @option_header %> - <%= turbo_frame_tag 'common_attributes_list' do %> - <%= render 'common_attributes_list' %> - <% end %> + <%= render 'common_attributes_list' %> From d4c6036ac9d0fabeb7b02afe544454f22241f4a5 Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Mon, 8 Jul 2024 12:49:30 -0400 Subject: [PATCH 6/9] fixed turbo error where wasn't getting removed from the list correctly --- app/controllers/common_attributes_controller.rb | 2 +- app/views/common_attributes/destroy.turbo_stream.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/common_attributes_controller.rb b/app/controllers/common_attributes_controller.rb index 13bb31f4..7bf05657 100644 --- a/app/controllers/common_attributes_controller.rb +++ b/app/controllers/common_attributes_controller.rb @@ -16,7 +16,7 @@ def index respond_to do |format| format.html format.turbo_stream do - render turbo_stream: turbo_stream.replace('common_attributes_list', partial: 'common_attributes_list', locals: { common_attributes: @common_attributes }) + render turbo_stream: turbo_stream.replace('common_attributes', partial: 'common_attributes_list', locals: { common_attributes: @common_attributes }) end end diff --git a/app/views/common_attributes/destroy.turbo_stream.erb b/app/views/common_attributes/destroy.turbo_stream.erb index f0e84b18..bc04c810 100644 --- a/app/views/common_attributes/destroy.turbo_stream.erb +++ b/app/views/common_attributes/destroy.turbo_stream.erb @@ -1,2 +1,2 @@ -<%= turbo_stream.update @common_attribute %> +<%= turbo_stream.update "common_attributes", @common_attribute %> <%= turbo_stream.update "flash", partial: 'layouts/flash' %> From 09608a22bf0a6bbba03165fd609471582cf92e87 Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Mon, 8 Jul 2024 16:49:38 -0400 Subject: [PATCH 7/9] turbo format fixed --- .../common_attributes_controller.rb | 30 +++++++++---------- app/models/room.rb | 2 +- .../_common_attribute.html.erb | 8 +++-- .../_common_attributes_list.html.erb | 21 +++++++++---- .../destroy.turbo_stream.erb | 6 ++-- app/views/common_attributes/index.html.erb | 15 ++-------- .../unarchive.turbo_stream.erb | 4 +++ config/routes.rb | 2 +- 8 files changed, 49 insertions(+), 39 deletions(-) create mode 100644 app/views/common_attributes/unarchive.turbo_stream.erb diff --git a/app/controllers/common_attributes_controller.rb b/app/controllers/common_attributes_controller.rb index 7bf05657..6e615612 100644 --- a/app/controllers/common_attributes_controller.rb +++ b/app/controllers/common_attributes_controller.rb @@ -1,6 +1,6 @@ class CommonAttributesController < ApplicationController before_action :auth_user - before_action :set_common_attribute, only: %i[edit update destroy ] + before_action :set_common_attribute, only: %i[edit update destroy unarchive] # GET /common_attributes or /common_attributes.json def index @@ -68,27 +68,27 @@ def update # DELETE /common_attributes/1 or /common_attributes/1.json def destroy - if @common_attribute.has_state? - @common_attribute.update(archived: true) - notice = "Common attribute was successfully archived." + if @common_attribute.update(archived: true) + @common_attributes = CommonAttribute.active + @option_header = "Delete/Archive" + end + flash.now[:notice] = "Common attribute was successfully archived." else - @common_attribute.destroy! - notice = "Common attribute was successfully deleted." - end - - respond_to do |format| - format.turbo_stream do - flash.now[:notice] = notice + if @common_attribute.destroy + @common_attributes = CommonAttribute.active + @option_header = "Delete/Archive" end - format.html { redirect_to common_attributes_url, notice: notice } + flash.now[:notice] = "Common attribute was successfully deleted." end end def unarchive - authorize :common_attribute, :unarchive? - CommonAttribute.find(params[:id]).update(archived: false) - redirect_to common_attributes_path, notice: "Common attribute was successfully unarchived." + if @common_attribute.update(archived: false) + @common_attributes = CommonAttribute.archived + flash.now[:notice] = "Common attribute was successfully unarchived." + @option_header = "Unarchive" + end end private diff --git a/app/models/room.rb b/app/models/room.rb index b2b4c9b5..eb577443 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -24,7 +24,7 @@ class Room < ApplicationRecord validates :rmrecnbr, presence: true, uniqueness: true validates :room_number, :room_type, presence: true - accepts_nested_attributes_for :specific_attributes + accepts_nested_attributes_for :active_specific_attributes scope :active, -> { where(archived: false) } scope :archived, -> { where(archived: true) } diff --git a/app/views/common_attributes/_common_attribute.html.erb b/app/views/common_attributes/_common_attribute.html.erb index be325746..207639bb 100644 --- a/app/views/common_attributes/_common_attribute.html.erb +++ b/app/views/common_attributes/_common_attribute.html.erb @@ -11,13 +11,15 @@ <% end %> - <%= link_to edit_common_attribute_path(common_attribute), 'aria-label': "edit_#{common_attribute.id}" do %> - + <% unless common_attribute.archived %> + <%= link_to edit_common_attribute_path(common_attribute), 'aria-label': "edit_#{common_attribute.id}" do %> + + <% end %> <% end %> <% if common_attribute.archived %> - <%= link_to unarchive_common_attribute_path(common_attribute), 'aria-label': "unarchive_#{common_attribute.id}" do %> + <%= link_to unarchive_common_attribute_path(common_attribute), data: { turbo_confirm: "Are you sure you want to unarchive this common attribute?" , turbo_method: :post }, 'aria-label': "unarchive_#{common_attribute.id}" do %> <% end %> <% else %> diff --git a/app/views/common_attributes/_common_attributes_list.html.erb b/app/views/common_attributes/_common_attributes_list.html.erb index 92604e68..7098e031 100644 --- a/app/views/common_attributes/_common_attributes_list.html.erb +++ b/app/views/common_attributes/_common_attributes_list.html.erb @@ -1,5 +1,16 @@ - - <% @common_attributes.each do |common_attribute| %> - <%= render common_attribute %> - <% end %> - \ No newline at end of file + + + + + + + + + + + + <% @common_attributes.each do |common_attribute| %> + <%= render common_attribute %> + <% end %> + +
DescriptionNeeds Checkbox?Needs Quantity Box?Edit<%= @option_header %>
diff --git a/app/views/common_attributes/destroy.turbo_stream.erb b/app/views/common_attributes/destroy.turbo_stream.erb index bc04c810..138b64d8 100644 --- a/app/views/common_attributes/destroy.turbo_stream.erb +++ b/app/views/common_attributes/destroy.turbo_stream.erb @@ -1,2 +1,4 @@ -<%= turbo_stream.update "common_attributes", @common_attribute %> -<%= turbo_stream.update "flash", partial: 'layouts/flash' %> +<%= turbo_stream.update 'common_attributes_list' do %> + <%= render 'common_attributes_list' %> +<% end %> +<%= render_flash_stream %> diff --git a/app/views/common_attributes/index.html.erb b/app/views/common_attributes/index.html.erb index 1b40ac38..94041218 100644 --- a/app/views/common_attributes/index.html.erb +++ b/app/views/common_attributes/index.html.erb @@ -7,21 +7,12 @@ <%= form_with(url: common_attributes_path, html: { class: 'mb-3' }, method: :get, data: { controller: "autosubmit", autosubmit_target: "form" }) do |form| %>
- <%= form.check_box :show_archived, class: "form-check-input", checked: @show_archived, data: { action: "input->autosubmit#search" } %> + <%= check_box_tag :show_archived, 1, @show_archived, data: { action: "input->autosubmit#search" } %> <%= form.label :show_archived, "Show Archived Common Attributes" %>
<% end %> - - - - - - - - - - + <%= turbo_frame_tag 'common_attributes_list' do %> <%= render 'common_attributes_list' %> -
DescriptionNeeds Checkbox?Needs Quantity Box?Edit<%= @option_header %>
+ <% end %> diff --git a/app/views/common_attributes/unarchive.turbo_stream.erb b/app/views/common_attributes/unarchive.turbo_stream.erb new file mode 100644 index 00000000..138b64d8 --- /dev/null +++ b/app/views/common_attributes/unarchive.turbo_stream.erb @@ -0,0 +1,4 @@ +<%= turbo_stream.update 'common_attributes_list' do %> + <%= render 'common_attributes_list' %> +<% end %> +<%= render_flash_stream %> diff --git a/config/routes.rb b/config/routes.rb index 67622d6d..35fa6924 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ post '/common_attribute_states/update_common_attribute_states/:id', to: 'common_attribute_states#update_common_attribute_states', as: :update_common_attribute_states resources :common_attributes, except: [:show] - get 'unarchive_common_attribute/:id', to: 'common_attributes#unarchive', as: :unarchive_common_attribute + post 'unarchive_common_attribute/:id', to: 'common_attributes#unarchive', as: :unarchive_common_attribute resources :rovers resources :zones do From f7a386dd84f43b9495ed13e56fc88e90db0972b9 Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Mon, 8 Jul 2024 16:52:47 -0400 Subject: [PATCH 8/9] changed application to only include active common attributes --- app/controllers/application_controller.rb | 2 +- app/controllers/common_attribute_states_controller.rb | 2 +- app/controllers/rooms_controller.rb | 2 +- app/models/room_status.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0b321e66..d61f9fdf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -79,7 +79,7 @@ def redirect_rover_to_correct_state(room:, room_state:, step:, mode: "new") index = steps.find_index(step) + 1 redirect = {} - CommonAttribute.all.present? ? redirect["common_attributes"] = true : redirect["common_attributes"] = false + CommonAttribute.active.present? ? redirect["common_attributes"] = true : redirect["common_attributes"] = false room.active_specific_attributes.present? ? redirect["specific_attributes"] = true : redirect["specific_attributes"] = false room.resources.present? ? redirect["resources"] = true : redirect["resources"] = false diff --git a/app/controllers/common_attribute_states_controller.rb b/app/controllers/common_attribute_states_controller.rb index 84edf660..5b6fdc5d 100644 --- a/app/controllers/common_attribute_states_controller.rb +++ b/app/controllers/common_attribute_states_controller.rb @@ -7,7 +7,7 @@ def new authorize CommonAttributeState - @common_attribute_states = CommonAttribute.all.map do |common_attribute| + @common_attribute_states = CommonAttribute.active.map do |common_attribute| common_attribute.common_attribute_states.new end end diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 2d7a9762..0f3f600a 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -11,7 +11,7 @@ def index # GET /rooms/1 or /rooms/1.json def show - @common_attributes = CommonAttribute.all + @common_attributes = CommonAttribute.active @new_note = Note.new(room: @room) @notes = @room.notes.order("created_at DESC") end diff --git a/app/models/room_status.rb b/app/models/room_status.rb index c0b3bf90..3a8b06c5 100644 --- a/app/models/room_status.rb +++ b/app/models/room_status.rb @@ -7,7 +7,7 @@ def initialize(room) end def common_attributes_exist? - CommonAttribute.count > 0 + CommonAttribute.active.count > 0 end def specific_attributes_exist? From c95dc4ee7a32e20ebcc84f77821fc09b70e0012f Mon Sep 17 00:00:00 2001 From: Satyadev Moolagani Date: Mon, 8 Jul 2024 16:55:55 -0400 Subject: [PATCH 9/9] remove unused turbo thing --- app/controllers/common_attributes_controller.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/controllers/common_attributes_controller.rb b/app/controllers/common_attributes_controller.rb index 6e615612..62d40687 100644 --- a/app/controllers/common_attributes_controller.rb +++ b/app/controllers/common_attributes_controller.rb @@ -12,13 +12,6 @@ def index @common_attributes = CommonAttribute.active @option_header = "Delete/Archive" end - - respond_to do |format| - format.html - format.turbo_stream do - render turbo_stream: turbo_stream.replace('common_attributes', partial: 'common_attributes_list', locals: { common_attributes: @common_attributes }) - end - end @new_common_attribute = CommonAttribute.new authorize @common_attributes