diff --git a/platform/features/hyperlink/bundle.js b/platform/features/hyperlink/bundle.js index 8a68538420..74c579b736 100644 --- a/platform/features/hyperlink/bundle.js +++ b/platform/features/hyperlink/bundle.js @@ -56,56 +56,43 @@ define([ "required": true, "cssClass": "l-input-lg" }, - { - "key": "showTitle", - "control": "checkbox", - "value": false - },{ + { "key": "displayFormat", "name": "Display Format", - "control": "composite", - "items": [ - { - "control": "select", - "options": [ - { - "name": "Link", - "value": "link" - }, - { - "value": "button", - "name": "Button" - } - ], - "cssClass": "l-inline" - } - ] + "control": "select", + "options": [ + { + "name": "Link", + "value": "link" + }, + { + "value": "button", + "name": "Button" + } + ], + "cssClass": "l-inline" }, { "key": "openNewTab", "name": "Tab to Open Hyperlink", - "control": "composite", - "items": [ - { - "control": "select", - "options": [ - { - "name": "Open in this tab", - "value": "thisTab" - }, - { - "value": "newTab", - "name": "Open in a new tab" - } - ], - "cssClass": "l-inline" - } - ] + "control": "select", + "options": [ + { + "name": "Open in this tab", + "value": "thisTab" + }, + { + "value": "newTab", + "name": "Open in a new tab" + } + ], + "cssClass": "l-inline" + } ], "model": { - "displayFormat": ["link"], - "openNewTab": ["thisTab"], + "displayFormat": "link", + "openNewTab": "thisTab", "showTitle": false } @@ -115,8 +102,7 @@ define([ { "key": "hyperlink", "type": "hyperlink", - "cssClass": "icon-check", - "name": "icon", + "name": "Hyperlink Display", "template": hyperlinkTemplate, "editable": false } diff --git a/platform/features/hyperlink/res/templates/hyperlink.html b/platform/features/hyperlink/res/templates/hyperlink.html index 52039872d3..8e04dbca7b 100644 --- a/platform/features/hyperlink/res/templates/hyperlink.html +++ b/platform/features/hyperlink/res/templates/hyperlink.html @@ -20,12 +20,13 @@ at runtime from the About dialog for additional information. --> diff --git a/platform/features/hyperlink/src/HyperlinkController.js b/platform/features/hyperlink/src/HyperlinkController.js index 5fc8eaec24..13f77a96ca 100644 --- a/platform/features/hyperlink/src/HyperlinkController.js +++ b/platform/features/hyperlink/src/HyperlinkController.js @@ -37,7 +37,7 @@ define( @returns true if the hyperlink is chosen to open in a different tab, false if the same tab **/ HyperlinkController.prototype.openNewTab = function () { - if (this.$scope.domainObject.getModel().openNewTab[0] === "thisTab") { + if (this.$scope.domainObject.getModel().openNewTab === "thisTab") { return false; } else { return true; @@ -47,7 +47,7 @@ define( @returns true if the hyperlink is chosen to be created as a button, false if a link **/ HyperlinkController.prototype.isButton = function () { - if (this.$scope.domainObject.getModel().displayFormat[0] === "link") { + if (this.$scope.domainObject.getModel().displayFormat === "link") { return false; } return true; diff --git a/platform/features/hyperlink/test/HyperlinkControllerSpec.js b/platform/features/hyperlink/test/HyperlinkControllerSpec.js index 4348b987bb..de941b54be 100644 --- a/platform/features/hyperlink/test/HyperlinkControllerSpec.js +++ b/platform/features/hyperlink/test/HyperlinkControllerSpec.js @@ -26,34 +26,63 @@ define( describe("The controller for hyperlinks", function () { var domainObject, - model, controller, - link = "http://nasa.gov"; + scope; beforeEach(function () { + scope = jasmine.createSpyObj( + "$scope", + ["domainObject"] + ); domainObject = jasmine.createSpyObj( - "domainObject", - ["getModel"] - ); - model = jasmine.createSpyObj( - "getModel", - ["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"); + "domainObject", + ["getModel"] + ); + scope.domainObject = domainObject; + controller = new HyperlinkController(scope); }); it("knows when it should open a new tab", function () { - expect(domainObject.getModel.openNewTab) - .toEqual("thisTab"); + scope.domainObject.getModel.andReturn({ + "displayFormat": "link", + "openNewTab": "newTab", + "showTitle": false + } + ); + controller = new HyperlinkController(scope); + expect(controller.openNewTab()) + .toBe(true); }); it("knows when it is a button", function () { - expect(domainObject.getModel.displayFormat) - .toEqual("button"); + scope.domainObject.getModel.andReturn({ + "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); }); }); }