Sha256: 37c46454e57ed93dc21d72ba5a40a3e8838b4a5f19a156d202a2f7503cd79217
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
module Concept module SKOSXL module Extension extend ActiveSupport::Concern included do validate :valid_label_language after_save do |concept| # Labelings (@labelings_by_id ||= {}).each do |labeling_relation_name, origin_mappings| # Remove all associated labelings of the given type concept.send(labeling_relation_name).destroy_all # (Re)create labelings reflecting a widget's parameters origin_mappings.each do |language, new_origins| new_origins = new_origins. split(Iqvoc::InlineDataHelper::SPLITTER).map(&:squish) # Iterate over all labels to be added and create them Iqvoc::XLLabel.base_class.by_origin(new_origins).each do |l| concept.send(labeling_relation_name).create!(:target => l) end end end end end def labelings_by_id=(hash) @labelings_by_id = hash end def labelings_by_id(relation_name, language) (@labelings_by_id && @labelings_by_id[relation_name] && @labelings_by_id[relation_name][language]) || self.send(relation_name).by_label_language(language). map { |l| l.target.origin }.join(Iqvoc::InlineDataHelper::JOINER) end def valid_label_language (@labelings_by_id || {}).each { |labeling_class_name, origin_mappings| origin_mappings.each { |language, new_origins| new_origins = new_origins.split(Iqvoc::InlineDataHelper::SPLITTER) Iqvoc::XLLabel.base_class.by_origin(new_origins).each do |label| if label.language != language.to_s errors.add(:base, I18n.t("txt.controllers.versioned_concept.label_error") % label) end end } } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iqvoc_skosxl-2.3.0 | app/models/concept/skosxl/extension.rb |
iqvoc_skosxl-2.1.0 | app/models/concept/skosxl/extension.rb |