include All::Permissions::Follow def option_cards Card::FollowOption.cards.compact end def options_rule_card Card.new( name: "follow_options_card", type_code: :pointer, content: option_cards.map { |oc| "[[#{oc.name}]]" }.join("\n") ) end format :html do def default_follow_item_args args args[:condition] ||= Env.params[:condition] || "*always" end view :follow_item, tags: :unknown_ok, cache: :never do |args| condition = args[:condition] wrap do card_form action: :update, success: { view: :follow_item } do [ follow_item_hidden_tags(condition), follow_item_button(condition), follow_item_link(condition) ] end end end def add_follow_item? condition card.new_card? || !card.include_item?(condition) end def follow_item_hidden_tags condition condkey = add_follow_item?(condition) ? :add_item : :drop_item hidden_tags condition: condition, condkey => condition end def follow_item_button condition action = add_follow_item?(condition) ? :add : :delete _optional_render "#{action}_follow_rule_button" end def follow_item_link condition link_to_card follow_item_link_target, follow_item_link_text(condition) end def follow_item_link_target set = card.rule_set setname = set.cardname set.tag.codename == "self" ? setname.left : setname.field("by name") end def follow_item_link_text condition if (option_card = Card.fetch condition) option_card.description card.rule_set else card.rule_set.follow_label end end def default_follow_status_args args args[:card_key] ||= card.set_prototype.key end view :follow_status do |args| ["