MediaWiki / OOUI: SelectWidget for multiple selections? - javascript

is there a class similar to a SelectWidget which allows to select multiple items from a list in the OOUI library? I want to use that in a MediaWiki VisualEditor instance I'm extending.
I guess I can also rewrite SelectWidget myself, but yeah maybe there's a solution already.

OOUI appears to have only CapsuleMultiselectWidget (tag list / capsule control).
Also, you should note this is a JS-only widget (no PHP implementation, or "PHP pendant" in OOUI-speak).
After quite an extensive search, it appears there's no simpler multi-select dropdown - there are a few open tasks to implement one:
T91147: Create a generalised multi-select widget
T108489: Generalise CapsuleMultiselectWidget into a MultiselectWidget
T117782: Implement CheckboxMultiselectWidget (and CheckboxMultiselectInputWidget)

Related

What toolkit does JIRA use for the basic search filters?

JIRA has a nice search tool built into the issue tracker -- date-pickers, multi-select label pickers, number filters (min/max), and the like. For the label filter specifically, I'm wondering if this is a feature that Atlassian home-rolled; or did they use a plug-and-play framework that I too can add to my site; or something in between? I realize there's some back-end stuff that needs to happen in order to populate the list, but the UI element itself looks really slick.
The image below, from jira.atlassian.com, shows the label filter I'm interested in.
I tried pulling apart the source on the page, but I only found things that appear to be unrelated: AUI (Atlassian's UI standards?) and AJS (a low-level jQuery-esque library?).
I think that this plugin is the one you need. But you still will need to do the backend magic to ensure it works.
http://harvesthq.github.io/chosen/

Javascript to enhance parameterized builds

The 'parameterized' builds in Jenkins are a bit limited. What if I want to have options that are related to one another?
For example 2 drop down lists. The selection from the first one controls the options in the second...
I don't really see any prescribed way to implement this, but a thought (and it feels super-hacky) would be to use javascript.
I've noticed you can enter <script> tags in the description attribute of parameters. Maybe a place to drop in some js? Also looks like prototype.js ships with the system.
So just how bad an idea is that, or is there a 'correct' way to do such a thing?
Check out the Active Choices Plugin it does exactly what you're looking for:
jenkins-ci.org - Active Choices Plugin
github.com - Active Choices Plugin
A Jenkins UI plugin for generating and rendering multiple value
options for a job parameter. The parameter options can be dynamically
generated from a Groovy script and can respond to changes in other job
parameters. The value options can be rendered as combo-boxes,
check-boxes, radio-buttons or rich HTML. Active Choices strives to
provide in a single plugin functionality found scattered among several
pre-existing plugins and some unique capabilities that are not
available yet.
The Active Choices plug-in provides additional Jenkins
parameter types that can be rendered as user interface (UI) controls
in job forms.
Once the plugin is installed three new parameter types become
available:
Active Choices Parameter
Active Choices Reactive Parameter
Active Choices Reactive Reference Parameter
Active Choices parameters allow users to select value(s) for a job parameter. Parameter values can be:
dynamically generated (using Groovy or a Scriptler script)
dynamically updated based on other UI parameters
multi-valued (can have more than one value)
rendered with a variety of UI controls, including dynamic HTML
I think you would be able to accomplish your listed example with the following dynamic parameters plugin without using javascript: https://github.com/tekante/Dynamic-Jenkins-Parameter/wiki. I have not personally used the plugin as a disclaimer. It looks like it will probably need to be built first based on what I have seen in the GitHub repo and the fact that I cannot find it on the official Jenkins plugin page.

A Better Django Admin ManyToMany Field Widget

I find the the Django Admin's default models.ManyToManyField widget to be cumbersome to use. It's the HTML select element and if you have a lot of Objects of the "other" model then it's quite impractical to actually find the "other" Objects you want to associate with "this" Object. And if you have a lot of objects of the "other" model it seems to even slows down the rendering of the Admin page.
I'm aware that I can build my own custom admin widget and apply it to my ManyToManyFields as I see fit, but are there any pre-built ones out there that I might use instead? In my dreams, I picture an auto-completing text input HTML widget. Is this even practical/possible to do in the Django admin framework?
Thanks.
Try using the filter_horizontal attribute on your admin class, for example:
class SomeModelAdmin(admin.ModelAdmin):
filter_horizontal = ('users',)
As mentioned in the documentation, "adding a ManyToManyField to this list will instead use a nifty unobtrusive JavaScript "filter" interface that allows searching within the options". filter_vertical does the same thing with a slightly different layout.
you could try using a raw id in the admin.
and the django docs:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields
if you are looking for something with auto-complete you might want to look at this as a starting point http://code.djangoproject.com/wiki/AutoCompleteSolutions
and finally a very simplistic inline Example:
models.py
class SomeModel(models.Model):
users = models.ManyToMany(User)
admin.py:
class SomeModelAdmin(admin.ModelAdmin):
raw_id_fields = ("users",)
I haven't actually played with it but I found this promising looking library referenced elsewhere.
It appears to do exactly what I wanted. Rather than loading the entire list of related objects (regardless of how many there are!) and presenting you with a picker to select a few of them, as filter_horizontal does, it presents a search/filter box and uses typeahead/autocomplete calls to retrieve results dynamically. This is great for the case where you have maybe 5000 users and want to pick 3 or 4 of them without waiting for 5k <option> elements to download and render.
This is an old question, but I want to add an answer here for people who find this just like I did: this situation is exactly what Django inline admins are for. Specifically, I use TabularInlines with raw id fields for many-to-many relations that have too many choices.
https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#django.contrib.admin.TabularInline
You can try using Inline model as such -
class ManyToManyInline(TabularInline):
model = MyModel.many_to_many_field_name.through
raw_id_fields = ("render_raw_id_using_this",)
#register(MyModel)
class YourAdminClass(AnyBaseClass):
exclude = ("many_to_many_field_name",)
inlines = (ManyToManyInline,)
Now there is another issue I faced, finding "render_raw_id_using_this" field name.
So, I moved to shell and tried finding fields in through model as such -
In [1]: MyModel.many_to_many_field_name.through._meta.fields
Out [1]: (<django.db.models.fields.AutoField: id>, <django.db.models.fields.related.ForeignKey: fieldname1>, <django.db.models.fields.related.ForeignKey: fieldname2>)
So, I replaced render_raw_id_using_this with fieldname1
Similarly, you can use these field names to render raw id instead of drop down list in Inline model.

Pretty javascript multiselect widget suitable for Spring Roo / Web MVC project?

I'm looking for a Javascript multiselect to use on my Spring Roo / Web MVC project, and worried that I could spend a while adding a widget from a library that then breaks other stuff. Requirements:
Prettier and more functional than the standard Dojo multiselect which Roo uses when scaffolding ManyToMany relationships, ie the user shouldn't have to hold down ctrl or shift to select more than one item.
Plays nicely with the javascript that is already used in the Roo scaffolding - so I guess that means first prize is something built on top of Dojo, although I'm not completely against adding other libraries.
Relatively self-contained... the less of my own javascript lying around, the better.
I'm aware that there are different styles of multiselect widget, eg an "available" list and a "selected" list vs a single list with select/deselect checkboxes vs autocomplete combobox... I'm open to any - it just has to be better than what I get for free with Roo.
Have you looked in dojox.form? Does CheckedMultiSelect help?
I know this is a bit late in the game as you may have finished your project, but for future, I had problems with multiSelect widgets as those I was testing were modifying DOM so <select multiple="multiple">
<option>...</option>
....
</select>
was effectively changed to something different like<div id="...">
<input>...
</div>
I found one widget which works differently: it hides original select and creates its' own element and when user selects or deselects element it syncs its' state with original select.
It is called dropdown-check-list and here is the link dropdown-check-list
This way you can use original select for e.g. Spring binding.

Javascript Click/Drag and Select Table rows and columns

I am wondering if anyone knows a java script library that would add a "select" type of functionality as seen in excel/google docs where you can click and select several different parts of a row and/or column. I am looking at adding this functionality to my web application. Does anyone know where of library's preferably in java script that will be able to add this.
Thanks in advance
jQuery has a plugin called pfSelect which provides the kind of functionality that I think you are looking for. You could take a look at that. And if you're not using jQuery, I'm pretty sure that every major JS ui library has this kind of functionality (Dojo's Grid, ExtJS' ArrayGrid, YUI's DataTable, etc.).

Categories

Resources