aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-08-03 17:30:58 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-08-03 17:30:58 -0400
commitb7c70cf115ea3d23e06fc7a3837e983b62993334 (patch)
treea666f9d1f29b779906a3883a0542850443f8743f /src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
parent098e3780c9d16738070a92dbfcdf68372a9d18a9 (diff)
a few updates and an option to switch between default backgrounds and cluster backgrounds.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 24439ef4c..b4d065d26 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -267,12 +267,17 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
getClusterColor = (doc: Doc) => {
if (this.props.Document.useClusters) {
let cluster = NumCast(doc.cluster);
- let set = this.sets.length > cluster ? this.sets[NumCast(doc.cluster)] : undefined;
+ if (this.sets.length <= cluster) {
+ setTimeout(() => this.updateClusters(), 0);
+ return;
+ }
+ let set = this.sets.length > cluster ? this.sets[cluster] : undefined;
let colors = ["#da42429e", "#31ea318c", "#8c4000", "#4a7ae2c4", "#d809ff", "#ff7601", "#1dffff", "yellow", "#1b8231f2", "#000000ad"];
let clusterColor = colors[cluster % colors.length];
- for (let i = 0; set && i < set.length; i++) {
- if (set[i].backgroundColor && set[i].backgroundColor !== set[i].defaultBackgroundColor) clusterColor = StrCast(set[i].backgroundColor);
- }
+ set && set.filter(s => !s.isBackground).map(s =>
+ s.backgroundColor && s.backgroundColor !== s.defaultBackgroundColor && (clusterColor = StrCast(s.backgroundColor)));
+ set && set.filter(s => s.isBackground).map(s =>
+ s.backgroundColor && s.backgroundColor !== s.defaultBackgroundColor && (clusterColor = StrCast(s.backgroundColor)));
return clusterColor;
}
return "";
@@ -652,13 +657,18 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
layoutItems.push({
description: `${this.props.Document.useClusters ? "Uncluster" : "Use Clusters"}`,
event: async () => {
- Docs.Prototypes.get(DocumentType.TEXT).defaultBackgroundColor = "#f1efeb";
+ Docs.Prototypes.get(DocumentType.TEXT).defaultBackgroundColor = "#f1efeb"; // backward compatibility with databases that didn't have a default background color on prototypes
Docs.Prototypes.get(DocumentType.COL).defaultBackgroundColor = "white";
this.props.Document.useClusters = !this.props.Document.useClusters;
},
icon: !this.props.Document.useClusters ? "expand-arrows-alt" : "compress-arrows-alt"
});
layoutItems.push({
+ description: `${this.props.Document.clusterOverridesDefaultBackground ? "Use Default Backgrounds" : "Clusters Override Defaults"}`,
+ event: async () => this.props.Document.clusterOverridesDefaultBackground = !this.props.Document.clusterOverridesDefaultBackground,
+ icon: !this.props.Document.useClusters ? "expand-arrows-alt" : "compress-arrows-alt"
+ });
+ layoutItems.push({
description: "Arrange contents in grid",
icon: "table",
event: async () => {