Fork me on GitHub
#portal
<
2024-01-25
>
Alexander Kouznetsov23:01:25

Is there a way in UI to drop individual values in the portal?

djblue23:01:26

Like filtering out stuff you've tapped out?

Alexander Kouznetsov23:01:51

Just completely removing them

Alexander Kouznetsov23:01:12

Like clearing all, but only the selected items

djblue00:01:02

Currently, this can be achieved via a custom tap list:

(def tap-list (atom (with-meta (list) {:portal.viewer/default :portal.viewer/inspector})))

(defn submit [x] (swap! tap-list conj x))

(add-tap #'submit)

(defn clear-selected [& args]
  (let [values (into #{} args)]
    (swap! tap-list (fn [taps] (remove values taps)))))

(p/register! #'clear-selected)

(p/inspect tap-list)

(tap> :hi)

djblue00:01:32

You could also implement the command in terms of the default Portal tap-list atom #'portal.runtime/tap-list but technically that's an internal implementation detail, but I probably won't change it 😂

djblue00:01:15

The other thing here is that items are removed by value, not by index since that info isn't really available to commands

Alexander Kouznetsov00:01:46

Interesting, thanks! Do you think it would make sense to have it in the standard features?

djblue00:01:53

I think if something can be accomplished by the user, I would rather not include it. Currently, there are certain commands that could be user added, but they were added before the ability to add your own commands and now I can't remove them.

1
Alexander Kouznetsov08:01:07

What’s the preferred way to configure such things on user’s side?