mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 05:38:12 +00:00
feat: AMD -> ES6 (#7029)
* feat: full amd -> es6 conversion * fix: move MCT to ES6 class * fix: default drop, correct imports * fix: correct all imports * fix: property typo * fix: avoid anonymous functions * fix: correct typo scarily small - can see why this e2e coverage issue is high priority * fix: use proper uuid format * style: fmt * fix: import vue correctly, get correct layout * fix: createApp without JSON fixes template issues * fix: don't use default on InspectorDataVisualization * fix: remove more .default calls * Update src/api/api.js Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com> * Update src/plugins/plugins.js Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com> * Update src/plugins/plugins.js Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com> * fix: suggestions * fix: drop unnecessary this.annotation initialization * fix: move all initialization calls to constructor * refactor: move vue dist import to webpack alias --------- Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>
This commit is contained in:
@ -20,53 +20,49 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(function () {
|
||||
function DisplayLayoutType() {
|
||||
return {
|
||||
name: 'Display Layout',
|
||||
creatable: true,
|
||||
description:
|
||||
'Assemble other objects and components together into a reusable screen layout. Simply drag in the objects you want, position and size them. Save your design and view or edit it at any time.',
|
||||
cssClass: 'icon-layout',
|
||||
initialize(domainObject) {
|
||||
domainObject.composition = [];
|
||||
domainObject.configuration = {
|
||||
items: [],
|
||||
layoutGrid: [10, 10]
|
||||
};
|
||||
export default function DisplayLayoutType() {
|
||||
return {
|
||||
name: 'Display Layout',
|
||||
creatable: true,
|
||||
description:
|
||||
'Assemble other objects and components together into a reusable screen layout. Simply drag in the objects you want, position and size them. Save your design and view or edit it at any time.',
|
||||
cssClass: 'icon-layout',
|
||||
initialize(domainObject) {
|
||||
domainObject.composition = [];
|
||||
domainObject.configuration = {
|
||||
items: [],
|
||||
layoutGrid: [10, 10]
|
||||
};
|
||||
},
|
||||
form: [
|
||||
{
|
||||
name: 'Horizontal grid (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutGrid', 0],
|
||||
required: true
|
||||
},
|
||||
form: [
|
||||
{
|
||||
name: 'Horizontal grid (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutGrid', 0],
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'Vertical grid (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutGrid', 1],
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'Horizontal size (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutDimensions', 0],
|
||||
required: false
|
||||
},
|
||||
{
|
||||
name: 'Vertical size (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutDimensions', 1],
|
||||
required: false
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
return DisplayLayoutType;
|
||||
});
|
||||
{
|
||||
name: 'Vertical grid (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutGrid', 1],
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'Horizontal size (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutDimensions', 0],
|
||||
required: false
|
||||
},
|
||||
{
|
||||
name: 'Vertical size (px)',
|
||||
control: 'numberfield',
|
||||
cssClass: 'l-input-sm l-numeric',
|
||||
property: ['configuration', 'layoutDimensions', 1],
|
||||
required: false
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
@ -20,93 +20,89 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define([], function () {
|
||||
/**
|
||||
* Handles drag interactions on frames in layouts. This will
|
||||
* provides new positions/dimensions for frames based on
|
||||
* relative pixel positions provided; these will take into account
|
||||
* the grid size (in a snap-to sense) and will enforce some minimums
|
||||
* on both position and dimensions.
|
||||
*
|
||||
* The provided position and dimensions factors will determine
|
||||
* whether this is a move or a resize, and what type of resize it
|
||||
* will be. For instance, a position factor of [1, 1]
|
||||
* will move a frame along with the mouse as the drag
|
||||
* proceeds, while a dimension factor of [0, 0] will leave
|
||||
* dimensions unchanged. Combining these in different
|
||||
* ways results in different handles; a position factor of
|
||||
* [1, 0] and a dimensions factor of [-1, 0] will implement
|
||||
* a left-edge resize, as the horizontal position will move
|
||||
* with the mouse while the horizontal dimensions shrink in
|
||||
* kind (and vertical properties remain unmodified.)
|
||||
*
|
||||
* @param {object} rawPosition the initial position/dimensions
|
||||
* of the frame being interacted with
|
||||
* @param {number[]} posFactor the position factor
|
||||
* @param {number[]} dimFactor the dimensions factor
|
||||
* @param {number[]} the size of each grid element, in pixels
|
||||
* @constructor
|
||||
* @memberof platform/features/layout
|
||||
*/
|
||||
function LayoutDrag(rawPosition, posFactor, dimFactor, gridSize) {
|
||||
this.rawPosition = rawPosition;
|
||||
this.posFactor = posFactor;
|
||||
this.dimFactor = dimFactor;
|
||||
this.gridSize = gridSize;
|
||||
}
|
||||
/**
|
||||
* Handles drag interactions on frames in layouts. This will
|
||||
* provides new positions/dimensions for frames based on
|
||||
* relative pixel positions provided; these will take into account
|
||||
* the grid size (in a snap-to sense) and will enforce some minimums
|
||||
* on both position and dimensions.
|
||||
*
|
||||
* The provided position and dimensions factors will determine
|
||||
* whether this is a move or a resize, and what type of resize it
|
||||
* will be. For instance, a position factor of [1, 1]
|
||||
* will move a frame along with the mouse as the drag
|
||||
* proceeds, while a dimension factor of [0, 0] will leave
|
||||
* dimensions unchanged. Combining these in different
|
||||
* ways results in different handles; a position factor of
|
||||
* [1, 0] and a dimensions factor of [-1, 0] will implement
|
||||
* a left-edge resize, as the horizontal position will move
|
||||
* with the mouse while the horizontal dimensions shrink in
|
||||
* kind (and vertical properties remain unmodified.)
|
||||
*
|
||||
* @param {object} rawPosition the initial position/dimensions
|
||||
* of the frame being interacted with
|
||||
* @param {number[]} posFactor the position factor
|
||||
* @param {number[]} dimFactor the dimensions factor
|
||||
* @param {number[]} the size of each grid element, in pixels
|
||||
* @constructor
|
||||
* @memberof platform/features/layout
|
||||
*/
|
||||
export default function LayoutDrag(rawPosition, posFactor, dimFactor, gridSize) {
|
||||
this.rawPosition = rawPosition;
|
||||
this.posFactor = posFactor;
|
||||
this.dimFactor = dimFactor;
|
||||
this.gridSize = gridSize;
|
||||
}
|
||||
|
||||
// Convert a delta from pixel coordinates to grid coordinates,
|
||||
// rounding to whole-number grid coordinates.
|
||||
function toGridDelta(gridSize, pixelDelta) {
|
||||
return pixelDelta.map(function (v, i) {
|
||||
return Math.round(v / gridSize[i]);
|
||||
});
|
||||
}
|
||||
// Convert a delta from pixel coordinates to grid coordinates,
|
||||
// rounding to whole-number grid coordinates.
|
||||
function toGridDelta(gridSize, pixelDelta) {
|
||||
return pixelDelta.map(function (v, i) {
|
||||
return Math.round(v / gridSize[i]);
|
||||
});
|
||||
}
|
||||
|
||||
// Utility function to perform element-by-element multiplication
|
||||
function multiply(array, factors) {
|
||||
return array.map(function (v, i) {
|
||||
return v * factors[i];
|
||||
});
|
||||
}
|
||||
// Utility function to perform element-by-element multiplication
|
||||
function multiply(array, factors) {
|
||||
return array.map(function (v, i) {
|
||||
return v * factors[i];
|
||||
});
|
||||
}
|
||||
|
||||
// Utility function to perform element-by-element addition
|
||||
function add(array, other) {
|
||||
return array.map(function (v, i) {
|
||||
return v + other[i];
|
||||
});
|
||||
}
|
||||
// Utility function to perform element-by-element addition
|
||||
function add(array, other) {
|
||||
return array.map(function (v, i) {
|
||||
return v + other[i];
|
||||
});
|
||||
}
|
||||
|
||||
// Utility function to perform element-by-element max-choosing
|
||||
function max(array, other) {
|
||||
return array.map(function (v, i) {
|
||||
return Math.max(v, other[i]);
|
||||
});
|
||||
}
|
||||
// Utility function to perform element-by-element max-choosing
|
||||
function max(array, other) {
|
||||
return array.map(function (v, i) {
|
||||
return Math.max(v, other[i]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new position object in grid coordinates, with
|
||||
* position and dimensions both offset appropriately
|
||||
* according to the factors supplied in the constructor.
|
||||
* @param {number[]} pixelDelta the offset from the
|
||||
* original position, in pixels
|
||||
*/
|
||||
LayoutDrag.prototype.getAdjustedPositionAndDimensions = function (pixelDelta) {
|
||||
const gridDelta = toGridDelta(this.gridSize, pixelDelta);
|
||||
/**
|
||||
* Get a new position object in grid coordinates, with
|
||||
* position and dimensions both offset appropriately
|
||||
* according to the factors supplied in the constructor.
|
||||
* @param {number[]} pixelDelta the offset from the
|
||||
* original position, in pixels
|
||||
*/
|
||||
LayoutDrag.prototype.getAdjustedPositionAndDimensions = function (pixelDelta) {
|
||||
const gridDelta = toGridDelta(this.gridSize, pixelDelta);
|
||||
|
||||
return {
|
||||
position: max(add(this.rawPosition.position, multiply(gridDelta, this.posFactor)), [0, 0]),
|
||||
dimensions: max(add(this.rawPosition.dimensions, multiply(gridDelta, this.dimFactor)), [1, 1])
|
||||
};
|
||||
return {
|
||||
position: max(add(this.rawPosition.position, multiply(gridDelta, this.posFactor)), [0, 0]),
|
||||
dimensions: max(add(this.rawPosition.dimensions, multiply(gridDelta, this.dimFactor)), [1, 1])
|
||||
};
|
||||
};
|
||||
|
||||
LayoutDrag.prototype.getAdjustedPosition = function (pixelDelta) {
|
||||
const gridDelta = toGridDelta(this.gridSize, pixelDelta);
|
||||
LayoutDrag.prototype.getAdjustedPosition = function (pixelDelta) {
|
||||
const gridDelta = toGridDelta(this.gridSize, pixelDelta);
|
||||
|
||||
return {
|
||||
position: max(add(this.rawPosition.position, multiply(gridDelta, this.posFactor)), [0, 0])
|
||||
};
|
||||
return {
|
||||
position: max(add(this.rawPosition.position, multiply(gridDelta, this.posFactor)), [0, 0])
|
||||
};
|
||||
|
||||
return LayoutDrag;
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user