I´m a newby but interested in solving the problem so I asked chat-gpt:
Here is the answer:
The script you found is a good start. It’s modifying the
poll-ui-builder
controller to set thepublicPoll
property totrue
when the controller’sonShow()
function is called. This is indeed intended to be added as a Theme Component.However, the code might not be working due to the order of execution. The original
onShow()
method setspublicPoll
tofalse
and then the modification setspublicPoll
totrue
afterwards.A correct way would be to call the parent’s
onShow
method first, and then setpublicPoll
totrue
:
<script type="text/discourse-plugin" version="0.8">
api.modifyClass("controller:poll-ui-builder", {
onShow() {
this._super(...arguments);
this.set('publicPoll', true);
}
});
</script>
You can add this script to your theme by following these steps:
- Go to the Discourse Admin dashboard.
- Under the “Customize” section, click on “Themes”.
- Select the theme that you want to modify.
- In the theme editing screen, click on “Edit CSS/HTML”.
- In the left sidebar, click on “</> Common”.
- Paste the above script into the “</> Common” section.
- Click on the “Save” button.
This will apply the change to your theme. Please remember that theme changes are only applied to users who are using that particular theme. If you have multiple themes, you’ll need to add this modification to each one.
Also, remember to clear your browser cache or do a hard reload to ensure that the changes are loaded correctly.
I will try to follow these steps with the admin of our Forum, but this takes a while, if someone else here want to try this in first please and give feedback I would be very happy.
Another thing i would love to change is the behaviour of the ui, i want to skip the simple screen, so i asked chat-gpt again:
In your current code, the extended view is controlled by the
showAdvanced
property. If this is set totrue
, the advanced view will be shown.To always show the advanced view, you can modify the
onShow()
method in thepoll-ui-builder
controller to setshowAdvanced
totrue
. You can add this modification to the theme component you created earlier. Here’s the updated script:
<script type="text/discourse-plugin" version="0.8">
api.modifyClass("controller:poll-ui-builder", {
onShow() {
this._super(...arguments);
this.set('publicPoll', true);
this.set('showAdvanced', true);
}
});
</script>
Remember to follow the steps I previously outlined to add this script to your theme. Once the script is saved, the advanced view should always be shown when the poll UI is loaded.
Again, remember to clear your browser cache or do a hard reload to ensure that the changes are loaded correctly.
I would love to try and test by myself somehow, but as mentioned before i´m just a moderator, not the admin of our site, so this will take some days or weeks.