Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare #5529

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open

Compare #5529

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
cfef002
Add compare workflow.
na9da May 25, 2021
310040b
Merge branch 'next' into compare
na9da May 31, 2021
0ef32ae
Fix import of createGuid.
na9da May 31, 2021
94aad69
Hide map dataset count & bottom dock on mount.
na9da Jun 1, 2021
65abd73
Add left & right date pickers.
na9da Jun 1, 2021
1c20ee5
DateTimePicker customizations required for the compare workflow.
na9da Jun 3, 2021
44a7c2f
Add location date filter.
na9da Jun 3, 2021
b849064
Extract doesImageryBelongToCatalogItem.
na9da Jun 3, 2021
a5e665b
Stop rendering stray "0" in DOM.
na9da Jun 3, 2021
bc31990
Remove unused imports.
na9da Jun 3, 2021
b3b6632
Fix map button styles.
na9da Jun 4, 2021
f8ea537
Cancel mouse pick when interacting with other elements.
na9da Jun 4, 2021
04d2094
Add location picking status updates.
na9da Jun 7, 2021
0b0d1e0
Activate/deactivate timeline stack when mounting/unmounting the timeline
na9da Jun 7, 2021
902d08d
Show legends for left/right items.
na9da Jun 7, 2021
4a43fb9
Change compare icons in workflow panel.
na9da Jun 8, 2021
1665b80
Style the datepicker more closely to the design.
na9da Jun 8, 2021
e50319c
Make workflow panel scrollable.
na9da Jun 8, 2021
d71d766
Use workflowPanelWidth instead of workbenchWidth.
na9da Jun 8, 2021
1c4a3d5
Add the clone item after the parent item.
na9da Jun 8, 2021
e4988f2
Fix bug that shows the drag-n-drop notification when it is not in use.
na9da Jun 8, 2021
b2f7aa7
Remove old splitter controls from the workbench.
na9da Jun 8, 2021
3bf6f83
Show compare mode when splitter is turned on.
na9da Jun 8, 2021
97d52cf
Import style helper.
na9da Jun 8, 2021
cf8f196
Remove stray attribute.
na9da Jun 8, 2021
a0f9a33
Add method docs.
na9da Jun 9, 2021
a9449e5
Merge branch 'next' into compare
na9da Jun 9, 2021
f98bfa2
Merge branch 'upgrade-html-to-react' into compare
na9da Jun 10, 2021
cbf8317
Pass option to ignore splitter when picking features via the
na9da Jun 10, 2021
4f925bc
Merge branch 'next' into compare
na9da Jun 10, 2021
3068580
Add feature flag `useExperimentalCompareWorkflow` to gate the new
na9da Jun 10, 2021
74e80f9
Exit pick mode when mousedown on elements other than the map.
na9da Jun 10, 2021
0beb983
Remove stale component.
na9da Jun 10, 2021
b6ad9a8
Fix test for map element.
na9da Jun 10, 2021
d4d6252
Enable experimental compare workflow via URL hash parameter.
na9da Jun 10, 2021
c8f9ef6
Check for props change when scrolling to selected date.
na9da Jun 16, 2021
8159eff
Replace find with some.
na9da Jun 16, 2021
20358b2
Merge branch 'next' into compare
na9da Jun 18, 2021
0b2c52c
Update CHANGES.md.
na9da Jun 18, 2021
5e46676
Merge branch 'main' into compare
na9da Oct 15, 2021
c8aeb23
Show workbench controls for compare items.
na9da Oct 15, 2021
b5d56c4
Disable items in both panels only when the user directly triggers the…
na9da Oct 18, 2021
3dcb14e
Re-implemented context items.
na9da Nov 3, 2021
3818db1
Merge branch 'main' into compare
na9da Nov 3, 2021
155418c
More compare workflow changes.
na9da Nov 4, 2021
355eeb8
Restore leftSmall and rightSmall icons.
na9da Nov 4, 2021
9149ed4
Fix broken specs.
na9da Nov 4, 2021
17fe50a
Added menu option to send all context items to front or back.
na9da Nov 7, 2021
ba1a06b
Highlight panel menu selection.
na9da Nov 7, 2021
820635f
Fix workflow/side panel animations.
na9da Nov 8, 2021
c95cdbe
Unset left/right panel item IDs if we cannot resolve them to an item.
na9da Nov 8, 2021
3d1e55a
Fix compare and explorer modal interaction.
na9da Nov 9, 2021
5786630
Improve styling.
na9da Nov 9, 2021
56f7f1f
Wrap item list checkbox text.
na9da Nov 10, 2021
91dab24
Add placeholder text for entire map panel.
na9da Nov 10, 2021
8a39561
Fixing a few bugs.
na9da Nov 11, 2021
15e0136
Merge branch 'main' into compare
na9da Nov 11, 2021
652e216
Fix timeline rendering.
na9da Nov 11, 2021
85405aa
Added comment for temp fix to timeline readjustment.
na9da Nov 11, 2021
434b3bd
Merge branch 'fix-super-get' into compare
na9da Nov 12, 2021
13c8261
Merge branch 'main' into compare
na9da Nov 12, 2021
5dbbe31
Fix lint errors.
na9da Nov 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into compare
  • Loading branch information
na9da committed Oct 15, 2021
commit 5e466764a9faea052c737b2892647c495322b15b
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ Change Log
* Activates/deactivates terria timeline stack when the Timeline.jsx component mounts or unmounts.
* Adds an `index` parameter to Workbench.add() method specifying the index where the item should be added
* [The next improvement]
* Wraps tool title bar text using `...`.

#### 8.0.0-alpha.84

Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Cesium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import TerriaViewer from "../ViewModels/TerriaViewer";
import CameraView from "./CameraView";
import Feature from "./Feature";
import GlobeOrMap from "./GlobeOrMap";
import hasTraits from "./hasTraits";
import hasTraits from "./Definition/hasTraits";
import MapInteractionMode from "./MapInteractionMode";
import Terria from "./Terria";
import UserDrawing from "./UserDrawing";
Expand Down
15 changes: 7 additions & 8 deletions lib/Models/Comparable.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import CatalogMemberMixin from "../ModelMixins/CatalogMemberMixin";
import MappableMixin from "../ModelMixins/MappableMixin";
import CatalogMemberTraits from "../Traits/CatalogMemberTraits";
import MappableTraits from "../Traits/MappableTraits";
import SplitterTraits from "../Traits/SplitterTraits";
import hasTraits from "./hasTraits";
import Model from "./Model";
import CatalogMemberTraits from "../Traits/TraitsClasses/CatalogMemberTraits";
import MappableTraits from "../Traits/TraitsClasses/MappableTraits";
import SplitterTraits from "../Traits/TraitsClasses/SplitterTraits";
import hasTraits from "./Definition/hasTraits";
import Model from "./Definition/Model";

export type Comparable = Model<
SplitterTraits & CatalogMemberTraits & MappableTraits
> &
MappableMixin.MappableMixin &
CatalogMemberMixin.CatalogMemberMixin;
MappableMixin.Instance &
CatalogMemberMixin.Instance;

/**
* Returns true if the item is Comparable.
Expand All @@ -20,7 +20,6 @@ export function isComparableItem(item: any): item is Comparable {
item &&
MappableMixin.isMixedInto(item) &&
CatalogMemberMixin.isMixedInto(item) &&
(item as any).supportsSplitting &&
hasTraits(item, MappableTraits, "show") &&
hasTraits(item, CatalogMemberTraits, "name") &&
hasTraits(item, SplitterTraits, "splitDirection");
Expand Down
36 changes: 16 additions & 20 deletions lib/Models/Terria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ interface ConfigParameters {
*/
feedbackMinLength?: number;

useExperimentalCompareWorkflow?: boolean;
/**
* Extra links to show in the credit line at the bottom of the map (currently only the Cesium map).
*/
extraCreditLinks?: { url: string; text: string }[];
}

