diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-04-28 00:08:57 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-04-28 00:08:57 -0400 |
commit | 13f1952137b27480a12fa4a20a4cfc49f823ebf8 (patch) | |
tree | 8e960a139cb49d9d3f96ba3457093aa86f9535f4 | |
parent | 1c3bcfe6a0fea9c4f9483ecbe9539b60128f61ed (diff) |
final dashFieldView cleanup
-rw-r--r-- | src/client/util/DashFieldView.scss | 4 | ||||
-rw-r--r-- | src/client/util/DashFieldView.tsx | 18 |
2 files changed, 9 insertions, 13 deletions
diff --git a/src/client/util/DashFieldView.scss b/src/client/util/DashFieldView.scss index e396788b5..35ff9c1e6 100644 --- a/src/client/util/DashFieldView.scss +++ b/src/client/util/DashFieldView.scss @@ -27,6 +27,10 @@ position: relative; display: inline-block; background-color: rgba(155, 155, 155, 0.24); + span { + min-width: 100%; + display: inline-block; + } } }
\ No newline at end of file diff --git a/src/client/util/DashFieldView.tsx b/src/client/util/DashFieldView.tsx index a135db003..d76e9d1ec 100644 --- a/src/client/util/DashFieldView.tsx +++ b/src/client/util/DashFieldView.tsx @@ -58,11 +58,9 @@ interface IDashFieldViewInternal { @observer export class DashFieldViewInternal extends React.Component<IDashFieldViewInternal> { - _reactionDisposer: IReactionDisposer | undefined; _textBoxDoc: Doc; _fieldKey: string; - _options: Doc[] = []; _fieldStringRef = React.createRef<HTMLSpanElement>(); @observable _showEnumerables: boolean = false; @observable _dashDoc: Doc | undefined; @@ -74,9 +72,9 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna if (this.props.docid) { DocServer.GetRefField(this.props.docid). - then(async dashDoc => dashDoc instanceof Doc && runInAction(() => this.setDashDoc(dashDoc))); + then(action(async dashDoc => dashDoc instanceof Doc && (this._dashDoc = dashDoc))); } else { - this.setDashDoc(this.props.tbox.props.DataDoc || this.props.tbox.dataDoc); + this._dashDoc = this.props.tbox.props.DataDoc || this.props.tbox.dataDoc; } } componentWillUnmount() { @@ -115,15 +113,6 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna } } - setDashDoc = (doc: Doc) => { - this._dashDoc = doc; - if (this._options?.length && !this._dashDoc[this._fieldKey]) { - this._dashDoc[this._fieldKey] = StrCast(this._options[0].title); - } - // NOTE: if the field key starts with "@", then the actual field key is stored in the field 'fieldKey' (removing the @). - //this._fieldKey = this._fieldKey?.startsWith("@") ? StrCast(this._textBoxDoc[StrCast(this._fieldKey as string).substring(1)]) : this._fieldKey as string; - } - // we need to handle all key events on the input span or else they will propagate to prosemirror. @action fieldSpanKeyDown = (e: KeyboardEvent, span: HTMLSpanElement) => { @@ -172,6 +161,7 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna } } + // display a collection of all the enumerable values for this field onPointerDownEnumerables = async (e: any) => { e.stopPropagation(); const collview = await Doc.addFieldEnumerations(this._textBoxDoc, this._fieldKey, [{ title: this._fieldKey }]); @@ -179,6 +169,8 @@ export class DashFieldViewInternal extends React.Component<IDashFieldViewInterna } + // clicking on the label creates a pivot view collection of all documents + // in the same collection. The pivot field is the fieldKey of this label onPointerDownLabelSpan = (e: any) => { e.stopPropagation(); let container = this.props.tbox.props.ContainingCollectionView; |