-
Notifications
You must be signed in to change notification settings - Fork 45
ui-select or select2 with angular-schema-form-dynamic-select? #15
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
Comments
I don't know about select2 for ASF, while I have considered also implementing ui-select, it is not currently in the pipeline. |
Just out of interest, why does it matter if it is a button? Or something else? |
Oh, I realized now what you meant. |
Angular schema form uiselect and dynamic select won't work together because
|
That sounds strange. In what way does the usage of buttons in ASFDS and the use of div:s in ui-select conflict? I am sorry if I am a bit daft, but I don't get it? |
The reason it is implemented that way in ASFDS is because that is the way the angular-strap select is invoked: http://mgcrea.github.io/angular-strap/#/selects-usage I would be strange if two different classes of HTML elements interacted like that. In what way doesn't it work? |
Ok, so now I went ahead and actually added basic support for ui-select in the develop branch, it turned out to be not that hard, I mixed stuff from the chengz and stevehu-forks and reworket it to work in the stuff in this component. There are some filter related errors to iron out, but in general, it seems to work pretty well. |
If you want to try out that, just 'bower update angular-schema-form-dynamic-select#develop', unless you work against the git repo directly. |
That's really cool. Thumbs up, I will give it a try and let you know.
|
Can you please show some code how to apply ui-select to ASFDS, i am new to angular js, i updated the installed the devstream but dont know how to use ui-select. |
First, update again. Then, the index.html in the root of the library is the demo application. The angular example resides in app.js, I have added two UI-selects there. The second doesn't work properly yet. |
Remember to use #develop, this is only in that branch. |
Thanks! :) |
I am getting Cannot GET /directives/decorators/bootstrap/uiselect/uiselect.html |
Are you sure you are using the angular-schema-form-dynamic-select.js in the root, and not the file in /src? |
Because the template caches should be populated with that content. |
Yes i am using js in the root ../bower_components/angular-schema-form-dynamic-select/angular-schema-form-dynamic-select.min.js |
I will have to use ../bower_components/angular-schema-form-dynamic-select/angular-schema-form-dynamic-select.js |
Getting this now: {{form.title}} |
Ok, I just realized it will not work like that. Then checkout the develop branch, and add the remaining dependencies for ui-select. I have not decided what will be included in the library, but just look in the index.html, and check so that all those scripts and css:es are available. |
These additional libraries should get you going: underscore |
I will add those I deem relevant to the dependencies in the bower.json after I have cleared up what is actually needed. |
Included all the dependencies, now getting Error: [$injector:unpr] Unknown provider: highlightFilterProvider <- highlightFilter |
I have included ngSanitize too. Any idea about this? |
I was getting /directives/decorators/bootstrap/uiselect/uiselect.html, so i made the directory structure in my app and put uiselect.html there, then i started getting Error: [$injector:unpr] Unknown provider: highlightFilterProvider <- highlightFilter |
Oh, sorry, you need to in stall angular-ui-utils:
|
Yes, angular-sanitize is needed too, basically, you can see what dependencies there are in the index.html. If they are all satisfied, it should work. |
I do suspect, however, that some of these dependencies are not completely necessary, however I am not sure how strict I should be about that. |
@subhendupsingh , if you do a git pull now, the uimultiselect works as well. There was a bug in the original implementation. |
Well, that part haven't changed, as far as I can see. I have not changed any of the callback in my example. |
Used the method you suggested with asyncCallback, still getting: Cannot read property 'forEach' of undefined |
How does your code look now? |
actually it is $http.post service and i have read somewhere that $http returns promise by default. Thats the reason i used it that way. |
The last thing I didn't understand. |
form[i].options = { and $scope.getCurrency=function(options){ |
Well, the defer.resolve must be inside the callback, or it'll never be called:
Also, I cannot test this code, it is just a suggestion. |
Also, do not look at e-mails, look here at github, as I (and most others) often edit messages for a short while after posting |
This is the code from my service do i need to return a promise from here? if(mode=='CURRENCY'){ endpoint=API_CURRENCY_ENDPOINT; return $http({method: "GET",url: endpoint}) .success(function(result){ //console.log(result); loginCb(result); }) .error(function(result){ //console.log(result.data); loginCb(result); }); } |
You are mixing two things that should not be mixed here, synchronous callbacks and asynchronous promises. I would recommend that you do not use a callback, and do not implement the .success and .error. (especially as the error is ignored)
If you someday feel you need control in DocumentsDataService.documentsData, like for caching and to on, implement that as well asynchronously, it is the way it is done in javascript. If you want to make it really simple, use the options.httpGet shorthand combined with the remapping functionality, actually the example is exactly your use case: |
Ok, I have found that there are several bugs in the current version of the ui-select component that affect this component, and they appear when I set an initial value:
|
Hold on, I am rewriting the implementation to make it simpler to understand. |
That would be great.
|
Well, I have been swearing over this for two days now, so this is the only way for me to avoid coming back as an insect, karma-speaking. :-) |
I hit some issues, and to not have to basically redo what the base implementation did, I asked them a question about it instead: |
I have now released 0.9.1. It fixes some of these issues. However UI-select does not work completely yet, it is possible to select multiple identical items in some cases and so on. But perhaps you can use that for now. |
What about callbacks? Are they working now?
|
Great i just saw in the examples, you have implemented uiselect with callback. |
Well, there was no problem with callbacks per se, but there was a problem with strapselect that had options, but not "options.multiple = true". |
Awesome! |
This is weird but i am still getting [ui.select:items] Expected an array but got '{}'. |
What, from getCurrency? |
To test i am just returning an array object: $scope.getCurrency=function(options){ var arr=[{"value":"INR","name":"Indian Rupee"}]; return arr; } |
And the form part? |
yes i have used plain callback. form[i].type = "uiselect"; form[i].options = { "callback": "getCurrency" }; |
From where do you get the error? In what source line is it? This would be one of those cases where a plnkr.co-example would be very helpful. That is actually the normal way to handle stuff like this on github these days, it is much faster to debug a running example that exhibits the behavior. Also, I must be going to bed now. Wait, it looks like you are in Delhi or something, you should too. :-) |
your "plain callback" thing got it working 👍 $scope.getCurrency=function(options){ var arr=[]; DocumentsDataService.documentsData("CURRENCY",null,null,function(result) { if (result != null && result != '') { for (i in result) { arr.push({ "value": result[i].isocode, "name": result[i].name }) } } }); return arr; } Thank you so much for all the help and patience and yes I am in Delhi and will happily go to bed now. Have good night!! |
So DocumentsDataService.documentsData was synchronous after all, and didn't return a promise then? No problem, thanks for all the feedback, if it weren't for that, it would have been more difficult. Good night! |
Closing this now, I'll monitor the success of the ui-select-issue so that can be brought up to 100%. |
How can I implement ui-select or select2 with angular-schema-form-dynamic-select, I see that select behaviour here is applied to a button, i want it to be a dropdown like ui-select or select 2.
The text was updated successfully, but these errors were encountered: