diff options
| author | srichman333 <sarah_n_richman@brown.edu> | 2024-03-31 13:24:39 -0400 | 
|---|---|---|
| committer | srichman333 <sarah_n_richman@brown.edu> | 2024-03-31 13:24:39 -0400 | 
| commit | c254b38690e27b32d3ac6316af9bb37d6d3e86aa (patch) | |
| tree | 0f94869895530d5f8b16631aa164bbcf4cd3e9d4 /src/client/util/DropConverter.ts | |
| parent | 4c4ab22252aba8f08d8a384e2bd0c6696db9b43b (diff) | |
| parent | 1e37adacfe5b44a71ed7d7dfd785c6c2d0808eae (diff) | |
Merge branch 'master' into dataviz-ai-sarah
Diffstat (limited to 'src/client/util/DropConverter.ts')
| -rw-r--r-- | src/client/util/DropConverter.ts | 45 | 
1 files changed, 25 insertions, 20 deletions
diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts index 3df3e36c6..ed5749d06 100644 --- a/src/client/util/DropConverter.ts +++ b/src/client/util/DropConverter.ts @@ -28,6 +28,7 @@ export function MakeTemplate(doc: Doc) {  }  /** + *   * Recursively converts 'doc' into a template that can be used to render other documents.   *   * For recurive Docs in the template, their target fieldKey is defined by their title, @@ -75,32 +76,36 @@ export function convertDropDataToButtons(data: DragManager.DocumentDragData) {                  remProps.map(prop => (dbox[prop] = undefined));              }          } else if (!doc.onDragStart && !doc.isButtonBar) { -            const layoutDoc = doc; // doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc; -            if (layoutDoc.type !== DocumentType.FONTICON) { -                !layoutDoc.isTemplateDoc && makeTemplate(layoutDoc); -            } -            layoutDoc.isTemplateDoc = true; -            dbox = Docs.Create.FontIconDocument({ -                _nativeWidth: 100, -                _nativeHeight: 100, -                _width: 100, -                _height: 100, -                backgroundColor: StrCast(doc.backgroundColor), -                title: StrCast(layoutDoc.title), -                btnType: ButtonType.ClickButton, -                icon: 'bolt', -                isSystem: false, -            }); -            dbox.title = ComputedField.MakeFunction('this.dragFactory.title'); -            dbox.dragFactory = layoutDoc; -            dbox.dropPropertiesToRemove = doc.dropPropertiesToRemove instanceof ObjectField ? ObjectField.MakeCopy(doc.dropPropertiesToRemove) : undefined; -            dbox.onDragStart = ScriptField.MakeFunction('makeDelegate(this.dragFactory)'); +            dbox = makeUserTemplateButton(doc);          } else if (doc.isButtonBar) {              dbox.ignoreClick = true;          }          data.droppedDocuments[i] = dbox;      });  } +export function makeUserTemplateButton(doc: Doc) { +    const layoutDoc = doc; // doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc; +    if (layoutDoc.type !== DocumentType.FONTICON) { +        !layoutDoc.isTemplateDoc && makeTemplate(layoutDoc); +    } +    layoutDoc.isTemplateDoc = true; +    const dbox = Docs.Create.FontIconDocument({ +        _nativeWidth: 100, +        _nativeHeight: 100, +        _width: 100, +        _height: 100, +        backgroundColor: StrCast(doc.backgroundColor), +        title: StrCast(layoutDoc.title), +        btnType: ButtonType.ClickButton, +        icon: 'bolt', +        isSystem: false, +    }); +    dbox.title = ComputedField.MakeFunction('this.dragFactory.title'); +    dbox.dragFactory = layoutDoc; +    dbox.dropPropertiesToRemove = doc.dropPropertiesToRemove instanceof ObjectField ? ObjectField.MakeCopy(doc.dropPropertiesToRemove) : undefined; +    dbox.onDragStart = ScriptField.MakeFunction('getCopy(this.dragFactory)'); +    return dbox; +}  ScriptingGlobals.add(      function convertToButtons(dragData: any) {          convertDropDataToButtons(dragData as DragManager.DocumentDragData);  | 
