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

Would like to see the PromptDialog allow for multiple field entries #1

Open
aherreraGH opened this issue Dec 17, 2018 · 14 comments
Open
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@aherreraGH
Copy link

Currently the PromptDialog only accepts one value. There should be an array that can be submitted in the "value" field, and then the done() callback function can do a loop through the results.

ex:

    core.make('osjs/dialog', 'prompt', {
      message: `Type in your name:`,
      value: ['First Name', 'Last Name'] 
    }, done(value => {...}
@andersevenrud andersevenrud self-assigned this Dec 17, 2018
@andersevenrud andersevenrud added the enhancement New feature or request label Dec 17, 2018
@aherreraGH
Copy link
Author

aherreraGH commented Dec 17, 2018

Would you need to know the type of value expected? i.e. string, or numeric so a spinner can be thrown in. Or a drop-down list of choices? Just thinking out loud here.

Another thought.. what about a dialog that asks the user to select from a series of images? Yeah, I'm getting ahead of myself here, just thinking of the possibilities.

@andersevenrud
Copy link
Member

Another thing that could be added is generic inputs, not just text fields:

{
  values: ['default text', true],
  inputs: [{
    type: "TextField",
    attributes: {
       placeholder: "First Name"
     }
  }, {
    type: "OptionField",
    attributes: {
      choices: [{a: 'Choice A', b: 'Choice B'}]
    }
  }]
}

Maybe something like this ?

@andersevenrud
Copy link
Member

Another thought.. what about a dialog that asks the user to select from a series of images? Yeah, I'm getting ahead of myself here, just thinking of the possibilities.

You can implement custom dialogs both globally and programatically.

If it's just application spesific, a custom Window is probably good enough.

@aherreraGH
Copy link
Author

aherreraGH commented Dec 17, 2018

Maybe something like this ?

Yeah, I think so.

You can implement custom dialogs both globally and programatically.
If it's just application spesific, a custom Window is probably good enough.

understood

@aherreraGH
Copy link
Author

aherreraGH commented Dec 17, 2018

In your example above, the "true" is related to the option field? Just making sure I'm following, if the user selects an option, the result would be "true" that an option was selected? Or would the result be the choice title/index/value selected?

{
  values: ['default text', true],
  inputs: [{
    type: "TextField",
    attributes: {
       placeholder: "First Name"
     }
  }, {
    type: "OptionField",
    attributes: {
      choices: [{a: 'Choice A', b: 'Choice B'}]
    }
  }]
}

Tried to bold the word true.

@andersevenrud
Copy link
Member

andersevenrud commented Dec 17, 2018

Here's an exaple of how to create a custom dialog on runtime (programatically) w/standard dialog interface/base class:

  const callback = (btn, value, dialog) => {
     console.log(btn, value)
  };

  core.make('osjs/dialogs')
    .create({
      buttons: ['ok'],
      window: {
        title: 'My Dialog',
        dimension: {width: 400, height: 400}
      }
    }, (dialog) => {
      // The callback for getting dialog value
      return dialog.app.getValue();
    }, callback)
    .render(($content, dialogWindow, dialog) => {
      dialog.app = app({
        // Your local dialog state
        value: 0
      }, {
       // Your local dialog actions
       setValue: value => ({value}),
       getValue: () => state => state.value
      }, (state, actions) => dialog.createView([
          // Your local dialog view
          h(RangeField, {
            min: 0,
            max: 100,
            onchange: (ev, value) => actions.setValue(value)
          })
      ]), $content);
    });

I haven't used JSX -- but you probably get the idea

@andersevenrud
Copy link
Member

In your example above, the "true" is related to the option field? Just making sure I'm following, if the user selects an option, the result would be "true" that an option was selected? Or would the result be the choice title/index/value selected?

The array of values was defined in the same order as inputs so they could be mapped over when the UI was created. Maybe that's confusing ?

@aherreraGH
Copy link
Author

I understand the order. I guess I got confused. So, value is the text that would show up as the label for the input field, correct?

default text: [ ]

Or how would I set the label, in your example?

@andersevenrud
Copy link
Member

An entry in values is what would show up in the corresponding inputs field, yes.

Labels could probably added like this:

  inputs: [{
    type: "TextField",
    label: "My Input",
    attributes: {
       placeholder: "First Name"
     }
  }]

@aherreraGH
Copy link
Author

Your custom example is good as well, and thought about using that for more complex stuff. But, for simple and quick prompts, I like the code you posted with inputs: [].

@aherreraGH
Copy link
Author

Don't forget t update documentation accordingly, to show single input prompt and multiple inputs prompt. Assuming single input would remain the same as it is now.

@aherreraGH
Copy link
Author

aherreraGH commented Dec 17, 2018

Just thought of it, I know you have authentication prompt, but for this. What if a user is required to enter a code that they don't want to be visible, i.e. using the password prompt for some private user code. Please include type: "PasswordField" if you haven't done so already. I'm guessing you're going to have TextField, TextArea, PasswordField, OptionField, etc... ?

@andersevenrud
Copy link
Member

TextField is just a wrapper around <input />, so the type attribute is valid here.

@aherreraGH
Copy link
Author

ooh. understood.

@andersevenrud andersevenrud added help wanted Extra attention is needed good first issue Good for newcomers labels Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants