Sha256: ddb2078918304ab12a7c053a34cbe12f4278357a11e7b103c84a1822c29ff993

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Decidim
  module NavigationMaps
    # Abstract class from which all models in this engine inherit.
    class Blueprint < ApplicationRecord
      include Decidim::HasUploadValidations

      self.table_name = "decidim_navigation_maps_blueprints"

      attribute :height, :integer, default: 475

      belongs_to :organization, foreign_key: :decidim_organization_id, class_name: "Decidim::Organization"
      belongs_to :content_block, foreign_key: :decidim_content_block_id, class_name: "Decidim::ContentBlock"
      has_many :areas,
               foreign_key: "decidim_navigation_maps_blueprint_id",
               class_name: "Decidim::NavigationMaps::BlueprintArea",
               dependent: :destroy

      validates :organization, presence: true
      validates :height, numericality: { greater_than: 0 }

      has_one_attached :image
      validates_upload :image, uploader: Decidim::NavigationMaps::BlueprintUploader

      def blueprint
        areas.map { |area| [area.area_id.to_s, area.to_geoson] }.to_h
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-navigation_maps-1.3.4 app/models/decidim/navigation_maps/blueprint.rb
decidim-navigation_maps-1.3.3 app/models/decidim/navigation_maps/blueprint.rb
decidim-navigation_maps-1.3.2 app/models/decidim/navigation_maps/blueprint.rb
decidim-navigation_maps-1.3.1 app/models/decidim/navigation_maps/blueprint.rb
decidim-navigation_maps-1.3.0 app/models/decidim/navigation_maps/blueprint.rb