class PIM::DataModelManager::LayoutManager::LayoutSections

Public Class Methods

new(data_model, layout, sections = nil, section = nil) click to toggle source
# File data-model-manager.rb, line 477
def initialize data_model, layout, sections = nil, section = nil
  super data_model
  @layout = layout
  @sections = sections
  @section = section
end

Public Instance Methods

[](section_name) click to toggle source
# File data-model-manager.rb, line 484
def [] section_name
  section_name = to_sym section_name
  section = nil
  sections = nil
  if (layout && layout.sections)
    sections = layout.sections
    section = sections[section_name]
    if (!section)
      PIM.log_warn("Could not find section '#{section_name}' in layout '#{layout.name}'")
    end
  end
  layout_sections = LayoutSections.new(data_model, layout, sections, section)
  layout_sections
end
add(attribute) click to toggle source
# File data-model-manager.rb, line 559
def add attribute
  if (@section)
    @section.add_attribute attribute
  else
    PIM.log_warn("Can not add attribute #{attribute} to section in module '#{data_model}'")
  end
end
attributes() click to toggle source
# File data-model-manager.rb, line 575
def attributes
  self
end
create(name, label) click to toggle source
# File data-model-manager.rb, line 499
def create name, label
  name = to_sym name
  if layout
    sections = layout.sections
    section = sections[name]
    if section
      if section.modification_status == :DELETED
        model_defined = section.model_defined
        section = PIM::Section.new(name, label, section.attributes)
        DataModuleObject.set_data_module(section, data_model)
        section.modification_status = :CREATED
        section.model_defined = model_defined
        sections[name] = section
      else
        PIM.log_warn("Could not create section '#{name}' in layout '#{layout.name}' because it already exists")
      end
    else
      section = PIM::Section.new(name, label)
      DataModuleObject.set_data_module(section, data_model)
      section.modification_status = :CREATED
      section.model_defined = false
      sections[name] = section
    end
  end
end
delete() click to toggle source
# File data-model-manager.rb, line 551
def delete
  if (@section)
    @section.modification_status = :DELETED
  else
    PIM.log_warn("Can not delete section because it is not defined in module '#{data_model}'")
  end
end
remove(attribute) click to toggle source
# File data-model-manager.rb, line 567
def remove attribute
  if (@section)
    @section.remove_attribute attribute
  else
    PIM.log_warn("Can not remove attribute #{attribute} to section in module '#{data_model}'")
  end
end
sort_order(attributes) click to toggle source
# File data-model-manager.rb, line 538
def sort_order attributes
  if (@section)
    attributes.keep_if { |attribute| @section.attributes.include?(to_sym(attribute)) }
    @section.sort_order = attributes
  else
    if layout.nil?
      PIM.log_warn("Nothing to sort, don't even know in which layout of module '#{data_model}'")
    else
      PIM.log_warn("Could not sort attributes of section because it is not defined for layout '#{layout.name}' in module '#{data_model}'")
    end
  end
end
update(label) click to toggle source
# File data-model-manager.rb, line 525
def update label
  if (@section)
    @section.label = label
    @section.modification_status = :UPDATED
  else
    if layout.nil?
      PIM.log_warn("Nothing to update, don't even know in which layout of module '#{data_model}'")
    else
      PIM.log_warn("Could not update section because it is not defined for layout '#{layout.name}' in module '#{data_model}'")
    end
  end
end