script-lab icon indicating copy to clipboard operation
script-lab copied to clipboard

Alternate UI treatment for custom functions?

Open akrantz opened this issue 5 years ago • 13 comments

Bug Report

I'm using ScriptLab in Excel for Windows. ScriptLab alpha/beta

Expected behavior:

Switching to a new snippet and reloading functions should only contain functions/metadata in that snippet. Functions/metadata from previous snippet should not be included.

Actual behavior:

It is keeping functions/metadata from previous snippets.

Steps to Reproduce:

  1. Insert a custom function:
/**
* @customfunction 
*
function first() {
}
  1. register the functions.
  2. click new snippet
  3. replace code with a new custom function:
/**
* @customfunction 
*
function second() {
}
  1. register the functions.

RESULT: Summary/Metadata shows functions "first" and "second". EXPECTED: Summary/Metadata should only show function "second".

akrantz avatar Mar 21 '19 12:03 akrantz

Old functions seem to stay around even with a new document or new Excel instance. Opening Internet Explorer and clearing the cache seems to remove them.

akrantz avatar Mar 21 '19 13:03 akrantz

This is by design. We want to register any functions you have in your workspace. That's also why the functions are prefixed with the snippet name (e.g., ScriptLab.BlankSnippet1.add32). If you don't want the old functions, just delete the old snippet.

Zlatkovsky avatar Mar 21 '19 15:03 Zlatkovsky

Sorry, but there needs to be another way to do this. It gets too cluttered. I don't see why you want all functions for all snippets to stay around. It should really just be functions for the current snippet.

akrantz avatar Mar 21 '19 15:03 akrantz

You are welcome to talk to Lena or Jakob to see if there is an alternate visual design, and then submit a PR with it.

That said, I feel very strongly that the rest of the CFs should continue to be registered. It's super handy for demos -- being able to have different snippets that each encapsulate a function, but have a workbook that already has all those CFs entered into it and working. And it's super handy for just having a toolbox of functions that you can run. If we only registered for the current snippet, it also means that you'd need to always open the code editor and find your snippet, whereas now you can run any ScriptLab-registered CF without even having any of the panes open.

Zlatkovsky avatar Mar 21 '19 15:03 Zlatkovsky

Switched title and moved to a "Longer term" milestone until we have an actionable proposal.

Zlatkovsky avatar Mar 21 '19 15:03 Zlatkovsky

Can I just have a clear button to clear existing registered functions?

akrantz avatar Mar 21 '19 15:03 akrantz

Also, do you understand my problem where I currently have no easy way to get rid of existing registered functions?

Perhaps there could be an option to control the behavior. You have a particular use case in mind, but I think if you step back, you might see how it can be confusing to others whom don't want to use it that way.

akrantz avatar Mar 21 '19 15:03 akrantz

As far as registration with Excel is concerned, I continue to think that we need to register all. In which case I don't know what a "clear" button is meant to do.

If you've played with a snippet and then don't need it anymore, just go ahead and delete it. That's the easiest way of reducing clutter, if those functions are "clutter". And if they're not, then you might well want to keep them registered.

I think an in-person discussion (likely with a designer like Jakob) would be the best way of moving forward on this.

Zlatkovsky avatar Mar 21 '19 15:03 Zlatkovsky

@akrantz is your problem with the clutter of seeing all of them together in a flat list in the SL UI, or having all of them registered in the workbook?

For the first one, I'd have to say I agree with you and originally wanted the functions to be grouped by snippet for the same reason.

For the latter, I agree with Michael, and think that having all your custom functions registered so that you can use them when you need them is pretty useful.

nico-bellante avatar Mar 26 '19 18:03 nico-bellante

Well, I think it is more of a function of how snippets are handled. When I import a new snippet, I expected the old snippet to be gone, that is only one snippet is active at a time. But what happens is that a snippet is imported and remains until explicitly deleted. I didn't understand that these stay around, and I do see that after deleting the snippet, those functions no longer appear.

I will agree that having the ability to load multiple snippets, the functions for those snippets should stay around.

Please understand though that since it shows my gists after being logged in, it wasn't clear that the top group of snippets that are loaded in this instance different and something I could delete and that is what determines which functions are registered.

I also was working across two machines, and had to manually import from the gist url, as there isn't a way to reload an enumerated GitHub gist as it is changed from elsewhere. I really would like a model where my snippet is auto-saved to the gist, and gist changes are automatically imported.

akrantz avatar Mar 26 '19 18:03 akrantz

I think of it like this:

The local snippets on your machine are akin to files you have downloaded from a repo locally. You can open these files and close these files with an editor, but they still stay there. The gists are more like pointers to files in the cloud, which you can dereference, bringing that gist down into a local file. There is the ability to update a gist, and by reopening it, you will get the latest changes.

As far as the auto-saving and auto-importing, I don't have the bandwidth to implement that this quarter, but I'd be happy to review a PR for it :)

nico-bellante avatar Mar 26 '19 21:03 nico-bellante

This is an important scenario for custom functions. What we need here is a proper office.js API that we can use to register and unregister custom functions as needed to get the right behavior.

wandyezj avatar Apr 04 '24 21:04 wandyezj

@wandyezj Yes please! This is - from my POV - related to this GitHub issue https://github.com/OfficeDev/office-js/issues/3486

4tti avatar Apr 10 '24 10:04 4tti