Module: ProxmoxFormHelper
- Defined in:
- app/helpers/proxmox_form_helper.rb
Overview
You should have received a copy of the GNU General Public License along with ForemanFogProxmox. If not, see <www.gnu.org/licenses/>.
Instance Method Summary collapse
- #add_child_link_typed(name, association, type, opts = {}) ⇒ Object
- #new_child_fields_template_typed(form_builder, association, options = { }) ⇒ Object
- #password_proxmox_f(f, attr, options = {}) ⇒ Object
- #password_proxmox_placeholder(obj, attr = nil) ⇒ Object
Instance Method Details
#add_child_link_typed(name, association, type, opts = {}) ⇒ Object
67 68 69 70 71 |
# File 'app/helpers/proxmox_form_helper.rb', line 67 def add_child_link_typed(name, association, type, opts = {}) opts[:class] = [opts[:class], "add_nested_fields btn btn-primary"].compact.join(" ") opts[:"data-association"] = (type + '_' + association.to_s).to_sym link_to_function(name.to_s, "add_child_node(this);tfm.numFields.initAll();", opts) end |
#new_child_fields_template_typed(form_builder, association, options = { }) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/proxmox_form_helper.rb', line 50 def new_child_fields_template_typed(form_builder, association, = { }) unless [:object].present? association_object = form_builder.object.class.reflect_on_association(association) [:object] = association_object.klass.new(association_object.foreign_key => form_builder.object.id) end [:partial] ||= association.to_s.singularize [:form_builder_local] ||= :f [:form_builder_attrs] ||= {} content_tag(:div, :class => "#{[:type]}_#{association}_fields_template form_template #{}", :style => "display: none;") do form_builder.fields_for(association, [:object], :child_index => "new_#{[:type]}_#{association}") do |f| render(:partial => [:partial], :layout => [:layout], :locals => { [:form_builder_local] => f }.merge([:form_builder_attrs])) end end end |
#password_proxmox_f(f, attr, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/proxmox_form_helper.rb', line 22 def password_proxmox_f(f, attr, = {}) = .delete(:unset) value = f.object[attr] if .delete(:keep_value) password_field_tag(:fakepassword, value, :style => 'display: none', :autocomplete => 'new-password-fake') + field(f, attr, ) do [:autocomplete] ||= 'new-password' [:placeholder] ||= password_proxmox_placeholder(f.object, attr) [:disabled] = true if [:value] = value if value.present? addClass , 'form-control' pass = f.password_field(attr, ) + '<span class="glyphicon glyphicon-warning-sign input-addon" title="'.html_safe + _('Caps lock ON') + '" style="display:none"></span>'.html_safe if = link_to_function(icon_text("edit", "", :kind => "pficon"), 'toggle_input_group(this)', {:id => 'disable-pass-btn', :class => 'btn btn-default', :title => _("Change the password")}) input_group(pass, input_group_btn()) else pass end end end |
#password_proxmox_placeholder(obj, attr = nil) ⇒ Object
45 46 47 48 |
# File 'app/helpers/proxmox_form_helper.rb', line 45 def password_proxmox_placeholder(obj, attr = nil) pass = obj.attributes.has_key?(attr) pass ? "********" : '' end |