Skip to content

Commit

Permalink
Merge pull request #2432 from concord-consortium/188559155-copy-multi…
Browse files Browse the repository at this point in the history
…-dataset-grids

Fix bug in copying multi-dataset Coordinate Grid tiles.
  • Loading branch information
bgoldowsky authored Nov 14, 2024
2 parents 2141a7d + 41ad218 commit a6d5c58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/components/tiles/geometry/geometry-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ export class GeometryContentComponent extends BaseComponent<IProps, IState> {
const content = this.getContent();
const data = content.getLinkedPointsData();
const remainingIds = getAllLinkedPoints(board);
for (const [link, points] of data.entries()) {
for (const points of data.values()) {
// Loop through points, adding new ones and updating any that need to be moved.
for (let i=0; i<points.coords.length; i++) {
const id = points.properties[i].id;
Expand All @@ -855,7 +855,8 @@ export class GeometryContentComponent extends BaseComponent<IProps, IState> {
name: labelProperties.name,
clientLabelOption: labelProperties.labelOption
};
const pt = createLinkedPoint(board, points.coords[i], allProps, { tileIds: [link] });
const tileIds = allProps.linkedTableId ? { tileIds: [allProps.linkedTableId] } : undefined;
const pt = createLinkedPoint(board, points.coords[i], allProps, tileIds);
this.handleCreatePoint(pt);
pointsChanged = true;
} else {
Expand Down
17 changes: 11 additions & 6 deletions src/models/tiles/geometry/geometry-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,22 @@ export const GeometryContentModel = GeometryBaseContentModel
},
/**
* Compile a map of data for all points that are part of linked datasets.
* The returned Map has the providing tile's ID as the key, and an object
* The returned Map has the sharedDataSet's ID as the key, and an object
* containing two parallel lists as its value:
*
* - coords: list of coordinate pairs
* - properties: list of point property objects (id and color)
* - properties: list of point property objects (id, color, linkedTableId)
*
* TODO: should we also look at the selections in the DataSet
*
* @returns the Map
*/
getLinkedPointsData() {
const data: Map<string,{coords:JXGCoordPair[],properties:{id:string, colorScheme:number}[]}> = new Map();
const data: Map<string,
{ coords:JXGCoordPair[], properties: { id:string, colorScheme:number, linkedTableId?:string }[] }> = new Map();
self.linkedDataSets.forEach(link => {
const coords: JXGCoordPair[] = [];
const properties: Array<{ id: string, colorScheme: number }> = [];
const properties: Array<{ id: string, colorScheme: number, linkedTableId?: string }> = [];
for (let ci = 0; ci < link.dataSet.cases.length; ++ci) {
const x = link.dataSet.attributes[0]?.numValue(ci);
for (let ai = 1; ai < link.dataSet.attributes.length; ++ai) {
Expand All @@ -234,11 +235,15 @@ export const GeometryContentModel = GeometryBaseContentModel
const y = attr.numValue(ci);
if (isFinite(x) && isFinite(y)) {
coords.push([x, y]);
properties.push({ id, colorScheme });
if (link.providerId) {
properties.push({ id, colorScheme, linkedTableId: link.providerId });
} else {
properties.push({ id, colorScheme });
}
}
}
}
data.set(link.providerId, { coords, properties });
data.set(link.id, { coords, properties });
});
return data;
}
Expand Down

0 comments on commit a6d5c58

Please sign in to comment.