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

Drag and drop added for images in the sidebar #645

Closed
wants to merge 0 commits into from

Conversation

divyabaid16
Copy link
Contributor

Fixes #644 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

GIF For the same:
Peek 2019-05-28 11-11

Thanks!

@@ -98,6 +99,12 @@ def update
render text: 'success'
end

def sort
params[:warpable].each_with_index do |id, index|
@warpable.where(id: id).update_all(position: index+1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surrounding space missing for operator +.

@codeclimate
Copy link

codeclimate bot commented May 28, 2019

Code Climate has analyzed commit dd041d6 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Style 1

View more on Code Climate.

@codecov
Copy link

codecov bot commented May 28, 2019

Codecov Report

Merging #645 into main will decrease coverage by 0.12%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #645      +/-   ##
==========================================
- Coverage   71.27%   71.15%   -0.13%     
==========================================
  Files          32       32              
  Lines        1288     1293       +5     
==========================================
+ Hits          918      920       +2     
- Misses        370      373       +3
Impacted Files Coverage Δ
app/controllers/images_controller.rb 72.97% <40%> (-2.39%) ⬇️

@divyabaid16
Copy link
Contributor Author

I tried to add the column position in Warpables but I'm getting the following error:

Selection_163

Can you please help me out @gauravano @jywarren ?
Thanks!

@jywarren
Copy link
Member

jywarren commented May 28, 2019 via email

@divyabaid16
Copy link
Contributor Author

@jywarren

Here, after drag and drop of the table rows, I tried to get the order in which they are present now,
it can be seen in

Processing by ImagesController#sort as */*
  Parameters: {"warpable"=>["100", "101", "99"]}

And, after getting the parameters, I updated the position, i.e a new colunm and displayed the table in sorted order of position according the the way, the params are sorted.

And regarding, warpable belonging to multiple map, I think while doing this, id of the particular map was recorded and changes was made only to the images in that map.

Thanks!

@divyabaid16
Copy link
Contributor Author

My error for this comment is solved.

I had cleaned all the tables and migrated it once again.

Thanks for your help @jywarren !

@jywarren
Copy link
Member

jywarren commented May 28, 2019 via email

@divyabaid16
Copy link
Contributor Author

I got your point @jywarren , I will try it now.
Thanks!

@divyabaid16
Copy link
Contributor Author

Hi @jywarren @gauravano @sashadev-sky
I'm still not able to reorder the images after the page is refreshed even though I had ordered the images in the database based on the position.
Can you please help me out with this?

Thanks!

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@divyabaid16 I made a commit suggestion that resolves the problem! And this is done client side so it won't effect other maps.

app/views/images/_index.html.erb Outdated Show resolved Hide resolved
@sashadev-sky
Copy link
Member

sashadev-sky commented May 30, 2019

My commit suggestion also still works if you delete the update to the feeds_controller:

@warpable = Warpable.sort_by('position')

and in the images_controller can delete:

 @warpable = Warpable.order('position')    
    respond_to do |format|
      format.json { head :no_content }
    end

Although i'm wondering about the respond_to block, is this just a RESTful way to handle not responding any content so should be kept? Is this a rails 3 practice or still the standard for newer versions?

@divyabaid16
Copy link
Contributor Author

Oh, I guess I had added that lines to feed_controller by mistake.
It has nothing to do with that.

Thanks!

@divyabaid16
Copy link
Contributor Author

Thank you @sashadev-sky for your changes suggested :)

I'm attaching the working GIF
Peek 2019-05-30 21-20

@jywarren @gauravano can you please review this now?

Thanks!

@divyabaid16
Copy link
Contributor Author

The test is failing because of too many lines in image_controller.

@sashadev-sky
Copy link
Member

@divyabaid16 try rebasing and testing it - because its throwing a server error for me now!

@divyabaid16
Copy link
Contributor Author

I have created a new pull request #670
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order images in the sidebar using drag and drop
3 participants