Revision e4e313dd

View differences:

src/sunstone/public/js/plugins/oneflow-templates.js
24 24
    </div>\
25 25
</div>\
26 26
<div class="reveal-body create_form">\
27
  <form id="create_service_template_form" action="">\
27
  <form data-abide="ajax" id="create_service_template_form" action="">\
28 28
    <div class="row">\
29 29
        <div class="service_template_param st_man large-6 columns">\
30 30
            <label for="service_name">' + tr("Name") +
31 31
                '<span class="tip">'+ tr("Name for this template") +'</span>'+
32 32
            '</label>'+
33
            '<input type="text" id="service_name" name="service_name" />\
33
            '<input type="text" id="service_name" name="service_name" required/>\
34 34
        </div>\
35 35
        <div class="service_template_param st_man large-6 columns">'+
36 36
        '</div>\
......
170 170
              <label for="name">' + tr("Role Name") +
171 171
                '<span class="tip">'+ tr("Name of the role") +'</span>'+
172 172
              '</label>\
173
              <input type="text" id="role_name" name="name"/>\
173
              <input type="text" id="role_name" name="name" required/>\
174 174
    </div>\
175 175
</div>\
176 176
<div class="row">\
......
1244 1244
        $(".service_networks tbody").append(
1245 1245
            '<tr>\
1246 1246
                <td>\
1247
                    <input class="service_network_name" type="text"/>\
1247
                    <input class="service_network_name" type="text" pattern="[\\w]+"/>\
1248
                    <small class="error">'+ tr("Only word characters are allowed") + '</small>\
1248 1249
                </td>\
1249 1250
                <td>\
1250 1251
                    <textarea class="service_network_description"/>\
......
1404 1405
        add_role_tab(roles_index);
1405 1406
    });
1406 1407

  
1407

  
1408
    $('#create_service_template_submit',dialog).click(function(){
1409
        var json_template = generate_json_service_template_from_form();
1410
        Sunstone.runAction("ServiceTemplate.create", json_template );
1411
        return false;
1412
    });
1413

  
1414
    $('#update_service_template_submit',dialog).click(function(){
1415
        var json_template = generate_json_service_template_from_form();
1416
        Sunstone.runAction("ServiceTemplate.update",service_template_to_update_id, JSON.stringify(json_template));
1417
        return false;
1408
    $('#create_service_template_form',dialog).on('invalid', function () {
1409
        notifyError(tr("One or more required fields are missing or malformed."));
1410
    }).on('valid', function() {
1411
        if ($('#create_service_template_form',dialog).attr("opennebula_action") == "create") {
1412
            var json_template = generate_json_service_template_from_form();
1413
            Sunstone.runAction("ServiceTemplate.create", json_template );
1414
            return false;
1415
        } else if ($('#create_service_template_form',dialog).attr("opennebula_action") == "update") {
1416
            var json_template = generate_json_service_template_from_form();
1417
            Sunstone.runAction("ServiceTemplate.update",service_template_to_update_id, JSON.stringify(json_template));
1418
            return false;
1419
        }
1418 1420
    });
1419 1421

  
1420 1422
    $('#create_service_template_reset', dialog).click(function(){
......
1595 1597

  
1596 1598
    dialog.die();
1597 1599

  
1600
    $("#create_service_template_form", dialog).attr("opennebula_action", "create");
1598 1601
    $("#create_service_template_header", dialog).show();
1599 1602
    $("#update_service_template_header", dialog).hide();
1600 1603
    $("#create_service_template_submit", dialog).show();
......
1630 1633
function fillUpUpdateServiceTemplateDialog(request, response){
1631 1634
    var dialog = $('#create_service_template_dialog',dialogs_context);
1632 1635

  
1636
    $("#create_service_template_form", dialog).attr("opennebula_action", "update");
1633 1637
    $("#create_service_template_header", dialog).hide();
1634 1638
    $("#update_service_template_header", dialog).show();
1635 1639
    $("#create_service_template_submit", dialog).hide();

Also available in: Unified diff