Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Adding footer message to Survey #435

Closed

Conversation

vhvb1989
Copy link

@vhvb1989 vhvb1989 commented Jul 13, 2022

Looking to have a feature like the one proposed in this PR where I can add a footer message as a hint that there are more items in the survey.

Related to: Azure/azure-dev#66

I am adding only the support for Select. If this idea and implementation would be OK, I could update multi-select and create some test cases.

@vhvb1989 vhvb1989 changed the title adding footer msg support Adding footer message to Survey Jul 13, 2022
@mislav
Copy link
Collaborator

mislav commented Jul 14, 2022

Thanks for proposing this!

I'm wary of adding a new overly-specific configuration option. Generally, if there was a way to indicate more items below or after the "fold", I'd be into that, but I would like to see this generalized solution built into the current configuration around pagination, and not being called something vague like a "footer".

Until this feature is available in Survey, would it be an option for your app to customize the template string to add the "below the fold" indicator? I'm thinking that you might not need to make any changes to Survey in order to override this string in your app

survey/select.go

Lines 69 to 85 in e47352f

var SelectQuestionTemplate = `
{{- define "option"}}
{{- if eq .SelectedIndex .CurrentIndex }}{{color .Config.Icons.SelectFocus.Format }}{{ .Config.Icons.SelectFocus.Text }} {{else}}{{color "default"}} {{end}}
{{- .CurrentOpt.Value}}{{ if ne ($.GetDescription .CurrentOpt) "" }} - {{color "cyan"}}{{ $.GetDescription .CurrentOpt }}{{end}}
{{- color "reset"}}
{{end}}
{{- if .ShowHelp }}{{- color .Config.Icons.Help.Format }}{{ .Config.Icons.Help.Text }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}}
{{- color .Config.Icons.Question.Format }}{{ .Config.Icons.Question.Text }} {{color "reset"}}
{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}}
{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}}
{{- else}}
{{- " "}}{{- color "cyan"}}[Use arrows to move, type to filter{{- if and .Help (not .ShowHelp)}}, {{ .Config.HelpInput }} for more help{{end}}]{{color "reset"}}
{{- "\n"}}
{{- range $ix, $option := .PageEntries}}
{{- template "option" $.IterateOption $ix $option}}
{{- end}}
{{- end}}`

@vhvb1989
Copy link
Author

vhvb1989 commented Jul 18, 2022

Thanks for proposing this!

I'm wary of adding a new overly-specific configuration option. Generally, if there was a way to indicate more items below or after the "fold", I'd be into that, but I would like to see this generalized solution built into the current configuration around pagination, and not being called something vague like a "footer".

Until this feature is available in Survey, would it be an option for your app to customize the template string to add the "below the fold" indicator? I'm thinking that you might not need to make any changes to Survey in order to override this string in your app

survey/select.go

Lines 69 to 85 in e47352f

var SelectQuestionTemplate = `
{{- define "option"}}
{{- if eq .SelectedIndex .CurrentIndex }}{{color .Config.Icons.SelectFocus.Format }}{{ .Config.Icons.SelectFocus.Text }} {{else}}{{color "default"}} {{end}}
{{- .CurrentOpt.Value}}{{ if ne ($.GetDescription .CurrentOpt) "" }} - {{color "cyan"}}{{ $.GetDescription .CurrentOpt }}{{end}}
{{- color "reset"}}
{{end}}
{{- if .ShowHelp }}{{- color .Config.Icons.Help.Format }}{{ .Config.Icons.Help.Text }} {{ .Help }}{{color "reset"}}{{"\n"}}{{end}}
{{- color .Config.Icons.Question.Format }}{{ .Config.Icons.Question.Text }} {{color "reset"}}
{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}}
{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}}
{{- else}}
{{- " "}}{{- color "cyan"}}[Use arrows to move, type to filter{{- if and .Help (not .ShowHelp)}}, {{ .Config.HelpInput }} for more help{{end}}]{{color "reset"}}
{{- "\n"}}
{{- range $ix, $option := .PageEntries}}
{{- template "option" $.IterateOption $ix $option}}
{{- end}}
{{- end}}`

Thank you @mislav
I have explored the template-override approach, but the template logic becomes extra complicated as it needs to figure it out if the last item from .Select.Options is in .PageEntries !!
It would be much simpler if this information is returned by paginate() fn and passed to SelectTemplateData. Then the template can show the footer message only when user is not seeing the last page.

@AlecAivazis AlecAivazis mentioned this pull request Sep 22, 2022
@AlecAivazis
Copy link
Owner

I'm going to close this PR since it's gone a bit stale. I agree we want something like this in general so let's try to figure out what the right API is that gives us a little more flexibility than a fixed string. For example, I'd like to be able to say 5 more at the bottom. I've opened #453 for that discussion

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants