Compare commits
2 Commits
couch-batc
...
fix-lad-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
637cf7a12f | ||
|
|
5a2afece06 |
@@ -36,6 +36,7 @@ export default class LADTableConfiguration extends EventEmitter {
|
||||
getConfiguration() {
|
||||
const configuration = this.domainObject.configuration || {};
|
||||
configuration.hiddenColumns = configuration.hiddenColumns || {};
|
||||
configuration.isFixedLayout = configuration.isFixedLayout ?? true;
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
63
src/plugins/LADTable/ViewActions.js
Normal file
63
src/plugins/LADTable/ViewActions.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
const expandColumns = {
|
||||
name: 'Expand Columns',
|
||||
key: 'expand-columns',
|
||||
description: "Increase column widths to fit currently available data.",
|
||||
cssClass: 'icon-arrows-right-left labeled',
|
||||
invoke: (objectPath, view) => {
|
||||
view.getViewContext().toggleFixedLayout();
|
||||
},
|
||||
showInStatusBar: true,
|
||||
group: 'view'
|
||||
};
|
||||
|
||||
const autosizeColumns = {
|
||||
name: 'Autosize Columns',
|
||||
key: 'autosize-columns',
|
||||
description: "Automatically size columns to fit the table into the available space.",
|
||||
cssClass: 'icon-expand labeled',
|
||||
invoke: (objectPath, view) => {
|
||||
view.getViewContext().toggleFixedLayout();
|
||||
},
|
||||
showInStatusBar: true,
|
||||
group: 'view'
|
||||
};
|
||||
|
||||
const viewActions = [
|
||||
expandColumns,
|
||||
autosizeColumns
|
||||
];
|
||||
|
||||
viewActions.forEach(action => {
|
||||
action.appliesTo = (objectPath, view = {}) => {
|
||||
const viewContext = view.getViewContext && view.getViewContext();
|
||||
if (!viewContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return viewContext.type === 'lad-table';
|
||||
};
|
||||
});
|
||||
|
||||
export default viewActions;
|
||||
@@ -25,7 +25,10 @@
|
||||
class="c-lad-table-wrapper u-style-receiver js-style-receiver"
|
||||
:class="staleClass"
|
||||
>
|
||||
<table class="c-table c-lad-table">
|
||||
<table
|
||||
class="c-table c-lad-table"
|
||||
:class="applyLayoutClass"
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@@ -102,6 +105,13 @@ export default {
|
||||
return 'is-stale';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
applyLayoutClass() {
|
||||
if (this.configuration.isFixedLayout) {
|
||||
return 'fixed-layout';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
},
|
||||
@@ -189,7 +199,15 @@ export default {
|
||||
this.viewContext.row = rowContext;
|
||||
},
|
||||
getViewContext() {
|
||||
return this.viewContext;
|
||||
return {
|
||||
...this.viewContext,
|
||||
type: 'lad-table',
|
||||
toggleFixedLayout: this.toggleFixedLayout
|
||||
|
||||
};
|
||||
},
|
||||
toggleFixedLayout() {
|
||||
this.configuration.isFixedLayout = !this.configuration.isFixedLayout;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ import LADTableViewProvider from './LADTableViewProvider';
|
||||
import LADTableSetViewProvider from './LADTableSetViewProvider';
|
||||
import ladTableCompositionPolicy from './LADTableCompositionPolicy';
|
||||
import LADTableConfigurationViewProvider from './LADTableConfigurationViewProvider';
|
||||
import LADTableViewActions from './ViewActions';
|
||||
|
||||
export default function plugin() {
|
||||
return function install(openmct) {
|
||||
@@ -52,5 +53,9 @@ export default function plugin() {
|
||||
});
|
||||
|
||||
openmct.composition.addPolicy(ladTableCompositionPolicy(openmct));
|
||||
|
||||
LADTableViewActions.forEach(action => {
|
||||
openmct.actions.register(action);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -199,6 +199,13 @@ div.c-table {
|
||||
}
|
||||
|
||||
.c-lad-table {
|
||||
&.fixed-layout {
|
||||
table-layout: fixed;
|
||||
td {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
th, td {
|
||||
width: 33%; // Needed to prevent size jumping as values dynamically update
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user