ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

Multiple Tagging with "Array of object" is allowing insertion of duplicate entries.

Open Rahul-Sagore opened this issue 10 years ago • 16 comments

Bug description:

I created tagging feature, where user can select from existing stored tags or create new if not existed. So if I have one tag "Algorithm" in dropdown, and user type "algo" then it allows creating new one. But if user type "algorithm" or "Algorithm", then both existing tag and "create new" displays. So it should allow insertion of new tag only if it is not already existing tag. screen shot 2016-09-25 at 12 59 18 pm

This is the array, which populates the ui-select: [ {uid: "0x943835545", name: "Algorithm"}]

Probably it should allow to filter on one property of object, for example name of the tag and ignore others. And if tag name exist then "Create new" label should disappear or disabled.

Link to minimally-working plunker that reproduces the issue:

This is happening on official Tagging example as well. This is someone else's plunker link. Check array of object example.

Version of Angular, UI-Select, and Bootstrap/Select2/Selectize CSS

Angular: AngularJS v1.3.13

UI-Select: 0.19.3

Rahul-Sagore avatar Oct 09 '16 06:10 Rahul-Sagore

Hi, I have th same issue...

davidetwc avatar Oct 11 '16 08:10 davidetwc

Are you using a custom tagging function? Or the default?

Jefiozie avatar Oct 14 '16 06:10 Jefiozie

Custom tagging means user can add new tags on the fly, right? This is the code I wrote, where addNewTag function return user typed string.

<ui-select multiple tagging="questionVm.addNewTag" theme="select2" ng-model="addQueVm.newQuestion.tags" class="mdl-select">
    <ui-select-match  placeholder="Enter tags">
        <span ng-bind="$item.name"></span>
    </ui-select-match>
    <ui-select-choices repeat="tag in (questionVm.allTags | filter: $select.search)">
        <span ng-bind="tag.name"></span>
    </ui-select-choices>
</ui-select>

I have handled the problem on frontend by calling custom function on "on-select" event, which handles unique tag insertion. But I wanted to know if there is something in-built in ui-select to make it unique based on single object property.

Rahul-Sagore avatar Oct 14 '16 06:10 Rahul-Sagore

I had a look at the code but I cannot find any thing that makes it a unique value. Maybe this is something you could implement? I think this will add value to the ui-select.

Jefiozie avatar Oct 14 '16 17:10 Jefiozie

Hi Guys, I had the same issue and I fixed and tested it in above PR.

zajacmp3 avatar Oct 20 '16 12:10 zajacmp3

Okay, that's great. Will test it. Hope you have tested it, and it's not breaking default functionalities, because this should be a configurable thing, not just default thing.

Not everybody need this.

Rahul-Sagore avatar Oct 20 '16 12:10 Rahul-Sagore

@zajacmp3, agree on the above comments also you are missing some test in your commit.

Jefiozie avatar Oct 20 '16 12:10 Jefiozie

Thanks, for fast reply. I wanted push it ASAP. Tests will be written too (not really TDD while debugging unknown plugin to me). In the scope of this changes we have to also propose changes to wiki. Any help much appreciated I am on hold with it till tomorrow.

zajacmp3 avatar Oct 20 '16 12:10 zajacmp3

My usage of it in html along with the tag:

                <ui-select multiple ng-model="vm.tags" theme="bootstrap" close-on-select="true" tagging="vm.createNewTag" object-unique-key="name" limit="25" >
                    <ui-select-match>{{$item.name}}</ui-select-match>
                    <ui-select-choices refresh="vm.truncateLongTags($select)" refresh-delay="0" repeat="tag in (vm.availableTags | filter: $select.search) track by tag.id">
                        <div ng-bind-html="tag.name"></div>
                    </ui-select-choices>
                </ui-select>

zajacmp3 avatar Oct 20 '16 12:10 zajacmp3

Added unit tests, corrected failing ones.

Functional is disabled by default. It is only enabled if you define the html tag object-unique-key.

I hope that will answer your concerns.

zajacmp3 avatar Oct 20 '16 14:10 zajacmp3

I registered my fix in bower so it can be moved further down the pipeline in my organization.

If you want to test it just add an entry in your projects bower.json

"dependencies": {
.
.
.
"angular-ui-select_duplicate_hot_fix": "v0.19.5.1",
.
.
.
}

zajacmp3 avatar Oct 21 '16 13:10 zajacmp3

Hi Guys,

They is no response from repo maintainers on PR: https://github.com/angular-ui/ui-select/pull/1830

Maybe some of you are familiar what maintainer meant? Is there any pending work to be done?

Thanks, Mateusz

zajacmp3 avatar Nov 22 '16 16:11 zajacmp3

Any update on this @Jefiozie

UsamaKhalil-KSO avatar Apr 17 '17 15:04 UsamaKhalil-KSO

@usamakhalil86 feel free to ask if you have any questions. We are with success using this code on production for 6 months.

zajacmp3 avatar Apr 17 '17 15:04 zajacmp3

@zajacmp3 is this going to merge?

armory09 avatar Jun 23 '17 05:06 armory09

@armory09 I wish. Sadly I don't have permissions to do that. I see that there are conflicts on PR so I am going to resolve them soon.

zajacmp3 avatar Jun 26 '17 09:06 zajacmp3