Compare commits

..

9 Commits

Author SHA1 Message Date
Henry
618a6e7e8d Remove unused steps from circleci configuration. Fixes #1782 2017-10-19 15:51:26 -07:00
Andrew Henry
63a8c91f71 Merge pull request #1781 from nasa/view-destroy
[Views] Clear regions on destroy
2017-10-19 12:17:24 -07:00
Victor Woeltjen
e59020fec7 [Views] Clear regions on destroy
Clear regions when a view is destroyed. This causes a view's
destroy method to be correctly invoked, allowing views to do
cleanup. Used by NSS heatmap view for sprint Alice,
https://github.com/nasa/openmct/projects/1
2017-10-19 10:57:53 -07:00
Pete Richards
a2e424203a Merge pull request #1777 from nasa/iframe-border-1776
[Frontend] Review and integrate the death of iframe borders
2017-10-13 20:59:50 -07:00
Charles Hacskaylo
16853644cb [Frontend] Kill iframe borders dead!
Fixes #1776
2017-10-13 17:05:37 -07:00
Victor Woeltjen
2272766c57 Merge pull request #1743 from nasa/layout-issue-1731
[Layout] Deselect object after removal
2017-10-13 13:48:59 -07:00
Victor Woeltjen
1d9cdea2d4 Merge pull request #1767 from nasa/inline-edit-bug-1757
[Edit] Prevent blur to update the model after return key is pressed
2017-10-13 13:07:05 -07:00
Pegah Sarram
715219c44d [Edit] Fix the issue with currentTarget being null and HTML being added on Enter
Remove the line break that is added when the return key is pressed.

Check the current target directly.

Use textContent for inline editing instead of innerHTML, which will hoist up some HTML content implicitly created around user input for a contenteditable span.

Note that there is a removeAllRanges in addition to a blur here; see
https://stackoverflow.com/questions/4878713/how-can-i-blur-a-div-where-contenteditable-true

Fix broken tests.

Fixes #1757
2017-10-13 11:50:40 -07:00
Pegah Sarram
00dc2875bf [Layout] Deselect object after removal
If the selected object is not in the composition, deselect it.

Add tests.

Fixes #1731
2017-10-10 15:39:29 -07:00
7 changed files with 66 additions and 32 deletions

View File

@@ -4,12 +4,6 @@ deployment:
commands:
- npm install canvas nomnoml
- ./build-docs.sh
- git fetch --unshallow
- git push git@heroku.com:openmctweb-demo.git $CIRCLE_SHA1:refs/heads/master
openmct-demo:
branch: live_demo
heroku:
appname: openmct-demo
openmctweb-staging-deux:
branch: mobile
heroku:

View File

@@ -42,23 +42,37 @@ define(
* @param event the mouse event
*/
ObjectHeaderController.prototype.updateName = function (event) {
if (event && (event.type === 'blur' || event.which === 13)) {
var name = event.currentTarget.innerHTML;
if (!event || !event.currentTarget) {
return;
}
if (name.length === 0) {
name = "Unnamed " + this.domainObject.getCapability("type").typeDef.name;
event.currentTarget.innerHTML = name;
}
if (event.type === 'blur') {
this.updateModel(event);
} else if (event.which === 13) {
this.updateModel(event);
event.currentTarget.blur();
window.getSelection().removeAllRanges();
}
};
if (name !== this.$scope.domainObject.model.name) {
this.domainObject.getCapability('mutation').mutate(function (model) {
model.name = name;
});
}
/**
* Updates the model.
*
* @param event the mouse event
* @param private
*/
ObjectHeaderController.prototype.updateModel = function (event) {
var name = event.currentTarget.textContent.replace(/\n/g, ' ');
if (event.which === 13) {
event.currentTarget.blur();
}
if (name.length === 0) {
name = "Unnamed " + this.domainObject.getCapability("type").typeDef.name;
event.currentTarget.textContent = name;
}
if (name !== this.domainObject.getModel().name) {
this.domainObject.getCapability('mutation').mutate(function (model) {
model.name = name;
});
}
};

View File

@@ -32,6 +32,7 @@ define(
mockTypeCapability,
mockEvent,
mockCurrentTarget,
model,
controller;
beforeEach(function () {
@@ -47,8 +48,11 @@ define(
type: mockTypeCapability
};
mockDomainObject = jasmine.createSpyObj("domainObject", ["getCapability", "model"]);
mockDomainObject.model = {name: "Test name"};
model = {
name: "Test name"
};
mockDomainObject = jasmine.createSpyObj("domainObject", ["getCapability", "getModel"]);
mockDomainObject.getModel.andReturn(model);
mockDomainObject.getCapability.andCallFake(function (key) {
return mockCapabilities[key];
});
@@ -57,7 +61,7 @@ define(
domainObject: mockDomainObject
};
mockCurrentTarget = jasmine.createSpyObj("currentTarget", ["blur", "innerHTML"]);
mockCurrentTarget = jasmine.createSpyObj("currentTarget", ["blur", "textContent"]);
mockCurrentTarget.blur.andReturn(mockCurrentTarget);
mockEvent = {
@@ -71,7 +75,7 @@ define(
it("updates the model with new name on blur", function () {
mockEvent.type = "blur";
mockCurrentTarget.innerHTML = "New name";
mockCurrentTarget.textContent = "New name";
controller.updateName(mockEvent);
expect(mockMutationCapability.mutate).toHaveBeenCalled();
@@ -79,23 +83,23 @@ define(
it("updates the model with a default for blank names", function () {
mockEvent.type = "blur";
mockCurrentTarget.innerHTML = "";
mockCurrentTarget.textContent = "";
controller.updateName(mockEvent);
expect(mockCurrentTarget.innerHTML.length).not.toEqual(0);
expect(mockCurrentTarget.textContent.length).not.toEqual(0);
expect(mockMutationCapability.mutate).toHaveBeenCalled();
});
it("does not update the model if the same name", function () {
mockEvent.type = "blur";
mockCurrentTarget.innerHTML = mockDomainObject.model.name;
mockCurrentTarget.textContent = mockDomainObject.getModel().name;
controller.updateName(mockEvent);
expect(mockMutationCapability.mutate).not.toHaveBeenCalled();
});
it("updates the model on enter keypress event only", function () {
mockCurrentTarget.innerHTML = "New name";
mockCurrentTarget.textContent = "New name";
controller.updateName(mockEvent);
expect(mockMutationCapability.mutate).not.toHaveBeenCalled();
@@ -105,12 +109,13 @@ define(
expect(mockMutationCapability.mutate).toHaveBeenCalledWith(jasmine.any(Function));
mockMutationCapability.mutate.mostRecentCall.args[0](mockDomainObject.model);
mockMutationCapability.mutate.mostRecentCall.args[0](model);
expect(mockDomainObject.model.name).toBe("New name");
expect(mockDomainObject.getModel().name).toBe("New name");
});
it("blurs the field on enter key press", function () {
mockCurrentTarget.textContent = "New name";
mockEvent.which = 13;
controller.updateName(mockEvent);

View File

@@ -26,5 +26,6 @@
display: block;
height: 100%;
width: 100%;
border: none;
}
}

View File

@@ -26,8 +26,12 @@
* @namespace platform/features/layout
*/
define(
['./LayoutDrag'],
function (LayoutDrag) {
[
'./LayoutDrag'
],
function (
LayoutDrag
) {
var DEFAULT_DIMENSIONS = [12, 8],
DEFAULT_GRID_SIZE = [32, 32],
@@ -124,6 +128,10 @@ define(
self.select(null, self.droppedIdToSelectAfterRefresh);
delete self.droppedIdToSelectAfterRefresh;
}
if (composition.indexOf(self.selectedId) === -1) {
self.clearSelection();
}
}
});
}

View File

@@ -424,6 +424,17 @@ define(
expect(selectedObj.showFrame).toEqual(jasmine.any(Function));
});
it("deselects the object that is no longer in the composition", function () {
mockScope.$watchCollection.mostRecentCall.args[1]();
var childObj = mockCompositionObjects[0];
controller.select(mockEvent, childObj.getId());
var composition = ["b", "c"];
mockScope.$watchCollection.mostRecentCall.args[1](composition);
expect(controller.selected(childObj)).toBe(false);
});
});
}
);

View File

@@ -33,6 +33,7 @@ define([
link: function (scope, element, attrs) {
var region = new Region(element[0]);
scope.$watch(attrs.mctView, region.show.bind(region));
scope.$on("$destroy", region.clear.bind(region));
}
};
}