-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automatically download adjacent ways when splitting a line
- Loading branch information
Showing
4 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { t } from '../core/localizer'; | ||
import { uiConfirm } from './confirm'; | ||
|
||
/** @param {iD.Context} context */ | ||
export function uiAsyncModal(context) { | ||
let _modal; | ||
|
||
/** | ||
* Open a model, and returns a promise. The promise | ||
* resolves with `true` if the user clicked 'Okay', | ||
* or `false` if they clicked 'Cancel' | ||
* @returns {Promise<boolean>} | ||
*/ | ||
function open(title, subtitle) { | ||
return new Promise((resolve) => { | ||
context.container().call(selection => { | ||
_modal = uiConfirm(selection).okButton(); | ||
|
||
_modal.select('.modal-section.header') | ||
.append('h3') | ||
.call(title); | ||
|
||
// insert the modal body | ||
const textSection = _modal.select('.modal-section.message-text'); | ||
textSection.call(subtitle); | ||
|
||
// insert a cancel button | ||
const buttonSection = _modal.select('.modal-section.buttons'); | ||
|
||
buttonSection | ||
.insert('button', '.ok-button') | ||
.attr('class', 'button cancel-button secondary-action') | ||
.call(t.append('confirm.cancel')); | ||
|
||
|
||
buttonSection.select('.cancel-button') | ||
.on('click.cancel', () => { | ||
_modal.remove(); | ||
resolve(false); | ||
}); | ||
|
||
buttonSection.select('.ok-button') | ||
.on('click.save', () => resolve(true)); | ||
}); | ||
}); | ||
} | ||
|
||
function close() { | ||
_modal.remove(); | ||
_modal = undefined; | ||
} | ||
|
||
|
||
return { open, close }; | ||
} |