Открыть боковую панель
nt_test133
nt_project_uxpg8lvcuq8w
Коммиты
62005593
Не подтверждена
Коммит
62005593
создал
Авг 20, 2016
по автору
Luke Bennett
Просмотр файлов
Updated validation error UI to be in line with the improved login/signup page in #13937
владелец
eab157f5
Изменения
3
Скрыть пробелы
Построчно
Рядом
app/assets/javascripts/username_validator.js.es6
Просмотр файла @
62005593
...
...
@@ -12,37 +12,27 @@
this.iconElement = $('<i></i>');
this.inputElement.parent().append(this.iconElement);
le
t debounceTimeout = _.debounce((username) => {
cons
t debounceTimeout = _.debounce((username) => {
this.validateUsername(username);
}, debounceTimeoutDuration);
this.inputElement.keyup(() => {
this.iconElement.removeClass()
.tooltip('destroy')
;
le
t username = this.inputElement.val();
this.iconElement.removeClass();
cons
t username = this.inputElement.val();
if (username === '') return;
this.iconElement.addClass(loadingIconClasses);
debounceTimeout(username);
});
}
validateUsername(username) {
this.iconElement.addClass(loadingIconClasses);
$.ajax({
type: 'GET',
url: `/u/${username}/exists`,
dataType: 'json',
success: (res) => {
if (res.exists) {
this.iconElement
.removeClass().addClass(errorIconClasses)
.tooltip({
title: usernameInUseMessage.replace(/\$1/g, username),
placement: tooltipPlacement
});
} else {
this.iconElement
.removeClass().addClass(successIconClasses)
.tooltip('destroy');
}
this.iconElement.removeClass();
if (res.exists) this.inputElement.addClass('validation-error');
}
});
}
...
...
app/assets/stylesheets/pages/login.scss
Просмотр файла @
62005593
...
...
@@ -71,12 +71,10 @@
position
:
absolute
;
right
:
8px
;
top
:
12px
;
&
.success
{
color
:
$green-normal
;
}
&
.error
{
color
:
$red-normal
;
}
}
.validation-error
{
border
:
1px
solid
$red-normal
;
box-shadow
:
0
0
3px
$red-normal
;
}
}
}
...
...
spec/features/users_spec.rb
Просмотр файла @
62005593
...
...
@@ -50,18 +50,16 @@
@username_field
=
find
'.username'
end
scenario
'shows an error
icon
if the username already exists'
do
scenario
'shows an error
border
if the username already exists'
do
fill_in
username_input
,
with:
user
.
username
expect
(
@username_field
).
to
have_css
loading_icon
wait_for_ajax
expect
(
@username_field
).
to
have_css
'.
fa.
error'
expect
(
@username_field
).
to
have_css
'.
validation-
error'
end
scenario
'show
s
a
success icon
if the username is available'
do
scenario
'
doesn\'t
show a
n error border
if the username is available'
do
fill_in
username_input
,
with:
'new-user'
expect
(
@username_field
).
to
have_css
loading_icon
wait_for_ajax
expect
(
@username_field
).
to
have_css
'.
fa.success
'
expect
(
@username_field
).
not_
to
have_css
'.
validation-error
'
end
end
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать