mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-6227 (Add copy-paste support for detail view fields):
DetailView widget now supports bool isCopyPaste property that can be set for fields. If this is set to true, the text of this field is displayed using ellipsis formatting* and a copy-paste icon is available right next to it. On clicking this icon, the full text is displayed *: tooltip is also enabled showing the original non-ellipsed value
This commit is contained in:
parent
a7d7fee0cb
commit
e65d6bd3a8
@ -1835,6 +1835,58 @@ div.list-view td.state.off span {
|
||||
float: left;
|
||||
width: 245px;
|
||||
}
|
||||
.detail-group .main-groups table td.value > span.copypasteenabledvalue {
|
||||
text-overflow: ellipsis;
|
||||
-o-text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.detail-group .main-groups table td.value > .copypasteactive {
|
||||
display: auto;
|
||||
white-space: nowrap;
|
||||
overflow: none;
|
||||
}
|
||||
|
||||
div.copypasteicon {
|
||||
background: url("../images/sprites.png") no-repeat scroll -271px -65px;
|
||||
float: left;
|
||||
height: 21px;
|
||||
margin-left: 6px;
|
||||
margin-top: 0px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
div.copypasteicon:hover {
|
||||
background: url("../images/sprites.png") no-repeat scroll -271px -646px;
|
||||
}
|
||||
|
||||
.detail-group .main-groups table td.value > span.copypasteenabledvalue {
|
||||
text-overflow: ellipsis;
|
||||
-o-text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.detail-group .main-groups table td.value > .copypasteactive {
|
||||
display: auto;
|
||||
white-space: nowrap;
|
||||
overflow: none;
|
||||
}
|
||||
|
||||
div.copypasteicon {
|
||||
background: url("../images/sprites.png") no-repeat scroll -271px -65px;
|
||||
float: left;
|
||||
height: 21px;
|
||||
margin-left: 6px;
|
||||
margin-top: 0px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
div.copypasteicon:hover {
|
||||
background: url("../images/sprites.png") no-repeat scroll -271px -646px;
|
||||
}
|
||||
|
||||
|
||||
.detail-group .main-groups table td.value > span select {
|
||||
width: 100% !important;
|
||||
|
||||
BIN
ui/images/sprites.png
Normal file → Executable file
BIN
ui/images/sprites.png
Normal file → Executable file
Binary file not shown.
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 190 KiB |
@ -1375,10 +1375,12 @@
|
||||
label: 'label.state'
|
||||
},
|
||||
apikey: {
|
||||
label: 'label.api.key'
|
||||
label: 'label.api.key',
|
||||
isCopyPaste: true
|
||||
},
|
||||
secretkey: {
|
||||
label: 'label.secret.key'
|
||||
label: 'label.secret.key',
|
||||
isCopyPaste: true
|
||||
},
|
||||
account: {
|
||||
label: 'label.account.name'
|
||||
|
||||
@ -456,6 +456,13 @@
|
||||
tooltip: '.tooltip-box'
|
||||
});
|
||||
|
||||
var removeCopyPasteIcons = function() {
|
||||
$detailView.find('.copypasteactive').removeClass('copypasteactive').addClass('copypasteenabledvalue');
|
||||
$detailView.find('td.value .copypasteicon').hide();
|
||||
};
|
||||
|
||||
removeCopyPasteIcons();
|
||||
|
||||
var convertInputs = function($inputs) {
|
||||
// Save and turn back into labels
|
||||
$inputs.each(function() {
|
||||
@ -606,11 +613,12 @@
|
||||
return false;
|
||||
}
|
||||
}
|
||||
restoreCopyPasteIcons();
|
||||
applyEdits($inputs, $editButton);
|
||||
} else { // Cancel
|
||||
restoreCopyPasteIcons();
|
||||
cancelEdits($inputs, $editButton);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -625,6 +633,9 @@
|
||||
tooltip: '.tooltip-box'
|
||||
});
|
||||
|
||||
var restoreCopyPasteIcons = function() {
|
||||
$detailView.find('td.value .copypasteicon').show();
|
||||
};
|
||||
|
||||
$detailView.find('td.value span').each(function() {
|
||||
var name = $(this).closest('tr').data('detail-view-field');
|
||||
@ -931,7 +942,6 @@
|
||||
|
||||
$(fields).each(function() {
|
||||
var fieldGroup = this;
|
||||
|
||||
var $detailTable = $('<tbody></tbody>').appendTo(
|
||||
$('<table></table>').appendTo(
|
||||
$('<div></div>').addClass('detail-group').appendTo($detailGroups.find('.main-groups'))
|
||||
@ -979,10 +989,33 @@
|
||||
|
||||
$name.html(_l(value.label));
|
||||
$value.html(_s(content));
|
||||
$value.attr('title', _s(content));
|
||||
|
||||
// Set up validation metadata
|
||||
$value.data('validation-rules', value.validation);
|
||||
|
||||
//add copypaste icon
|
||||
if (value.isCopyPaste) {
|
||||
var $copyicon = $('<div>').addClass('copypasteicon').insertAfter($value);
|
||||
$value.addClass('copypasteenabledvalue');
|
||||
|
||||
//set up copypaste eventhandler
|
||||
$copyicon.click(function() {
|
||||
//reset other values' formatting
|
||||
$(this).closest('table').find('span.copypasteactive').removeClass('copypasteactive').addClass('copypasteenabledvalue');
|
||||
//find the corresponding value
|
||||
var $correspValue = $(this).closest('tr').find('.value').find('span');
|
||||
$value.removeClass("copypasteenabledvalue").addClass("copypasteactive");
|
||||
var correspValueElem = $correspValue.get(0);
|
||||
//select the full value
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(correspValueElem);
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
});
|
||||
}
|
||||
|
||||
// Set up editable metadata
|
||||
if (typeof(value.isEditable) == 'function')
|
||||
$value.data('detail-view-is-editable', value.isEditable(context));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user