.card-panel = simple_form_for(:printer) do |f| = f.error_notification .form-inputs -# - if current_user.admin? and params[:controller] =~ /service/ -# / %input{ name: 'parent_id', collection: policy_scope(Account), class: :validate} -# - else %input{ type: :hidden, name: 'parent', value: 'Account' } %input{ type: :hidden, name: 'parent_id', value: resource.id } .row = f.input :name .row = f.input :cups_printer, placeholder: t('.cups_printer'), required: true, disabled: @disabled .row = f.input :command, placeholder: t('.cups_cmd'), required: true, disabled: @disabled .row = f.input :paper, placeholder: t('.paper'), required: true, disabled: @disabled .row .input-field.col.s4 %label{ style: "margin-top: -20px"}= t('.service_active') .switch %label = t(:passive) =f.check_box :active, disabled: @disabled %span.lever = t(:active) %br %br .row / = f.input :last_monitored_at, disabled: true %ul %li tidsstyring %li - unless @disabled .row .form-actions.right-align = f.button :submit, t('.account_printer_submit'), class: "printer_commit" :coffeescript $ -> $(document.body).on 'click', 'input.printer_commit', (e) -> e.preventDefault() e.stopPropagation() $form = $(e.target).closest('form') data = $form.serialize() jqxhr = $.ajax url: '/admin/printers.js', type: 'post', data: data, dataType: 'html' jqxhr.done (response) -> $('#account_printers').prepend(response) fadeItOut $('.message_container .alert-success') jqxhr.fail (response) -> $('body').append(response) fadeItOut $('.message_container .alert-danger'), 5000