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

Allow custom data copy function #56

Open
andreasrueedlinger opened this issue Feb 28, 2018 · 6 comments
Open

Allow custom data copy function #56

andreasrueedlinger opened this issue Feb 28, 2018 · 6 comments

Comments

@andreasrueedlinger
Copy link

andreasrueedlinger commented Feb 28, 2018

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

Current behavior
Currently when copying a model value, JSON.parse(JSON.stringify(dropElmModel)) is used to copy the value. If the model value has circular references and if you want to manipulate the model data before it is copied it would be nice to provide a function that replaces the JSON copy mechanism.

Expected behavior
ngxDroppable directive has a property copyModelValue or similar where you can provide a custom function to copy a value.

@ErwinSanquer
Copy link

Any update regarding this feature ?
Great job btw !

@ErwinSanquer
Copy link

ErwinSanquer commented Mar 30, 2018

I try to change the value in the event (drag) but when it's drop it still keep the old value.
I did find a way to change the dropped Item, but definitly not that nice implementation.

<div class="ngx-dnd-container" (drop)="builderDrop($event)" ngxDroppable="oneway-target" [removeOnSpill]="true" [model]="droppedItems">
                        <div class="ngx-dnd-item" ngxDraggable="['oneway-target']" *ngFor="let item of droppedItems" [model]="item">{{item.name_application_field}}</div>
</div>
builderDrop(e: any) {
        if (e.value IS_YOUR_OLD_TYPE) {
            const index = this.droppedItems.indexOf(e.value);
            this.droppedItems.splice(index, 1, new ApplicationField(new Date().getTime(), e.value.field_type,
                this.applicationId, e.value.field_type, {}));
       }
}

The if in the builderDrop is mandatory if you want to be able to sort the element with the modified type, otherwise it create a new elem each time you drop.
Still should be nice to have some update feature or some explanation on how to achieve this properly.

@Hypercubed
Copy link
Contributor

Yes, the drop event is how I am doing it now. I would like to allow a custom method for copy but have yet decided the best ergonomics for this. I've found that passing functions into components can be troublesome.

@ErwinSanquer
Copy link

Maybe allowing to use .map() could be the solution if you want to avoid passing a function ?

@Eve-Sama
Copy link

Eve-Sama commented Nov 6, 2020

Anything about this feature?

@Delagen
Copy link

Delagen commented May 14, 2021

Any updates?

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

5 participants