Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conditional parameter- hide/show fields depending on, what user selects #5648

Closed
s19946 opened this issue Nov 16, 2022 · 5 comments
Closed
Assignees
Labels
area: Visual Studio The issue is related to Visual Studio New Project Dialog features related to template engine. gathering-feedback The issue requires feedback in order to be planned, please comment if the feature is useful for you Iteration:2023January size:0.5 triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Milestone

Comments

@s19946
Copy link

s19946 commented Nov 16, 2022

Is it possible to hide/show fields depending on, what a user selects from the dropdown field in the template?
Let's say I have a dropdown with the options: "A", "B", "C". If user selects "A", then it shows up a text field below: "Text1",
if user selects "B", then it shows up a different text field below: "Text2" and some checkbox(bool), if "C" nothing happened.
Depending on, what user wrote/selected, different files would show up after creating a new template .

"symbols": {
    "Letter": {
      "type": "parameter",
      "datatype": "choice",
      "choices": [
        {
          "choice": "A"
        },
        {
          "choice": "B"
        },
        {
          "choice": "C"
        },
   "Text1": {
      "type": "parameter",
      "datatype": "text",
    },
    "Text2": {
      "type": "parameter",
      "datatype": "text",
    },
    "Checkbox": {
      "type": "parameter"
       "datatype": "bool"
    },     
}
@vlada-shubina
Copy link
Member

@s19946 this was implemented in #4491 and already supported for dotnet new.
Visual Studio is considering to add the support for the feature.

@s19946
Copy link
Author

s19946 commented Nov 16, 2022

@vlada-shubina thanks, should I use "isEnabled" to control field visibility? I tried something like below code, but the fields are still visible, no matter what choice I select

"symbols": {
	"Letter": {
	"type": "parameter",
	"datatype": "choice",
	"choices": [
			{
			"choice": "A"
			},
			{
			"choice": "B"
			},
			{
			"choice": "C"
			}
		]
	},
	"Text1": {
		"type": "parameter",
		"datatype": "text",
		"isEnabled": "Letter == A"
	},
	"Text2": {
		"type": "parameter",
		"datatype": "text",
		"isEnabled": "Letter == B"
	},
	"Checkbox": {
		"type": "parameter"
		"datatype": "bool",
		"isEnabled": "Letter == B"
	},
}

@s19946 s19946 changed the title hide/show fields depending, what user selects conditional parameter- hide/show fields depending on, what user selects Nov 18, 2022
@vlada-shubina vlada-shubina added need-investigation The issue needs the second look and more investigation area: Visual Studio The issue is related to Visual Studio New Project Dialog features related to template engine. labels Nov 21, 2022
@vlada-shubina
Copy link
Member

@s19946 isEnabled is correct flag to use.

Assuming you are testing it in Visual Studio, but the support for this feature is not implemented in Visual Studio yet.
It is only available for .NET SDK (dotnet new) at this point.

I'll keep the issue open to track the feedback on the feature.

@vlada-shubina vlada-shubina removed the need-investigation The issue needs the second look and more investigation label Nov 21, 2022
@vlada-shubina vlada-shubina added the gathering-feedback The issue requires feedback in order to be planned, please comment if the feature is useful for you label Dec 5, 2022
@YuliiaKovalova YuliiaKovalova added the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Jan 3, 2023
@donJoseLuis donJoseLuis added this to the 8.0P1 milestone Jan 5, 2023
@YuliiaKovalova
Copy link
Member

The relevant issue was created on the developercommunity.
You can track the state there.

mkArtakMSFT pushed a commit to dotnet/aspnetcore that referenced this issue Sep 15, 2023
…des. (#50684)

Fixes #50433 (Add root level interactivity option)
Fixes #50646 (Remove workaround for Counter component)
Fixes #50636 (Clarify the names of the interactive render modes)

In terms of the code we now emit, there should be nothing controversial here. The template just has to do quite a bit of if/else in many places to account for all these options and how rendermodes are used and not used based on them.

The PR is big because the renames have really wide impact, but almost all the "files changes" are just due to renames. The only real code changes are in the project templates.

# Testing impact

Adding this option, the BlazorWeb template now has **so many** possible combinations of options, including:

 - Whether or not to enable Server interactivity
 - Whether or not to enable WebAssembly interactivity
 - Whether or not to be interactive from the root
 - Whether or not to include sample content
 - Whether or not to use ProgramMain

So that's around 32 combinations of output - without even accounting for auth options! We don't currently have E2E verification of any of them, as those tests are skipped due to unreliability. We're going to have to lean hard on CTI validations for this, and make sure all the important combinations are covered - cc @mkArtakMSFT.

# Options design update

Having a list of 6 separate checkboxes in VS is pretty unpleasant and hard to understand:

<img src="https://github.com/dotnet/aspnetcore/assets/1101362/93713e83-0793-4140-82e1-95ca63580e3d" width="500" />

So, in this PR I'm proposing (and have implemented, but we can still change it), a change to use dropdowns for the interactivity type and location options. This reduces the number of inputs by one, and means they can be more self-describing:

<img src="https://github.com/dotnet/aspnetcore/assets/1101362/649c93fd-d464-499c-b1f2-36436ebf4e3c" width="500" />

 * The "interactivity type" choices are:
   * **None**
   * **Server** (default)
   * **WebAssembly**
   * **Auto (Server and WebAssembly)**.
 * The "interactivity location" choices are:
   * **Per page/component** (default)
   * **Global**

Note that "interactivity location" is disabled if interactivity type == "None", but [only CLI honors that right now](dotnet/templating#5648) (VS should add support later, and until then, location will have no effect if there's no interactivity).

I think this is much easier to understand, since you no longer have to infer that enabling both Server and WebAssembly means you're going to get Auto. It's also much better in the CLI, since it was completely ridiculous before that `--use-server` defaulted to true but `--use-wasm` defaulted to false, so to get WebAssembly you needed to set `--use-server false --use wasm`. Now you would say `--interactivity webassembly` (and not `wasm` - that was weird too).

![image](https://github.com/dotnet/aspnetcore/assets/1101362/0b4751ad-f91b-4bac-8edf-9e31aa761fbf)
@brodrigz
Copy link

Still not supported on Visual Studio 2022, is this being tracked anywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Visual Studio The issue is related to Visual Studio New Project Dialog features related to template engine. gathering-feedback The issue requires feedback in order to be planned, please comment if the feature is useful for you Iteration:2023January size:0.5 triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Projects
None yet
Development

No branches or pull requests

5 participants