aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/DocumentDecorations.tsx4
-rw-r--r--src/client/views/Main.tsx1
-rw-r--r--src/client/views/collections/CollectionSchemaView.scss66
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx101
4 files changed, 113 insertions, 59 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index a8090dc8f..47098c3b5 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -10,8 +10,8 @@ import { DragManager } from "../util/DragManager";
import { LinkMenu } from "./nodes/LinkMenu";
import { ListField } from "../../fields/ListField";
const higflyout = require("@hig/flyout");
-const { anchorPoints } = higflyout;
-const Flyout = higflyout.default;
+export const { anchorPoints } = higflyout;
+export const Flyout = higflyout.default;
@observer
export class DocumentDecorations extends React.Component {
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index ac51a7d87..b0ca347df 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -86,6 +86,7 @@ export class Main extends React.Component {
library.add(faFilm);
library.add(faMusic);
+
this.initEventListeners();
Documents.initProtos(() => this.initAuthenticationRouters());
}
diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index 863bb256a..c3a2e88ac 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -1,4 +1,57 @@
@import "../global_variables";
+
+//options menu styling
+#schemaOptionsMenuBtn {
+ position: absolute;
+ height: 20px;
+ width: 20px;
+ border-radius: 50%;
+ z-index: 21;
+ right: 4px;
+ top: 4px;
+ pointer-events: auto;
+ background-color:black;
+ display:inline-block;
+ padding: 0px;
+ font-size: 100%;
+}
+#schema-options-header {
+ text-align: center;
+ padding: 0px;
+ margin: 0px;
+}
+.schema-options-subHeader {
+ color: $intermediate-color;
+ margin-bottom: 5px;
+}
+#schemaOptionsMenuBtn:hover {
+ transform: scale(1.15);
+}
+
+#preview-schema-checkbox-div {
+ margin-left: 20px;
+ font-size: 12px;
+}
+
+ #options-flyout-div {
+ text-align: left;
+ padding:0px;
+ z-index: 100;
+ font-family: $sans-serif;
+ padding-left: 5px;
+ }
+
+ #schema-col-checklist {
+ overflow: scroll;
+ text-align: left;
+ //background-color: $light-color-secondary;
+ line-height: 25px;
+ max-height: 175px;
+ font-family: $sans-serif;
+ font-size: 12px;
+ }
+
+
.collectionSchemaView-container {
border: 1px solid $intermediate-color;
border-radius: $border-radius;
@@ -6,7 +59,7 @@
position: absolute;
width: 100%;
height: 100%;
- overflow: hidden;
+
.collectionSchemaView-content {
position: absolute;
height: 100%;
@@ -21,6 +74,17 @@
}
.collectionSchemaView-previewHandle {
position: absolute;
+ height: 15px;
+ width: 15px;
+ z-index: 20;
+ right: 0;
+ top: 20px;
+ background: Black ;
+ }
+ .collectionSchemaView-dividerDragger{
+ position: relative;
+ background: black;
+ float: left;
height: 37px;
width: 20px;
z-index: 20;
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 062babe58..c2645ea73 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -16,9 +16,14 @@ import "./CollectionSchemaView.scss";
import { COLLECTION_BORDER_WIDTH, CollectionView } from "./CollectionView";
import { CollectionViewBase } from "./CollectionViewBase";
import { setupDrag } from "../../util/DragManager";
-import { Key } from "./../../../fields/Key";
-import { Server } from "../../Server";
+import '../DocumentDecorations.scss';
+import { Flyout, anchorPoints } from "../DocumentDecorations";
import { ListField } from "../../../fields/ListField";
+import { Key } from "../../../fields/Key";
+import { Server } from "../../Server";
+import { library } from '@fortawesome/fontawesome-svg-core';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faCog } from '@fortawesome/free-solid-svg-icons';
// bcz: need to add drag and drop of rows and columns. This seems like it might work for rows: https://codesandbox.io/s/l94mn1q657
@@ -39,7 +44,7 @@ class KeyToggle extends React.Component<{ keyId: string, checked: boolean, toggl
render() {
if (this.key) {
return (<div key={this.key.Id}>
- <input type="checkbox" checked={this.props.checked} onChange={() => this.key && this.props.toggle(this.key)} />{this.key.Name}
+ <input type="checkbox" checked={this.props.checked} onChange={() => this.key && this.props.toggle(this.key)} /> {this.key.Name}
</div>)
} else {
return <div></div>
@@ -61,6 +66,7 @@ export class CollectionSchemaView extends CollectionViewBase {
@observable _columnsPercentage = 0;
@computed get splitPercentage() { return this.props.Document.GetNumber(KeyStore.SchemaSplitPercentage, 0); }
+
renderCell = (rowProps: CellInfo) => {
let props: FieldViewProps = {
doc: rowProps.value[0],
@@ -151,6 +157,15 @@ export class CollectionSchemaView extends CollectionViewBase {
})
}
+ //toggles preview side-panel of schema
+ @action
+ toggleExpander = (event: React.ChangeEvent<HTMLInputElement>) => {
+ this._startSplitPercent = this.splitPercentage;
+ if (this._startSplitPercent == this.splitPercentage) {
+ this.props.Document.SetNumber(KeyStore.SchemaSplitPercentage, this.splitPercentage == 0 ? 33 : 0);
+ }
+ }
+
@observable keys: Key[] = [];
findAllDocumentKeys = (): { [id: string]: boolean } => {
@@ -215,37 +230,6 @@ export class CollectionSchemaView extends CollectionViewBase {
e.stopPropagation();
e.preventDefault();
}
- @action
- onExpanderUp = (e: PointerEvent): void => {
- e.stopPropagation();
- e.preventDefault();
- document.removeEventListener("pointermove", this.onExpanderMove);
- document.removeEventListener('pointerup', this.onExpanderUp);
- if (this._startSplitPercent == this.splitPercentage) {
- this.props.Document.SetNumber(KeyStore.SchemaSplitPercentage, this.splitPercentage == 0 ? 33 : 0);
- }
- }
- onExpanderDown = (e: React.PointerEvent) => {
- this._startSplitPercent = this.splitPercentage;
- e.stopPropagation();
- e.preventDefault();
- document.addEventListener("pointermove", this.onExpanderMove);
- document.addEventListener('pointerup', this.onExpanderUp);
- }
-
- onPointerDown = (e: React.PointerEvent) => {
- // if (e.button === 2 && this.active) {
- // e.stopPropagation();
- // e.preventDefault();
- // } else
- {
- // if (e.buttons === 1) {
- // if (this.props.isSelected()) {
- // e.stopPropagation();
- // }
- // }
- }
- }
@action
onColumnsMove = (e: PointerEvent): void => {
@@ -286,10 +270,16 @@ export class CollectionSchemaView extends CollectionViewBase {
focusDocument = (doc: Document) => { }
+ onPointerDown = (e: React.PointerEvent): void => {
+ //
+ }
+
render() {
+ library.add(faCog);
const columns = this.columns;
const children = this.props.Document.GetList<Document>(this.props.fieldKey, []);
const selected = children.length > this._selectedIndex ? children[this._selectedIndex] : undefined;
+ //all the keys/columns that will be displayed in the schema
const allKeys = this.findAllDocumentKeys();
let content = this._selectedIndex == -1 || !selected ? (null) : (
<Measure onResize={this.setScaling}>
@@ -310,14 +300,28 @@ export class CollectionSchemaView extends CollectionViewBase {
}
</Measure>
)
- let previewHandle = !this.props.active() ? (null) : (
- <div className="collectionSchemaView-previewHandle" onPointerDown={this.onExpanderDown} />);
- let columnsHandle = !this.props.active() ? (null) : (
- <div className="collectionSchemaView-columnsHandle" onPointerDown={this.onColumnsDown} />);
let dividerDragger = this.splitPercentage == 0 ? (null) :
<div className="collectionSchemaView-dividerDragger" onPointerDown={this.onDividerDown} style={{ width: `${this.DIVIDER_WIDTH}px` }} />
- let colDividerDragger = this._columnsPercentage == 0 ? (null) :
- <div className="collectionSchemaView-colDividerDragger" onPointerDown={this.onColDividerDown} style={{ height: `${this.DIVIDER_WIDTH}px` }} />
+
+ //options button and menu
+ let optionsMenu = !this.props.active() ? (null) : (<Flyout
+ anchorPoint={anchorPoints.LEFT_TOP}
+ content={<div>
+ <div id="schema-options-header"><h5><b>Options</b></h5></div>
+ <div id="options-flyout-div">
+ <h6 className="schema-options-subHeader">Preview Window</h6>
+ <div id="preview-schema-checkbox-div"><input type="checkbox" key={"Show Preview"} checked={this.splitPercentage != 0} onChange={this.toggleExpander} /> Show Preview </div>
+ <h6 className="schema-options-subHeader" >Displayed Columns</h6>
+ <ul id="schema-col-checklist" >
+ {Array.from(Object.keys(allKeys)).map(item => {
+ return (<KeyToggle checked={allKeys[item]} key={item} keyId={item} toggle={this.toggleKey} />)
+ })}
+ </ul>
+ </div>
+ </div>
+ }>
+ <button id="schemaOptionsMenuBtn"><FontAwesomeIcon style={{ color: "white" }} icon="cog" size="sm" /></button>
+ </Flyout>);
return (
<div className="collectionSchemaView-container" onPointerDown={this.onPointerDown} ref={this._mainCont} style={{ borderWidth: `${COLLECTION_BORDER_WIDTH}px` }} >
@@ -348,19 +352,6 @@ export class CollectionSchemaView extends CollectionViewBase {
getTrProps={this.getTrProps}
/>
</div>
- {colDividerDragger}
- <div className="collectionSchemaView-addColumn" style={{ height: `${this._columnsPercentage}%` }} >
- {/* <input type="checkbox" id="addColumn-toggle" />
- <label htmlFor="addColumn-toggle" title="Add Column"><p>+</p></label> */}
-
- <div className="addColumn-options">
- <ul style={{ overflow: "scroll" }}>
- {Array.from(Object.keys(allKeys)).map(item => {
- return (<KeyToggle checked={allKeys[item]} key={item} keyId={item} toggle={this.toggleKey} />)
- })}
- </ul>
- </div>
- </div>
</div>
}
</Measure>
@@ -368,9 +359,7 @@ export class CollectionSchemaView extends CollectionViewBase {
<div className="collectionSchemaView-previewRegion" style={{ width: `calc(${this.props.Document.GetNumber(KeyStore.SchemaSplitPercentage, 0)}% - ${this.DIVIDER_WIDTH}px)` }}>
{content}
</div>
- {previewHandle}
- {columnsHandle}
-
+ {optionsMenu}
</div>
</div >
)