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

Add UI for re-ordering services #1

Closed
adamcooke opened this issue Feb 25, 2015 · 7 comments · May be fixed by #225
Closed

Add UI for re-ordering services #1

adamcooke opened this issue Feb 25, 2015 · 7 comments · May be fixed by #225

Comments

@adamcooke
Copy link
Owner

No description provided.

@notrab
Copy link
Contributor

notrab commented Jul 14, 2015

@adamcooke Can you explain a little more as to how you intended this to work? I wouldn't mind submitting a PR for such functionality.

@adamcooke
Copy link
Owner Author

The Service model has a field called position which is used to set the order that services are displayed in the interface. Unfortunately, this attribute isn't exposed anywhere.

I think I was just thinking of adding a simple JQuery UI sortable widget which would let you just drag and drop the order of services on the service list page.

I'd pop a form around the whole table, put a hidden field - hidden_field_tag('order[]', service.id) - on each table row and then automatically submit the form when the order was changed. A controller action will receive the order param array with the IDs in order and that can be passed to the model...

Finally, I would likely add a class method to Service called reorder which accepts an array of IDs in the which they should be displayed and update all the services with their new positions.

def self.reorder(ids)
  ids.map(&:to_i).each_with_index do |id, index|
    service = Service.find(id)
    service.update(:position => index + 1)
  end
end

@notrab
Copy link
Contributor

notrab commented Jul 14, 2015

👍I was thinking the same. I'll try and submit this unless you or anyone else beats me to it.

@pgnuta
Copy link

pgnuta commented May 8, 2016

Did this get anywhere? Looks like it went dead but i think its an important feature so that messing with the database in the background is not required.

@sodul
Copy link

sodul commented Jun 14, 2016

+1 on the feature, it looks like the internals already allow for this to work so it would be a nice to have.

@benji-lewis
Copy link

+1

@marcencov
Copy link

marcencov commented Sep 23, 2017

Any news about reorder? I need sorting inside "service group". How I can do this?
If I add services with name 4, 2, 3, 1 this list not sorted by name.

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

Successfully merging a pull request may close this issue.

6 participants