settings: Add save instructions below pill container on changes.

Fixes #8088.
This commit is contained in:
Shubham Padia 2018-03-15 17:26:31 +05:30 committed by Tim Abbott
parent dd5ce49ce0
commit 4fb1704e6e
4 changed files with 51 additions and 2 deletions

View File

@ -29,6 +29,7 @@ var cancel_selector = "#user-groups #1 .cancel";
var saved_selector = "#user-groups #1 .saved"; var saved_selector = "#user-groups #1 .saved";
var name_selector = "#user-groups #1 .name"; var name_selector = "#user-groups #1 .name";
var description_selector = "#user-groups #1 .description"; var description_selector = "#user-groups #1 .description";
var instructions_selector = "#user-groups #1 .save-instructions";
(function test_populate_user_groups() { (function test_populate_user_groups() {
var realm_user_group = { var realm_user_group = {
@ -178,6 +179,7 @@ var description_selector = "#user-groups #1 .description";
var saved_fade_out_called = false; var saved_fade_out_called = false;
var cancel_fade_to_called = false; var cancel_fade_to_called = false;
var instructions_fade_to_called = false;
$(saved_selector).fadeOut = function () { $(saved_selector).fadeOut = function () {
saved_fade_out_called = true; saved_fade_out_called = true;
}; };
@ -193,12 +195,25 @@ var description_selector = "#user-groups #1 .description";
$(cancel_selector).fadeTo = function () { $(cancel_selector).fadeTo = function () {
cancel_fade_to_called = true; cancel_fade_to_called = true;
}; };
$(instructions_selector).css = function (data) {
if (typeof(data) === 'string') {
assert.equal(data, 'display');
}
assert.equal(typeof(data), 'object');
assert.equal(data.display, 'block');
assert.equal(data.opacity, '0');
return $(instructions_selector);
};
$(instructions_selector).fadeTo = function () {
instructions_fade_to_called = true;
};
text_cleared = false; text_cleared = false;
config.updater(alice); config.updater(alice);
// update_cancel_button is called. // update_cancel_button is called.
assert(saved_fade_out_called); assert(saved_fade_out_called);
assert(cancel_fade_to_called); assert(cancel_fade_to_called);
assert(instructions_fade_to_called);
assert.equal(text_cleared, true); assert.equal(text_cleared, true);
}()); }());
input_typeahead_called = true; input_typeahead_called = true;
@ -458,20 +473,27 @@ var description_selector = "#user-groups #1 .description";
}; };
var cancel_fade_out_called = false; var cancel_fade_out_called = false;
var instructions_fade_out_called = false;
$(cancel_selector).show(); $(cancel_selector).show();
$(cancel_selector).fadeOut = function () { $(cancel_selector).fadeOut = function () {
cancel_fade_out_called = true; cancel_fade_out_called = true;
}; };
$(instructions_selector).fadeOut = function () {
instructions_fade_out_called = true;
};
// Cancel button removed if user group if user group has no changes. // Cancel button removed if user group if user group has no changes.
var fake_this = $.create('fake-#update_cancel_button'); var fake_this = $.create('fake-#update_cancel_button');
handler_name.call(fake_this); handler_name.call(fake_this);
assert(cancel_fade_out_called); assert(cancel_fade_out_called);
assert(instructions_fade_out_called);
// Check for handler_desc to achieve 100% coverage. // Check for handler_desc to achieve 100% coverage.
cancel_fade_out_called = false; cancel_fade_out_called = false;
instructions_fade_out_called = false;
handler_desc.call(fake_this); handler_desc.call(fake_this);
assert(cancel_fade_out_called); assert(cancel_fade_out_called);
assert(instructions_fade_out_called);
}()); }());
(function test_user_groups_save_group_changes_triggered() { (function test_user_groups_save_group_changes_triggered() {
@ -489,6 +511,10 @@ var description_selector = "#user-groups #1 .description";
var api_endpoint_called = false; var api_endpoint_called = false;
var cancel_fade_out_called = false; var cancel_fade_out_called = false;
var saved_fade_to_called = false; var saved_fade_to_called = false;
var instructions_fade_out_called = false;
$(instructions_selector).fadeOut = function () {
instructions_fade_out_called = true;
};
$(cancel_selector).fadeOut = function () { $(cancel_selector).fadeOut = function () {
cancel_fade_out_called = true; cancel_fade_out_called = true;
}; };
@ -516,6 +542,7 @@ var description_selector = "#user-groups #1 .description";
}); });
opts.success(); opts.success();
assert(cancel_fade_out_called); assert(cancel_fade_out_called);
assert(instructions_fade_out_called);
assert(saved_fade_to_called); assert(saved_fade_to_called);
}()); }());
}; };
@ -562,6 +589,10 @@ var description_selector = "#user-groups #1 .description";
var cancel_fade_out_called = false; var cancel_fade_out_called = false;
var saved_fade_to_called = false; var saved_fade_to_called = false;
var instructions_fade_out_called = false;
$(instructions_selector).fadeOut = function () {
instructions_fade_out_called = true;
};
$(cancel_selector).fadeOut = function () { $(cancel_selector).fadeOut = function () {
cancel_fade_out_called = true; cancel_fade_out_called = true;
}; };
@ -582,6 +613,7 @@ var description_selector = "#user-groups #1 .description";
(function test_post_success() { (function test_post_success() {
opts.success(); opts.success();
assert(cancel_fade_out_called); assert(cancel_fade_out_called);
assert(instructions_fade_out_called);
assert(saved_fade_to_called); assert(saved_fade_to_called);
}()); }());
}; };

