def standardize_items # noop to override default behavior, which wouldn't let '_left' through and # would therefore break end format :html do view :pointer_core do wrap_with :div, pointer_items, class: "pointer-list" end view :core do if card.content == "_left" core_inherit_content else render :pointer_core end end view :closed_content do render_core items: { view: :link } end view :editor do item_names = inheriting? ? [] : card.item_names %( #{hidden_field :content, class: 'card-content'}
#{inheritance_checkbox}
Groups
#{groups item_names}
Individuals
#{_render_list item_list: item_names, extra_css_class: 'perm-indiv-ul'}
) end private def groups item_names group_options.map do |option| checked = !item_names.delete(option.name).nil? icon = glyphicon "question-sign", "link-muted" option_link = link_to_card option.name, icon, target: "wagn_role" box = check_box_tag "#{option.key}-perm-checkbox", option.name, checked, class: "perm-checkbox-button" <<-HTML
HTML end * "\n" end def group_options Auth.as_bot do Card.search({ type_id: RoleID, sort: "name" }, "roles by name") end end def inheritable? @inheritable ||= begin set_name = card.cardname.trunk_name set_card = Card.fetch(set_name) not_set = set_card && set_card.type_id != SetID not_set ? false : set_card.inheritable? end end def inheriting? @inheriting ||= inheritable? && card.content == "_left" end def inheritance_checkbox return unless inheritable? <<-HTML
#{check_box_tag 'inherit', 'inherit', inheriting?}
HTML end def core_inherit_content args={} sc = args[:set_context] text = if sc && sc.tag_name.key == Card[:self].key core_inherit_for_content_for_self_set sc else "Inherit from left card" end %(#{text}) end def core_inherit_for_content_for_self_set set_context task = card.tag.codename ancestor = Card[set_context.trunk_name.trunk_name] links = ancestor.who_can(task.to_sym).map do |card_id| link_to_card card_id, nil, target: args[:target] end * ", " "Inherit ( #{links} )" rescue "Inherit" end end