Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
cd700231
Unverified
Commit
cd700231
authored
Dec 11, 2017
by
Douglas Hall
Committed by
GitHub
Dec 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16861 from edx/douglashall/ENT-796
Fix optional registration fields toggle.
parents
9b10dd70
ede8ee4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
9 deletions
+43
-9
lms/static/js/spec/student_account/register_spec.js
+28
-2
lms/static/js/student_account/views/RegisterView.js
+15
-7
No files found.
lms/static/js/spec/student_account/register_spec.js
View file @
cd700231
...
...
@@ -213,7 +213,12 @@
}
]
};
var
createRegisterView
=
function
(
that
)
{
var
createRegisterView
=
function
(
that
,
formFields
)
{
var
fields
=
formFields
;
if
(
typeof
fields
===
'undefined'
)
{
fields
=
FORM_DESCRIPTION
.
fields
;
}
// Initialize the register model
model
=
new
RegisterModel
({},
{
url
:
FORM_DESCRIPTION
.
submit_url
,
...
...
@@ -222,7 +227,7 @@
// Initialize the register view
view
=
new
RegisterView
({
fields
:
FORM_DESCRIPTION
.
fields
,
fields
:
fields
,
model
:
model
,
thirdPartyAuth
:
THIRD_PARTY_AUTH
,
platformName
:
PLATFORM_NAME
...
...
@@ -537,6 +542,27 @@
// The iframe has been deleted
expect
(
$content
.
find
(
'iframe'
).
length
).
toEqual
(
0
);
});
it
(
'displays optional fields toggle'
,
function
()
{
createRegisterView
(
this
);
expect
(
view
.
$
(
'.checkbox-optional_fields_toggle'
)).
toBeVisible
();
});
it
(
'hides optional fields toggle when there are no visible optional fields'
,
function
()
{
createRegisterView
(
this
,
[
{
placeholder
:
''
,
name
:
'hidden_optional'
,
label
:
'Hidden Optional'
,
defaultValue
:
''
,
type
:
'hidden'
,
required
:
false
,
instructions
:
'Used for testing hidden input fields that are optional.'
,
restrictions
:
{}
}
]);
expect
(
view
.
$
(
'.checkbox-optional_fields_toggle'
)).
toHaveClass
(
'hidden'
);
});
});
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
lms/static/js/student_account/views/RegisterView.js
View file @
cd700231
...
...
@@ -94,27 +94,35 @@
buildForm
:
function
(
data
)
{
var
html
=
[],
i
,
field
,
len
=
data
.
length
,
requiredFields
=
[],
optionalFields
=
[];
this
.
fields
=
data
;
this
.
hasOptionalFields
=
false
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
data
[
i
].
errorMessages
)
{
field
=
data
[
i
];
if
(
field
.
errorMessages
)
{
// eslint-disable-next-line no-param-reassign
data
[
i
].
errorMessages
=
this
.
escapeStrings
(
data
[
i
]
.
errorMessages
);
field
.
errorMessages
=
this
.
escapeStrings
(
field
.
errorMessages
);
}
if
(
data
[
i
]
.
required
)
{
requiredFields
.
push
(
data
[
i
]
);
if
(
field
.
required
)
{
requiredFields
.
push
(
field
);
}
else
{
optionalFields
.
push
(
data
[
i
]);
if
(
field
.
type
!==
'hidden'
)
{
// For the purporse of displaying the optional field toggle,
// the form should be considered to have optional fields
// only if all of the optional fields are being rendering as
// input elements that are visible on the page.
this
.
hasOptionalFields
=
true
;
}
optionalFields
.
push
(
field
);
}
}
this
.
hasOptionalFields
=
optionalFields
.
length
>
0
;
html
=
this
.
renderFields
(
requiredFields
,
'required-fields'
);
html
.
push
.
apply
(
html
,
this
.
renderFields
(
optionalFields
,
'optional-fields'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment