Skip to content

Commit 89b9b8f

Browse files
committed
feat: compy local data to new item on compare
1 parent b97d25b commit 89b9b8f

File tree

13 files changed

+88
-3
lines changed

13 files changed

+88
-3
lines changed

lib/Models/Catalog/CatalogItems/CsvCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export default class CsvCatalogItem
3737

3838
private _csvFile?: File;
3939

40+
get fileInput(): File | undefined {
41+
return this._csvFile;
42+
}
43+
4044
constructor(
4145
id: string | undefined,
4246
terria: Terria,

lib/Models/Catalog/CatalogItems/CzmlCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export default class CzmlCatalogItem
9292
@observable _dataSource: CzmlDataSource | undefined;
9393
private _czmlFile?: File;
9494

95+
get fileInput(): File | undefined {
96+
return this._czmlFile;
97+
}
98+
9599
setFileInput(file: File) {
96100
this._czmlFile = file;
97101
}

lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Model, { ModelConstructorParameters } from "../../Definition/Model";
2525
import HasLocalData from "../../HasLocalData";
2626
import Terria from "../../Terria";
2727
import proxyCatalogItemUrl from "../proxyCatalogItemUrl";
28+
import CommonStrata from "../../Definition/CommonStrata";
2829

2930
class GeoJsonCatalogItem
3031
extends CesiumIonMixin(GeoJsonMixin(CreateModel(GeoJsonCatalogItemTraits)))
@@ -47,6 +48,10 @@ class GeoJsonCatalogItem
4748

4849
protected _file?: File;
4950

51+
get fileInput(): File | undefined {
52+
return this._file;
53+
}
54+
5055
setFileInput(file: File) {
5156
this._file = file;
5257
}

lib/Models/Catalog/CatalogItems/GeoRssCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ export default class GeoRssCatalogItem
144144

145145
private _georssFile?: File;
146146

147+
get fileInput(): File | undefined {
148+
return this._georssFile;
149+
}
150+
147151
setFileInput(file: File) {
148152
this._georssFile = file;
149153
}

lib/Models/Catalog/CatalogItems/GpxCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class GpxCatalogItem extends GeoJsonMixin(CreateModel(GpxCatalogItemTraits)) {
3131

3232
private _gpxFile?: File;
3333

34+
get fileInput(): File | undefined {
35+
return this._gpxFile;
36+
}
37+
3438
setFileInput(file: File) {
3539
this._gpxFile = file;
3640
}

lib/Models/Catalog/CatalogItems/KmlCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class KmlCatalogItem
4040

4141
private _kmlFile?: File;
4242

43+
get fileInput(): File | undefined {
44+
return this._kmlFile;
45+
}
46+
4347
setFileInput(file: File) {
4448
this._kmlFile = file;
4549
}

lib/Models/Catalog/CatalogItems/ShapefileCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class ShapefileCatalogItem
4646

4747
protected _file?: File;
4848

49+
get fileInput(): File | undefined {
50+
return this._file;
51+
}
52+
4953
setFileInput(file: File) {
5054
this._file = file;
5155
}

lib/Models/Catalog/CatalogReferences/SplitItemReference.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ReferenceMixin from "../../../ModelMixins/ReferenceMixin";
55
import SplitItemReferenceTraits from "../../../Traits/TraitsClasses/SplitItemReferenceTraits";
66
import CreateModel from "../../Definition/CreateModel";
77
import { BaseModel } from "../../Definition/Model";
8+
import HasLocalData from "../../HasLocalData";
89

910
/**
1011
* This item is a reference to a copy of the original item from which it was created.
@@ -53,7 +54,17 @@ export default class SplitItemReference extends ReferenceMixin(
5354
try {
5455
// Ensure the target we create is a concrete item
5556
sourceItem = getDereferencedIfExists(sourceItem);
56-
return sourceItem.duplicateModel(this.uniqueId, this);
57+
const clone = sourceItem.duplicateModel(this.uniqueId, this);
58+
59+
if (HasLocalData.is(sourceItem) && HasLocalData.is(clone)) {
60+
const file = sourceItem.fileInput;
61+
if (file) {
62+
// clone.hasLocalData = true;
63+
// clone.setFileInput(file);
64+
}
65+
}
66+
67+
return clone;
5768
} catch (e) {
5869
throw TerriaError.from(e, {
5970
title: { key: "splitterTool.errorTitle" },

lib/Models/Catalog/Gltf/AssImpCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export default class AssImpCatalogItem
5252

5353
@observable hasLocalData = false;
5454

55+
get fileInput(): File | undefined {
56+
return undefined;
57+
}
58+
5559
@action
5660
setFileInput(file: File | Blob) {
5761
const dataUrl = URL.createObjectURL(file);

lib/Models/Catalog/Gltf/GltfCatalogItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export default class GltfCatalogItem
4040

4141
@observable hasLocalData = false;
4242

43+
get fileInput(): File | undefined {
44+
return undefined;
45+
}
46+
4347
@action
4448
setFileInput(file: File | Blob) {
4549
const dataUrl = URL.createObjectURL(file);

0 commit comments

Comments
 (0)