How to present boolean options along with selecting exactly 1 of them as “primary”?

I have a situation in a web browser where I have a number (let’s say 3-10) of alternatives to present to the user.

  • The end user must choose at least one of these options to be enabled
  • The end user must choose exactly one of the enabled options to be the “primary” option.

I’m not sure how best to do this, though. Here’s a contrived situation about a stew that might help illustrate this better:

enter image description here

There are 7 potential ingredients, the user has to enable or disable each of them (cries out for a checkbox) but at least one of them has to be enabled; and exactly one of them must be the primary ingredient (cries out for a radio button).

  • If I choose a dumb form with no constraint checking, this is easy to implement, but they could choose Beef, Pork, and Carrots as the enabled ingredients and then Potatoes as the primary ingredient (which is a problem since they did not check the Potatoes box among the enabled ingredients)

  • Or I could put the primary ingredient first, then allow them to select secondary ingredients, and force the primary ingredient to be selected in the list of secondary ingredients (beef in the example below) and not allow it to be unselected. Not too hard to implement in HTML / Javascript, but then there’s some trickiness… what if I start with the UI state below, then select the primary ingredient as Onions, then as Chicken, and then Pork? What happens to the checkboxes for Onions, Chicken, and Beef?

enter image description here

Both of these options require duplicating the list twice.

  • Or I could try to use some kind of multichoice slider to select the primary ingredient… which would eliminate the need to duplicate the list… but this isn’t a built-in HTML feature and I’d have to roll my own or try to apply some 3rd-party UI element.

  • Or I could place a radiobutton and a checkbox in front of each ingredient (radiobutton for primary ingredient, checkbox to enable non-primary ingredients) which is compact and simple in presentation, but most likely confusing in semantics.

Any suggestions?

Selecting a polygon within an array of complex polygons

I have an array of polygons which are arrays of points. There are no gaps and none of them overlap like a Voronoi diagram.

Unlike a Voronoi diagram I cannot simply find the nearest centroid to select a polygon, this returns the correct polygon most of the time but sometimes the point lies within a neighboring polygon.

The developer tools in my chrome browser seem to be able to do it with the selection tool but I have no idea how it is doing it.

Selecting consecutive rows with same values and one that differs

So there is this question that explains how to do it but what I want is to find the duration from idle to active for a given userID and status for example for Brown it should show something like this:

userID        status     Duration_in_this_status (min)  ------  -------------------   ------ Brown         idle             40 Brown         idle             ? 

The ? inidcated that it is the time from this

userID  tStamp                status ------  -------------------   ------ Jason   2017-10-18 03:20:00   idle   Brown   2017-10-18 03:20:28   idle   Brown   2017-10-18 03:25:28   idle   Brown   2017-10-18 04:00:28   active     Brown   2017-10-18 04:10:28   active     -> Brown   2017-10-18 04:35:28   idle   Brown   2017-10-18 04:45:28   idle   

till now.

I tried to modify the answer from the above question but all I could managae was create a variable @next_time and increase it when the if goes to @groupNumber +1 but I couldn’t work it out because all it does it increases the year by one.

   SELECT userID, status, TIMESTAMPDIFF(minute, MIN(tStamp), MAX(tStamp)) AS  duration     FROM (        SELECT        t.*         , @groupNumber := IF(@prev_userID != userID OR @prev_status !=  status, @groupNumber + 1 and @next_time=@next_time+1, @groupNumber) AS gn     , @prev_userID := userID     , @prev_status := status     , @next_time   := tStamp     FROM t     , (SELECT @groupNumber := 0, @prev_userID := NULL, @prev_status := NULL) var_init_subquery     ORDER BY userID, tStamp ) sq GROUP BY gn, userID, statu 

So can any one help me to get that next value using these user-defined variables? Thanks

MySQL version 8.0.16

Optimising query for date based selecting

I am looking to speed up querying of records from a specific date range.

My table has millions of rows and the dates are in Unix epoch format, in text format IIRC ( i don't work weekends so can't be certain)

I am pulling in a single schedule record, which has an unique ID field attributed to it.

This ID field is recognised in a separate table called movement, and this movement field stores movement and timing data for the schedule.

