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

feat(sortable): add support for custom item template #1554

Closed
dlcooper opened this issue Jan 24, 2017 · 10 comments
Closed

feat(sortable): add support for custom item template #1554

dlcooper opened this issue Jan 24, 2017 · 10 comments

Comments

@dlcooper
Copy link

I have a list of cups (complex model) and want a different image for each cup but the API for doesn't seem to support such a concept.

` <bs-sortable
[(ngModel)]="itemObjectsLeft"
fieldName="name"
itemClass="sortable-item"
itemActiveClass="sortable-item-active"
placeholderItem="Drag here"
placeholderClass="sortable-item"
wrapperClass="sortable-wrapper"

class Cup {
type:string
name:string
}
`

Is there a way to do that based on the value of the type property?

Maybe there could be a "template" or "templateRef" Input that would have access to the list item.

Something like:

<bs-sortable [(ngModel)]="myCups" templateRef="cupRenderingTemplate"...> </bs-sortable>

@valorkin valorkin changed the title Different style for each sortable item feat(sortable): add support for custom item template Jan 25, 2017
@valorkin
Copy link
Member

yep, need to mark sortable as experimental, some how
adding custom item template would be good

@valorkin
Copy link
Member

I just made a prototype of this idea, but I need to clarify one thing
please check 5ed3ba4#diff-456830bd92e54b2e7c01693e0f6654af

is it enough? or item template should include .sortable-item' div`?

@dlcooper
Copy link
Author

dlcooper commented Jan 25, 2017 via email

@dlcooper
Copy link
Author

dlcooper commented Jan 26, 2017 via email

@valorkin
Copy link
Member

I have some urgent things to fix, but tomorrow I hope to get in this

@dlcooper
Copy link
Author

dlcooper commented Feb 1, 2017

This is great!

It would nice to have a template parameter to compute whether the item is draggable. i.e.

let-draggable="{{isDraggable(item)}}"

or, you could just call me wrong and make the

item template should include .sortable-item'div`?

as you suggested earlier.

@Le0Michine
Copy link
Contributor

@dlcooper not sure if I understand you correctly, do you want to make some items in sortable container undraggable i.e. they should always keep their positions? If so when

item template should include .sortable-item'div`?

won't help because you still will be able to drag other items and it can affect positions of disabled items as well (according to current implementation for sure). Or probably you just want to disable whole container?

@dlcooper
Copy link
Author

dlcooper commented Feb 2, 2017 via email

@Le0Michine
Copy link
Contributor

@dlcooper OK, I see. It is added to next PR but not sure how long it will take to approve it, it is quite big.

@IlyaSurmay
Copy link
Contributor

Custom template support was added in #1580

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

No branches or pull requests

4 participants