aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx190
1 files changed, 125 insertions, 65 deletions
diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
index 7df445b88..ffc4dd0b1 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
@@ -419,6 +419,8 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps & Co
// const mainCollection = this._dataViz?.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView;
// mainCollection.addDocument(doc);
//this._dataViz?.getRandomSample();
+
+ console.log(this.maxMatches(3, Array.from([[2], [1], [2]])));
}
get templatesPreviewContents(){
@@ -810,6 +812,41 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps & Co
this.forceUpdate();
}
+ findMatches = () => {
+
+ }
+
+ maxMatches = (fieldsCt: number, matches: number[][]) => {
+ const used: boolean[] = Array(fieldsCt).fill(false);
+ const mt: number[] = Array(fieldsCt).fill(-1);
+
+ const augmentingPath = (v: number): boolean => {
+ if (used[v]) return false;
+ used[v] = true;
+ for (const to of matches[v]) {
+ if (mt[to] === -1 || augmentingPath(mt[to])) {
+ mt[to] = v;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ for (let v = 0; v < fieldsCt; ++v) {
+ console.log(v)
+ used.fill(false);
+ augmentingPath(v);
+ }
+
+ let numMatches: number = 0;
+
+ for (let i = 0; i < fieldsCt; ++i) {
+ if (mt[i] !== -1) ++numMatches;
+ }
+
+ return numMatches;
+ }
+
get dashboardContents(){
return (
<div className='docCreatorMenu-dashboard-view'>
@@ -985,26 +1022,31 @@ enum FieldSize {
HUGE = 'huge'
}
+type Field = {
+ tl: [number, number],
+ br: [number, number],
+ types: FieldType[],
+ sizes?: FieldSize[],
+ opts: FieldOpts;
+};
+
export interface TemplateDocInfos {
height: number;
width: number;
- fields: {tl: [number, number], br: [number, number], types: FieldType[], sizes?: FieldSize[]}[];
-}
-
-export interface TemplateDocField {
- coordinates: {tl: [number, number], br: [number, number]};
- getDoc: (parentWidth: number, parentHeight: number, title: string, content: string) => Doc;
+ fields: Field[];
}
export interface FieldOpts {
backgroundColor?: string;
- roundedCorners?: boolean;
- vertCenteredText?: boolean;
- horizCenteredText?: boolean;
- transparency?: number;
+ color?: string;
+ cornerRounding?: number;
+ borderWidth?: number;
+ borderColor?: string;
+ contentXCentering?: 'left' | 'center' | 'right';
+ contentYCentering?: 'top' | 'center' | 'bottom';
+ opacity?: number;
rotation?: number;
//animation?: boolean;
- fontColor?: string;
fontBold?: boolean;
fontTransform?: 'toUpper' | 'toLower';
}
@@ -1023,7 +1065,9 @@ export class FieldFuncs {
public static TextField = (coords: {tl: [number, number], br: [number, number]}, parentWidth: number, parentHeight: number, title: string, content: string, opts: FieldOpts) => {
const {width, height, coord} = FieldFuncs.getDimensions(coords, parentWidth, parentHeight);
- const doc = Docs.Create.TextDocument(content, {
+ const bool = true;
+
+ const docWithBasicOpts = (Docs.Create.TextDocument)(content, {
_height: height,
_width: width,
title: title,
@@ -1031,11 +1075,15 @@ export class FieldFuncs {
y: coord.y,
_text_fontSize: `${height/2}` ,
backgroundColor: opts.backgroundColor ?? '',
-
-
- })
+ color: opts.color,
+ _layout_borderRounding: `${opts.cornerRounding}`,
+ borderWidth: opts.borderWidth,
+ borderColor: opts.borderColor,
+ opacity: opts.opacity,
+ _layout_centered: opts.contentXCentering === 'center' ? true : false,
+ });
- return doc;
+ return docWithBasicOpts;
}
public static ImageField = (coords: {tl: [number, number], br: [number, number]}, parentWidth: number, parentHeight: number, title: string, content: string) => {
@@ -1071,70 +1119,82 @@ export class TemplateLayouts {
tl: [-.6, -.9],
br: [.6, -.8],
types: [FieldType.TEXT],
- sizes: [FieldSize.TINY]
+ sizes: [FieldSize.TINY],
+ opts: {
+
+ }
}, {
tl: [-.9, -.7],
br: [.9, .2],
types: [FieldType.TEXT, FieldType.VISUAL],
- sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE]
+ sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE],
+ opts: {
+
+ }
}, {
tl: [-.6, .3],
br: [.6, .4],
types: [FieldType.TEXT],
- sizes: [FieldSize.TINY]
+ sizes: [FieldSize.TINY],
+ opts: {
+
+ }
}, {
tl: [-.9, .5],
br: [.9, .9],
types: [FieldType.TEXT, FieldType.VISUAL],
- sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE]
- }]
- };
+ sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE],
+ opts: {
- public static FourField002: TemplateDocInfos = {
- width: 450,
- height: 600,
- fields: [{
- tl: [-.6, -.9],
- br: [.6, -.8],
- types: [FieldType.TEXT],
- sizes: [FieldSize.TINY]
- }, {
- tl: [-.9, -.7],
- br: [.9, .2],
- types: [FieldType.TEXT, FieldType.VISUAL],
- sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE]
- }, {
- tl: [-.9, .3],
- br: [-.05, .9],
- types: [FieldType.TEXT],
- sizes: [FieldSize.TINY]
- }, {
- tl: [.05, .3],
- br: [.9, .9],
- types: [FieldType.TEXT, FieldType.VISUAL],
- sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE]
+ }
}]
};
- public static TwoFieldPlusCarousel: TemplateDocInfos = {
- width: 500,
- height: 600,
- fields: [{
- tl: [-.9, -.99],
- br: [.9, -.7],
- types: [FieldType.TEXT],
- sizes: [FieldSize.TINY]
- }, {
- tl: [-.9, -.65],
- br: [.9, .35],
- types: [],
- sizes: []
- }, {
- tl: [-.9, .4],
- br: [.9, .95],
- types: [FieldType.TEXT],
- sizes: [FieldSize.TINY]
- }]
- };
+// public static FourField002: TemplateDocInfos = {
+// width: 450,
+// height: 600,
+// fields: [{
+// tl: [-.6, -.9],
+// br: [.6, -.8],
+// types: [FieldType.TEXT],
+// sizes: [FieldSize.TINY]
+// }, {
+// tl: [-.9, -.7],
+// br: [.9, .2],
+// types: [FieldType.TEXT, FieldType.VISUAL],
+// sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE]
+// }, {
+// tl: [-.9, .3],
+// br: [-.05, .9],
+// types: [FieldType.TEXT],
+// sizes: [FieldSize.TINY]
+// }, {
+// tl: [.05, .3],
+// br: [.9, .9],
+// types: [FieldType.TEXT, FieldType.VISUAL],
+// sizes: [FieldSize.MEDIUM, FieldSize.LARGE, FieldSize.HUGE]
+// }]
+// };
+
+// public static TwoFieldPlusCarousel: TemplateDocInfos = {
+// width: 500,
+// height: 600,
+// fields: [{
+// tl: [-.9, -.99],
+// br: [.9, -.7],
+// types: [FieldType.TEXT],
+// sizes: [FieldSize.TINY]
+// }, {
+// tl: [-.9, -.65],
+// br: [.9, .35],
+// types: [],
+// sizes: []
+// }, {
+// tl: [-.9, .4],
+// br: [.9, .95],
+// types: [FieldType.TEXT],
+// sizes: [FieldSize.TINY]
+// }]
+// };
} \ No newline at end of file