Giter Club home page Giter Club logo

Comments (7)

adamcooke avatar adamcooke commented on September 2, 2024 2

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

from staytus.

benji-lewis avatar benji-lewis commented on September 2, 2024 1

+1

from staytus.

notrab avatar notrab commented on September 2, 2024

@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.

from staytus.

notrab avatar notrab commented on September 2, 2024

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

from staytus.

pgnuta avatar pgnuta commented on September 2, 2024

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.

from staytus.

sodul avatar sodul commented on September 2, 2024

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

from staytus.

marcencov avatar marcencov commented on September 2, 2024

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.

from staytus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.