diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/documents/Documents.ts | 13 | ||||
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingView.tsx | 3 | ||||
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx | 5 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 40527964a..2e9484db4 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -1233,7 +1233,7 @@ export namespace DocUtils { return ctor ? ctor(path, options) : undefined; } - export function addDocumentCreatorMenuItems(docTextAdder: (d: Doc) => void, docAdder: (d: Doc) => void, x: number, y: number, simpleMenu: boolean = false): void { + export function addDocumentCreatorMenuItems(docTextAdder: (d: Doc) => void, docAdder: (d: Doc) => void, x: number, y: number, simpleMenu: boolean = false, pivotField?: string, pivotValue?: string): void { !simpleMenu && ContextMenu.Instance.addItem({ description: "Quick Notes", subitems: DocListCast((Doc.UserDoc()["template-notes"] as Doc).data).map((note, i) => ({ @@ -1241,10 +1241,13 @@ export namespace DocUtils { event: undoBatch((args: { x: number, y: number }) => { const textDoc = Docs.Create.TextDocument("", { _width: 200, x, y, _autoHeight: note._autoHeight !== false, - title: StrCast(note.title) + "#" + (note.aliasCount = NumCast(note.aliasCount) + 1) + title: StrCast(note.title) + "#" + (note.aliasCount = NumCast(note.aliasCount) + 1), }); textDoc.layoutKey = "layout_" + note.title; textDoc[textDoc.layoutKey] = note; + if (pivotField) { + textDoc[pivotField] = pivotValue + } docTextAdder(textDoc); }), icon: StrCast(note.icon) as IconProp @@ -1261,6 +1264,9 @@ export namespace DocUtils { created.width = 300; created.height = 35; EquationBox.SelectOnLoad = created[Id]; + if (pivotField) { + created[pivotField] = pivotValue + } docAdder?.(created); } }, icon: "calculator" @@ -1274,6 +1280,9 @@ export namespace DocUtils { newDoc.x = x; newDoc.y = y; if (newDoc.type === DocumentType.RTF) FormattedTextBox.SelectOnLoad = newDoc[Id]; + if (pivotField) { + newDoc[pivotField] = pivotValue + } docAdder?.(newDoc); } }), diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 4e2bdbfa5..d3b3778a7 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -121,7 +121,8 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti let changed = false; this.filteredChildren.map(d => { if (!d[this.pivotField]) { - d[this.pivotField] = `New Column` + d[this.pivotField] = columnHeaders.length > 0 ? columnHeaders[0].heading : `New Column` + // d[this.pivotField] = columnHeaders[0].heading }; const sectionValue = d[this.pivotField] as object; // the next five lines ensures that floating point rounding errors don't create more than one section -syip diff --git a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx index 1167a0ea8..8b7461fc0 100644 --- a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx @@ -187,11 +187,14 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFiel const layoutItems: ContextMenuProps[] = []; const docItems: ContextMenuProps[] = []; const dataDoc = this.props.DataDoc || this.props.Document; + const pivotValue = this.getValue(this.props.heading); DocUtils.addDocumentCreatorMenuItems((doc) => { + const key = this.props.pivotField; + doc[key] = this.getValue(this.props.heading); FormattedTextBox.SelectOnLoad = doc[Id]; return this.props.addDocument?.(doc); - }, this.props.addDocument, x, y, true); + }, this.props.addDocument, x, y, true, this.props.pivotField, pivotValue); Array.from(Object.keys(Doc.GetProto(dataDoc))).filter(fieldKey => dataDoc[fieldKey] instanceof RichTextField || dataDoc[fieldKey] instanceof ImageField || typeof (dataDoc[fieldKey]) === "string").map(fieldKey => docItems.push({ |