class PIM::DataModelManager::LayoutManager

Public Class Methods

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

Public Instance Methods

[](layout_name) click to toggle source
# File data-model-manager.rb, line 420
def [] layout_name
  layout_name = to_sym layout_name
  layout = data_model.module_layouts[layout_name]
  if (!layout)
    PIM.log_warn("Could not find layout '#{layout_name}' in module '#{data_model.name}'")
  end
  LayoutManager.new data_model, layout, layout_name
end
create(layout_name) click to toggle source
# File data-model-manager.rb, line 429
def create layout_name
  layout_name = PIM.to_sym(layout_name)
  layout = data_model.module_layouts[layout_name]
  if (layout && layout.modification_status != :DELETED)
    PIM.log_warn "Could not create layout '#{layout_name}' because it is already defined in module '#{data_model.name}'"
  else
    model_defined = (layout)? layout.model_defined : false
    layout = data_model.layout layout_name, {}
    layout.modification_status = :CREATED
    layout.model_defined = model_defined
  end
end
delete() click to toggle source
# File data-model-manager.rb, line 466
def delete
  if (layout)
    layout.modification_status = :DELETED
  else
    PIM.log_warn("Could not delete layout '#{layout_name}' because it is not defined in module '#{data_model.name}'")
  end
end
sections() click to toggle source
# File data-model-manager.rb, line 416
def sections
  LayoutSections.new(data_model, layout)
end
sort_order(sections) click to toggle source
# File data-model-manager.rb, line 456
def sort_order sections
  layout = data_model.module_layouts[layout_name]
  if (layout)
    sections.keep_if { |section| layout.sections.include?(PIM::Utils.to_sym(section)) }
    layout.sort_order = sections
  else
    PIM.log_warn("Could not sort sections for layout '#{layout_name}' because it is not defined in module '#{data_model.name}'")
  end
end
update(new_name) click to toggle source
# File data-model-manager.rb, line 442
def update new_name
  new_name = to_sym new_name
  layout = data_model.module_layouts[layout_name]
  if (layout)
    model_defined = layout.model_defined
    data_model.module_layouts.delete layout_name
    layout = data_model.layout new_name, layout.sections
    layout.modification_status = :UPDATED
    layout.model_defined = model_defined
  else
    PIM.log_warn("Could not update layout '#{layout_name}' because it is not defined in module '#{data_model.name}'")
  end
end