Revision 5593ab62

b/ui/static/main.css
1206 1206
    margin-top: 2px;
1207 1207
}
1208 1208

  
1209
#metadata-wizard button.more-margin {
1210
    margin-top: 6px;
1211
}
1212

  
1213 1209
#metadata-wizard button.edit {
1214 1210
    height: 15px;
1215 1211
    width: 70px;
b/ui/templates/machines.html
670 670

  
671 671
// intercept click on edit button in metadata edit dialog
672 672
$('#edit-dialog button.edit').live('click', function(){
673
    // TODO
674
    // show input form for tag name
675
    $(this).parent().find('label').html("<input type=\"text\" maxlength=\"15\" class=\"edit-meta-key\" value=\"" +
676
                                        $(this).parent().find('label').text() + 
677
                                        "\" / ><label class=\"oldValue\">" + 
678
                                        $(this).parent().find('label').text() + "</label>");
679 673
    // show input form for tag value
680 674
    $(this).parent().find('p').html("<textarea class=\"edit-meta-value\" l=\"3\">" +
681 675
                                        $(this).parent().find('p').text() + 
......
684 678
    // show/hide the appropriate buttons
685 679
    $(this).hide(); // this button (edit)
686 680
    $(this).siblings().show(); // save and cancel buttons
687
    $(this).siblings('button.remove').addClass('more-margin');
688 681

  
689 682
    return false;
690 683
});
691 684

  
692 685
// intercept click on cancel button in metadata edit dialog
693 686
$('#edit-dialog button.cancel').live('click', function(){
694
    // put the old values and close the forms
695
    $(this).parent().find('label').html($(this).parent().find('label.oldValue').text());
687
    // put the old value and close the forms
696 688
    $(this).parent().find('p').html($(this).parent().find('p.oldValue').text());
697 689
    // show/hide the appropriate buttons
698 690
    $(this).hide(); // this button (cancel)
699 691
    $(this).next().hide(); // the save button
700 692
    $(this).prev().show(); // the edit button
701
    $(this).siblings('button.remove').removeClass('more-margin');
702 693

  
703 694
    return false;
704 695
});
......
706 697
// intercept click on save button in metadata edit dialog
707 698
$('#edit-dialog button.save').live('click', function(){
708 699
    // get the updated values and the old key
709
    var oldKey = $(this).parent().find('label.oldValue').text();
710
    var newKey = $(this).parent().find('input.edit-meta-key').val();
711
    var newValue = $(this).parent().find('textarea.edit-meta-value').val();
712
    // put the new values and close the forms
713
    $(this).parent().find('label').html(newKey);
700
    var oldKey = $(this).parent().find('label').text();
701
    var newValue = $(this).parent().find('textarea.edit-meta-value').val().substring(0,150);
702
    // put the new value and close the forms
714 703
    $(this).parent().find('p').html(newValue);
715
    // check if the new metadata key is the same with the old one
716
    if ( oldKey != newKey ) {
717
        // if the key has changed, delete old pair
718
        delete_metadata(serverID, oldKey)
719
    }
720
    // add or update meatadata pair
704
    // update meatadata pair
721 705
    add_metadata(serverID, newKey, newValue);
722 706

  
723 707
    // show/hide the appropriate buttons
724 708
    $(this).hide(); // this button (save)
725 709
    $(this).prev().hide(); // the cancel button
726 710
    $(this).prev().prev().show(); // the edit button
727
    $(this).siblings('button.remove').removeClass('more-margin');
728 711

  
729 712
    return false;
730 713
});

Also available in: Unified diff