Revision c669d252

View differences:

src/sunstone/public/js/plugins/vms-tab.js
1365 1365

  
1366 1366
    // Populate permissions grid
1367 1367
    setPermissionsTable(vm_info,'');
1368

  
1369
     $('input#scheduling_date').appendDtpicker();
1370 1368
}
1371 1369

  
1372 1370
function updateVMDisksInfo(request,vm){
......
1405 1403

  
1406 1404

  
1407 1405
    $('#add_scheduling_action').live('click', function(){
1408
        // Create a new row with add button
1409
        // Change focus
1406

  
1410 1407
        $("#add_scheduling_action").attr("disabled", "disabled");
1411 1408

  
1412
        // 
1413 1409
        $("#scheduling_actions_table").append('<tr><td></td>\
1414 1410
             <td class="action_row"><select id="select_new_action" class="select_new_action" name="select_action">\
1415 1411
                                <option value="shutdown">' + tr("shutdown") + '</option>\
......
1427 1423
                                <option value="snapshot-create">' + tr("snapshot-create") + '</option>\
1428 1424
                              </select>\
1429 1425
              </td>\
1430
             <td class="time_row"><input id="date_time_input"></td>\
1426
             <td class="time_row"><input id="date_time_input"><a class="date_time_picker_add_link">t</a></td>\
1431 1427
             <td>\
1432 1428
                <button id="submit_scheduling_action" class="button small secondary radius" >' + tr("Add") +'</button>\
1433 1429
             </td>\
1434 1430
           </tr>');
1435 1431

  
1432
        $(".date_time_picker_add_link").die();
1433
        $(".date_time_picker_add_link").live("click", function() {
1434
            setupDateTimePicker('#date_time_input', "");
1435
        });
1436

  
1436 1437
        return false;
1437 1438
    }); 
1438 1439

  
......
1501 1502

  
1502 1503
    // Listener for key,value pair edit action
1503 1504
    $(".edit_e").live("click", function() {
1504

  
1505 1505
        // Action
1506
        $("#add_scheduling_action").attr("disabled", "disabled");
1507

  
1506 1508
        var index=this.id.substring(5,this.id.length);
1507 1509

  
1508 1510
        var value_str = $(".tr_action_"+index+" .action_row").text();
......
1525 1527

  
1526 1528
        // Time
1527 1529
        var time_value_str = $(".tr_action_"+index+" .time_row").text();
1528
        $(".tr_action_"+index+" .time_row").html('<input class="input_edit_time" id="input_edit_time_'+index+'" type="text" value="'+time_value_str+'"/>')
1530
        $(".tr_action_"+index+" .time_row").html('<div><input style="width:90%;" class="input_edit_time" id="input_edit_time_'+ 
1531
                        index+'" type="text" value="'+time_value_str+'">\
1532
                        <a class="date_time_picker_link">t</a></div>');
1533

  
1534
        $(".date_time_picker_link").die();
1535
        $(".date_time_picker_link").live("click", function() {
1536
            setupDateTimePicker('#input_edit_time_'+index, time_value_str);
1537
        });
1529 1538
    });
1530 1539

  
1531 1540
     $(".select_action").live("change", function() {
......
1544 1553

  
1545 1554
        // Let OpenNebula know
1546 1555
        Sunstone.runAction("VM.update_template",vm_info.ID,template_str);
1556
        $("#add_scheduling_action").removeAttr("disabled");
1547 1557
    });
1548 1558

  
1549 1559
    $(".input_edit_time").live("change", function() {
......
1565 1575

  
1566 1576
        // Let OpenNebula know
1567 1577
        Sunstone.runAction("VM.update_template",vm_info.ID,template_str);
1578
        $("#add_scheduling_action").removeAttr("disabled");
1568 1579
    });
1569 1580

  
1570 1581
    return str;
......
1600 1611
    str += '<tr class="tr_action_'+scheduling_action.ID+'">\
1601 1612
             <td class="id_row">'+scheduling_action.ID+'</td>\
1602 1613
             <td class="action_row">'+scheduling_action.ACTION+'</td>\
1603
             <td class="time_row">'+time_str+'</td>\
1614
             <td nowrap class="time_row">'+time_str+'</td>\
1604 1615
             <td class="done_row">'+done_str+'</td>\
1605 1616
             <td class="message_row">'+message_str+'</td>\
1606 1617
             <td>\
......
1624 1635
                  <h3>\
1625 1636
                    <small id="">'+tr("Date Time Picker")+'</small>\
1626 1637
                  </h3>\
1627
                  </div>\
1628
                  <input type="text" name="date" value="2012/01/01 10:00">\
1629
                  <script type="text/javascript">\
1630
                    $(function(){\
1631
                      $("*[name=date]").appendDtpicker({"inline": true, "current": '+time_str+'});\
1632
                    });\
1633
                  </script>')
1638
                  <form id="date_time_form" action="">\
1639
                    </div>\
1640
                    <input type="text" name="date" value="2012/01/01 10:00">\
1641
                    <script type="text/javascript">\
1642
                      $(function(){\
1643
                        $("*[name=date]").appendDtpicker({"inline": true, "current": "'+time_str+'"});\
1644
                      });\
1645
                    </script>\
1646
                    <div class="form_buttons">\
1647
                      <button class="button radius right success" id="date_time_form" type="submit">'+tr("Done")+'</button>\
1648
                    </div>\
1649
                    <a class="close-reveal-modal">&#215;</a>\
1650
                  </form>');
1634 1651

  
1635 1652
    dialog.addClass("reveal-modal large");
1653
    dialog.reveal();
1636 1654

  
1655
    $("*[name=date]").val(time_str)
1656
    $('#date_time_form',dialog).die();
1637 1657

  
1638
    $('#date_time_picker_dialog',dialog).submit(function(){
1658
    $('#date_time_form',dialog).live('click', function(){
1639 1659
        var date_str = $('*[name=date]').val();
1640
        alert(date_str);
1641
        return false;
1660
        console.log(input_to_fill);
1661
        $(input_to_fill).val(date_str);
1662
        $(input_to_fill).trigger("change");
1642 1663

  
1643
        var enforce = false;
1644
        if ($("#enforce", this).is(":checked")) {
1645
          enforce = true;
1646
        }
1647

  
1648
        var data  = {};
1649
        addSectionJSON(data, this);
1650

  
1651
        var obj = {
1652
          "vm_template": data,
1653
          "enforce": (enforce == "on" ? true : false),
1654
        }
1655
        console.log(enforce)
1656
        console.log(obj)
1657

  
1658
        Sunstone.runAction('VM.resize', vm_id, obj);
1659

  
1660
        $resize_capacity_dialog.trigger("reveal:close")
1664
        $date_time_picker_dialog.trigger("reveal:close")
1661 1665
        return false;
1662 1666
    });
1663 1667
};

Also available in: Unified diff