Module: ForemanPuppet::PuppetclassesHelper
Instance Method Summary
collapse
#class_update_text, #import_proxy_links, #import_proxy_select
Instance Method Details
#link_to_add_function(text, options) ⇒ Object
44
45
46
47
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 44
def link_to_add_function(text, options)
link_to_function(text, 'tfm.classEditor.addPuppetClass(this)',
options.merge('data-original-title': _('Click to add %s') % options[:'data-class-name']))
end
|
#link_to_add_puppetclass(klass, type) ⇒ Object
37
38
39
40
41
42
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 37
def link_to_add_puppetclass(klass, type)
options = options_for_puppetclass_selection(klass, type)
text = link_to_add_function(truncate(klass.name, length: 28), options)
tag.span(text) +
link_to_add_function('', options.merge(class: 'glyphicon glyphicon-plus-sign'))
end
|
#link_to_remove_function(text, options) ⇒ Object
31
32
33
34
35
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 31
def link_to_remove_function(text, options)
options.delete_if { |key, _value| !options[key].to_s } title = (_('Click to remove %s') % options[:'data-class-name'])
link_to_function(text, 'tfm.classEditor.removePuppetClass(this)', options.merge!('data-original-title': title))
end
|
#link_to_remove_puppetclass(klass, type) ⇒ Object
25
26
27
28
29
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 25
def link_to_remove_puppetclass(klass, type)
options = options_for_puppetclass_selection(klass, type)
text = link_to_remove_function(truncate(klass.name, length: 28), options)
tag.span(text) + link_to_remove_function('', options.merge(class: 'glyphicon glyphicon-minus-sign'))
end
|
#options_for_puppetclass_selection(klass, type) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 49
def options_for_puppetclass_selection(klass, type)
{
'data-class-id': klass.id,
'data-class-name': klass.name,
'data-type': type,
'data-url': foreman_puppet.parameters_puppetclass_path(id: klass.id),
rel: 'twipsy',
}
end
|
#overridden?(puppetclass) ⇒ Boolean
6
7
8
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 6
def overridden?(puppetclass)
puppetclass.class_params.present? && puppetclass.class_params.map(&:override).all?
end
|
#puppetclass_group_with_icon(list, selected) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 15
def puppetclass_group_with_icon(list, selected)
css_options = if (list.last - selected).empty?
{ class: 'hide' }
else
{}
end
link_to_function(icon_text('plus', list.first, css_options),
"tfm.classEditor.expandClassList(this, '#pc_#{list.first}')")
end
|
#puppetclass_in_environment?(environment, puppetclass) ⇒ Boolean
10
11
12
13
|
# File 'app/helpers/foreman_puppet/puppetclasses_helper.rb', line 10
def puppetclass_in_environment?(environment, puppetclass)
return false unless environment
environment.puppetclasses.map(&:id).include?(puppetclass.id)
end
|