View File

@ -79,21 +79,28 @@ exports.populate_user_groups = function () {
function update_cancel_button() { function update_cancel_button() {
var cancel_button = $('#user-groups #' + data.id + ' .cancel'); var cancel_button = $('#user-groups #' + data.id + ' .cancel');
var saved_button = $('#user-groups #' + data.id + ' .saved'); var saved_button = $('#user-groups #' + data.id + ' .saved');
var save_instructions = $('#user-groups #' + data.id + ' .save-instructions');
if (is_user_group_changed() && if (is_user_group_changed() &&
!cancel_button.is(':visible')) { !cancel_button.is(':visible')) {
saved_button.fadeOut(0); saved_button.fadeOut(0);
cancel_button.css({display: 'inline-block', opacity: 0}).fadeTo(400, 1); cancel_button.css({display: 'inline-block', opacity: 0}).fadeTo(400, 1);
save_instructions.css({display: 'block', opacity: 0}).fadeTo(400, 1);
} else if (!is_user_group_changed() && } else if (!is_user_group_changed() &&
cancel_button.is(':visible')) { cancel_button.is(':visible')) {
cancel_button.fadeOut(); cancel_button.fadeOut();
save_instructions.fadeOut();
} }
} }
function show_saved_button() { function show_saved_button() {
var cancel_button = $('#user-groups #' + data.id + ' .cancel'); var cancel_button = $('#user-groups #' + data.id + ' .cancel');
var saved_button = $('#user-groups #' + data.id + ' .saved'); var saved_button = $('#user-groups #' + data.id + ' .saved');
var save_instructions = $('#user-groups #' + data.id + ' .save-instructions');
if (!saved_button.is(':visible')) { if (!saved_button.is(':visible')) {
cancel_button.fadeOut(0); cancel_button.fadeOut(0);
save_instructions.fadeOut(0);
saved_button.css({display: 'inline-block', opacity: 0}).fadeTo(400, 1); saved_button.css({display: 'inline-block', opacity: 0}).fadeTo(400, 1);
} }
} }

View File

@ -979,6 +979,13 @@ input[type=checkbox].inline-block {
float: right; float: right;
} }
#user-groups .save-instructions {
display: none;
opacity: 0;
color: #333;
font-size: 0.9em;
}
/* -- new settings overlay -- */ /* -- new settings overlay -- */
#settings_page { #settings_page {
height: 95vh; height: 95vh;

View File

@ -9,7 +9,7 @@
{{t 'Saved' }} {{t 'Saved' }}
</button> </button>
<button class="save-status cancel"> <button class="save-status cancel">
{{t 'Cancel' }} {{t 'Discard changes' }}
</button> </button>
<button class="button rounded small delete btn-danger"> <button class="button rounded small delete btn-danger">
{{t 'Delete' }} {{t 'Delete' }}
@ -20,6 +20,9 @@
<div class="pill-container" data-group-pills="{{name}}"> <div class="pill-container" data-group-pills="{{name}}">
<div class="input" contenteditable="true" data-placeholder="{{t 'Add member...' }}"></div> <div class="input" contenteditable="true" data-placeholder="{{t 'Add member...' }}"></div>
</div> </div>
<div class="save-instructions">
{{t 'Click outside the input box to save. We\'ll automatically notify anyone that was added or removed.'}}
</div>
</p> </p>
</div> </div>
{{/with}} {{/with}}