Project creation/destruction admin table turbo streams
This commit is contained in:
@@ -14,6 +14,8 @@ module Projects
|
|||||||
create_default_task_statuses(project)
|
create_default_task_statuses(project)
|
||||||
project.update!(status: :ready)
|
project.update!(status: :ready)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
project.broadcast_append_later_to Project, :admin_table, partial: 'projects/row'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Project < ApplicationRecord
|
|||||||
enum :status, %w[preparing ready archived].index_by(&:itself), default: :preparing
|
enum :status, %w[preparing ready archived].index_by(&:itself), default: :preparing
|
||||||
|
|
||||||
validates :name, :code, :status, presence: true
|
validates :name, :code, :status, presence: true
|
||||||
validates :code, exclusion: { in: %w[new] }, uniqueness: true, format: { with: /\A[a-z]{2,}\z/ }
|
validates :code, exclusion: { in: %w[new] }, uniqueness: true, format: { with: /\A[a-z][a-z0-9]{1,}\z/ }
|
||||||
|
|
||||||
has_many :tasks, dependent: :restrict_with_exception
|
has_many :tasks, dependent: :restrict_with_exception
|
||||||
has_many :task_statuses, dependent: :destroy
|
has_many :task_statuses, dependent: :destroy
|
||||||
@@ -15,6 +15,7 @@ class Project < ApplicationRecord
|
|||||||
|
|
||||||
after_commit :schedule_post_init_job, on: :create
|
after_commit :schedule_post_init_job, on: :create
|
||||||
after_destroy_commit :drop_tasks_number_sequence
|
after_destroy_commit :drop_tasks_number_sequence
|
||||||
|
after_destroy_commit :broadcast_the_destroy
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
return unless id
|
return unless id
|
||||||
@@ -42,4 +43,8 @@ class Project < ApplicationRecord
|
|||||||
def drop_tasks_number_sequence
|
def drop_tasks_number_sequence
|
||||||
self.class.connection.execute "DROP SEQUENCE IF EXISTS #{tasks_number_sequence_name}"
|
self.class.connection.execute "DROP SEQUENCE IF EXISTS #{tasks_number_sequence_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def broadcast_the_destroy
|
||||||
|
broadcast_remove_to Project, :admin_table
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
li id="project_#{project.id}" = link_to project.name, project
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
.row
|
.row
|
||||||
= link_to 'New', new_project_path
|
= link_to 'New', new_project_path
|
||||||
|
|
||||||
ul
|
/ TODO: admin view, extract when doing roles stuff
|
||||||
- @projects.each do |project|
|
ul#projects
|
||||||
li
|
= render collection: @projects, partial: 'row', as: :project
|
||||||
= link_to project.name, project
|
|
||||||
|
= turbo_stream_from Project, :admin_table
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Rails.application.configure do
|
|||||||
# Replace the default in-process and non-durable queuing backend for Active Job.
|
# Replace the default in-process and non-durable queuing backend for Active Job.
|
||||||
config.active_job.queue_adapter = :solid_queue
|
config.active_job.queue_adapter = :solid_queue
|
||||||
config.solid_queue.connects_to = { database: { writing: :queue } }
|
config.solid_queue.connects_to = { database: { writing: :queue } }
|
||||||
config.solid_queue.logger = ActiveSupport::Logger.new(STDOUT)
|
config.solid_queue.logger = ActiveSupport::Logger.new($stdout)
|
||||||
|
|
||||||
# Raises error for missing translations.
|
# Raises error for missing translations.
|
||||||
# config.i18n.raise_on_missing_translations = true
|
# config.i18n.raise_on_missing_translations = true
|
||||||
|
|||||||
Reference in New Issue
Block a user