Module: Protege::ToolkitsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/protege/toolkits_helper.rb
Overview
View helpers for the toolkit dashboard. The member-tool checklist is built from the uniform extension
manifest; the allow/deny gate is edited as ToolkitRule child rows (see the toolkit-rules partials).
The overview helpers keep computed display values (tool names, proactive/count labels) out of the
templates.
Instance Method Summary collapse
-
#all_toolkits ⇒ ActiveRecord::Relation<Protege::Toolkit>
Every
Toolkitfor the global sidebar listing, ordered by name. -
#attachable_toolkits(agent) ⇒ ActiveRecord::Relation<Protege::Toolkit>
The toolkits not yet attached to an agent — the options for its attach form.
-
#gate_rule_kind_color(rule) ⇒ Symbol
The badge colour for a gate rule — green for allow, red for deny.
-
#toolkit_overview(toolkit) ⇒ Hash{String=>String}
The labelled summary rows shown in a toolkit's overview card.
-
#toolkit_tool_count_label(toolkit) ⇒ String
A short "N tools" label for a toolkit listing.
-
#toolkit_tool_options ⇒ Array<Protege::Manifest::Entry>
The tool manifest entries offered as the member-tool checklist — the toolkit equivalent of
AgentsHelper#agent_tool_options, built from the uniform extension manifest.
Instance Method Details
#all_toolkits ⇒ ActiveRecord::Relation<Protege::Toolkit>
Every Toolkit for the global sidebar listing, ordered by name.
12 13 14 |
# File 'app/helpers/protege/toolkits_helper.rb', line 12 def all_toolkits Toolkit.order(:name) end |
#attachable_toolkits(agent) ⇒ ActiveRecord::Relation<Protege::Toolkit>
The toolkits not yet attached to an agent — the options for its attach form.
52 53 54 |
# File 'app/helpers/protege/toolkits_helper.rb', line 52 def attachable_toolkits(agent) Toolkit.where.not(id: agent.toolkit_ids).order(:name) end |
#gate_rule_kind_color(rule) ⇒ Symbol
The badge colour for a gate rule — green for allow, red for deny.
44 45 46 |
# File 'app/helpers/protege/toolkits_helper.rb', line 44 def gate_rule_kind_color(rule) rule.allow? ? :green : :red end |
#toolkit_overview(toolkit) ⇒ Hash{String=>String}
The labelled summary rows shown in a toolkit's overview card.
28 29 30 |
# File 'app/helpers/protege/toolkits_helper.rb', line 28 def toolkit_overview(toolkit) { 'Tools' => toolkit_member_tool_names(toolkit) } end |
#toolkit_tool_count_label(toolkit) ⇒ String
A short "N tools" label for a toolkit listing.
36 37 38 |
# File 'app/helpers/protege/toolkits_helper.rb', line 36 def toolkit_tool_count_label(toolkit) pluralize(toolkit.member_tool_ids.size, 'tool') end |
#toolkit_tool_options ⇒ Array<Protege::Manifest::Entry>
The tool manifest entries offered as the member-tool checklist — the toolkit equivalent of
AgentsHelper#agent_tool_options, built from the uniform extension manifest.
20 21 22 |
# File 'app/helpers/protege/toolkits_helper.rb', line 20 def Manifest.registered(:tool) end |