refactor(procedure): expose procedure tags on model
This commit is contained in:
parent
d0c6560f25
commit
8cf9aec0f7
2 changed files with 7 additions and 7 deletions
|
@ -63,7 +63,7 @@ module Administrateurs
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@procedure ||= Procedure.new(for_individual: true)
|
@procedure ||= Procedure.new(for_individual: true)
|
||||||
@existing_tags = get_existing_tags
|
@existing_tags = Procedure.tags
|
||||||
end
|
end
|
||||||
|
|
||||||
SIGNIFICANT_DOSSIERS_THRESHOLD = 30
|
SIGNIFICANT_DOSSIERS_THRESHOLD = 30
|
||||||
|
@ -403,11 +403,5 @@ module Administrateurs
|
||||||
def cloned_from_library?
|
def cloned_from_library?
|
||||||
params[:from_new_from_existing].present?
|
params[:from_new_from_existing].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_existing_tags
|
|
||||||
unnest = Arel::Nodes::NamedFunction.new('UNNEST', [Procedure.arel_table[:tags]])
|
|
||||||
query = Procedure.select(unnest.as('tags')).distinct.order('tags')
|
|
||||||
Procedure.connection.query(query.to_sql).flatten
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -833,6 +833,12 @@ class Procedure < ApplicationRecord
|
||||||
published_at || created_at
|
published_at || created_at
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.tags
|
||||||
|
unnest = Arel::Nodes::NamedFunction.new('UNNEST', [self.arel_table[:tags]])
|
||||||
|
query = self.select(unnest.as('tags')).distinct.order('tags')
|
||||||
|
self.connection.query(query.to_sql).flatten
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def move_new_children_to_new_parent_coordinate(new_draft)
|
def move_new_children_to_new_parent_coordinate(new_draft)
|
||||||
|
|
Loading…
Add table
Reference in a new issue