From 9bba0ed57ef30b1dd15d378be7b03fdf449f6a69 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 10 Aug 2017 22:04:44 -0400 Subject: [PATCH] Move request review up next to comment --- modules/ui/commit.js | 61 +++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/modules/ui/commit.js b/modules/ui/commit.js index 72e23306e..37e745e2a 100644 --- a/modules/ui/commit.js +++ b/modules/ui/commit.js @@ -65,16 +65,18 @@ export function uiCommit(context) { .append('div') .attr('class', 'body'); - var commentSection = body + + // Fields + var fieldSection = body .append('div') .attr('class', 'modal-section form-field commit-form'); - commentSection + fieldSection .append('label') .attr('class', 'form-label') .text(t('commit.message_label')); - var commentField = commentSection + var commentField = fieldSection .append('textarea') .attr('class', 'commit-form-comment') .attr('placeholder', t('commit.description_placeholder')) @@ -108,10 +110,10 @@ export function uiCommit(context) { ); }); - var clippyArea = commentSection.append('div') + var clippyArea = fieldSection.append('div') .attr('class', 'clippy-area'); - var changeSetInfo = commentSection.append('div') + var changeSetInfo = fieldSection.append('div') .attr('class', 'changeset-info'); changeSetInfo.append('a') @@ -123,6 +125,17 @@ export function uiCommit(context) { .text(t('commit.about_changeset_comments')); + var requestReview = fieldSection + .append('p') + .attr('class', 'request-review') + .text(t('commit.request_review')); + + requestReview + .append('input') + .attr('type', 'checkbox') + .on('change', toggleRequestReview()); + + // Warnings var warnings = body.selectAll('div.warning-section') .data([context.history().validate(changes)]); @@ -176,16 +189,6 @@ export function uiCommit(context) { .attr('class', 'commit-info') .text(t('commit.upload_explanation')); - var requestReview = saveSection - .append('p') - .attr('class', 'request-review') - .text(t('commit.request_review')); - - requestReview - .append('input') - .attr('type', 'checkbox') - .on('change', toggleRequestReview()); - osm.userDetails(function(err, user) { if (err) return; @@ -387,28 +390,22 @@ export function uiCommit(context) { }; } + function toggleRequestReview() { var toggled = false; - return function() { - var changeset; - if (toggled) { - changeset = updateChangeset({ - review_requested: undefined - }); - } else { - changeset = updateChangeset({ - review_requested: 'yes' - }); - } - toggled = !toggled; - var expanded = !tagSection - .selectAll('a.hide-toggle.expanded') - .empty(); - tagSection.call(rawTagEditor + return function() { + var changeset = updateChangeset({ review_requested: (toggled ? 'yes' : undefined) }); + var expanded = !tagSection.selectAll('a.hide-toggle.expanded').empty(); + + toggled = !toggled; + + tagSection + .call(rawTagEditor .expanded(expanded) .readOnlyTags(readOnlyTags) - .tags(_.clone(changeset.tags))); + .tags(_.clone(changeset.tags)) + ); }; }