DEV-1587: fix collection edit modal bugs #112
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
'new collection' modal trigger user always anonymous
current behavior
From
mb
landing page, when a user clicks "New Collection" (from the collection toolbar under "Featured collections" and above the listing of collections), the New Collection (also sometimes says Edit Collection, depending on the situation) modal appears. Regardless of login status, this modal tells the user their new collection will be temporary unless they log in (even if the user is already logged in).the fix
The modal already had a
userIsAnonymous
variable but it wasn't getting set in this context (via the results toolbar inmb
) so the change in UI never happened. (To be fair, this variable is getting set when you create a collection vials
collection toolbar). Instead of relying on passing down the variable from thels
ormb
XML, I'm using theHT
global variable that holds info about login status:HT.login_status.logged_in
.to test
On dev-3, click the "New Collection" button before logging in and see the usual "This collection will be temporary" message. Log in, then click the button again. The message should not appear and you should have the ability to make the collection public.
modal allows form submit without collection name (which leads to Application Error)
current behavior
If you create a new collection but don't give it a name in the form, you can still submit the form (via "Save Changes" button). After the form is submitted, the application can't redirect you to your collection or list of collections because you didn't supply any information, so you'll get an "Application Error" page instead.
the fix
I added form validation to the "Collection name" field in the New Collection form.
to test
On dev-3, click the "New Collection" button and without filling out any fields, click "Save Changes" to submit the form. You should now get two error messages: one under the Collection Name field and another in the footer of the modal letting you know that you need to fix something and try again.