mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 16:36:13 +00:00
The second update of the Hyperlink Domain Object with fixed changes
This commit is contained in:
parent
a5f6940d67
commit
3e2fd8967a
@ -56,56 +56,43 @@ define([
|
|||||||
"required": true,
|
"required": true,
|
||||||
"cssClass": "l-input-lg"
|
"cssClass": "l-input-lg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "showTitle",
|
|
||||||
"control": "checkbox",
|
|
||||||
"value": false
|
|
||||||
},{
|
|
||||||
"key": "displayFormat",
|
"key": "displayFormat",
|
||||||
"name": "Display Format",
|
"name": "Display Format",
|
||||||
"control": "composite",
|
"control": "select",
|
||||||
"items": [
|
"options": [
|
||||||
{
|
{
|
||||||
"control": "select",
|
"name": "Link",
|
||||||
"options": [
|
"value": "link"
|
||||||
{
|
},
|
||||||
"name": "Link",
|
{
|
||||||
"value": "link"
|
"value": "button",
|
||||||
},
|
"name": "Button"
|
||||||
{
|
}
|
||||||
"value": "button",
|
],
|
||||||
"name": "Button"
|
"cssClass": "l-inline"
|
||||||
}
|
|
||||||
],
|
|
||||||
"cssClass": "l-inline"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "openNewTab",
|
"key": "openNewTab",
|
||||||
"name": "Tab to Open Hyperlink",
|
"name": "Tab to Open Hyperlink",
|
||||||
"control": "composite",
|
"control": "select",
|
||||||
"items": [
|
"options": [
|
||||||
{
|
{
|
||||||
"control": "select",
|
"name": "Open in this tab",
|
||||||
"options": [
|
"value": "thisTab"
|
||||||
{
|
},
|
||||||
"name": "Open in this tab",
|
{
|
||||||
"value": "thisTab"
|
"value": "newTab",
|
||||||
},
|
"name": "Open in a new tab"
|
||||||
{
|
}
|
||||||
"value": "newTab",
|
],
|
||||||
"name": "Open in a new tab"
|
"cssClass": "l-inline"
|
||||||
}
|
|
||||||
],
|
|
||||||
"cssClass": "l-inline"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"model": {
|
"model": {
|
||||||
"displayFormat": ["link"],
|
"displayFormat": "link",
|
||||||
"openNewTab": ["thisTab"],
|
"openNewTab": "thisTab",
|
||||||
"showTitle": false
|
"showTitle": false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +102,7 @@ define([
|
|||||||
{
|
{
|
||||||
"key": "hyperlink",
|
"key": "hyperlink",
|
||||||
"type": "hyperlink",
|
"type": "hyperlink",
|
||||||
"cssClass": "icon-check",
|
"name": "Hyperlink Display",
|
||||||
"name": "icon",
|
|
||||||
"template": hyperlinkTemplate,
|
"template": hyperlinkTemplate,
|
||||||
"editable": false
|
"editable": false
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,13 @@
|
|||||||
at runtime from the About dialog for additional information.
|
at runtime from the About dialog for additional information.
|
||||||
-->
|
-->
|
||||||
<div class="s-hyperlink" ng-controller="HyperlinkController as hyperlink">
|
<div class="s-hyperlink" ng-controller="HyperlinkController as hyperlink">
|
||||||
<div>
|
<div>
|
||||||
<a href="{{domainObject.getModel().url}}"
|
<a href="{{domainObject.getModel().url}}"
|
||||||
ng-attr-target="{{hyperlink.openNewTab() ? '_blank' : undefined}}"
|
ng-attr-target="{{hyperlink.openNewTab() ? '_blank' : undefined}}"
|
||||||
ng-class="{
|
ng-class="{
|
||||||
's-button': hyperlink.isButton()}">
|
's-button': hyperlink.isButton()
|
||||||
{{domainObject.getModel().displayText}}
|
}">
|
||||||
</a>
|
{{domainObject.getModel().displayText}}
|
||||||
</div>
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,7 +37,7 @@ define(
|
|||||||
@returns true if the hyperlink is chosen to open in a different tab, false if the same tab
|
@returns true if the hyperlink is chosen to open in a different tab, false if the same tab
|
||||||
**/
|
**/
|
||||||
HyperlinkController.prototype.openNewTab = function () {
|
HyperlinkController.prototype.openNewTab = function () {
|
||||||
if (this.$scope.domainObject.getModel().openNewTab[0] === "thisTab") {
|
if (this.$scope.domainObject.getModel().openNewTab === "thisTab") {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@ -47,7 +47,7 @@ define(
|
|||||||
@returns true if the hyperlink is chosen to be created as a button, false if a link
|
@returns true if the hyperlink is chosen to be created as a button, false if a link
|
||||||
**/
|
**/
|
||||||
HyperlinkController.prototype.isButton = function () {
|
HyperlinkController.prototype.isButton = function () {
|
||||||
if (this.$scope.domainObject.getModel().displayFormat[0] === "link") {
|
if (this.$scope.domainObject.getModel().displayFormat === "link") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,34 +26,63 @@ define(
|
|||||||
|
|
||||||
describe("The controller for hyperlinks", function () {
|
describe("The controller for hyperlinks", function () {
|
||||||
var domainObject,
|
var domainObject,
|
||||||
model,
|
|
||||||
controller,
|
controller,
|
||||||
link = "http://nasa.gov";
|
scope;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
scope = jasmine.createSpyObj(
|
||||||
|
"$scope",
|
||||||
|
["domainObject"]
|
||||||
|
);
|
||||||
domainObject = jasmine.createSpyObj(
|
domainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
["getModel"]
|
["getModel"]
|
||||||
);
|
);
|
||||||
model = jasmine.createSpyObj(
|
scope.domainObject = domainObject;
|
||||||
"getModel",
|
controller = new HyperlinkController(scope);
|
||||||
["link","openNewTab","displayFormat"]
|
|
||||||
);
|
|
||||||
domainObject.getModel.link = link;
|
|
||||||
domainObject.getModel.displayFormat = "button";
|
|
||||||
domainObject.getModel.openNewTab = "thisTab";
|
|
||||||
controller = new HyperlinkController();
|
|
||||||
});
|
|
||||||
it("opens a specific given link", function () {
|
|
||||||
expect(domainObject.getModel.link)
|
|
||||||
.toEqual("http://nasa.gov");
|
|
||||||
});
|
});
|
||||||
it("knows when it should open a new tab", function () {
|
it("knows when it should open a new tab", function () {
|
||||||
expect(domainObject.getModel.openNewTab)
|
scope.domainObject.getModel.andReturn({
|
||||||
.toEqual("thisTab");
|
"displayFormat": "link",
|
||||||
|
"openNewTab": "newTab",
|
||||||
|
"showTitle": false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
controller = new HyperlinkController(scope);
|
||||||
|
expect(controller.openNewTab())
|
||||||
|
.toBe(true);
|
||||||
});
|
});
|
||||||
it("knows when it is a button", function () {
|
it("knows when it is a button", function () {
|
||||||
expect(domainObject.getModel.displayFormat)
|
scope.domainObject.getModel.andReturn({
|
||||||
.toEqual("button");
|
"displayFormat": "button",
|
||||||
|
"openNewTab": "thisTab",
|
||||||
|
"showTitle": false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
controller = new HyperlinkController(scope);
|
||||||
|
expect(controller.isButton())
|
||||||
|
.toEqual(true);
|
||||||
|
});
|
||||||
|
it("knows when it should open in the same tab", function () {
|
||||||
|
scope.domainObject.getModel.andReturn({
|
||||||
|
"displayFormat": "link",
|
||||||
|
"openNewTab": "thisTab",
|
||||||
|
"showTitle": false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
controller = new HyperlinkController(scope);
|
||||||
|
expect(controller.openNewTab())
|
||||||
|
.toBe(false);
|
||||||
|
});
|
||||||
|
it("knows when it is a link", function () {
|
||||||
|
scope.domainObject.getModel.andReturn({
|
||||||
|
"displayFormat": "link",
|
||||||
|
"openNewTab": "thisTab",
|
||||||
|
"showTitle": false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
controller = new HyperlinkController(scope);
|
||||||
|
expect(controller.openNewTab())
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user