Restrict registration UI

pull/1/head
yflory 4 years ago
parent 22e278b84d
commit 8735fafe0d

@ -253,36 +253,32 @@ define([
create['registration'] = function () { create['registration'] = function () {
var key = 'registration'; var key = 'registration';
var $div = makeBlock(key, true); // Msg.admin_registrationHint, .admin_registrationTitle, .admin_registrationButton var $div = makeBlock(key); // Msg.admin_registrationHint, .admin_registrationTitle, .admin_registrationButton
var $button = $div.find('button');
var state = APP.instanceStatus.restrictRegistration; var state = APP.instanceStatus.restrictRegistration;
if (state) { var $cbox = $(UI.createCheckbox('cp-settings-userfeedback',
$button.text(Messages.admin_registrationAllow); Messages.admin_registrationTitle,
} else { state, { label: { class: 'noTitle' } }));
$button.removeClass('btn-primary').addClass('btn-danger'); var spinner = UI.makeSpinner($cbox);
} var $checkbox = $cbox.find('input').on('change', function() {
var called = false; spinner.spin();
$div.find('button').click(function () { var val = $checkbox.is(':checked') || false;
called = true; $checkbox.attr('disabled', 'disabled');
sFrameChan.query('Q_ADMIN_RPC', { sFrameChan.query('Q_ADMIN_RPC', {
cmd: 'ADMIN_DECREE', cmd: 'ADMIN_DECREE',
data: ['RESTRICT_REGISTRATION', [!state]] data: ['RESTRICT_REGISTRATION', [val]]
}, function (e) { }, function (e) {
if (e) { UI.warn(Messages.error); console.error(e); } if (e) { UI.warn(Messages.error); console.error(e); }
APP.updateStatus(function () { APP.updateStatus(function () {
called = false; spinner.done();
state = APP.instanceStatus.restrictRegistration; state = APP.instanceStatus.restrictRegistration;
if (state) { $checkbox[0].checked = state;
console.log($button); $checkbox.removeAttr('disabled');
$button.text(Messages.admin_registrationAllow);
$button.addClass('btn-primary').removeClass('btn-danger');
} else {
$button.text(Messages.admin_registrationButton);
$button.removeClass('btn-primary').addClass('btn-danger');
}
}); });
}); });
}); });
$cbox.appendTo($div);
return $div; return $div;
}; };

Loading…
Cancel
Save