2020-05-04 06:10:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DesignManagement
|
|
|
|
class DesignCollection
|
|
|
|
attr_reader :issue
|
|
|
|
|
|
|
|
delegate :designs, :project, to: :issue
|
|
|
|
|
|
|
|
def initialize(issue)
|
|
|
|
@issue = issue
|
|
|
|
end
|
|
|
|
|
2020-08-07 21:10:07 +00:00
|
|
|
def ==(other)
|
|
|
|
other.is_a?(self.class) && issue == other.issue
|
|
|
|
end
|
|
|
|
|
2020-05-04 06:10:10 +00:00
|
|
|
def find_or_create_design!(filename:)
|
|
|
|
designs.find { |design| design.filename == filename } ||
|
2020-08-05 15:09:59 +00:00
|
|
|
designs.safe_find_or_create_by!(project: project, filename: filename) do |design|
|
|
|
|
design.move_to_end
|
|
|
|
end
|
2020-05-04 06:10:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def versions
|
|
|
|
@versions ||= DesignManagement::Version.for_designs(designs)
|
|
|
|
end
|
|
|
|
|
|
|
|
def repository
|
|
|
|
project.design_repository
|
|
|
|
end
|
|
|
|
|
|
|
|
def designs_by_filename(filenames)
|
|
|
|
designs.current.where(filename: filenames)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|