From 9a63f35496c82fd8be89e9490f65ac6354c7b752 Mon Sep 17 00:00:00 2001 From: Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> Date: Mon, 10 Jul 2023 02:25:25 -0400 Subject: fixed collection linear view to an extent still errors remaining and work that needs to be done! --- src/client/views/nodes/button/FontIconBox.tsx | 74 +++++++++++++++++++++------ 1 file changed, 57 insertions(+), 17 deletions(-) (limited to 'src/client/views/nodes/button') diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx index 7d5c38140..8314f2d86 100644 --- a/src/client/views/nodes/button/FontIconBox.tsx +++ b/src/client/views/nodes/button/FontIconBox.tsx @@ -98,8 +98,14 @@ export class FontIconBox extends DocComponent() { @computed get label() { return StrCast(this.rootDoc.icon_label, StrCast(this.rootDoc.title)); } - Icon = (color: string) => { - const icon = StrCast(this.dataDoc[this.fieldKey ?? 'icon'] ?? this.dataDoc.icon, 'user') as any; + Icon = (color: string, iconFalse?: boolean) => { + let icon; + if (iconFalse ) { + icon = StrCast(this.dataDoc[this.fieldKey ?? 'iconFalse'] ?? this.dataDoc.icon, 'user') as any; + if (icon) return + else return null + } + icon = StrCast(this.dataDoc[this.fieldKey ?? 'icon'] ?? this.dataDoc.icon, 'user') as any; const trailsIcon = () => ; return !icon ? null : icon === 'pres-trail' ? trailsIcon() : ; }; @@ -309,25 +315,18 @@ export class FontIconBox extends DocComponent() { console.log(e); } + console.log("current item: ", text); + // Get items to place into the list const list: IListItemProps[] = this.buttonList .filter(value => !Doc.noviceMode || !noviceList.length || noviceList.includes(value)) .map(value => ( { text: value, - style: { fontFamily: value } + style: { fontFamily: value }, + onClick: undoable(() => script.script.run({ self: this.rootDoc, value }), value) // shortcut: '#', } - //
script.script.run({ self: this.rootDoc, value }), value)}> - // {value[0].toUpperCase() + value.slice(1)} - //
)); const label = @@ -338,7 +337,7 @@ export class FontIconBox extends DocComponent() { ); return ( - + ) return ( @@ -466,6 +465,7 @@ export class FontIconBox extends DocComponent() { const switchToggle: boolean = BoolCast(this.rootDoc.switchToggle); const buttonText: string = StrCast(this.rootDoc.buttonText); const tooltip: string = StrCast(this.rootDoc.toolTip); + // Colors const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color); const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor); @@ -507,6 +507,7 @@ export class FontIconBox extends DocComponent() { } render() { + // determine dash button metadata const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color); const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor); const tooltip: string = StrCast(this.rootDoc.toolTip); @@ -523,7 +524,46 @@ export class FontIconBox extends DocComponent() { // prettier-ignore switch (this.type) { case ButtonType.EditableText: return this.editableText; - case ButtonType.DropdownList: button = this.dropdownListButton; break; + case ButtonType.DropdownList: + let script = ScriptCast(this.rootDoc.script); + let noviceList: string[] = []; + let text: string | undefined; + let dropdown = true; + let icon: IconProp = 'caret-down'; + try { + if (script?.script.originalScript.startsWith('setView')) { + const selected = SelectionManager.Docs().lastElement(); + if (selected) { + if (StrCast(selected.type) === DocumentType.COL) { + text = StrCast(selected._type_collection); + } else { + dropdown = false; + text = selected.type === DocumentType.RTF ? 'Text' : StrCast(selected.type); + icon = Doc.toIcon(selected); + } + } else { + dropdown = false; + icon = 'globe-asia'; + text = 'User Default'; + } + noviceList = [CollectionViewType.Freeform, CollectionViewType.Schema, CollectionViewType.Stacking, CollectionViewType.NoteTaking]; + } else text = StrCast((RichTextMenu.Instance?.TextView?.EditorView ? RichTextMenu.Instance : Doc.UserDoc()).fontFamily); + } catch (e) { + console.log(e); + } + // Get items to place into the list + const list: IListItemProps[] = this.buttonList + .filter(value => !Doc.noviceMode || !noviceList.length || noviceList.includes(value)) + .map(value => ( + { + text: value, + style: { fontFamily: value }, + onClick: undoable(() => script.script.run({ self: this.rootDoc, value }), value) + // shortcut: '#', + } + )); + button = + break; case ButtonType.ColorButton: button = this.colorButton; break; case ButtonType.NumberDropdownButton: button = this.numberDropdownButton; break; case ButtonType.NumberInlineButton: button = this.numberInlineButton; break; @@ -532,7 +572,7 @@ export class FontIconBox extends DocComponent() { case ButtonType.ToggleButton: button = this.toggleButton; break; case ButtonType.TextButton: // Script for checking the outcome of the toggle - const script = ScriptCast(this.rootDoc.script); + script = ScriptCast(this.rootDoc.script); const checkResult = script?.script.run({ _readOnly_: true }).result; button = (
@@ -548,7 +588,7 @@ export class FontIconBox extends DocComponent() { ); break; case ButtonType.MenuButton: button = ( - + ); break; } -- cgit v1.2.3-70-g09d2