.block-header

h2 
  | Constantes

-grouped_constants = constants.group_by { |constant| constant.kind } -for kind in grouped_constants.keys

.card.m-b-5
  .card-header style="padding: 20px;"
    .media
      .media-body.m-t-0
        .row
          .col-md-3
            h2
              small.m-0 Tipo de constante
              h5.m-0 #{grouped_constants[kind].first.name}
              small.m-0 #{grouped_constants[kind].count} valores
          .col-md-9
            -for constant in grouped_constants[kind]
              a.btn.btn-link.bgm-lightgray.m-5.c-gray onclick="editConstant(#{constant.id},'#{constant.kind}','#{constant.value}')"
                .di-block.v-middle #{constant.value}

.footer-text

a.text.btn.bgm-white.c-gray data-toggle="modal" data-target="#new-constant" Nueva constante

a.btn.btn-float.bgm-blue.m-btn.waves-effect.waves-circle.waves-float data-toggle=“modal” data-target=“#new-constant”

i.zmdi.zmdi-plus

slim :'sinatra-hexacta/constants/new'

.modal.fade id=“edit-constant” tabindex=“-1” role=“dialog” aria-labelledby=“editConstant”

.modal-dialog
  form.modal-content.action method="POST" data-toggle="validator"
    .modal-content
      .modal-header
        h4.modal-title Editar constante
      .modal-body
        .row
          .col-sm-12
            == input({ :id => 'edit_value', :name => "value", :title => "Valor", :type => 'text', :value => nil, :required => true })
      .modal-footer
        a.btn.waves-effect.bgm-red#delete.pull-left.c-white Borrar
        button.btn.btn-link.waves-effect data-dismiss="modal" type="button" Cerrar
        button.btn.btn-link.waves-effect type="submit" Actualizar

javascript:

function editConstant(constant_id,kind,value) {
  $('#edit-constant .action').attr('action', '/constants/' + constant_id);

  $('#edit-constant #edit_kind').val(kind);
  $('#edit-constant #edit_value').val(value);

  $('#edit-constant #edit_kind').trigger("chosen:updated");
  $('#edit-constant #delete').attr("onclick","rm_object('constants','"+ constant_id +"')");
  $('#edit-constant').modal('show');
}