Skip to content
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

Merged
merged 1 commit into from Mar 17, 2017
Merged

Conversation

jcoyne
Copy link
Contributor

@jcoyne jcoyne commented Mar 14, 2017

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


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' });

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');

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);

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);

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);

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);

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' });

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');

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);

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);

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);

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);

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);

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);

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);

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);

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);

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);

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.

@jcoyne jcoyne force-pushed the remove_ajax branch 2 times, most recently from dc74034 to 8e41a1a Compare March 15, 2017 02:45
Copy link
Member

@mjgiarlo mjgiarlo left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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',
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Contributor

@dlpierce dlpierce left a 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. 👍

@hackartisan hackartisan merged commit e6a2c12 into master Mar 17, 2017
@hackartisan hackartisan deleted the remove_ajax branch March 17, 2017 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants