mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Add tooltip to disabled upload button to specify what is blocking the upload
This commit is contained in:
@@ -14,6 +14,7 @@ import { uiCommitChanges } from './commit_changes';
|
||||
import { uiCommitWarnings } from './commit_warnings';
|
||||
import { uiRawTagEditor } from './raw_tag_editor';
|
||||
import { utilDetect } from '../util/detect';
|
||||
import { tooltip } from '../util/tooltip';
|
||||
import { utilRebind } from '../util';
|
||||
import { modeBrowse } from '../modes';
|
||||
import { svgIcon } from '../svg';
|
||||
@@ -258,13 +259,16 @@ export function uiCommit(context) {
|
||||
.attr('class', 'label')
|
||||
.text(t('commit.cancel'));
|
||||
|
||||
buttonEnter
|
||||
var uploadButton = buttonEnter
|
||||
.append('button')
|
||||
.attr('class', 'action button save-button')
|
||||
.append('span')
|
||||
.attr('class', 'action button save-button');
|
||||
|
||||
uploadButton.append('span')
|
||||
.attr('class', 'label')
|
||||
.text(t('commit.save'));
|
||||
|
||||
var uploadBlockerTooltip = getUploadBlockerMessage();
|
||||
|
||||
// update
|
||||
buttonSection = buttonSection
|
||||
.merge(buttonEnter);
|
||||
@@ -276,15 +280,21 @@ export function uiCommit(context) {
|
||||
});
|
||||
|
||||
buttonSection.selectAll('.save-button')
|
||||
.attr('disabled', function() {
|
||||
var n = d3_select('#preset-input-comment').node();
|
||||
return (n && n.value.length) ? null : true;
|
||||
})
|
||||
.classed('disabled', uploadBlockerTooltip !== undefined)
|
||||
.on('click.save', function() {
|
||||
this.blur(); // avoid keeping focus on the button - #4641
|
||||
dispatch.call('save', this, _changeset);
|
||||
if (!d3_select(this).classed('disabled')) {
|
||||
this.blur(); // avoid keeping focus on the button - #4641
|
||||
dispatch.call('save', this, _changeset);
|
||||
}
|
||||
});
|
||||
|
||||
// remove any existing tooltip
|
||||
buttonSection.selectAll('.save-button .tooltip').remove();
|
||||
|
||||
if (uploadBlockerTooltip) {
|
||||
buttonSection.selectAll('.save-button')
|
||||
.call(tooltip().title(uploadBlockerTooltip).placement('top'));
|
||||
}
|
||||
|
||||
// Raw Tag Editor
|
||||
var tagSection = body.selectAll('.tag-section.raw-tag-editor')
|
||||
@@ -323,6 +333,22 @@ export function uiCommit(context) {
|
||||
}
|
||||
|
||||
|
||||
function getUploadBlockerMessage() {
|
||||
var errorCount = context.issueManager().getErrors().length;
|
||||
if (errorCount > 0) {
|
||||
return t('commit.outstanding_errors_message', { count: errorCount });
|
||||
|
||||
} else {
|
||||
var n = d3_select('#preset-input-comment').node();
|
||||
var hasChangesetComment = n && n.value.length > 0;
|
||||
if (!hasChangesetComment) {
|
||||
return t('commit.comment_needed_message');
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function changeTags(changed, onInput) {
|
||||
if (changed.hasOwnProperty('comment')) {
|
||||
if (changed.comment === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user