From 96faf75ac329ae17ceaf66d96a7d7a80549b772d Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 22 Apr 2023 15:28:57 -0400 Subject: [PATCH 01/16] feat: impl of moved in/out (optional) --- README.md | 4 + package-lock.json | 4 +- src/common.js | 3 +- src/graphing/blips.js | 104 +++++++++++++++++++-- src/graphing/components/quadrants.js | 29 +++--- src/images/moved.svg | 9 ++ src/images/{existing.svg => no-change.svg} | 0 src/models/blip.js | 10 +- src/stylesheets/_quadrants.scss | 4 +- src/util/factory.js | 14 +-- src/util/inputSanitizer.js | 8 ++ 11 files changed, 158 insertions(+), 31 deletions(-) create mode 100644 src/images/moved.svg rename src/images/{existing.svg => no-change.svg} (100%) diff --git a/README.md b/README.md index bf131853d..115a73c5c 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ Create a Google Sheet. Give it at least the below column headers, and put in the | Apache Kylin | assess | platforms | TRUE | Apache Kylin is an open source analytics solution ... | | JSF | hold | languages & frameworks | FALSE | We continue to see teams run into trouble using JSF ... | +### Moved In / Out + +If you want to show movement of blips, add the optional columns `hasMovedIn` and `hasMovedOut` to your dataset + ### Sharing the sheet - In Google Sheets, click on "Share". diff --git a/package-lock.json b/package-lock.json index 14ab98e2a..ade18ec84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "build-your-own-radar", - "version": "0.3.0", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "build-your-own-radar", - "version": "0.3.0", + "version": "1.0.0", "license": "AGPL-3.0", "dependencies": { "chance": "^1.1.8", diff --git a/src/common.js b/src/common.js index bed7cdf5e..0fb5dc3cf 100644 --- a/src/common.js +++ b/src/common.js @@ -6,7 +6,8 @@ require('./images/search-logo-2x.svg') require('./images/banner-image-mobile.jpg') require('./images/banner-image-desktop.jpg') require('./images/new.svg') -require('./images/existing.svg') +require('./images/moved.svg') +require('./images/no-change.svg') require('./images/arrow-icon.svg') require('./images/first-quadrant-btn-bg.svg') require('./images/second-quadrant-btn-bg.svg') diff --git a/src/graphing/blips.js b/src/graphing/blips.js index 0de925e42..89409f51f 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -48,7 +48,7 @@ function thereIsCollision(coordinates, allCoordinates, blipWidth) { return allCoordinates.some(function (currentCoordinates) { return ( Math.abs(currentCoordinates.coordinates[0] - coordinates[0]) < - currentCoordinates.width / 2 + blipWidth / 2 + 10 && + currentCoordinates.width / 2 + blipWidth / 2 + 10 && Math.abs(currentCoordinates.coordinates[1] - coordinates[1]) < currentCoordinates.width / 2 + blipWidth / 2 + 10 ) }) @@ -75,11 +75,11 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor const maxIterations = 200 const chance = new Chance( Math.PI * - graphConfig.quadrantWidth * - graphConfig.quadrantHeight * - graphConfig.quadrantsGap * - graphConfig.blipWidth * - maxIterations, + graphConfig.quadrantWidth * + graphConfig.quadrantHeight * + graphConfig.quadrantsGap * + graphConfig.blipWidth * + maxIterations, ) let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip) let iterationCounter = 0 @@ -104,9 +104,20 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor } function blipAssistiveText(blip) { + let blipType; + if (blip.isNew()) { + blipType = 'new' + } else if (blip.hasMovedIn()) { + blipType = 'moved in' + } else if (blip.hasMovedOut()) { + blipType = 'moved out' + } else { + blipType = 'existing' + } + return blip.isGroup() ? `\`${blip.ring().name()} ring, group of ${blip.blipText()}` - : `${blip.ring().name()} ring, ${blip.name()}, ${blip.isNew() ? 'new' : 'existing'} blip.` + : `${blip.ring().name()} ring, ${blip.name()}, ${blipType} blip.` } function addOuterCircle(parentSvg, order, scale = 1) { parentSvg @@ -120,6 +131,60 @@ function addOuterCircle(parentSvg, order, scale = 1) { .style('transform', `scale(${scale})`) } +function addMovedInLine(parentSvg, order, scale = 1) { + let path; + + switch (order) { + case 'first': + path = 'M16.5 34.44c0-.86.7-1.56 1.56-1.56c8.16 0 14.8-6.64 14.8-14.8c0-.86.7-1.56 1.56-1.56c.86 0 1.56.7 1.56 1.56C36 27.96 27.96 36 18.07 36C17.2 36 16.5 35.3 16.5 34.44z'; + break; + case 'second': + path = 'M16.5 1.56c0 .86.7 1.56 1.56 1.56c8.16 0 14.8 6.64 14.8 14.8c0 .86.7 1.56 1.56 1.56c.86 0 1.56-.7 1.56-1.56C36 8.04 27.96 0 18.07 0C17.2 0 16.5.7 16.5 1.56z'; + break; + case 'third': + path = 'M19.5 34.44c0-.86-.7-1.56-1.56-1.56c-8.16 0-14.8-6.64-14.8-14.8c0-.86-.7-1.56-1.56-1.56S0 17.2 0 18.07C0 27.96 8.04 36 17.93 36C18.8 36 19.5 35.3 19.5 34.44z' + break; + case 'fourth': + path = 'M19.5 1.56c0 0.86-0.7 1.56-1.56 1.56c-8.16 0-14.8 6.64-14.8 14.8c0 0.86-0.7 1.56-1.56 1.56S0 18.8 0 17.93C0 8.04 8.04 0 17.93 0C18.8 0 19.5 0.7 19.5 1.56z'; + break; + + } + + parentSvg + .append('path') + .attr('opacity', '1') + .attr('class', order) + .attr('d', path) + .style('transform', `scale(${scale})`) +} + + +function addMovedOutLine(parentSvg, order, scale = 1) { + let path; + + switch (order) { + case 'first': + path = 'M19.5 1.56c0 0.86-0.7 1.56-1.56 1.56c-8.16 0-14.8 6.64-14.8 14.8c0 0.86-0.7 1.56-1.56 1.56S0 18.8 0 17.93C0 8.04 8.04 0 17.93 0C18.8 0 19.5 0.7 19.5 1.56z'; + break; + case 'second': + path = 'M19.5 34.44c0-.86-.7-1.56-1.56-1.56c-8.16 0-14.8-6.64-14.8-14.8c0-.86-.7-1.56-1.56-1.56S0 17.2 0 18.07C0 27.96 8.04 36 17.93 36C18.8 36 19.5 35.3 19.5 34.44z' + break; + case 'third': + path = 'M16.5 1.56c0 .86.7 1.56 1.56 1.56c8.16 0 14.8 6.64 14.8 14.8c0 .86.7 1.56 1.56 1.56c.86 0 1.56-.7 1.56-1.56C36 8.04 27.96 0 18.07 0C17.2 0 16.5.7 16.5 1.56z'; + break; + case 'fourth': + path = 'M16.5 34.44c0-.86.7-1.56 1.56-1.56c8.16 0 14.8-6.64 14.8-14.8c0-.86.7-1.56 1.56-1.56c.86 0 1.56.7 1.56 1.56C36 27.96 27.96 36 18.07 36C17.2 36 16.5 35.3 16.5 34.44z'; + break; + } + + parentSvg + .append('path') + .attr('opacity', '1') + .attr('class', order) + .attr('d', path) + .style('transform', `scale(${scale})`) +} + function drawBlipCircle(group, blip, xValue, yValue, order) { group .attr('transform', `scale(1) translate(${xValue - 16}, ${yValue - 16})`) @@ -138,6 +203,16 @@ function newBlip(blip, xValue, yValue, order, group) { addOuterCircle(group, order, blip.scale) } +function movedInBlip(blip, xValue, yValue, order, group) { + drawBlipCircle(group, blip, xValue, yValue, order) + addMovedInLine(group, order, blip.scale) +} + +function movedOutBlip(blip, xValue, yValue, order, group) { + drawBlipCircle(group, blip, xValue, yValue, order) + addMovedOutLine(group, order, blip.scale) +} + function existingBlip(blip, xValue, yValue, order, group) { drawBlipCircle(group, blip, xValue, yValue, order) } @@ -171,14 +246,26 @@ function drawBlipInCoordinates(blip, coordinates, order, quadrantGroup) { .attr('data-blip-id', blipId) .attr('data-ring-name', blip.ring().name()) + console.log(blip.name() + ' ' + blip.isNew() + ' ' + blip.hasMovedIn() + ' ' + blip.hasMovedOut() + ' ' + blip.isGroup()) + if (blip.isGroup()) { + console.log('group blip') groupBlip(blip, x, y, order, group) } else if (blip.isNew()) { + console.log('is new blip') newBlip(blip, x, y, order, group) + } else if (blip.hasMovedIn()) { + console.log('moved in'); + movedInBlip(blip, x, y, order, group) + } else if (blip.hasMovedOut()) { + console.log('moved out'); + movedOutBlip(blip, x, y, order, group) } else { existingBlip(blip, x, y, order, group) } + console.log('end') + group .append('text') .attr('x', blip.isGroup() ? (blip.isNew() ? 45 : 64) : 18) @@ -283,6 +370,8 @@ const plotRadarBlips = function (parentElement, rings, quadrantWrapper, tooltip) quadrantOrder = quadrantWrapper.order blips = quadrant.blips() + console.log(blips) + rings.forEach(function (ring, i) { const ringBlips = blips.filter(function (blip) { return blip.ring() === ring @@ -303,6 +392,7 @@ const plotRadarBlips = function (parentElement, rings, quadrantWrapper, tooltip) } ringBlips.forEach(function (blip) { + console.log('here') const coordinates = findBlipCoordinates( blip, minRadius, diff --git a/src/graphing/components/quadrants.js b/src/graphing/components/quadrants.js index 100014cac..61578980d 100644 --- a/src/graphing/components/quadrants.js +++ b/src/graphing/components/quadrants.js @@ -169,10 +169,9 @@ function selectRadarQuadrant(order, startAngle, name) { if (order === 'first' || order === 'second') { radarLegendsContainer.style( 'left', - `${ - parentWidth - - getScaledQuadrantWidth(scale) + - (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) + `${parentWidth - + getScaledQuadrantWidth(scale) + + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) }px`, ) } else { @@ -401,15 +400,23 @@ function renderRadarLegends(radarElement) { .attr('alt', 'new blip legend icon') .node().outerHTML - const existingImage = legendsContainer + const movedImage = legendsContainer .append('img') - .attr('src', '/images/existing.svg') + .attr('src', '/images/moved.svg') .attr('width', '37px') .attr('height', '37px') - .attr('alt', 'existing blip legend icon') + .attr('alt', 'moved in or out blip legend icon') .node().outerHTML - legendsContainer.html(`${newImage} New ${existingImage} Existing`) + const noChangeImage = legendsContainer + .append('img') + .attr('src', '/images/no-change.svg') + .attr('width', '37px') + .attr('height', '37px') + .attr('alt', 'no change blip legend icon') + .node().outerHTML + + legendsContainer.html(`${newImage} New ${movedImage} Moved in/out ${noChangeImage} No change`) } function renderMobileView(quadrant) { @@ -475,16 +482,14 @@ function quadrantScrollHandler( radarElement.style('left', `${leftQuadrantLeftValue}px`) radarLegendsContainer.style( 'left', - `${ - leftQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) + `${leftQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) }px`, ) } else { radarElement.style('left', `${rightQuadrantLeftValue}px`) radarLegendsContainer.style( 'left', - `${ - rightQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) + `${rightQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) }px`, ) } diff --git a/src/images/moved.svg b/src/images/moved.svg new file mode 100644 index 000000000..98e75152f --- /dev/null +++ b/src/images/moved.svg @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/src/images/existing.svg b/src/images/no-change.svg similarity index 100% rename from src/images/existing.svg rename to src/images/no-change.svg diff --git a/src/models/blip.js b/src/models/blip.js index 25f0ff1a5..bc7701b60 100644 --- a/src/models/blip.js +++ b/src/models/blip.js @@ -1,6 +1,6 @@ const { graphConfig } = require('../graphing/config') const IDEAL_BLIP_WIDTH = 22 -const Blip = function (name, ring, isNew, topic, description) { +const Blip = function (name, ring, isNew, hasMovedIn, hasMovedOut, topic, description) { let self, blipText, isGroup, id, groupIdInGraph self = {} @@ -32,6 +32,14 @@ const Blip = function (name, ring, isNew, topic, description) { return isNew } + self.hasMovedIn = function () { + return hasMovedIn || false; + } + + self.hasMovedOut = function () { + return hasMovedOut || false + } + self.isGroup = function () { return isGroup } diff --git a/src/stylesheets/_quadrants.scss b/src/stylesheets/_quadrants.scss index b105ba82c..2afcc513b 100644 --- a/src/stylesheets/_quadrants.scss +++ b/src/stylesheets/_quadrants.scss @@ -402,8 +402,8 @@ top: calc($quadrantWidth * 2 + $quadrantsGap); } - img:nth-child(2) { - margin-left: 48px; + img:nth-child(n + 2) { + margin-left: 24px; } } diff --git a/src/util/factory.js b/src/util/factory.js index 5e30243ef..8c41cc37c 100644 --- a/src/util/factory.js +++ b/src/util/factory.js @@ -53,7 +53,7 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { quadrants[blip.quadrant] = new Quadrant(blip.quadrant[0].toUpperCase() + blip.quadrant.slice(1)) } quadrants[blip.quadrant].add( - new Blip(blip.name, ringMap[blip.ring], blip.isNew.toLowerCase() === 'true', blip.topic, blip.description), + new Blip(blip.name, ringMap[blip.ring], blip.isNew.toLowerCase() === 'true', blip.hasMovedIn.toLowerCase() === 'true', blip.hasMovedOut.toLowerCase() === 'true', blip.topic, blip.description), ) }) @@ -75,8 +75,8 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { const size = featureToggles.UIRefresh2022 ? getGraphSize() : window.innerHeight - 133 < 620 - ? 620 - : window.innerHeight - 133 + ? 620 + : window.innerHeight - 133 new GraphingRadar(size, radar).init().plot() } @@ -110,6 +110,8 @@ const plotRadarGraph = function (title, blips, currentRadarName, alternativeRada blip.name, ringMap[ring], blip.isNew.toLowerCase() === 'true', + blip.hasMovedIn.toLowerCase() === 'true', + blip.hasMovedOut.toLowerCase() === 'true', blip.topic, blip.description, ) @@ -395,9 +397,9 @@ function plotFooter(content) { .append('p') .html( 'Powered by Thoughtworks. ' + - 'By using this service you agree to Thoughtworks\' terms of use. ' + - 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + - 'This software is open source and available for download and self-hosting.', + 'By using this service you agree to Thoughtworks\' terms of use. ' + + 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + + 'This software is open source and available for download and self-hosting.', ) } diff --git a/src/util/inputSanitizer.js b/src/util/inputSanitizer.js index 86598749a..0d567106f 100644 --- a/src/util/inputSanitizer.js +++ b/src/util/inputSanitizer.js @@ -33,6 +33,8 @@ const InputSanitizer = function () { blip.description = sanitizeHtml(blip.description, relaxedOptions) blip.name = sanitizeHtml(blip.name, restrictedOptions) blip.isNew = sanitizeHtml(blip.isNew, restrictedOptions) + blip.hasMovedIn = sanitizeHtml(blip.hasMovedIn, restrictedOptions) + blip.hasMovedOut = sanitizeHtml(blip.hasMovedOut, restrictedOptions) blip.ring = sanitizeHtml(blip.ring, restrictedOptions) blip.quadrant = sanitizeHtml(blip.quadrant, restrictedOptions) @@ -45,18 +47,24 @@ const InputSanitizer = function () { const descriptionIndex = header.indexOf('description') const nameIndex = header.indexOf('name') const isNewIndex = header.indexOf('isNew') + const hasMovedInIndex = header.indexOf('hasMovedIn') + const hasMovedOutIndex = header.indexOf('hasMovedOut') const quadrantIndex = header.indexOf('quadrant') const ringIndex = header.indexOf('ring') const description = descriptionIndex === -1 ? '' : blip[descriptionIndex] const name = nameIndex === -1 ? '' : blip[nameIndex] const isNew = isNewIndex === -1 ? '' : blip[isNewIndex] + const hasMovedIn = hasMovedInIndex === -1 ? '' : blip[hasMovedInIndex] + const hasMovedOut = hasMovedOutIndex === -1 ? '' : blip[hasMovedOutIndex] const ring = ringIndex === -1 ? '' : blip[ringIndex] const quadrant = quadrantIndex === -1 ? '' : blip[quadrantIndex] blip.description = sanitizeHtml(description, relaxedOptions) blip.name = sanitizeHtml(name, restrictedOptions) blip.isNew = sanitizeHtml(isNew, restrictedOptions) + blip.hasMovedIn = sanitizeHtml(hasMovedIn, restrictedOptions) + blip.hasMovedOut = sanitizeHtml(hasMovedOut, restrictedOptions) blip.ring = sanitizeHtml(ring, restrictedOptions) blip.quadrant = sanitizeHtml(quadrant, restrictedOptions) From 6e6f882eec52f404af7df6a7e88f5ec6a18043f4 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 22 Apr 2023 15:29:58 -0400 Subject: [PATCH 02/16] chore: run prettier-lint:fix --- src/graphing/blips.js | 68 ++++++++++++++++------------ src/graphing/components/quadrants.js | 13 ++++-- src/models/blip.js | 2 +- src/util/factory.js | 20 +++++--- 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/src/graphing/blips.js b/src/graphing/blips.js index 89409f51f..bbebeed48 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -48,7 +48,7 @@ function thereIsCollision(coordinates, allCoordinates, blipWidth) { return allCoordinates.some(function (currentCoordinates) { return ( Math.abs(currentCoordinates.coordinates[0] - coordinates[0]) < - currentCoordinates.width / 2 + blipWidth / 2 + 10 && + currentCoordinates.width / 2 + blipWidth / 2 + 10 && Math.abs(currentCoordinates.coordinates[1] - coordinates[1]) < currentCoordinates.width / 2 + blipWidth / 2 + 10 ) }) @@ -75,11 +75,11 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor const maxIterations = 200 const chance = new Chance( Math.PI * - graphConfig.quadrantWidth * - graphConfig.quadrantHeight * - graphConfig.quadrantsGap * - graphConfig.blipWidth * - maxIterations, + graphConfig.quadrantWidth * + graphConfig.quadrantHeight * + graphConfig.quadrantsGap * + graphConfig.blipWidth * + maxIterations, ) let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip) let iterationCounter = 0 @@ -104,7 +104,7 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor } function blipAssistiveText(blip) { - let blipType; + let blipType if (blip.isNew()) { blipType = 'new' } else if (blip.hasMovedIn()) { @@ -132,22 +132,25 @@ function addOuterCircle(parentSvg, order, scale = 1) { } function addMovedInLine(parentSvg, order, scale = 1) { - let path; + let path switch (order) { case 'first': - path = 'M16.5 34.44c0-.86.7-1.56 1.56-1.56c8.16 0 14.8-6.64 14.8-14.8c0-.86.7-1.56 1.56-1.56c.86 0 1.56.7 1.56 1.56C36 27.96 27.96 36 18.07 36C17.2 36 16.5 35.3 16.5 34.44z'; - break; + path = + 'M16.5 34.44c0-.86.7-1.56 1.56-1.56c8.16 0 14.8-6.64 14.8-14.8c0-.86.7-1.56 1.56-1.56c.86 0 1.56.7 1.56 1.56C36 27.96 27.96 36 18.07 36C17.2 36 16.5 35.3 16.5 34.44z' + break case 'second': - path = 'M16.5 1.56c0 .86.7 1.56 1.56 1.56c8.16 0 14.8 6.64 14.8 14.8c0 .86.7 1.56 1.56 1.56c.86 0 1.56-.7 1.56-1.56C36 8.04 27.96 0 18.07 0C17.2 0 16.5.7 16.5 1.56z'; - break; + path = + 'M16.5 1.56c0 .86.7 1.56 1.56 1.56c8.16 0 14.8 6.64 14.8 14.8c0 .86.7 1.56 1.56 1.56c.86 0 1.56-.7 1.56-1.56C36 8.04 27.96 0 18.07 0C17.2 0 16.5.7 16.5 1.56z' + break case 'third': - path = 'M19.5 34.44c0-.86-.7-1.56-1.56-1.56c-8.16 0-14.8-6.64-14.8-14.8c0-.86-.7-1.56-1.56-1.56S0 17.2 0 18.07C0 27.96 8.04 36 17.93 36C18.8 36 19.5 35.3 19.5 34.44z' - break; + path = + 'M19.5 34.44c0-.86-.7-1.56-1.56-1.56c-8.16 0-14.8-6.64-14.8-14.8c0-.86-.7-1.56-1.56-1.56S0 17.2 0 18.07C0 27.96 8.04 36 17.93 36C18.8 36 19.5 35.3 19.5 34.44z' + break case 'fourth': - path = 'M19.5 1.56c0 0.86-0.7 1.56-1.56 1.56c-8.16 0-14.8 6.64-14.8 14.8c0 0.86-0.7 1.56-1.56 1.56S0 18.8 0 17.93C0 8.04 8.04 0 17.93 0C18.8 0 19.5 0.7 19.5 1.56z'; - break; - + path = + 'M19.5 1.56c0 0.86-0.7 1.56-1.56 1.56c-8.16 0-14.8 6.64-14.8 14.8c0 0.86-0.7 1.56-1.56 1.56S0 18.8 0 17.93C0 8.04 8.04 0 17.93 0C18.8 0 19.5 0.7 19.5 1.56z' + break } parentSvg @@ -158,23 +161,26 @@ function addMovedInLine(parentSvg, order, scale = 1) { .style('transform', `scale(${scale})`) } - function addMovedOutLine(parentSvg, order, scale = 1) { - let path; + let path switch (order) { case 'first': - path = 'M19.5 1.56c0 0.86-0.7 1.56-1.56 1.56c-8.16 0-14.8 6.64-14.8 14.8c0 0.86-0.7 1.56-1.56 1.56S0 18.8 0 17.93C0 8.04 8.04 0 17.93 0C18.8 0 19.5 0.7 19.5 1.56z'; - break; + path = + 'M19.5 1.56c0 0.86-0.7 1.56-1.56 1.56c-8.16 0-14.8 6.64-14.8 14.8c0 0.86-0.7 1.56-1.56 1.56S0 18.8 0 17.93C0 8.04 8.04 0 17.93 0C18.8 0 19.5 0.7 19.5 1.56z' + break case 'second': - path = 'M19.5 34.44c0-.86-.7-1.56-1.56-1.56c-8.16 0-14.8-6.64-14.8-14.8c0-.86-.7-1.56-1.56-1.56S0 17.2 0 18.07C0 27.96 8.04 36 17.93 36C18.8 36 19.5 35.3 19.5 34.44z' - break; + path = + 'M19.5 34.44c0-.86-.7-1.56-1.56-1.56c-8.16 0-14.8-6.64-14.8-14.8c0-.86-.7-1.56-1.56-1.56S0 17.2 0 18.07C0 27.96 8.04 36 17.93 36C18.8 36 19.5 35.3 19.5 34.44z' + break case 'third': - path = 'M16.5 1.56c0 .86.7 1.56 1.56 1.56c8.16 0 14.8 6.64 14.8 14.8c0 .86.7 1.56 1.56 1.56c.86 0 1.56-.7 1.56-1.56C36 8.04 27.96 0 18.07 0C17.2 0 16.5.7 16.5 1.56z'; - break; + path = + 'M16.5 1.56c0 .86.7 1.56 1.56 1.56c8.16 0 14.8 6.64 14.8 14.8c0 .86.7 1.56 1.56 1.56c.86 0 1.56-.7 1.56-1.56C36 8.04 27.96 0 18.07 0C17.2 0 16.5.7 16.5 1.56z' + break case 'fourth': - path = 'M16.5 34.44c0-.86.7-1.56 1.56-1.56c8.16 0 14.8-6.64 14.8-14.8c0-.86.7-1.56 1.56-1.56c.86 0 1.56.7 1.56 1.56C36 27.96 27.96 36 18.07 36C17.2 36 16.5 35.3 16.5 34.44z'; - break; + path = + 'M16.5 34.44c0-.86.7-1.56 1.56-1.56c8.16 0 14.8-6.64 14.8-14.8c0-.86.7-1.56 1.56-1.56c.86 0 1.56.7 1.56 1.56C36 27.96 27.96 36 18.07 36C17.2 36 16.5 35.3 16.5 34.44z' + break } parentSvg @@ -246,7 +252,9 @@ function drawBlipInCoordinates(blip, coordinates, order, quadrantGroup) { .attr('data-blip-id', blipId) .attr('data-ring-name', blip.ring().name()) - console.log(blip.name() + ' ' + blip.isNew() + ' ' + blip.hasMovedIn() + ' ' + blip.hasMovedOut() + ' ' + blip.isGroup()) + console.log( + blip.name() + ' ' + blip.isNew() + ' ' + blip.hasMovedIn() + ' ' + blip.hasMovedOut() + ' ' + blip.isGroup(), + ) if (blip.isGroup()) { console.log('group blip') @@ -255,10 +263,10 @@ function drawBlipInCoordinates(blip, coordinates, order, quadrantGroup) { console.log('is new blip') newBlip(blip, x, y, order, group) } else if (blip.hasMovedIn()) { - console.log('moved in'); + console.log('moved in') movedInBlip(blip, x, y, order, group) } else if (blip.hasMovedOut()) { - console.log('moved out'); + console.log('moved out') movedOutBlip(blip, x, y, order, group) } else { existingBlip(blip, x, y, order, group) diff --git a/src/graphing/components/quadrants.js b/src/graphing/components/quadrants.js index 61578980d..d0d0e5599 100644 --- a/src/graphing/components/quadrants.js +++ b/src/graphing/components/quadrants.js @@ -169,9 +169,10 @@ function selectRadarQuadrant(order, startAngle, name) { if (order === 'first' || order === 'second') { radarLegendsContainer.style( 'left', - `${parentWidth - - getScaledQuadrantWidth(scale) + - (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) + `${ + parentWidth - + getScaledQuadrantWidth(scale) + + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) }px`, ) } else { @@ -482,14 +483,16 @@ function quadrantScrollHandler( radarElement.style('left', `${leftQuadrantLeftValue}px`) radarLegendsContainer.style( 'left', - `${leftQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) + `${ + leftQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) }px`, ) } else { radarElement.style('left', `${rightQuadrantLeftValue}px`) radarLegendsContainer.style( 'left', - `${rightQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) + `${ + rightQuadrantLeftValue + (getScaledQuadrantWidth(scale) / 2 - getElementWidth(radarLegendsContainer) / 2) }px`, ) } diff --git a/src/models/blip.js b/src/models/blip.js index bc7701b60..405239147 100644 --- a/src/models/blip.js +++ b/src/models/blip.js @@ -33,7 +33,7 @@ const Blip = function (name, ring, isNew, hasMovedIn, hasMovedOut, topic, descri } self.hasMovedIn = function () { - return hasMovedIn || false; + return hasMovedIn || false } self.hasMovedOut = function () { diff --git a/src/util/factory.js b/src/util/factory.js index 8c41cc37c..90f9c9d91 100644 --- a/src/util/factory.js +++ b/src/util/factory.js @@ -53,7 +53,15 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { quadrants[blip.quadrant] = new Quadrant(blip.quadrant[0].toUpperCase() + blip.quadrant.slice(1)) } quadrants[blip.quadrant].add( - new Blip(blip.name, ringMap[blip.ring], blip.isNew.toLowerCase() === 'true', blip.hasMovedIn.toLowerCase() === 'true', blip.hasMovedOut.toLowerCase() === 'true', blip.topic, blip.description), + new Blip( + blip.name, + ringMap[blip.ring], + blip.isNew.toLowerCase() === 'true', + blip.hasMovedIn.toLowerCase() === 'true', + blip.hasMovedOut.toLowerCase() === 'true', + blip.topic, + blip.description, + ), ) }) @@ -75,8 +83,8 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { const size = featureToggles.UIRefresh2022 ? getGraphSize() : window.innerHeight - 133 < 620 - ? 620 - : window.innerHeight - 133 + ? 620 + : window.innerHeight - 133 new GraphingRadar(size, radar).init().plot() } @@ -397,9 +405,9 @@ function plotFooter(content) { .append('p') .html( 'Powered by Thoughtworks. ' + - 'By using this service you agree to Thoughtworks\' terms of use. ' + - 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + - 'This software is open source and available for download and self-hosting.', + 'By using this service you agree to Thoughtworks\' terms of use. ' + + 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + + 'This software is open source and available for download and self-hosting.', ) } From 76b327d020696b32aa68a109382e317d2d6fbb59 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 22 Apr 2023 15:35:45 -0400 Subject: [PATCH 03/16] refactor: remove conditional --- src/models/blip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/blip.js b/src/models/blip.js index 405239147..b8cb25289 100644 --- a/src/models/blip.js +++ b/src/models/blip.js @@ -33,11 +33,11 @@ const Blip = function (name, ring, isNew, hasMovedIn, hasMovedOut, topic, descri } self.hasMovedIn = function () { - return hasMovedIn || false + return hasMovedIn } self.hasMovedOut = function () { - return hasMovedOut || false + return hasMovedOut } self.isGroup = function () { From 624c611c96b87e2f5939a48d568925ebef438946 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 22 Apr 2023 15:35:50 -0400 Subject: [PATCH 04/16] tests: update tests --- spec/models/blip-spec.js | 28 ++++++++++++++++++++++++++-- spec/util/inputSanitizer-spec.js | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/spec/models/blip-spec.js b/spec/models/blip-spec.js index 67f3c944d..14e9e44eb 100644 --- a/spec/models/blip-spec.js +++ b/spec/models/blip-spec.js @@ -14,7 +14,7 @@ describe('Blip', function () { }) it('has a topic', function () { - blip = new Blip('My Blip', new Ring('My Ring'), true, 'topic', 'description') + blip = new Blip('My Blip', new Ring('My Ring'), true, false, false, 'topic', 'description') expect(blip.topic()).toEqual('topic') }) @@ -24,7 +24,7 @@ describe('Blip', function () { }) it('has a description', function () { - blip = new Blip('My Blip', new Ring('My Ring'), true, 'topic', 'description') + blip = new Blip('My Blip', new Ring('My Ring'), true, false, false, 'topic', 'description') expect(blip.description()).toEqual('description') }) @@ -67,6 +67,30 @@ describe('Blip', function () { expect(blip.isNew()).toBe(false) }) + it('has moved in', function () { + blip = new Blip('My Blip', new Ring('My Ring'), false, true) + + expect(blip.hasMovedIn()).toBe(true) + }) + + it('has not moved in', function () { + blip = new Blip('My Blip', new Ring('My Ring'), false, false) + + expect(blip.hasMovedIn()).toBe(false) + }) + + it('has moved out', function () { + blip = new Blip('My Blip', new Ring('My Ring'), false, false, true) + + expect(blip.hasMovedOut()).toBe(true) + }) + + it('has not moved out', function () { + blip = new Blip('My Blip', new Ring('My Ring'), false, false, false) + + expect(blip.hasMovedOut()).toBe(false) + }) + it('has false as default value for isGroup', function () { expect(blip.isGroup()).toEqual(false) }) diff --git a/spec/util/inputSanitizer-spec.js b/spec/util/inputSanitizer-spec.js index 60a1a0118..9287e9f2a 100644 --- a/spec/util/inputSanitizer-spec.js +++ b/spec/util/inputSanitizer-spec.js @@ -107,6 +107,8 @@ describe('Input Santizer for Protected sheet', function () { ring: '', quadrant: '', isNew: '', + hasMovedIn: '', + hasMovedOut: '', }) }) }) From 159836f59fba171c12245ccdf9f1f6b9224829d8 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 22 Apr 2023 16:06:04 -0400 Subject: [PATCH 05/16] tests: add tests for assistiveText --- spec/graphing/blips-spec.js | 40 ++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/spec/graphing/blips-spec.js b/spec/graphing/blips-spec.js index 7b5a454a0..7622ae63b 100644 --- a/spec/graphing/blips-spec.js +++ b/spec/graphing/blips-spec.js @@ -190,7 +190,45 @@ describe('Blips', function () { } const actual = blipAssistiveText(blip) - expect(actual).toEqual('`ring1 ring, group of 12 New Blips') + expect(actual).toEqual('ring1 ring, group of 12 New Blips') + }) + + it('should return moved in assistive text for moved in blip', function () { + const blip = { + isGroup: () => false, + ring: () => { + return { + name: () => 'ring1', + } + }, + blipText: () => '12 New Blips', + name: () => 'blip1', + isNew: () => false, + hasMovedIn: () => true, + hasMovedOut: () => false, + } + + const actual = blipAssistiveText(blip) + expect(actual).toEqual('ring1 ring, blip1, moved in blip.') + }) + + it('should return moved out blip assistive text for moved out blip', function () { + const blip = { + isGroup: () => false, + ring: () => { + return { + name: () => 'ring1', + } + }, + blipText: () => '12 New Blips', + name: () => 'blip1', + isNew: () => false, + hasMovedIn: () => false, + hasMovedOut: () => true, + } + + const actual = blipAssistiveText(blip) + expect(actual).toEqual('ring1 ring, blip1, moved out blip.') }) it('should return group blip with appropriate values', function () { From 87ebf2304ac30f9e9ab22682144d38c6cceb524d Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 22 Apr 2023 16:07:20 -0400 Subject: [PATCH 06/16] tests: add tests for assistiveText --- spec/graphing/blips-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/graphing/blips-spec.js b/spec/graphing/blips-spec.js index 7622ae63b..d8b290e6e 100644 --- a/spec/graphing/blips-spec.js +++ b/spec/graphing/blips-spec.js @@ -190,7 +190,7 @@ describe('Blips', function () { } const actual = blipAssistiveText(blip) - expect(actual).toEqual('ring1 ring, group of 12 New Blips') + expect(actual).toEqual('`ring1 ring, group of 12 New Blips') }) it('should return moved in assistive text for moved in blip', function () { From 2b9c118d1bd5e856cbaec2b9c7ea2291c0109d38 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 23 Apr 2023 17:06:47 -0400 Subject: [PATCH 07/16] remove console.logging --- src/graphing/blips.js | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/graphing/blips.js b/src/graphing/blips.js index bbebeed48..265e4a118 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -48,7 +48,7 @@ function thereIsCollision(coordinates, allCoordinates, blipWidth) { return allCoordinates.some(function (currentCoordinates) { return ( Math.abs(currentCoordinates.coordinates[0] - coordinates[0]) < - currentCoordinates.width / 2 + blipWidth / 2 + 10 && + currentCoordinates.width / 2 + blipWidth / 2 + 10 && Math.abs(currentCoordinates.coordinates[1] - coordinates[1]) < currentCoordinates.width / 2 + blipWidth / 2 + 10 ) }) @@ -75,11 +75,11 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor const maxIterations = 200 const chance = new Chance( Math.PI * - graphConfig.quadrantWidth * - graphConfig.quadrantHeight * - graphConfig.quadrantsGap * - graphConfig.blipWidth * - maxIterations, + graphConfig.quadrantWidth * + graphConfig.quadrantHeight * + graphConfig.quadrantsGap * + graphConfig.blipWidth * + maxIterations, ) let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip) let iterationCounter = 0 @@ -252,28 +252,18 @@ function drawBlipInCoordinates(blip, coordinates, order, quadrantGroup) { .attr('data-blip-id', blipId) .attr('data-ring-name', blip.ring().name()) - console.log( - blip.name() + ' ' + blip.isNew() + ' ' + blip.hasMovedIn() + ' ' + blip.hasMovedOut() + ' ' + blip.isGroup(), - ) - if (blip.isGroup()) { - console.log('group blip') groupBlip(blip, x, y, order, group) } else if (blip.isNew()) { - console.log('is new blip') newBlip(blip, x, y, order, group) } else if (blip.hasMovedIn()) { - console.log('moved in') movedInBlip(blip, x, y, order, group) } else if (blip.hasMovedOut()) { - console.log('moved out') movedOutBlip(blip, x, y, order, group) } else { existingBlip(blip, x, y, order, group) } - console.log('end') - group .append('text') .attr('x', blip.isGroup() ? (blip.isNew() ? 45 : 64) : 18) @@ -378,8 +368,6 @@ const plotRadarBlips = function (parentElement, rings, quadrantWrapper, tooltip) quadrantOrder = quadrantWrapper.order blips = quadrant.blips() - console.log(blips) - rings.forEach(function (ring, i) { const ringBlips = blips.filter(function (blip) { return blip.ring() === ring @@ -400,7 +388,6 @@ const plotRadarBlips = function (parentElement, rings, quadrantWrapper, tooltip) } ringBlips.forEach(function (blip) { - console.log('here') const coordinates = findBlipCoordinates( blip, minRadius, From 76454cac3768b1e8f1e8fb55bb94b12853613225 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 23 Apr 2023 17:07:25 -0400 Subject: [PATCH 08/16] fix linting --- src/graphing/blips.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/graphing/blips.js b/src/graphing/blips.js index 265e4a118..4d7a82494 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -48,7 +48,7 @@ function thereIsCollision(coordinates, allCoordinates, blipWidth) { return allCoordinates.some(function (currentCoordinates) { return ( Math.abs(currentCoordinates.coordinates[0] - coordinates[0]) < - currentCoordinates.width / 2 + blipWidth / 2 + 10 && + currentCoordinates.width / 2 + blipWidth / 2 + 10 && Math.abs(currentCoordinates.coordinates[1] - coordinates[1]) < currentCoordinates.width / 2 + blipWidth / 2 + 10 ) }) @@ -75,11 +75,11 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor const maxIterations = 200 const chance = new Chance( Math.PI * - graphConfig.quadrantWidth * - graphConfig.quadrantHeight * - graphConfig.quadrantsGap * - graphConfig.blipWidth * - maxIterations, + graphConfig.quadrantWidth * + graphConfig.quadrantHeight * + graphConfig.quadrantsGap * + graphConfig.blipWidth * + maxIterations, ) let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip) let iterationCounter = 0 From 19cd2936fee6b317eefd531a9c812b379b1939e1 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 25 Apr 2023 08:05:46 -0400 Subject: [PATCH 09/16] feat: add dynamic legend --- src/common.js | 1 + src/graphing/components/quadrants.js | 18 +++++++++++++++--- src/graphing/radar.js | 20 +++++++++++++++++++- src/images/existing.svg | 9 +++++++++ src/models/radar.js | 1 + 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/images/existing.svg diff --git a/src/common.js b/src/common.js index 0fb5dc3cf..363b731ce 100644 --- a/src/common.js +++ b/src/common.js @@ -7,6 +7,7 @@ require('./images/banner-image-mobile.jpg') require('./images/banner-image-desktop.jpg') require('./images/new.svg') require('./images/moved.svg') +require('./images/existing.svg') require('./images/no-change.svg') require('./images/arrow-icon.svg') require('./images/first-quadrant-btn-bg.svg') diff --git a/src/graphing/components/quadrants.js b/src/graphing/components/quadrants.js index d0d0e5599..da97fb283 100644 --- a/src/graphing/components/quadrants.js +++ b/src/graphing/components/quadrants.js @@ -390,7 +390,7 @@ function renderRadarQuadrants(size, svg, quadrant, rings, ringCalculator, tip) { return quadrantGroup } -function renderRadarLegends(radarElement) { +function renderRadarLegends(radarElement, hasMovements) { const legendsContainer = radarElement.append('div').classed('radar-legends', true) const newImage = legendsContainer @@ -406,7 +406,15 @@ function renderRadarLegends(radarElement) { .attr('src', '/images/moved.svg') .attr('width', '37px') .attr('height', '37px') - .attr('alt', 'moved in or out blip legend icon') + .attr('alt', `moved in or out blip legend icon`) + .node().outerHTML + + const existingImage = legendsContainer + .append('img') + .attr('src', '/images/existing.svg') + .attr('width', '37px') + .attr('height', '37px') + .attr('alt', 'existing blip legend icon') .node().outerHTML const noChangeImage = legendsContainer @@ -417,7 +425,11 @@ function renderRadarLegends(radarElement) { .attr('alt', 'no change blip legend icon') .node().outerHTML - legendsContainer.html(`${newImage} New ${movedImage} Moved in/out ${noChangeImage} No change`) + if (hasMovements) { + legendsContainer.html(`${newImage} New ${movedImage} Moved in/out ${noChangeImage} No change`) + } else { + legendsContainer.html(`${newImage} New ${existingImage} Existing`) + } } function renderMobileView(quadrant) { diff --git a/src/graphing/radar.js b/src/graphing/radar.js index 4bc161253..15be2049e 100644 --- a/src/graphing/radar.js +++ b/src/graphing/radar.js @@ -826,12 +826,30 @@ const Radar = function (size, radar) { }) if (featureToggles.UIRefresh2022) { - renderRadarLegends(radarElement) + let hasMovements = hasMovementData(quadrants) + renderRadarLegends(radarElement, hasMovements) hideTooltipOnScroll(tip) addRadarLinkInPdfView() } } + function hasMovementData(quadrants) { + let hasMovements = false + + for (var quadrantWrapper of quadrants) { + let quadrant = quadrantWrapper.quadrant + + for (var blip of quadrant.blips()) { + if (blip.hasMovedIn() || blip.hasMovedOut()) { + hasMovements = true + break + } + } + } + + return hasMovements + } + return self } diff --git a/src/images/existing.svg b/src/images/existing.svg new file mode 100644 index 000000000..98f4d440d --- /dev/null +++ b/src/images/existing.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/src/models/radar.js b/src/models/radar.js index ab7b90c5e..e26aeba20 100644 --- a/src/models/radar.js +++ b/src/models/radar.js @@ -65,6 +65,7 @@ const Radar = function () { setNumbers(quadrant.blips()) addingQuadrant++ } + self.addRings = function (allRings) { rings = allRings } From 2817b3be84349a18bcad9778f66db1be7c0f89c0 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 8 Jul 2023 07:05:17 -0400 Subject: [PATCH 10/16] refactor: introduce new blip.status field --- spec/graphing/blips-spec.js | 43 ++++++++++++++++++++++++++++++-- spec/models/blip-spec.js | 27 ++++++++++---------- spec/util/inputSanitizer-spec.js | 3 +-- src/graphing/blips.js | 15 +++++------ src/graphing/radar.js | 32 ++++++++++++------------ src/models/blip.js | 18 ++++++++++--- src/util/contentValidator.js | 7 +++++- src/util/factory.js | 16 ++++++------ src/util/inputSanitizer.js | 12 +++------ 9 files changed, 112 insertions(+), 61 deletions(-) diff --git a/spec/graphing/blips-spec.js b/spec/graphing/blips-spec.js index e00ac399f..4184735b0 100644 --- a/spec/graphing/blips-spec.js +++ b/spec/graphing/blips-spec.js @@ -187,13 +187,52 @@ describe('Blips', function () { blipText: () => '12 New Blips', name: 'blip1', isNew: () => true, + status: () => null } const actual = blipAssistiveText(blip) expect(actual).toEqual('`ring1 ring, group of 12 New Blips') }) - it('should return moved in assistive text for moved in blip', function () { + it('should return correct assistive text for new blip', function () { + const blip = { + isGroup: () => false, + ring: () => { + return { + name: () => 'ring1', + } + }, + blipText: () => '12 New Blips', + name: () => 'blip1', + isNew: () => true, + hasMovedIn: () => false, + hasMovedOut: () => false, + } + + const actual = blipAssistiveText(blip) + expect(actual).toEqual('ring1 ring, blip1, new blip.') + }) + + it('should return correct assistive text for existing blip', function () { + const blip = { + isGroup: () => false, + ring: () => { + return { + name: () => 'ring1', + } + }, + blipText: () => '12 New Blips', + name: () => 'blip1', + isNew: () => false, + hasMovedIn: () => false, + hasMovedOut: () => false, + } + + const actual = blipAssistiveText(blip) + expect(actual).toEqual('ring1 ring, blip1, existing blip.') + }) + + it('should return correct assistive text for moved in blip', function () { const blip = { isGroup: () => false, ring: () => { @@ -212,7 +251,7 @@ describe('Blips', function () { expect(actual).toEqual('ring1 ring, blip1, moved in blip.') }) - it('should return moved out blip assistive text for moved out blip', function () { + it('should return correct assistive text for moved out blip', function () { const blip = { isGroup: () => false, ring: () => { diff --git a/spec/models/blip-spec.js b/spec/models/blip-spec.js index 14e9e44eb..5762caaac 100644 --- a/spec/models/blip-spec.js +++ b/spec/models/blip-spec.js @@ -14,7 +14,7 @@ describe('Blip', function () { }) it('has a topic', function () { - blip = new Blip('My Blip', new Ring('My Ring'), true, false, false, 'topic', 'description') + blip = new Blip('My Blip', new Ring('My Ring'), true, null, 'topic', 'description') expect(blip.topic()).toEqual('topic') }) @@ -24,7 +24,7 @@ describe('Blip', function () { }) it('has a description', function () { - blip = new Blip('My Blip', new Ring('My Ring'), true, false, false, 'topic', 'description') + blip = new Blip('My Blip', new Ring('My Ring'), true, null, 'topic', 'description') expect(blip.description()).toEqual('description') }) @@ -67,30 +67,31 @@ describe('Blip', function () { expect(blip.isNew()).toBe(false) }) - it('has moved in', function () { - blip = new Blip('My Blip', new Ring('My Ring'), false, true) + it('status is new', function () { + blip = new Blip('My Blip', new Ring('My Ring'), null, 'new') - expect(blip.hasMovedIn()).toBe(true) + expect(blip.isNew()).toBe(true) }) - it('has not moved in', function () { - blip = new Blip('My Blip', new Ring('My Ring'), false, false) + it('status has moved in', function () { + blip = new Blip('My Blip', new Ring('My Ring'), null, 'Moved In') - expect(blip.hasMovedIn()).toBe(false) + expect(blip.hasMovedIn()).toBe(true) }) - it('has moved out', function () { - blip = new Blip('My Blip', new Ring('My Ring'), false, false, true) + it('status has moved out', function () { + blip = new Blip('My Blip', new Ring('My Ring'), null, 'Moved Out') expect(blip.hasMovedOut()).toBe(true) }) - it('has not moved out', function () { - blip = new Blip('My Blip', new Ring('My Ring'), false, false, false) + it('status has no change', function () { + blip = new Blip('My Blip', new Ring('My Ring'), null, 'No Change') - expect(blip.hasMovedOut()).toBe(false) + expect(blip.hasNoChange()).toBe(true) }) + it('has false as default value for isGroup', function () { expect(blip.isGroup()).toEqual(false) }) diff --git a/spec/util/inputSanitizer-spec.js b/spec/util/inputSanitizer-spec.js index 9287e9f2a..cd968f182 100644 --- a/spec/util/inputSanitizer-spec.js +++ b/spec/util/inputSanitizer-spec.js @@ -107,8 +107,7 @@ describe('Input Santizer for Protected sheet', function () { ring: '', quadrant: '', isNew: '', - hasMovedIn: '', - hasMovedOut: '', + status: '', }) }) }) diff --git a/src/graphing/blips.js b/src/graphing/blips.js index 7a17ff1b4..7de2f03a9 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -48,7 +48,7 @@ function thereIsCollision(coordinates, allCoordinates, blipWidth) { return allCoordinates.some(function (currentCoordinates) { return ( Math.abs(currentCoordinates.coordinates[0] - coordinates[0]) < - currentCoordinates.width / 2 + blipWidth / 2 + 10 && + currentCoordinates.width / 2 + blipWidth / 2 + 10 && Math.abs(currentCoordinates.coordinates[1] - coordinates[1]) < currentCoordinates.width / 2 + blipWidth / 2 + 10 ) }) @@ -75,11 +75,11 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor const maxIterations = 200 const chance = new Chance( Math.PI * - graphConfig.quadrantWidth * - graphConfig.quadrantHeight * - graphConfig.quadrantsGap * - graphConfig.blipWidth * - maxIterations, + graphConfig.quadrantWidth * + graphConfig.quadrantHeight * + graphConfig.quadrantsGap * + graphConfig.blipWidth * + maxIterations, ) let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip) let iterationCounter = 0 @@ -104,7 +104,8 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor } function blipAssistiveText(blip) { - let blipType + let blipType; + if (blip.isNew()) { blipType = 'new' } else if (blip.hasMovedIn()) { diff --git a/src/graphing/radar.js b/src/graphing/radar.js index 5f70ca25e..d76bbe2dd 100644 --- a/src/graphing/radar.js +++ b/src/graphing/radar.js @@ -161,12 +161,12 @@ const Radar = function (size, radar) { .attr( 'transform', 'scale(' + - blip.width / 34 + - ') translate(' + - (-404 + x * (34 / blip.width) - 17) + - ', ' + - (-282 + y * (34 / blip.width) - 17) + - ')', + blip.width / 34 + + ') translate(' + + (-404 + x * (34 / blip.width) - 17) + + ', ' + + (-282 + y * (34 / blip.width) - 17) + + ')', ) .attr('class', order) } @@ -194,12 +194,12 @@ const Radar = function (size, radar) { .attr( 'transform', 'scale(' + - blip.width / 34 + - ') translate(' + - (-404 + x * (34 / blip.width) - 17) + - ', ' + - (-282 + y * (34 / blip.width) - 17) + - ')', + blip.width / 34 + + ') translate(' + + (-404 + x * (34 / blip.width) - 17) + + ', ' + + (-282 + y * (34 / blip.width) - 17) + + ')', ) .attr('class', order) } @@ -653,9 +653,9 @@ const Radar = function (size, radar) { .append('p') .html( 'Powered by Thoughtworks. ' + - 'By using this service you agree to Thoughtworks\' terms of use. ' + - 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + - 'This software is open source and available for download and self-hosting.', + 'By using this service you agree to Thoughtworks\' terms of use. ' + + 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + + 'This software is open source and available for download and self-hosting.', ) } @@ -842,7 +842,7 @@ const Radar = function (size, radar) { let quadrant = quadrantWrapper.quadrant for (var blip of quadrant.blips()) { - if (blip.hasMovedIn() || blip.hasMovedOut()) { + if (blip.status() !== '') { hasMovements = true break } diff --git a/src/models/blip.js b/src/models/blip.js index b8cb25289..ae5ef3930 100644 --- a/src/models/blip.js +++ b/src/models/blip.js @@ -1,6 +1,6 @@ const { graphConfig } = require('../graphing/config') const IDEAL_BLIP_WIDTH = 22 -const Blip = function (name, ring, isNew, hasMovedIn, hasMovedOut, topic, description) { +const Blip = function (name, ring, isNew, status, topic, description) { let self, blipText, isGroup, id, groupIdInGraph self = {} @@ -29,15 +29,27 @@ const Blip = function (name, ring, isNew, hasMovedIn, hasMovedOut, topic, descri } self.isNew = function () { + if (status) { + return status.toLowerCase() === 'new' + } + return isNew } self.hasMovedIn = function () { - return hasMovedIn + return status.toLowerCase() === 'moved in' } self.hasMovedOut = function () { - return hasMovedOut + return status.toLowerCase() === 'moved out' + } + + self.hasNoChange = function () { + return status.toLowerCase() === 'no change' + } + + self.status = function () { + return status.toLowerCase() || '' } self.isGroup = function () { diff --git a/src/util/contentValidator.js b/src/util/contentValidator.js index 01c598652..e0bd533d9 100644 --- a/src/util/contentValidator.js +++ b/src/util/contentValidator.js @@ -21,11 +21,16 @@ const ContentValidator = function (columnNames) { } self.verifyHeaders = function () { - _.each(['name', 'ring', 'quadrant', 'isNew', 'description'], function (field) { + _.each(['name', 'ring', 'quadrant', 'description'], function (field) { if (columnNames.indexOf(field) === -1) { throw new MalformedDataError(ExceptionMessages.MISSING_HEADERS) } }) + + // At least one of isNew or status must be present + if (columnNames.indexOf('isNew') === -1 && columnNames.indexOf('status') === -1) { + throw new MalformedDataError(ExceptionMessages.MISSING_HEADERS) + } } return self diff --git a/src/util/factory.js b/src/util/factory.js index feeb0dd44..ead65cfe1 100644 --- a/src/util/factory.js +++ b/src/util/factory.js @@ -57,8 +57,7 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { blip.name, ringMap[blip.ring], blip.isNew.toLowerCase() === 'true', - blip.hasMovedIn.toLowerCase() === 'true', - blip.hasMovedOut.toLowerCase() === 'true', + blip.status, blip.topic, blip.description, ), @@ -83,8 +82,8 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { const size = featureToggles.UIRefresh2022 ? getGraphSize() : window.innerHeight - 133 < 620 - ? 620 - : window.innerHeight - 133 + ? 620 + : window.innerHeight - 133 new GraphingRadar(size, radar).init().plot() } @@ -118,8 +117,7 @@ const plotRadarGraph = function (title, blips, currentRadarName, alternativeRada blip.name, ringMap[ring], blip.isNew.toLowerCase() === 'true', - blip.hasMovedIn.toLowerCase() === 'true', - blip.hasMovedOut.toLowerCase() === 'true', + blip.status, blip.topic, blip.description, ) @@ -407,9 +405,9 @@ function plotFooter(content) { .append('p') .html( 'Powered by Thoughtworks. ' + - 'By using this service you agree to Thoughtworks\' terms of use. ' + - 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + - 'This software is open source and available for download and self-hosting.', + 'By using this service you agree to Thoughtworks\' terms of use. ' + + 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + + 'This software is open source and available for download and self-hosting.', ) } diff --git a/src/util/inputSanitizer.js b/src/util/inputSanitizer.js index 0d567106f..8ecbb78bf 100644 --- a/src/util/inputSanitizer.js +++ b/src/util/inputSanitizer.js @@ -33,8 +33,7 @@ const InputSanitizer = function () { blip.description = sanitizeHtml(blip.description, relaxedOptions) blip.name = sanitizeHtml(blip.name, restrictedOptions) blip.isNew = sanitizeHtml(blip.isNew, restrictedOptions) - blip.hasMovedIn = sanitizeHtml(blip.hasMovedIn, restrictedOptions) - blip.hasMovedOut = sanitizeHtml(blip.hasMovedOut, restrictedOptions) + blip.status = sanitizeHtml(blip.status, restrictedOptions) blip.ring = sanitizeHtml(blip.ring, restrictedOptions) blip.quadrant = sanitizeHtml(blip.quadrant, restrictedOptions) @@ -47,24 +46,21 @@ const InputSanitizer = function () { const descriptionIndex = header.indexOf('description') const nameIndex = header.indexOf('name') const isNewIndex = header.indexOf('isNew') - const hasMovedInIndex = header.indexOf('hasMovedIn') - const hasMovedOutIndex = header.indexOf('hasMovedOut') + const statusIndex = header.indexOf('status') const quadrantIndex = header.indexOf('quadrant') const ringIndex = header.indexOf('ring') const description = descriptionIndex === -1 ? '' : blip[descriptionIndex] const name = nameIndex === -1 ? '' : blip[nameIndex] const isNew = isNewIndex === -1 ? '' : blip[isNewIndex] - const hasMovedIn = hasMovedInIndex === -1 ? '' : blip[hasMovedInIndex] - const hasMovedOut = hasMovedOutIndex === -1 ? '' : blip[hasMovedOutIndex] + const status = statusIndex === -1 ? '' : blip[statusIndex] const ring = ringIndex === -1 ? '' : blip[ringIndex] const quadrant = quadrantIndex === -1 ? '' : blip[quadrantIndex] blip.description = sanitizeHtml(description, relaxedOptions) blip.name = sanitizeHtml(name, restrictedOptions) blip.isNew = sanitizeHtml(isNew, restrictedOptions) - blip.hasMovedIn = sanitizeHtml(hasMovedIn, restrictedOptions) - blip.hasMovedOut = sanitizeHtml(hasMovedOut, restrictedOptions) + blip.status = sanitizeHtml(status, restrictedOptions) blip.ring = sanitizeHtml(ring, restrictedOptions) blip.quadrant = sanitizeHtml(quadrant, restrictedOptions) From 94c366ab5cccd63111f8ed240880bf99615cab23 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 8 Jul 2023 07:10:01 -0400 Subject: [PATCH 11/16] docs: update readme --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad9df4c31..442ef94b7 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,16 @@ Create a Google Sheet. Give it at least the below column headers, and put in the | Apache Kylin | assess | platforms | TRUE | Apache Kylin is an open source analytics solution ... | | JSF | hold | languages & frameworks | FALSE | We continue to see teams run into trouble using JSF ... | -### Moved In / Out +### Want to show blip movement information? -If you want to show movement of blips, add the optional columns `hasMovedIn` and `hasMovedOut` to your dataset +If you want to show movement of blips, add the optional column `status` to your dataset. + +This column accepts the following case-insensitive values : + +- `New` - appearing on the radar for the first time +- `Moved In` - moving towards the center of the radar +- `Moved Out` - moving towards the edge of the radar +- `No Change` - no change in position ### Sharing the sheet From 9676c361403ab7c5426e655c3f484c065326d7db Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sat, 8 Jul 2023 07:11:23 -0400 Subject: [PATCH 12/16] fix: linting --- spec/graphing/blips-spec.js | 2 +- spec/models/blip-spec.js | 1 - src/graphing/blips.js | 14 +++++++------- src/graphing/radar.js | 30 +++++++++++++++--------------- src/util/factory.js | 10 +++++----- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/spec/graphing/blips-spec.js b/spec/graphing/blips-spec.js index 4184735b0..97c4fef05 100644 --- a/spec/graphing/blips-spec.js +++ b/spec/graphing/blips-spec.js @@ -187,7 +187,7 @@ describe('Blips', function () { blipText: () => '12 New Blips', name: 'blip1', isNew: () => true, - status: () => null + status: () => null, } const actual = blipAssistiveText(blip) diff --git a/spec/models/blip-spec.js b/spec/models/blip-spec.js index 5762caaac..185ef0ce8 100644 --- a/spec/models/blip-spec.js +++ b/spec/models/blip-spec.js @@ -91,7 +91,6 @@ describe('Blip', function () { expect(blip.hasNoChange()).toBe(true) }) - it('has false as default value for isGroup', function () { expect(blip.isGroup()).toEqual(false) }) diff --git a/src/graphing/blips.js b/src/graphing/blips.js index 7de2f03a9..a6dabc8dc 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -48,7 +48,7 @@ function thereIsCollision(coordinates, allCoordinates, blipWidth) { return allCoordinates.some(function (currentCoordinates) { return ( Math.abs(currentCoordinates.coordinates[0] - coordinates[0]) < - currentCoordinates.width / 2 + blipWidth / 2 + 10 && + currentCoordinates.width / 2 + blipWidth / 2 + 10 && Math.abs(currentCoordinates.coordinates[1] - coordinates[1]) < currentCoordinates.width / 2 + blipWidth / 2 + 10 ) }) @@ -75,11 +75,11 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor const maxIterations = 200 const chance = new Chance( Math.PI * - graphConfig.quadrantWidth * - graphConfig.quadrantHeight * - graphConfig.quadrantsGap * - graphConfig.blipWidth * - maxIterations, + graphConfig.quadrantWidth * + graphConfig.quadrantHeight * + graphConfig.quadrantsGap * + graphConfig.blipWidth * + maxIterations, ) let coordinates = calculateRadarBlipCoordinates(minRadius, maxRadius, startAngle, quadrantOrder, chance, blip) let iterationCounter = 0 @@ -104,7 +104,7 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor } function blipAssistiveText(blip) { - let blipType; + let blipType if (blip.isNew()) { blipType = 'new' diff --git a/src/graphing/radar.js b/src/graphing/radar.js index d76bbe2dd..17415a8c2 100644 --- a/src/graphing/radar.js +++ b/src/graphing/radar.js @@ -161,12 +161,12 @@ const Radar = function (size, radar) { .attr( 'transform', 'scale(' + - blip.width / 34 + - ') translate(' + - (-404 + x * (34 / blip.width) - 17) + - ', ' + - (-282 + y * (34 / blip.width) - 17) + - ')', + blip.width / 34 + + ') translate(' + + (-404 + x * (34 / blip.width) - 17) + + ', ' + + (-282 + y * (34 / blip.width) - 17) + + ')', ) .attr('class', order) } @@ -194,12 +194,12 @@ const Radar = function (size, radar) { .attr( 'transform', 'scale(' + - blip.width / 34 + - ') translate(' + - (-404 + x * (34 / blip.width) - 17) + - ', ' + - (-282 + y * (34 / blip.width) - 17) + - ')', + blip.width / 34 + + ') translate(' + + (-404 + x * (34 / blip.width) - 17) + + ', ' + + (-282 + y * (34 / blip.width) - 17) + + ')', ) .attr('class', order) } @@ -653,9 +653,9 @@ const Radar = function (size, radar) { .append('p') .html( 'Powered by Thoughtworks. ' + - 'By using this service you agree to Thoughtworks\' terms of use. ' + - 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + - 'This software is open source and available for download and self-hosting.', + 'By using this service you agree to Thoughtworks\' terms of use. ' + + 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + + 'This software is open source and available for download and self-hosting.', ) } diff --git a/src/util/factory.js b/src/util/factory.js index ead65cfe1..f7eb901fe 100644 --- a/src/util/factory.js +++ b/src/util/factory.js @@ -82,8 +82,8 @@ const plotRadar = function (title, blips, currentRadarName, alternativeRadars) { const size = featureToggles.UIRefresh2022 ? getGraphSize() : window.innerHeight - 133 < 620 - ? 620 - : window.innerHeight - 133 + ? 620 + : window.innerHeight - 133 new GraphingRadar(size, radar).init().plot() } @@ -405,9 +405,9 @@ function plotFooter(content) { .append('p') .html( 'Powered by Thoughtworks. ' + - 'By using this service you agree to Thoughtworks\' terms of use. ' + - 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + - 'This software is open source and available for download and self-hosting.', + 'By using this service you agree to Thoughtworks\' terms of use. ' + + 'You also agree to our privacy policy, which describes how we will gather, use and protect any personal data contained in your public Google Sheet. ' + + 'This software is open source and available for download and self-hosting.', ) } From 74095a178b6edb4094aeba0a2dd0987945161ef5 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Fri, 28 Jul 2023 09:05:53 +1000 Subject: [PATCH 13/16] feat: update google sheets to support additional column --- src/util/sheet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/sheet.js b/src/util/sheet.js index 341f5bfdb..e84212f54 100644 --- a/src/util/sheet.js +++ b/src/util/sheet.js @@ -66,7 +66,7 @@ const Sheet = function (sheetReference) { const sheetNames = self.sheetResponse.result.sheets.map((s) => s.properties.title) sheetName = !sheetName ? sheetNames[0] : sheetName self - .getData(sheetName + '!A1:E') + .getData(sheetName + '!A1:F') .then((r) => createBlips(self.sheetResponse.result.properties.title, r.result.values, sheetNames)) .catch(handleError) } From dbaed8ae8a5774bdf6d548fa625dba4ac1b3d06f Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 10 Apr 2024 18:47:39 -0400 Subject: [PATCH 14/16] feat: update assistive text to use status as-is --- spec/graphing/blips-spec.js | 44 ++++++++++++++----------------------- src/graphing/blips.js | 14 +----------- src/models/blip.js | 2 +- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/spec/graphing/blips-spec.js b/spec/graphing/blips-spec.js index 97c4fef05..8666c6594 100644 --- a/spec/graphing/blips-spec.js +++ b/spec/graphing/blips-spec.js @@ -199,18 +199,15 @@ describe('Blips', function () { isGroup: () => false, ring: () => { return { - name: () => 'ring1', + name: () => 'Trial', } }, - blipText: () => '12 New Blips', - name: () => 'blip1', - isNew: () => true, - hasMovedIn: () => false, - hasMovedOut: () => false, + name: () => 'Some cool tech', + status: () => 'New', } const actual = blipAssistiveText(blip) - expect(actual).toEqual('ring1 ring, blip1, new blip.') + expect(actual).toEqual('Trial ring, Some cool tech, New.') }) it('should return correct assistive text for existing blip', function () { @@ -218,18 +215,15 @@ describe('Blips', function () { isGroup: () => false, ring: () => { return { - name: () => 'ring1', + name: () => 'Trial', } }, - blipText: () => '12 New Blips', - name: () => 'blip1', - isNew: () => false, - hasMovedIn: () => false, - hasMovedOut: () => false, + name: () => 'Some cool tech', + status: () => 'No change', } const actual = blipAssistiveText(blip) - expect(actual).toEqual('ring1 ring, blip1, existing blip.') + expect(actual).toEqual('Trial ring, Some cool tech, No change.') }) it('should return correct assistive text for moved in blip', function () { @@ -237,18 +231,15 @@ describe('Blips', function () { isGroup: () => false, ring: () => { return { - name: () => 'ring1', + name: () => 'Trial', } }, - blipText: () => '12 New Blips', - name: () => 'blip1', - isNew: () => false, - hasMovedIn: () => true, - hasMovedOut: () => false, + name: () => 'Some cool tech', + status: () => 'Moved in', } const actual = blipAssistiveText(blip) - expect(actual).toEqual('ring1 ring, blip1, moved in blip.') + expect(actual).toEqual('Trial ring, Some cool tech, Moved in.') }) it('should return correct assistive text for moved out blip', function () { @@ -256,18 +247,15 @@ describe('Blips', function () { isGroup: () => false, ring: () => { return { - name: () => 'ring1', + name: () => 'Trial', } }, - blipText: () => '12 New Blips', - name: () => 'blip1', - isNew: () => false, - hasMovedIn: () => false, - hasMovedOut: () => true, + name: () => 'Some cool tech', + status: () => 'Moved out', } const actual = blipAssistiveText(blip) - expect(actual).toEqual('ring1 ring, blip1, moved out blip.') + expect(actual).toEqual('Trial ring, Some cool tech, Moved out.') }) it('should return group blip with appropriate values', function () { diff --git a/src/graphing/blips.js b/src/graphing/blips.js index 3a302c67f..ac25a5fa3 100644 --- a/src/graphing/blips.js +++ b/src/graphing/blips.js @@ -104,21 +104,9 @@ function findBlipCoordinates(blip, minRadius, maxRadius, startAngle, allBlipCoor } function blipAssistiveText(blip) { - let blipType - - if (blip.isNew()) { - blipType = 'new' - } else if (blip.hasMovedIn()) { - blipType = 'moved in' - } else if (blip.hasMovedOut()) { - blipType = 'moved out' - } else { - blipType = 'existing' - } - return blip.isGroup() ? `\`${blip.ring().name()} ring, group of ${blip.blipText()}` - : `${blip.ring().name()} ring, ${blip.name()}, ${blipType} blip.` + : `${blip.ring().name()} ring, ${blip.name()}, ${blip.status()}.` } function addOuterCircle(parentSvg, order, scale = 1) { parentSvg diff --git a/src/models/blip.js b/src/models/blip.js index ae5ef3930..340cb9cec 100644 --- a/src/models/blip.js +++ b/src/models/blip.js @@ -49,7 +49,7 @@ const Blip = function (name, ring, isNew, status, topic, description) { } self.status = function () { - return status.toLowerCase() || '' + return status.toLowerCase() || 'New' } self.isGroup = function () { From 21310bd26096a9dc52f64bc0075bda0b50b13061 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 10 Apr 2024 18:58:04 -0400 Subject: [PATCH 15/16] feat: simplify hasMovements --- src/graphing/radar.js | 10 +++------- src/models/blip.js | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/graphing/radar.js b/src/graphing/radar.js index 17415a8c2..76954834f 100644 --- a/src/graphing/radar.js +++ b/src/graphing/radar.js @@ -828,28 +828,24 @@ const Radar = function (size, radar) { }) if (featureToggles.UIRefresh2022) { - let hasMovements = hasMovementData(quadrants) - renderRadarLegends(radarElement, hasMovements) + renderRadarLegends(radarElement, hasMovementData(quadrants)) hideTooltipOnScroll(tip) addRadarLinkInPdfView() } } function hasMovementData(quadrants) { - let hasMovements = false - for (var quadrantWrapper of quadrants) { let quadrant = quadrantWrapper.quadrant for (var blip of quadrant.blips()) { if (blip.status() !== '') { - hasMovements = true - break + return true } } } - return hasMovements + return false } return self diff --git a/src/models/blip.js b/src/models/blip.js index 340cb9cec..ae5ef3930 100644 --- a/src/models/blip.js +++ b/src/models/blip.js @@ -49,7 +49,7 @@ const Blip = function (name, ring, isNew, status, topic, description) { } self.status = function () { - return status.toLowerCase() || 'New' + return status.toLowerCase() || '' } self.isGroup = function () { From 1f117ab595b19ab1cecc1000d1b2381483293570 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 10 Apr 2024 19:01:26 -0400 Subject: [PATCH 16/16] feat: add topic and descriptions to tests --- spec/models/blip-spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/models/blip-spec.js b/spec/models/blip-spec.js index 185ef0ce8..d8e4654d1 100644 --- a/spec/models/blip-spec.js +++ b/spec/models/blip-spec.js @@ -56,37 +56,37 @@ describe('Blip', function () { }) it('is new', function () { - blip = new Blip('My Blip', new Ring('My Ring'), true) + blip = new Blip('My Blip', new Ring('My Ring'), true, null, 'My Topic', 'My Description') expect(blip.isNew()).toBe(true) }) it('is not new', function () { - blip = new Blip('My Blip', new Ring('My Ring'), false) + blip = new Blip('My Blip', new Ring('My Ring'), false, null, 'My Topic', 'My Description') expect(blip.isNew()).toBe(false) }) it('status is new', function () { - blip = new Blip('My Blip', new Ring('My Ring'), null, 'new') + blip = new Blip('My Blip', new Ring('My Ring'), null, 'new', 'My Topic', 'My Description') expect(blip.isNew()).toBe(true) }) it('status has moved in', function () { - blip = new Blip('My Blip', new Ring('My Ring'), null, 'Moved In') + blip = new Blip('My Blip', new Ring('My Ring'), null, 'Moved In', 'My Topic', 'My Description') expect(blip.hasMovedIn()).toBe(true) }) it('status has moved out', function () { - blip = new Blip('My Blip', new Ring('My Ring'), null, 'Moved Out') + blip = new Blip('My Blip', new Ring('My Ring'), null, 'Moved Out', 'My Topic', 'My Description') expect(blip.hasMovedOut()).toBe(true) }) it('status has no change', function () { - blip = new Blip('My Blip', new Ring('My Ring'), null, 'No Change') + blip = new Blip('My Blip', new Ring('My Ring'), null, 'No Change', 'My Topic', 'My Description') expect(blip.hasNoChange()).toBe(true) })