mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 16:10:23 +00:00
[Fixed Position] Improve button support
Improve button support from toolbars by adding a click function when generating structures for mct-toolbar based on view definitions. WTD-879.
This commit is contained in:
@ -106,23 +106,41 @@ define(
|
||||
// to the current selection.
|
||||
function isApplicable(item) {
|
||||
var property = (item || {}).property,
|
||||
method = (item || {}).method,
|
||||
exclusive = !(item || {}).inclusive;
|
||||
|
||||
// Check if a selected item defines this property
|
||||
function hasProperty(selected) {
|
||||
return selected[property] !== undefined;
|
||||
return (property && (selected[property] !== undefined)) ||
|
||||
(method && (typeof selected[method] === 'function'));
|
||||
}
|
||||
|
||||
return property && selection.map(hasProperty).reduce(
|
||||
return selection.map(hasProperty).reduce(
|
||||
exclusive ? and : or,
|
||||
exclusive
|
||||
) && isConsistent(property);
|
||||
}
|
||||
|
||||
// Invoke all functions in selections with the given name
|
||||
function invoke(method, value) {
|
||||
if (method) {
|
||||
selection.forEach(function (selected) {
|
||||
if (typeof selected[method] === 'function') {
|
||||
selected[method](value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare a toolbar item based on current selection
|
||||
function convertItem(item) {
|
||||
var converted = Object.create(item || {});
|
||||
converted.key = addKey(item.property);
|
||||
if (item.property) {
|
||||
converted.key = addKey(item.property);
|
||||
}
|
||||
if (item.method) {
|
||||
converted.click = function (v) { invoke(item.method, v); };
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user