Add action menu to meal categories#920
Conversation
Add an action menu icon to the meal category accordion. Clicking the icon opens an F7 action sheet with options to either remove all entries from the meal category or to move them to another meal category.
Add a new action menu item to let the user manually set the timestamp (hour & minute only) of all items in a meal category. This supports all hour cycles and thus different locales. The option does not exist if the user does not have "Show Timestamps" turned on and it is disabled when there are no items in the meal category.
|
|
Yeah I think it looks better, something still feels off to me though. I think it's a ux thing. @EmilJunker Any suggestions? |
|
A also think the horizontal three dots look best. I have two minor suggestions though:
|
|
One more idea: many users have said they find it unintuitive that long pressing the |
|
I moved the three dots next to the + icon (see pic below) and only show them when there are items in the group now. I'll commit these changes if they get your approval. I'll also take a look at the quick add functionality.
However, a question: I took a look at a few other PRs and I guess I would need to update the settings version and write some migration code due to recently having added settings for showing a trend line in the statistics (#918) and showing the total portion size (#916). If so: shall I add that code to this PR or create a new one? |
As long as the new settings are just booleans and
If you choose to add the quick add feature to the action menu, you would of course need to revert that change and always show the three dots button. Sorry, my bad. |
Moves the action menu button (switch from menu_open to more_horiz) from the right side of the accordion title bar next to the + sign in the footer of the meal category.
|
I just built and the app in in the browser and noticed a couple of problems:
|
Yes, you are correct. I tested it yesterday, and it did work at that point. I'll take a look at that.
I agree. I'll change that. |
|
@EmilJunker Does it feel natural/intuitive that pressing the 3 dots opens the action menu? |
Yes, I think the UX feels alright. |
Bug was: removing elements while in a foreach
Unfortunately F7 does not seem to offer classes with the css `gap` to space flex items from each other. To still have a margin between the buttons we add a basic margin class to the action menu button. This might conflict with very long meal category macro summaries.
I could not reproduce that. Can you try again with these changes? Although there is still a bug with the time and RTL languages. The picker for hour and minutes gets also shown from right to left, but as far as I know, the time is still read from left to right in an RTL language.
I'll see if I can implement cancelling the smart select (same issue applies to the picker), but at first glance F7 does not offer a way to only handle the input when the user clicks on the sheet close link. |
Add a backdrop to prevent clicks from propagating in the background elements.
|
Well, this would be a workaround: let mealSelection = app.f7.smartSelect.create({
el: smartSelect,
openIn: "sheet",
sheetBackdrop: true,
closeOnSelect: true, // <--
sheetCloseLinkText: app.strings.dialogs["cancel"] || "Cancel", // using cancel instead of default "Done"
on: {
closed: (selection) => {
let selectedMealName = validMealNames[selection.$selectEl.val()];
selection.destroy();
smartSelect.remove();
app.Group.updateItemGroup(self, mealNames, selectedMealName);
}
}
});This closes the smart select sheet when a selection is done. Thus, clicking anywhere else/closing the smart select means that no change could've been made. |
I'll try to test it again tomorrow if I have time.
That's true. I'm sure there is a way to fix this, but it's been a while since I implemented the RTL layout (in #363) and I don't remember that many details.
I don't know if this would work, but you can try it. If Framework7 really doesn't offer any way to do it then it can stay as it is. |
|
I just tested the app again in the browser and everything looks and feels pretty good. The bugs I listed above seem to have been fixed. I also tried the workaround you suggested with the Another related problem is there is currently no way to cancel updating the timestamps. Hence, if you accidentally press on the "update timestamps" button, you are forced to update all the timestamps in that category and there is no way to prevent it (except for closing the whole app, but that's obviously not very user friendly). Also, there ist still the bug that you mentioned where the hours and minutes are incorrectly swapped in the RTL layout. I attempted a quick fix it by setting the |
I am currently working on that. I add a button to the smart select on open that sets a flag so it is clear the user canceled the selection. On any change, I set the flag that there was a user change. With that, it would be possible to cancel the selection.
I guess it would be possible to do the same thing here, however, I thought about using the F7 calendar instead. That one has a time picker as well, but I would need to manually remove the calendar element. Another option would be to use a F7 dialog and use an E:
I assume this was caused by the check if the option for the meal name has the same name as the group. When the name gets localized (the default names) this check fails and the first option gets selected per default. I'll change it to select based on the index and the group ID. |
Introduces a custom cancel button to the meal selection smart select sheet and ensures that group updates only occur if the user changes the selection and does not cancel.
Instead of setting the pre-selected meal category by name, we set it based on index. This way we prevent issues with the localized names of the default meal category names.
Switch from a custom time picker to a modified F7 time picker by hiding other calendar elements.
Instead of letting the user open the time picker from the calendar we call the method to open the time picker when the calendar opens and close the calendar when the time picker closes. That way we can hide the calendar (assuming the device isn't very slow and shows the calendar for a frame).
Sets the direction of the time picker columns to left-to-right to ensure hours and minutes are displayed correctly in the time picker.
Set the time picker value to the diary entry's date with the current time, ensuring the selected date matches the diary entry context. This way users who update their timestamps on another day will not have wrong date info when exporting the data. Inside the app it does not make a difference as the displayed time does not include the date.
Updates class assignments for picker columns to ensure correct scroll behavior.
|
Okay, I think the mentioned bugs should be fixed now. Feel free to test the changes when you have some time and let me know if you encounter any issues or inconsistencies. |
|
I don't have time to test it thoroughly right now, but I just built and ran the app in the browser and at first glance it looks and feels quite good. I only noticed one bug that affects both the "move items to another meal" and "update timestamps" operations: when I try to cancel them by pressing the Android back button [ |
Instead of using flags for a changed selection and a not cancelled selection, we now track only if the user has explicitly confirmed the action. That way any sort of exit made are now handled as there will be no user confirmation flag set.
|
Any news? ^^ |
|
I still haven't tested the latest changes, but if you tested everything and are confident and satisfied with it, I'd say it can be merged. |





This adds an action menu to the meal categories. It currently holds these actions:
All of these features are only enabled when there is at least one item in the meal category. The timestamp action is only visible when the user enabled "Show Timestamp" in the settings. Since the date part of the timestamp is retrieved from the entry timestamp instead of the item timestamp, this should also work when there was no timestamp saved (due to having the setting turned off).
The action menu can be opened with a button in the title bar of the accordion. Why a button? I tried to handle this with a taphold event, but the accordion opening/closing while holding results in a touchend event and thus never reaching the timeout for the taphold. The icon used is "MenuOpen" which seems fitting, but I am open to suggestions if anything seems like a better fit.
Some images