New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop using asynchronous requests on the edit form #3147
Conversation
|
||
it 'creates a row when something is selected', -> | ||
spyOn(target.input, 'val').and.returnValue('123'); | ||
spyOn(target, 'searchData').and.returnValue({ id: '123', text: 'foo bar' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line exceeds maximum allowed length. Length is 82, max is 80.
Line contains a trailing semicolon.
expect(target.errors).toEqual([ 'ID cannot be empty.' ]) | ||
|
||
it 'creates a row when something is selected', -> | ||
spyOn(target.input, 'val').and.returnValue('123'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
it 'creates a row when something is selected', -> | ||
spyOn(target.input, 'val').and.returnValue('123'); | ||
spyOn(target, 'searchData').and.returnValue({ id: '123', text: 'foo bar' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line exceeds maximum allowed length. Length is 82, max is 80.
Line contains a trailing semicolon.
expect(target.errors).toEqual([ 'ID cannot be empty.' ]) | ||
|
||
it 'creates a row when something is selected', -> | ||
spyOn(target.input, 'val').and.returnValue('123'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
|
||
# verify that the ajax call was made | ||
expect(@spy_on_json).toHaveBeenCalled() | ||
expect(target.select2('open')).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains a trailing semicolon.
dc74034
to
8e41a1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Largely looks good to me. Left a few suggestions/questions. Would like someone else to review in depth.
end | ||
|
||
def ability | ||
::Ability.new(user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be memoized to avoid having to create a new Ability
instance per call to #add
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Although it won't be noticeable compared to the time required to write to solr.
end | ||
|
||
# Remove the object from the members set and the ordered members list | ||
def remove(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method also do an ability check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the controller is doing an ability check for this object before we get here.
%> | ||
<%= text_field_tag "find_#{name}", | ||
'', | ||
placeholder: 'Search for a work', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in i18n?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be.
These requests caused the lock to be lost, so the page couldn't be saved (#3127). Completely removed the "Add parent relationships" section as this was not locking the parent. It was unclear how we should simultaneously update multiple objects and what should happen if the lock for one of them was stale. This should also fix #3133 as we are no longer passing the ordered_member_ids as an attribute to the work actor for update. Instead we are using a custom attribute and only making adds and deletions instead of rewriting the whole set. Fixes #3133 Fixes #3127
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran through the forms locally and it worked well. 👍
These requests caused the lock to be lost, so the page couldn't be saved
(#3127). Completely removed the "Add parent relationships" section as
this was not locking the parent. It was unclear how we should
simultaneously update multiple objects and what should happen if the
lock for one of them was stale.
This should also fix #3133 as we are no longer passing the
ordered_member_ids as an attribute to the work actor for update. Instead
we are using a custom attribute and only making adds and deletions
instead of rewriting the whole set.
Fixes #3133
Fixes #3127