Sha256: eebcffc8b4c32e16a9b67056af18896e9b0df31fb5ed413ac5e918cc82b8e131

Contents?: true

Size: 819 Bytes

Versions: 13

Compression:

Stored size: 819 Bytes

Contents

event :initialize_because_of_type_change, :prepare_to_store,
      on: :update, changed: :type do
  self.content = content
  initialize_theme
  if (items = old_skin_items)&.present?
    field :stylesheets, content: items
  end
end

event :copy_theme, :prepare_to_store, on: :create do
  initialize_theme
end

event :validate_theme_template, :validate, on: :create do
  return unless (theme = theme_card) && theme.type_code != :bootswatch_skin

  errors.add :abort, t(:bootstrap_not_valid_theme, theme_name: theme.name)
end

private

# I suspect we should remove this after Decko 1.0
def old_skin_items
  skin = Card.new type: :pointer, content: db_content_before_act
  skin.drop_item "bootstrap default skin"
  skin.item_names
end

def initialize_theme
  field :colors, type: :scss
  field :variables, type: :scss
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-mod-bootstrap-0.18.1 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.18.0 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.17.0 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.16.0 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.6 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.5 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.4 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.3 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.1.2 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.2.pre1 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.1.1 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.1 set/type/bootswatch_skin/events.rb
card-mod-bootstrap-0.15.0 set/type/bootswatch_skin/events.rb