Skip to content

Commit

Permalink
feat[Op#56284]: specify last project folders in edit
Browse files Browse the repository at this point in the history
  • Loading branch information
akabiru committed Aug 8, 2024
1 parent 912569b commit e9f8721
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
variant: :large
)

render(::Storages::Admin::Storages::ProjectsStorageFormModalComponent.new(project_storage:))
render(::Storages::Admin::Storages::ProjectsStorageFormModalComponent.new(project_storage:, last_project_folders:))
end
%>
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ class ProjectsStorageModalComponent < ApplicationComponent
DIALOG_ID = "storages--projects-storage-modal".freeze
DIALOG_BODY_ID = "storages--projects-storage-modal-body".freeze

def initialize(project_storage:, **)
def initialize(project_storage:, last_project_folders:, **)
@project_storage = project_storage
@storage = project_storage.storage
@last_project_folders = last_project_folders

super(@project_storage, **)
end

Expand All @@ -46,7 +48,7 @@ def initialize(project_storage:, **)
def dialog_id = DIALOG_ID
def dialog_body_id = DIALOG_BODY_ID

attr_reader :project_storage, :storage
attr_reader :project_storage, :storage, :last_project_folders

def title
if new_record?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class Storages::Admin::Storages::ProjectStoragesController < ApplicationControll
def index; end

def new
respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new(project_storage: @project_storage)
respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new(
project_storage: @project_storage, last_project_folders: {}
)
end

def create # rubocop:disable Metrics/AbcSize
Expand All @@ -74,7 +76,14 @@ def create # rubocop:disable Metrics/AbcSize
end

def edit
respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new(project_storage: @project_storage)
last_project_folders = Storages::LastProjectFolder
.where(project_storage: @project_storage)
.pluck(:mode, :origin_folder_id)
.to_h

respond_with_dialog Storages::Admin::Storages::ProjectsStorageModalComponent.new(
project_storage: @project_storage, last_project_folders:
)
end

def update
Expand Down

0 comments on commit e9f8721

Please sign in to comment.