interface StartOptions {
Expand Down Expand Up @@ -441,9 +444,16 @@ export default class Terria {
customRequestSchedulerLimits: undefined,
persistViewerMode: true,
openAddData: false,
feedbackPreamble: "feedback.feedbackPreamble",
feedbackPreamble: "translate#feedback.feedbackPreamble",
feedbackMinLength: 0,
useExperimentalCompareWorkflow: false
extraCreditLinks: [
// Default credit links (shown at the bottom of the Cesium map)
{
text: "map.extraCreditLinks.dataAttribution",
url: "about.html#data-attribution"
},
{ text: "map.extraCreditLinks.disclaimer", url: "about.html#disclaimer" }
]
};

@observable
Expand Down Expand Up @@ -532,6 +542,8 @@ export default class Terria {
*/
@observable compareRightItemId?: string;

augmentedVirtuality?: any;

readonly notificationState: NotificationState = new NotificationState();

private readonly developmentEnv = process?.env?.NODE_ENV === "development";
Expand Down Expand Up @@ -1752,23 +1764,7 @@ async function interpretHash(
if (["clean", "hideWelcomeMessage", "start", "share"].includes(property))
return;
const propertyValue = hashProperties[property];
if (property === "clean") {
terria.initSources.splice(0, terria.initSources.length);
} else if (property === "hideWelcomeMessage") {
terria.configParameters.showWelcomeMessage = false;
} else if (property === "start") {
try {
// a share link that hasn't been shortened: JSON embedded in URL (only works for small quantities of JSON)
const startData = JSON.parse(propertyValue);
interpretStartData(terria, startData, "Start data from hash");
} catch (e) {
throw TerriaError.from(e, {
message: { key: "parsingStartDataErrorMessage" }
});
}
} else if (property === "useExperimentalCompareWorkflow") {
terria.configParameters.useExperimentalCompareWorkflow = true;
} else if (defined(propertyValue) && propertyValue.length > 0) {
if (defined(propertyValue) && propertyValue.length > 0) {
userProperties.set(property, propertyValue);
} else {
const initSourceFile = generateInitializationUrl(
Expand Down
38 changes: 15 additions & 23 deletions lib/Models/Workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,33 +168,25 @@ export default class Workbench {
*
* @param item The item to add to or remove from the workbench.
*/
public async add(
item: BaseModel | BaseModel[],
index: number = 0
): Promise<void> {
public async add(item: BaseModel | BaseModel[]): Promise<Result<unknown>> {
if (Array.isArray(item)) {
await Promise.all(item.reverse().map(i => this.add(i, index)));
return;
const results = await Promise.all(item.reverse().map(i => this.add(i)));
return Result.combine(results, {
title: i18next.t("workbench.addItemErrorTitle"),
message: i18next.t("workbench.addItemErrorMessage"),
importance: -1
});
}

try {
if (ReferenceMixin.is(item)) {
await item.loadReference();
this.insertItem(item);

let error: TerriaError | undefined;

const target = item.target;
if (
target &&
GroupMixin.isMixedInto(target) &&
!MappableMixin.isMixedInto(target) &&
!ChartableMixin.isMixedInto(target)
) {
this.remove(item);
} else if (target) {
return this.add(target, index);
}
} else {
// Item is not a reference, so add the item
this.insertItem(item, index);
if (ReferenceMixin.isMixedInto(item)) {
error = (await item.loadReference()).error;
if (item.target) {
this.remove(item);
return this.add(item.target);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Models/doesImageryFeatureBelongToCatalogItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MappableMixin, { ImageryParts } from "../ModelMixins/MappableMixin";
import { BaseModel } from "./Definition/Model";
import Feature from "./Feature";
import { BaseModel } from "./Model";

/**
* Returns true if the given feature belongs to the catalog item
Expand Down
32 changes: 12 additions & 20 deletions lib/ReactViews/Compare/Compare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ import styled from "styled-components";
import createGuid from "terriajs-cesium/Source/Core/createGuid";
import ImagerySplitDirection from "terriajs-cesium/Source/Scene/ImagerySplitDirection";
import filterOutUndefined from "../../Core/filterOutUndefined";
import CommonStrata from "../../Models/CommonStrata";
import SplitItemReference from "../../Models/Catalog/CatalogReferences/SplitItemReference";
import { Comparable, isComparableItem } from "../../Models/Comparable";
import hasTraits from "../../Models/hasTraits";
import { BaseModel } from "../../Models/Model";
import SplitItemReference from "../../Models/SplitItemReference";
import CommonStrata from "../../Models/Definition/CommonStrata";
import hasTraits from "../../Models/Definition/hasTraits";
import { BaseModel } from "../../Models/Definition/Model";
import Terria from "../../Models/Terria";
import Workbench from "../../Models/Workbench";
import ViewState from "../../ReactViewModels/ViewState";
import { GLYPHS } from "../../Styled/Icon";
import Text from "../../Styled/Text";
import WorkflowPanel, { Box } from "../../Styled/WorkflowPanel";
import CatalogMemberTraits from "../../Traits/CatalogMemberTraits";
import MappableTraits from "../../Traits/MappableTraits";
import SplitterTraits from "../../Traits/SplitterTraits";
import Legend from "../Workbench/Controls/Legend";
import CatalogMemberTraits from "../../Traits/TraitsClasses/CatalogMemberTraits";
import MappableTraits from "../../Traits/TraitsClasses/MappableTraits";
import SplitterTraits from "../../Traits/TraitsClasses/SplitterTraits";
import CompareItemControls from "./CompareItemControls";
import DatePicker from "./DatePicker";
import DimensionSelectors from "./DimensionSelectors";
import ItemList, { MappableCatalogItem } from "./ItemList";
import ItemSelector from "./ItemSelector";
import LocationDateFilter from "./LocationDateFilter";
Expand Down Expand Up @@ -182,8 +181,7 @@ const Compare: React.FC<PropsType> = observer(props => {
}
onChange={changeLeftItem}
/>
{leftItem && <DimensionSelectors item={leftItem} />}
{leftItem && <Legend item={leftItem} />}
{leftItem && <CompareItemControls item={leftItem} />}
</Box>
<Box icon={GLYPHS.rightSmall} title={t("compare.rightPanel")}>
<ItemSelector
Expand All @@ -195,15 +193,9 @@ const Compare: React.FC<PropsType> = observer(props => {
}
onChange={changeRightItem}
/>
{rightItem && <DimensionSelectors item={rightItem} />}
{rightItem && <Legend item={rightItem} />}
{rightItem && <CompareItemControls item={rightItem} />}
</Box>
<Box
icon={GLYPHS.bothPanels}
title={t("compare.bothPanels")}
collapsible
isCollapsed
>
<Box icon={GLYPHS.bothPanels} title={t("compare.bothPanels")}>
<ItemList
items={itemsInBothPanels}
onChange={changeItemInBothPanels}
Expand Down Expand Up @@ -291,7 +283,7 @@ async function cloneItem(item: Comparable): Promise<string | undefined> {
try {
terria.addModel(ref);
// Insert below the parent item in the workbench
await terria.workbench.add(ref, terria.workbench.indexOf(item) + 1);
await terria.workbench.add(ref /*terria.workbench.indexOf(item) + 1*/);
} catch (e) {
return undefined;
}
Expand Down
25 changes: 25 additions & 0 deletions lib/ReactViews/Compare/CompareItemControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { Comparable } from "../../Models/Comparable";
import SelectableDimensions, {
DEFAULT_PLACEMENT
} from "../../Models/SelectableDimensions";
import DimensionSelectorSection from "../Workbench/Controls/DimensionSelectorSection";
import Legend from "../Workbench/Controls/Legend";
import OpacitySection from "../Workbench/Controls/OpacitySection";

const CompareItemControls: React.FC<{ item: Comparable }> = ({ item }) => {
return (
<>
<OpacitySection item={item} />
{SelectableDimensions.is(item) && (
<DimensionSelectorSection item={item} placement={DEFAULT_PLACEMENT} />
)}
<Legend item={item} />
{SelectableDimensions.is(item) && (
<DimensionSelectorSection item={item} placement={"belowLegend"} />
)}
</>
);
};

export default CompareItemControls;
6 changes: 2 additions & 4 deletions lib/ReactViews/Compare/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useTranslation } from "react-i18next";
import styled, { DefaultTheme, ThemeProvider } from "styled-components";
import JulianDate from "terriajs-cesium/Source/Core/JulianDate";
import DiscretelyTimeVaryingMixin from "../../ModelMixins/DiscretelyTimeVaryingMixin";
import CommonStrata from "../../Models/CommonStrata";
import { Comparable } from "../../Models/Comparable";
import CommonStrata from "../../Models/Definition/CommonStrata";
import Button from "../../Styled/Button";
import Icon, { StyledIcon } from "../../Styled/Icon";
import { formatDateTime } from "../BottomDock/Timeline/DateFormats";
Expand Down Expand Up @@ -40,9 +40,7 @@ const DatePicker: React.FC<PropsType> = observer(props => {
const [isPickerOpen, setIsPickerOpen] = useState(false);

// Check if the item has dates, otherwise render nothing
const item:
| DiscretelyTimeVaryingMixin.DiscretelyTimeVaryingMixin
| undefined =
const item: DiscretelyTimeVaryingMixin.Instance | undefined =
DiscretelyTimeVaryingMixin.isMixedInto(props.item) &&
(props.item.discreteTimes?.length ?? 0) > 0
? props.item
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Compare/DimensionSelectors.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { observer } from "mobx-react";
import React from "react";
import { useTranslation } from "react-i18next";
import CommonStrata from "../../Models/CommonStrata";
import { Comparable } from "../../Models/Comparable";
import CommonStrata from "../../Models/Definition/CommonStrata";
import SelectableDimensions, {
SelectableDimension
} from "../../Models/SelectableDimensions";
Expand Down
33 changes: 13 additions & 20 deletions lib/ReactViews/Compare/ItemList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { observer } from "mobx-react";
import React from "react";
import styled from "styled-components";
import Model from "../../Models/Model";
import Model from "../../Models/Definition/Model";
import Checkbox from "../../Styled/Checkbox/Checkbox";
import CatalogMemberTraits from "../../Traits/CatalogMemberTraits";
import MappableTraits from "../../Traits/MappableTraits";
import CatalogMemberTraits from "../../Traits/TraitsClasses/CatalogMemberTraits";
import MappableTraits from "../../Traits/TraitsClasses/MappableTraits";
import Text from "../../Styled/Text";

export type MappableCatalogItem = Model<MappableTraits & CatalogMemberTraits>;

Expand All @@ -20,10 +21,10 @@ const ItemList: React.FC<PropsType> = observer(({ items, onChange }) => {
item =>
item.uniqueId && (
<li key={item.uniqueId}>
<Selector
item={item}
selected={item.show}
onChange={show => onChange(item, show)}
<Checkbox
isChecked={item.show}
onChange={ev => onChange(item, ev.target.checked)}
label={<SelectorText medium>{item.name}</SelectorText>}
/>
</li>
)
Expand All @@ -38,19 +39,6 @@ type SelectorProps = {
onChange: (selected: boolean) => void;
};

const Selector: React.FC<SelectorProps> = observer(props => {
const { item, selected, onChange } = props;
return (
<Label>
<Checkbox
isChecked={selected}
onChange={ev => onChange(ev.target.checked)}
/>
<div>{item.name}</div>
</Label>
);
});

const UList = styled.ul`
list-style: none;
padding: 0px;
Expand All @@ -59,6 +47,7 @@ const UList = styled.ul`
> li {
display: flex;
align-items: center;
height: 32px;
}
`;

Expand All @@ -71,4 +60,8 @@ const Label = styled.label`
}
`;

const SelectorText = styled(Text)`
margin-left: 10px;
`;

export default ItemList;
2 changes: 1 addition & 1 deletion lib/ReactViews/Compare/LocationDateFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Comparable } from "../../Models/Comparable";
import doesImageryFeatureBelongToItem from "../../Models/doesImageryFeatureBelongToCatalogItem";
import Feature from "../../Models/Feature";
import ViewState from "../../ReactViewModels/ViewState";
import { TimeFilterCoordinates } from "../../Traits/TimeFilterTraits";
import { TimeFilterCoordinates } from "../../Traits/TraitsClasses/TimeFilterTraits";
import LocationPicker from "./LocationPicker";

type PropsType = {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.