Each schedule has its associated movement rows (usually…

Optimising query for date based selecting

Selecting objects to maximize value while under multiple constraints

I think it will be best to explain the problem first and then explain what I am thinking:

I have a dataset similar to the following:

fruit,calories,cost apple,100,1 apple,200,1.5 apple,150,2 pear,300,3 pear,100,.5 pear,250,2 orange,100,1 orange,120,1 orange,400,2 

And I am trying to maximize my calories while keeping my cost within a certain range. At this point it is just a knapsack problem, but what if I have to have 1 apple, 1 pear, and 2 oranges, or some other arbitrary set of fruit numbers?

I can’t really wrap my head around how this should work, given the extra constraint. I’ve thought about trying to merge my cost and calories into 1 metric somehow, but I am pretty sure that can’t work since it loses.

My most recent thought is potentially keeping track of fruit count in a list, and if the proper amount of fruit has been reached it will skip to the next fruit. I am thinking about this in a similar way to a knapsack with 3 constraints, weight, value, and size, but the size is just fruit count essentially.

Hoping someone on here can tell me if I am heading in the right direction or if there is an algorithm that does this that I can look into.

Thank you!

Hierarchical list for selecting an element

The user is trying to select an element which will be used in a form. So it could be like selecting interests in an app where you can pick the more general case (e.g. sports) or the more specific (e.g. baseball).

I have hierarchical data where:
* Exactly one node may be selected.
* Users can select nodes anywhere in the tree
* Leaf nodes must be selectable
* Parent nodes may be selectable. Selecting a parent node represents a selection of all of its leaf node descendants.
* Selectable parent nodes are uncommon.
* The depth of the data is deeper than can be readily shown on the screen all at once.

I am developing an interface for browsing this data. This data needs to be usable on both desktop and mobile interfaces on the web.

I am thinking of modeling an interface after what Apple does with hierarchical menus, like the one below. The differences in my case are primarily that:
* The items can have three states: selectable node, refinable node, and nodes with both capabilities. How do I make this look uncluttered?
* My design must operate reasonably on both desktop and mobile. How do I design the refinement signifier in an unobtrusive way that is clear even on desktop views.
* My lists have a lot of heterogenous content. This happens only rarely in Apple menus, like the shut down button in the second screenshot. How do I show heterogenous content without looking disjoint?
iOS settings menu

Notice the blue row at the bottom representing differing content.
iOS shut down screen

What I’ve been thinking of so far is similar to the Apple design. These next two screenshots show the top level of the hierarchy here, and…
Top level of hierarchy

…the screen after food is selected.
Refinement of hierarchy

I like the multi-screen approach to this design for my use case, so I am primarily looking for feedback on exactly what icons/buttons to put in, and how to separate out content. I’m particularly interested in examples on the web and high fidelity mock examples, but I’m open to lower fidelity feedback as well.

The one structural thing that I think could be changed is in the combination case where a parent node can also be selected. Conceptually I’ve illustrated it here:
Alternate design to combination case

I’d like to draw attention to the fact that this makes the rows less crowded, and seem more homogenous. But I’m not sure exactly how to design the current level selection mechanism. How could I clearly indicate that the current level can be selected? Relatedly, how do I indicate the situation where the current level can’t be selected?

Bundle Product Price is Not Updating On Product Page – near to add to cart button. When Selecting Options

I have created a bundle product with 2 options.

One option is a dropdown menu (required).

The 2nd option is a checkbox (required).

When I select my options the price in the right column is not updated.

Once added to cart the price reflected is correct.

Magento version is 2.2.7

Any ideas?

(I have overrides luma theme)

Auto populate a lookup field with multiple entries after selecting multiple entries from a lookup

Please excuse me for the vaugness, required due to the type of work.

I have a list that indicates upcoming work on various items. When the work is finished on those items, drawings need updated. As it is, I have the items showing the date that the work is finished and a lookup that lists the various work numbers being performed on that item. The work being performed affects various drawings, so I have another lookup that looks up all the drawings. I want the first lookup for the work numbers to cascade to the drawings lookup, so that when I select the work numbers, only the drawings that are affected will auto populate. I do not have access to InfoPath or SPD (my company restricted that). So, all I can do is put script in a webpart. Any ideas?

I have found script that works when the first lookup is just one item, it will then show only the items that apply in the next lookup. I can’t seem to find anything that will let me select multiple items in the first lookup and display all applicable items in the second.

Best practice for selecting multiple items in map view

I’m working on an app (touch input) in which it should be possible to select one or more items. Think about google maps: you search for ‘restaurant’ and a couple of restaurants are shown on the map, now you want to select 3 of them.

Right now I’m thinking about

  • press to view one item
  • press+hold > give feedback to the user > press to select multiple items > CTA to view items.

This is not an ideal solution and I’ll need to explain this interaction to the user at first use.

I’m wondering if someone has another idea or suggestion that is more user-friendly and intuitive?