Sha256: a111b79052dafcf8f1a89e5f8bfef6aa5e12eb60fb5445f7cffff09dc27e4336
Contents?: true
Size: 1.39 KB
Versions: 16
Compression:
Stored size: 1.39 KB
Contents
# -*- encoding : utf-8 -*- def list_fields Card.search({ left: name, type_id: Card::ListID }, "list fields") end def listed_by_fields Card.search({ left: name, type_id: Card::ListedByID }, "listed by fields") end def linker_lists Card.search({ type_id: Card::ListID, link_to: name }, "lists that link to #{name}") end def codename_list_exist? Codename.exists? :list end event :trunk_cardtype_of_a_list_relation_changed, :finalize, changed: :type, on: :update, when: :codename_list_exist? do type_key_was = (tk = Card.quick_fetch(type_id_before_last_save)) && tk.key list_fields.each do |card| card.update_listed_by_cache_for card.item_keys, type_key: type_key_was card.update_listed_by_cache_for card.item_keys end listed_by_fields.each &:update_cached_list end event :trunk_name_of_a_list_relation_changed, :finalize, changed: :name, on: :update, when: :codename_list_exist? do list_fields.each do |card| card.update_listed_by_cache_for card.item_keys end listed_by_fields.each &:update_cached_list end event :cardtype_of_list_item_changed, :validate, changed: :type, on: :save, when: :codename_list_exist? do linker_lists.each do |card| next unless card.item_type_id != type_id errors.add(:type, "can't be changed because #{name} " \ "is referenced by list card #{card.name}") end end
Version data entries
16 entries across 16 versions & 1 rubygems