Skip to content

Commit

Permalink
Merge pull request #2431 from concord-consortium/188534586-fix-copy-s…
Browse files Browse the repository at this point in the history
…parrows

Fix copying of straight sparrows with tile copy
  • Loading branch information
bgoldowsky authored Nov 13, 2024
2 parents 59bf034 + 6f6014b commit adcd063
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
28 changes: 25 additions & 3 deletions cypress/e2e/functional/document_tests/tiles_copy_test_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DataflowToolTile from '../../../support/elements/tile/DataflowToolTile';
import SimulatorTile from '../../../support/elements/tile/SimulatorTile';
import DiagramToolTile from '../../../support/elements/tile/DiagramToolTile';
import XYPlotToolTile from "../../../support/elements/tile/XYPlotToolTile";
import ArrowAnnotation from "../../../support/elements/tile/ArrowAnnotation";

const student5 = `${Cypress.config("qaUnitStudent5")}`;
const student6 = `${Cypress.config("qaUnitStudent6")}`;
Expand All @@ -24,8 +25,9 @@ let clueCanvas = new ClueCanvas,
dataflowToolTile = new DataflowToolTile,
simulatorTile = new SimulatorTile,
diagramTile = new DiagramToolTile,
graphTile = new XYPlotToolTile;
let canvas = new Canvas;
graphTile = new XYPlotToolTile,
aa = new ArrowAnnotation,
canvas = new Canvas;

const imageName = "Image Tile";
const simName = "Test Simulation";
Expand Down Expand Up @@ -72,6 +74,8 @@ function testPrimaryWorkspace1() {
cy.get('.primary-workspace .numberline-tool-container .point-inner-circle').not(".mouse-follow-point").should('have.length', 2);
// Make sure the image tile were copied correctly
cy.get('.primary-workspace .image-tool .editable-tile-title-text').should("contain", imageName);
// Make sure the annotations were copied correctly
aa.getAnnotationArrows().should("have.length", 2);

canvas.deleteDocument();
}
Expand Down Expand Up @@ -137,7 +141,25 @@ context('Test copy tiles from one document to other document', function () {
tableToolTile.getTableCell().eq(2).should('contain', '2.5');
});

cy.log('Add graph tile');
cy.log('Add Sparrows to table tile');
aa.getAnnotationModeButton().click(); // sparrow mode on
aa.getAnnotationLayer().should("have.class", "editing");
aa.getAnnotationButtons().should("have.length", 2);
// Curved sparrow between the two cells
aa.getAnnotationArrows().should("not.exist");
aa.getAnnotationButtons().eq(0).click();
aa.getAnnotationButtons().eq(1).click();
aa.getAnnotationArrows().should("have.length", 1);
// Straight sparrow from one of the cells
aa.getAnnotationMenuExpander().click();
aa.getStraightArrowToolbarButton().click();
aa.getAnnotationModeButton().should("have.attr", "title", "Sparrow: straight");
aa.getAnnotationButtons().eq(1).click({force: true});
aa.getAnnotationSvg().click(300, 100);
aa.getAnnotationArrows().should("have.length", 2);
aa.getAnnotationModeButton().click(); // sparrow mode off

cy.log('Add geometry tile');
clueCanvas.addTile('geometry');
cy.get('.spacer').click();
geometryToolTile.getGeometryTile().last().click();
Expand Down
8 changes: 5 additions & 3 deletions src/models/document/document-content-with-annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ export const DocumentContentModelWithAnnotations = BaseDocumentContentModel
// TODO Make generic to handle any type of annotation, not just arrow annotations
const annotations: Record<string, IArrowAnnotation> = {};
Array.from(self.annotations.values()).forEach(annotation => {
const includesSource = tileIds.includes(annotation.sourceObject?.tileId ?? "");
const includesTarget = tileIds.includes(annotation.targetObject?.tileId ?? "");
const include = anyReference ? includesSource || includesTarget : includesSource && includesTarget;
const tiles_connected
= [annotation.sourceObject?.tileId, annotation.targetObject?.tileId].filter(x => x);
const include = anyReference
? tiles_connected.find(id => id && tileIds.includes(id))
: tiles_connected.every(id => id && tileIds.includes(id));
if (include) {
annotations[annotation.id] = annotation;
}
Expand Down

0 comments on commit adcd063

Please sign in to comment.