Compare commits

..

5 Commits

Author SHA1 Message Date
Joshi
bbe3847bff Update version to 1.3.0 2020-09-03 09:49:10 -07:00
Jamie V
91d1681698 [Navigation Tree] Prevent showing "no items" while still loading (#3341)
* no  showing "no items" if still loading

* added additional no items variable to handle dictionary composition loading race conditions

* code cleanup

* more descript variable name
2020-08-31 11:23:50 -07:00
Shefali Joshi
efd97de743 [Conditionals] Ensure correct conditions are updated after reordering (#3336)
* Use id of condition instead of index to ensure
2020-08-28 11:54:52 -07:00
Charles Hacskaylo
c4cd725c9a [Navigation] Properly handle overflow in conditional style selection tree (#3338) 2020-08-28 11:46:03 -07:00
Jamie V
23e5efbb19 Merge pull request #3243 from nasa/iso-date-format
Merging new ISODateFormatter
2020-08-28 11:13:09 -07:00
7 changed files with 132 additions and 38 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "openmct",
"version": "1.3.0-SNAPSHOT",
"version": "1.3.0",
"description": "The Open MCT core platform",
"dependencies": {},
"devDependencies": {

View File

@@ -125,11 +125,17 @@ export default class ConditionManager extends EventEmitter {
}
}
updateCondition(conditionConfiguration, index) {
let condition = this.conditions[index];
this.conditionSetDomainObject.configuration.conditionCollection[index] = conditionConfiguration;
condition.update(conditionConfiguration);
this.persistConditions();
updateCondition(conditionConfiguration) {
let condition = this.findConditionById(conditionConfiguration.id);
if (condition) {
condition.update(conditionConfiguration);
}
let index = this.conditionSetDomainObject.configuration.conditionCollection.findIndex(item => item.id === conditionConfiguration.id);
if (index > -1) {
this.conditionSetDomainObject.configuration.conditionCollection[index] = conditionConfiguration;
this.persistConditions();
}
}
updateConditionDescription(condition) {
@@ -202,12 +208,18 @@ export default class ConditionManager extends EventEmitter {
this.persistConditions();
}
removeCondition(index) {
let condition = this.conditions[index];
condition.destroy();
this.conditions.splice(index, 1);
this.conditionSetDomainObject.configuration.conditionCollection.splice(index, 1);
this.persistConditions();
removeCondition(id) {
let index = this.conditions.findIndex(item => item.id === id);
if (index > -1) {
this.conditions[index].destroy();
this.conditions.splice(index, 1);
}
let conditionCollectionIndex = this.conditionSetDomainObject.configuration.conditionCollection.findIndex(item => item.id === id);
if (conditionCollectionIndex > -1) {
this.conditionSetDomainObject.configuration.conditionCollection.splice(conditionCollectionIndex, 1);
this.persistConditions();
}
}
findConditionById(id) {
@@ -220,8 +232,8 @@ export default class ConditionManager extends EventEmitter {
reorderPlan.forEach((reorderEvent) => {
let item = oldConditions[reorderEvent.oldIndex];
newCollection.push(item);
this.conditionSetDomainObject.configuration.conditionCollection = newCollection;
});
this.conditionSetDomainObject.configuration.conditionCollection = newCollection;
this.persistConditions();
}

View File

@@ -27,13 +27,32 @@ describe('ConditionManager', () => {
let conditionMgr;
let mockListener;
let openmct = {};
let mockCondition = {
let mockDefaultCondition = {
isDefault: true,
id: '1234-5678',
configuration: {
criteria: []
}
};
let mockCondition1 = {
id: '2345-6789',
configuration: {
criteria: []
}
};
let updatedMockCondition1 = {
id: '2345-6789',
configuration: {
trigger: 'xor',
criteria: []
}
};
let mockCondition2 = {
id: '3456-7890',
configuration: {
criteria: []
}
};
let conditionSetDomainObject = {
identifier: {
namespace: "",
@@ -43,7 +62,9 @@ describe('ConditionManager', () => {
location: "mine",
configuration: {
conditionCollection: [
mockCondition
mockCondition1,
mockCondition2,
mockDefaultCondition
]
}
};
@@ -59,7 +80,7 @@ describe('ConditionManager', () => {
let mockDomainObject = {
useCapability: function () {
return mockCondition;
return mockDefaultCondition;
}
};
mockInstantiate.and.callFake(function () {
@@ -107,7 +128,11 @@ describe('ConditionManager', () => {
openmct.objects.get.and.returnValues(new Promise(function (resolve, reject) {
resolve(conditionSetDomainObject);
}), new Promise(function (resolve, reject) {
resolve(mockCondition);
resolve(mockCondition1);
}), new Promise(function (resolve, reject) {
resolve(mockCondition2);
}), new Promise(function (resolve, reject) {
resolve(mockDefaultCondition);
}));
openmct.objects.makeKeyString.and.returnValue(conditionSetDomainObject.identifier.key);
openmct.objects.observe.and.returnValue(function () {});
@@ -126,9 +151,65 @@ describe('ConditionManager', () => {
});
it('creates a conditionCollection with a default condition', function () {
expect(conditionMgr.conditionSetDomainObject.configuration.conditionCollection.length).toEqual(1);
let defaultConditionId = conditionMgr.conditions[0].id;
expect(defaultConditionId).toEqual(mockCondition.id);
expect(conditionMgr.conditionSetDomainObject.configuration.conditionCollection.length).toEqual(3);
let defaultConditionId = conditionMgr.conditions[2].id;
expect(defaultConditionId).toEqual(mockDefaultCondition.id);
});
it('reorders a conditionCollection', function () {
let reorderPlan = [{
oldIndex: 1,
newIndex: 0
},
{
oldIndex: 0,
newIndex: 1
},
{
oldIndex: 2,
newIndex: 2
}];
conditionMgr.reorderConditions(reorderPlan);
expect(conditionMgr.conditionSetDomainObject.configuration.conditionCollection.length).toEqual(3);
expect(conditionMgr.conditionSetDomainObject.configuration.conditionCollection[0].id).toEqual(mockCondition2.id);
expect(conditionMgr.conditionSetDomainObject.configuration.conditionCollection[1].id).toEqual(mockCondition1.id);
});
it('updates the right condition after reorder', function () {
let reorderPlan = [{
oldIndex: 1,
newIndex: 0
},
{
oldIndex: 0,
newIndex: 1
},
{
oldIndex: 2,
newIndex: 2
}];
conditionMgr.reorderConditions(reorderPlan);
conditionMgr.updateCondition(updatedMockCondition1);
expect(conditionMgr.conditions[1].trigger).toEqual(updatedMockCondition1.configuration.trigger);
});
it('removes the right condition after reorder', function () {
let reorderPlan = [{
oldIndex: 1,
newIndex: 0
},
{
oldIndex: 0,
newIndex: 1
},
{
oldIndex: 2,
newIndex: 2
}];
conditionMgr.reorderConditions(reorderPlan);
conditionMgr.removeCondition(mockCondition1.id);
expect(conditionMgr.conditions.length).toEqual(2);
expect(conditionMgr.conditionSetDomainObject.configuration.conditionCollection[0].id).toEqual(mockCondition2.id);
});
});

View File

@@ -308,15 +308,15 @@ export default {
};
this.condition.configuration.criteria.push(criteriaObject);
},
dragStart(e) {
e.dataTransfer.setData('dragging', e.target); // required for FF to initiate drag
e.dataTransfer.effectAllowed = "copyMove";
e.dataTransfer.setDragImage(e.target.closest('.c-condition-h'), 0, 0);
dragStart(event) {
event.dataTransfer.clearData();
event.dataTransfer.setData('dragging', event.target); // required for FF to initiate drag
event.dataTransfer.effectAllowed = "copyMove";
event.dataTransfer.setDragImage(event.target.closest('.c-condition-h'), 0, 0);
this.$emit('setMoveIndex', this.conditionIndex);
},
dragEnd(event) {
dragEnd() {
this.dragStarted = false;
event.dataTransfer.clearData();
this.$emit('dragComplete');
},
dropCondition(event, targetIndex) {
@@ -359,10 +359,10 @@ export default {
},
destroy() {
},
removeCondition(ev) {
this.$emit('removeCondition', this.conditionIndex);
removeCondition() {
this.$emit('removeCondition', this.condition.id);
},
cloneCondition(ev) {
cloneCondition() {
this.$emit('cloneCondition', {
condition: this.condition,
index: this.conditionIndex
@@ -380,8 +380,7 @@ export default {
},
persist() {
this.$emit('updateCondition', {
condition: this.condition,
index: this.conditionIndex
condition: this.condition
});
},
initCap(str) {

View File

@@ -223,10 +223,10 @@ export default {
this.conditionManager.addCondition();
},
updateCondition(data) {
this.conditionManager.updateCondition(data.condition, data.index);
this.conditionManager.updateCondition(data.condition);
},
removeCondition(index) {
this.conditionManager.removeCondition(index);
removeCondition(id) {
this.conditionManager.removeCondition(id);
},
reorder(reorderPlan) {
this.conditionManager.reorderConditions(reorderPlan);

View File

@@ -2,8 +2,6 @@
display: flex;
flex-direction: column;
flex: 1 1 auto;
//TODO: Do we need this???
//padding-right: $interiorMarginSm;
overflow: auto;
> * + * { margin-top: $interiorMargin; }
@@ -245,6 +243,7 @@
border: 1px solid $colorInteriorBorder;
border-radius: $controlCr;
padding: $interiorMargin;
overflow: auto;
}
}

View File

@@ -76,7 +76,7 @@
@expanded="handleExpanded"
/>
<li
v-if="visibleItems.length === 0"
v-if="visibleItems.length === 0 && !noVisibleItems"
:style="emptyStyles()"
class="c-tree__item c-tree__item--empty"
>
@@ -140,7 +140,8 @@ export default {
getChildHeight: false,
settingChildrenHeight: false,
isMobile: isMobile.mobileName,
multipleRootChildren: false
multipleRootChildren: false,
noVisibleItems: false
};
},
computed: {
@@ -318,6 +319,7 @@ export default {
this.noScroll = true;
}
this.noVisibleItems = false;
this.updatevisibleItems();
});
} else {
@@ -565,6 +567,7 @@ export default {
return;
}
this.noVisibleItems = true;
this.visibleItems = [];
await this.$nextTick(); // prevents "ghost" image of visibleItems
this.childrenSlideClass = 'slide-left';