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

Add input dialogs #6327

Merged
merged 3 commits into from May 10, 2019
Merged

Add input dialogs #6327

merged 3 commits into from May 10, 2019

Conversation

@fcollonval
Copy link
Member

@fcollonval fcollonval commented May 9, 2019

References

Closes #6326

Code changes

Add three functions to request simple input from user through a dialog.

let dialog_n = getNumber({
 title: 'What\'s your code?',
 label: 'Code',
 value: 10
});
let n = (await dialog_n).value

let dialog_t = getText({
 title: 'What\'s your name?',
 label: 'Name',
 placeholder: 'John Smith',
 text: 'Bill Doe'
});
let t = (await dialog_t).value

let dialog_i = getItem({
 title: 'Choose your favourite color',
 label: 'Color',
 items: ['red', 'blue', 'green'],
 current: 2,
 editable: true
});
let i = (await dialog_i).value

The getItem can be editable.

User-facing changes

None

Backwards-incompatible changes

None

Edit: update example to reflect the fact that the function are returning a Dialog.IResult<T> and not directly the value. This means (await dialog).button.accept is available.

@jupyterlab-dev-mode
Copy link

@jupyterlab-dev-mode jupyterlab-dev-mode bot commented May 9, 2019

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@blink1073
Copy link
Member

@blink1073 blink1073 commented May 9, 2019

This a very pretty PR, well done!

@blink1073
Copy link
Member

@blink1073 blink1073 commented May 9, 2019

The CI error is because of the capitalization difference between the import and the file name.

option.textContent = item;
this._list.appendChild(option);
});
Styling.wrapSelect(this._list);
Copy link
Member

@blink1073 blink1073 May 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns a new parent node that should be the one you call this._list.

@blink1073
Copy link
Member

@blink1073 blink1073 commented May 10, 2019

The wrapper node doesn't directly have a .value, you can either store a reference to the original select node or use .firstChild.value.

@fcollonval
Copy link
Member Author

@fcollonval fcollonval commented May 10, 2019

@blink1073 thanks for the tip. And sorry for the delay, the company proxy is not git friendly 😞

@blink1073
Copy link
Member

@blink1073 blink1073 commented May 10, 2019

Ha, I can sympathize 😉. Thanks!

@blink1073 blink1073 merged commit 5211238 into jupyterlab:master May 10, 2019
9 checks passed
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
@fcollonval fcollonval deleted the 6326-input-dialog branch Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants