From 59a03f711c48aa51a53759dcece88cd6d6204010 Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Thu, 6 Aug 2020 16:29:46 -0500 Subject: trying novice tools --- src/client/views/nodes/FontIconBox.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/client/views/nodes/FontIconBox.tsx') diff --git a/src/client/views/nodes/FontIconBox.tsx b/src/client/views/nodes/FontIconBox.tsx index c0eb78d98..71832b0dc 100644 --- a/src/client/views/nodes/FontIconBox.tsx +++ b/src/client/views/nodes/FontIconBox.tsx @@ -64,14 +64,18 @@ export class FontIconBox extends DocComponent( const backgroundColor = StrCast(this.layoutDoc._backgroundColor, StrCast(this.rootDoc.backgroundColor, this.props.backgroundColor?.(this.rootDoc))); const shape = StrCast(this.layoutDoc.iconShape, "round"); const button = ; - return !this.layoutDoc.toolTip ? button : + return !this.layoutDoc.toolTip || (this.layoutDoc.developerFeature && Doc.UserDoc().noviceMode) ? button : {StrCast(this.layoutDoc.toolTip)}}> {button} ; -- cgit v1.2.3-70-g09d2 From 915bb3796541116897dfc016a0ed3253c2f856cc Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Thu, 6 Aug 2020 19:22:37 -0500 Subject: temporary fix for novice tools --- src/client/views/PropertiesButtons.tsx | 11 +++++++++++ src/client/views/nodes/DocumentView.tsx | 11 +++++++++++ src/client/views/nodes/FontIconBox.tsx | 5 +++-- 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'src/client/views/nodes/FontIconBox.tsx') diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx index 29afd447f..837919a60 100644 --- a/src/client/views/PropertiesButtons.tsx +++ b/src/client/views/PropertiesButtons.tsx @@ -427,6 +427,17 @@ export class PropertiesButtons extends React.Component<{}, {}> { @action deleteDocument = () => { this.selectedDocumentView?.props.ContainingCollectionView?.removeDocument(this.selectedDocumentView?.props.Document); + const recent = Cast(Doc.UserDoc().myRecentlyClosed, Doc) as Doc; + const selected = SelectionManager.SelectedDocuments().slice(); + SelectionManager.DeselectAll(); + + selected.map(dv => { + const effectiveAcl = GetEffectiveAcl(dv.props.Document); + if (effectiveAcl === AclEdit || effectiveAcl === AclAdmin) { // deletes whatever you have the right to delete + recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true); + dv.props.removeDocument?.(dv.props.Document); + } + }); } @computed diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index b9e685b44..711ca8935 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -571,6 +571,17 @@ export class DocumentView extends DocComponent(Docu } else { SelectionManager.DeselectAll(); this.props.removeDocument?.(this.props.Document); + const recent = Cast(Doc.UserDoc().myRecentlyClosed, Doc) as Doc; + const selected = SelectionManager.SelectedDocuments().slice(); + SelectionManager.DeselectAll(); + + selected.map(dv => { + const effectiveAcl = GetEffectiveAcl(dv.props.Document); + if (effectiveAcl === AclEdit || effectiveAcl === AclAdmin) { // deletes whatever you have the right to delete + recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true); + dv.props.removeDocument?.(dv.props.Document); + } + }); } } diff --git a/src/client/views/nodes/FontIconBox.tsx b/src/client/views/nodes/FontIconBox.tsx index 71832b0dc..c465bb3bd 100644 --- a/src/client/views/nodes/FontIconBox.tsx +++ b/src/client/views/nodes/FontIconBox.tsx @@ -59,6 +59,8 @@ export class FontIconBox extends DocComponent( } render() { + + console.log(Doc.UserDoc()); const label = StrCast(this.rootDoc.label, StrCast(this.rootDoc.title)); const color = StrCast(this.layoutDoc.color, this._foregroundColor); const backgroundColor = StrCast(this.layoutDoc._backgroundColor, StrCast(this.rootDoc.backgroundColor, this.props.backgroundColor?.(this.rootDoc))); @@ -67,7 +69,6 @@ export class FontIconBox extends DocComponent( style={{ boxShadow: this.layoutDoc.ischecked ? `4px 4px 12px black` : undefined, backgroundColor: this.layoutDoc.iconShape === "square" ? backgroundColor : "", - display: (this.layoutDoc.developerFeature && Doc.UserDoc().noviceMode) ? "none" : "" }}>
{( {!label ? (null) :
{label}
}
; - return !this.layoutDoc.toolTip || (this.layoutDoc.developerFeature && Doc.UserDoc().noviceMode) ? button : + return (this.layoutDoc.developerFeature && Doc.UserDoc().noviceMode) ? (null) : !this.layoutDoc.toolTip ? button : {StrCast(this.layoutDoc.toolTip)}}> {button} ; -- cgit v1.2.3-70-g09d2 From 42a8ba8f3021d4ccc56cfdf4fea1c0bad9d8e818 Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Fri, 7 Aug 2020 00:31:14 -0500 Subject: delete changes --- src/client/views/PropertiesButtons.tsx | 8 +++++--- src/client/views/nodes/DocumentView.tsx | 8 ++++---- src/client/views/nodes/FontIconBox.tsx | 2 -- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/client/views/nodes/FontIconBox.tsx') diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx index 776b50838..a905dc1e7 100644 --- a/src/client/views/PropertiesButtons.tsx +++ b/src/client/views/PropertiesButtons.tsx @@ -3,7 +3,7 @@ import { faArrowAltCircleDown, faArrowAltCircleRight, faArrowAltCircleUp, faChec import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { action, computed, observable, runInAction } from "mobx"; import { observer } from "mobx-react"; -import { Doc, DocListCast } from "../../fields/Doc"; +import { Doc, DocListCast, AclEdit, AclAdmin } from "../../fields/Doc"; import { RichTextField } from '../../fields/RichTextField'; import { Cast, NumCast, BoolCast } from "../../fields/Types"; import { emptyFunction, setupMoveUpEvents, Utils } from "../../Utils"; @@ -30,6 +30,7 @@ import { undoBatch, UndoManager } from '../util/UndoManager'; import { DocumentType } from '../documents/DocumentTypes'; import { InkField } from '../../fields/InkField'; import { PresBox } from './nodes/PresBox'; +import { GetEffectiveAcl } from "../../fields/util"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -428,10 +429,8 @@ export class PropertiesButtons extends React.Component<{}, {}> { @undoBatch @action deleteDocument = () => { - this.selectedDocumentView?.props.ContainingCollectionView?.removeDocument(this.selectedDocumentView?.props.Document); const recent = Cast(Doc.UserDoc().myRecentlyClosed, Doc) as Doc; const selected = SelectionManager.SelectedDocuments().slice(); - SelectionManager.DeselectAll(); selected.map(dv => { const effectiveAcl = GetEffectiveAcl(dv.props.Document); @@ -440,6 +439,9 @@ export class PropertiesButtons extends React.Component<{}, {}> { dv.props.removeDocument?.(dv.props.Document); } }); + this.selectedDoc && (this.selectedDoc.deleted = true); + this.selectedDocumentView?.props.ContainingCollectionView?.removeDocument(this.selectedDocumentView?.props.Document); + SelectionManager.DeselectAll(); } @computed diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 707b7d2a1..3592dc393 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -565,14 +565,11 @@ export class DocumentView extends DocComponent(Docu } } - @undoBatch + @undoBatch @action deleteClicked = (): void => { if (Doc.UserDoc().activeWorkspace === this.props.Document) { alert("Can't delete the active workspace"); } else { - SelectionManager.DeselectAll(); - this.props.Document.deleted = true; - this.props.removeDocument?.(this.props.Document); const recent = Cast(Doc.UserDoc().myRecentlyClosed, Doc) as Doc; const selected = SelectionManager.SelectedDocuments().slice(); SelectionManager.DeselectAll(); @@ -584,6 +581,9 @@ export class DocumentView extends DocComponent(Docu dv.props.removeDocument?.(dv.props.Document); } }); + + this.props.Document.deleted = true; + this.props.removeDocument?.(this.props.Document); } } diff --git a/src/client/views/nodes/FontIconBox.tsx b/src/client/views/nodes/FontIconBox.tsx index c465bb3bd..95faabb48 100644 --- a/src/client/views/nodes/FontIconBox.tsx +++ b/src/client/views/nodes/FontIconBox.tsx @@ -59,8 +59,6 @@ export class FontIconBox extends DocComponent( } render() { - - console.log(Doc.UserDoc()); const label = StrCast(this.rootDoc.label, StrCast(this.rootDoc.title)); const color = StrCast(this.layoutDoc.color, this._foregroundColor); const backgroundColor = StrCast(this.layoutDoc._backgroundColor, StrCast(this.rootDoc.backgroundColor, this.props.backgroundColor?.(this.rootDoc))); -- cgit v1.2.3-70-g09d2 From ea3a2d51e130b1ea5954d9bb13658d25d8eac975 Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Fri, 7 Aug 2020 01:23:00 -0500 Subject: trying novice buttons --- src/client/documents/Documents.ts | 1 - src/client/util/CurrentUserUtils.ts | 71 +++++++++++++++++++++++++++------- src/client/views/nodes/FontIconBox.tsx | 2 +- 3 files changed, 57 insertions(+), 17 deletions(-) (limited to 'src/client/views/nodes/FontIconBox.tsx') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 50b7368d3..a06b4a581 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -205,7 +205,6 @@ export interface DocumentOptions { audioEnd?: number; // the time frame where the audio should stop playing border?: string; //for searchbox hovercolor?: string; - developerFeature?: boolean; } class EmptyBox { diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index c5d3fffc7..b1c98e549 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -385,10 +385,9 @@ export class CurrentUserUtils { return doc["template-icons"] as Doc; } - static creatorBtnDescriptors(doc: Doc): { + static creatorBtnDescriptors(doc: Doc, novice: boolean): { title: string, toolTip: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activeInkPen?: Doc, backgroundColor?: string, dragFactory?: Doc, hidden?: any, - developerFeature?: boolean }[] { if (doc.emptyPresentation === undefined) { doc.emptyPresentation = Docs.Create.PresDocument(new List(), @@ -461,7 +460,6 @@ export class CurrentUserUtils { toolTip: "Drag a screengrabber", title: "Grab", icon: "photo-video", click: 'openOnRight(getCopy(this.dragFactory, true))', drag: 'getCopy(this.dragFactory, true)', dragFactory: doc.emptyScreenshot as Doc, - developerFeature: true, }; const audio = { toolTip: "Drag a audio recorder", title: "Audio", @@ -482,35 +480,35 @@ export class CurrentUserUtils { const search = { toolTip: "Drag a search box", title: "Query", icon: "search", click: 'openOnRight(getCopy(this.dragFactory, true))', drag: 'getCopy(this.dragFactory, true)', - dragFactory: doc.emptySearch as Doc, developerFeature: true, + dragFactory: doc.emptySearch as Doc, }; const script = { toolTip: "Drag a scripting box", title: "Script", icon: "terminal", click: 'openOnRight(getCopy(this.dragFactory, true))', drag: 'getCopy(this.dragFactory, true)', dragFactory: doc.emptyScript as Doc, - developerFeature: true, }; const mobile = { toolTip: "Drag a mobile view", title: "Phone", icon: "mobile", click: 'openOnRight(Doc.UserDoc().activeMobileMenu)', drag: 'this.dragFactory', dragFactory: doc.activeMobileMenu as Doc, - developerFeature: true, }; const preview = { toolTip: "Drag a document previewer", title: "Prev", icon: "expand", click: 'openOnRight(getCopy(this.dragFactory, true))', drag: 'getCopy(this.dragFactory, true)', dragFactory: doc.emptyDocHolder as Doc, - developerFeature: true, }; const repl = { toolTip: "Toggle a Calculator REPL", title: "repl", icon: "calculator", click: 'addOverlayWindow("ScriptingRepl", { x: 300, y: 100, width: 200, height: 200, title: "Scripting REPL" })', - developerFeature: true, }; // novice : [collection, web, compare, audio, button, pres] - return [collection, web, compare, screen, audio, button, pres, search, script, preview, repl]; + if (novice) { + return [collection, web, compare, audio, button, pres]; + } else { + return [collection, web, compare, screen, audio, button, pres, search, script, preview, repl]; + } } @@ -525,10 +523,9 @@ export class CurrentUserUtils { alreadyCreatedButtons = dragDocs.map(d => StrCast(d.title)); } } - const buttons = CurrentUserUtils.creatorBtnDescriptors(doc).filter(d => !alreadyCreatedButtons?.includes(d.title)); + const buttons = CurrentUserUtils.creatorBtnDescriptors(doc, true).filter(d => !alreadyCreatedButtons?.includes(d.title)); const creatorBtns = buttons.map(({ title, toolTip, icon, ignoreClick, drag, - click, ischecked, activeInkPen, backgroundColor, dragFactory, - developerFeature }) => Docs.Create.FontIconDocument({ + click, ischecked, activeInkPen, backgroundColor, dragFactory }) => Docs.Create.FontIconDocument({ _nativeWidth: 50, _nativeHeight: 50, _width: 50, _height: 50, icon, title, @@ -542,12 +539,55 @@ export class CurrentUserUtils { backgroundColor, removeDropProperties: new List(["dropAction"]), dragFactory, - developerFeature, })); if (dragCreatorSet === undefined) { doc.myItemCreators = new PrefetchProxy(Docs.Create.MasonryDocument(creatorBtns, { - title: "Basic Item Creators", _showTitle: "title", _xMargin: 0, + title: "Basic Item Creators", + hidden: ComputedField.MakeFunction("!self.target.noviceMode") as any, + _showTitle: "title", _xMargin: 0, + _autoHeight: true, _width: 500, _columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", + dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), + })); + } else { + creatorBtns.forEach(nb => Doc.AddDocToList(doc.myItemCreators as Doc, "data", nb)); + } + return doc.myItemCreators as Doc; + } + + static async setupDevCreatorButtons(doc: Doc) { + let alreadyCreatedButtons: string[] = []; + const dragCreatorSet = await Cast(doc.myItemCreators, Doc, null); + if (dragCreatorSet) { + const dragCreators = await Cast(dragCreatorSet.data, listSpec(Doc)); + if (dragCreators) { + const dragDocs = await Promise.all(dragCreators); + alreadyCreatedButtons = dragDocs.map(d => StrCast(d.title)); + } + } + const buttons = CurrentUserUtils.creatorBtnDescriptors(doc, false).filter(d => !alreadyCreatedButtons?.includes(d.title)); + const creatorBtns = buttons.map(({ title, toolTip, icon, ignoreClick, drag, + click, ischecked, activeInkPen, backgroundColor, dragFactory }) => Docs.Create.FontIconDocument({ + _nativeWidth: 50, _nativeHeight: 50, _width: 50, _height: 50, + icon, + title, + toolTip, + ignoreClick, + dropAction: "copy", + onDragStart: drag ? ScriptField.MakeFunction(drag) : undefined, + onClick: click ? ScriptField.MakeScript(click) : undefined, + ischecked: ischecked ? ComputedField.MakeFunction(ischecked) : undefined, + activeInkPen, + backgroundColor, + removeDropProperties: new List(["dropAction"]), + dragFactory, + })); + + if (dragCreatorSet === undefined) { + doc.myItemCreators = new PrefetchProxy(Docs.Create.MasonryDocument(creatorBtns, { + title: "Basic Item Creators", + hidden: ComputedField.MakeFunction("self.target.noviceMode") as any, + _showTitle: "title", _xMargin: 0, _autoHeight: true, _width: 500, _columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), })); @@ -724,12 +764,13 @@ export class CurrentUserUtils { static async setupToolsBtnPanel(doc: Doc) { // setup a masonry view of all he creators const creatorBtns = await CurrentUserUtils.setupCreatorButtons(doc); + const devBtns = await CurrentUserUtils.setupDevCreatorButtons(doc); const templateBtns = CurrentUserUtils.setupUserTemplateButtons(doc); doc["tabs-button-tools"] = undefined; if (doc.myCreators === undefined) { - doc.myCreators = new PrefetchProxy(Docs.Create.StackingDocument([creatorBtns, templateBtns], { + doc.myCreators = new PrefetchProxy(Docs.Create.StackingDocument([creatorBtns, devBtns, templateBtns], { title: "all Creators", _yMargin: 0, _autoHeight: true, _xMargin: 0, _width: 500, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", })); diff --git a/src/client/views/nodes/FontIconBox.tsx b/src/client/views/nodes/FontIconBox.tsx index 95faabb48..a6b1678b5 100644 --- a/src/client/views/nodes/FontIconBox.tsx +++ b/src/client/views/nodes/FontIconBox.tsx @@ -74,7 +74,7 @@ export class FontIconBox extends DocComponent( {!label ? (null) :
{label}
} ; - return (this.layoutDoc.developerFeature && Doc.UserDoc().noviceMode) ? (null) : !this.layoutDoc.toolTip ? button : + return !this.layoutDoc.toolTip ? button : {StrCast(this.layoutDoc.toolTip)}}> {button} ; -- cgit v1.2.3-70-g09d2