Maui Shell Uri Navigation, Multiplate pages on stack and backwards navigation - maui

I am developing a warehouse management application using Maui.
At the moment, I am using the GoToAsync method to navigate between pages, however, I have encountered a problem.
The structure of my pages:
Main menu with several buttons, select the first one:
Location ->
search location ->(after scanning the code)
3.List of products on the location ->(after selecting the product)
4.List with operations to perform (each one displays a different page) -> select the first one
5.Move the product to another location
etc.
Depending on the button selected in point 4, a different number of pages can be put on the stack, for example, after selecting the operation in point 5, 3 or 4 or 5 more pages can be put on the stack.
This is how I register my pages:
Routing.RegisterRoute(nameof(MenuPage), typeof(MenuPage)); Routing.RegisterRoute(nameof(ProductSearchPage), typeof(ProductSearchPage)); Routing.RegisterRoute(nameof(ProductListPage), typeof(ProductListPage)); Routing.RegisterRoute(nameof(ProductDetailsPage), typeof(ProductDetailsPage));
So as you can see I don't create a hierarchy of Uri addresses e.g. Page1/Page2/Page3 because, pages like the code finder, or the product list can be accessed from different places in the program.
What I'm trying to do is go back to one of the pages set aside on the stack. In the example given above, I would like each operation selected in item 4 to, in effect, backtrack me to the list of products from level 3. I am unable to determine this using GoToAsync("../../../...") because I do not know how many pages have been set aside.
I would also like to mention that a page like a search engine or a list sends a message about the selected code or item has a list, and this is handled on one of the pages on the stack ( that is why I do not know how many pages I have to backtrack)
I tried GoToAsync(Page3) however it takes me to a new instance of that page, and additionally puts another page back on the stack.
Any ideas how I could approach such an issue?
Is Shell Uri navigation the right mechanism for this type of project?

Related

Including list view of relationship entity on update page

I am trying to extend an update view to include a list view of some related items below the edit form.
I have two models, Publishers and Volumes, which have a many to many relationship. What I am trying to do is this.... when a user clicks on the edit button for a publisher, I want them to go to a page with the standard edit fields, but also have a list view below the form that lists all of the volumes that are connected to that publisher via their relationship.
Is there an easy way to do this?
I hope this makes sense.
As #tabacitu mentioned, Backpack doesn't currently have an built in solution for this. That said, this could maybe work for you:
This would allow you to use all functionality of the nested list view including interacting with the entities without conflicting at all with the parent
Step 1, Build your normal CRUDs
Build out two normal CRUDs, one for Publishers, and one for Volumes
Step 2, Make a frameless layout
copy vendor/backpack/base/layout.blade.php
name it frameless-layout.blade.php
remove #include('backpack::inc.main_header') and #include('backpack::inc.sidebar')
Step 3, Make a custom list view
copy vendor/backpack/crud/list.blade.php
name it sub-list.blade.php
change the top line to #extends('backpack::frameless-layout')
Step 4, Make a custom field
Create a custom form field that contains an iFrame
Inside your custom field template, have it set the url of the iFrame to the "list" url of the related resource
You'd also need to utilize List Filters and a method for setting them dynamically so that the sub-list shows only the records related to the parent
Step 5, Configure and use the field
In your crud controllers, use the addField to add the the configuration for the new field and its related model
Indeed, there's no standard functionality to do that in Backpack. It's a pretty unusual way to do things. But it's not too difficult to achieve it.
If there aren't too many Vendors for one Publisher (as I expect it's the case here), I would keep it simple and NOT try to include the entire Backpack list view (with ajax, buttons, filters, etc) on top of the form. I would add a standard HTML table with the entries (and optionally buttons to Edit Vendor with target=_blank).
Here's how I would go about it:
In the Publisher CRUD, I would use a custom view for the Edit operation; you can do that using $this->crud->setEditView('edit_publisher_with_vendors') in your setup() method;
In that custom edit view (edit_publisher_with_vendors.blade.php in my example), I would copy-paste everything inside the edit.blade.php view that Backpack/CRUD is using, and add a table with the Vendors on top of the Edit form; notice you have the current entry as $entry in this view; since there's a relationship on the model, you would be able to check if it has vendors using $entry->vendors()->count(), and get the vendors using $entry->vendors.
Hope it helps.

Ionic UI Router issue: 2nd level state views not loading

I can't wrap my head around this issue I've been experiencing, or perhaps I'm missing some crucial point here. I jotted down this sample app on ionic playground, it is of course a simplified version of my app.
Basically I have a tabbed layout with two views which share a common datasource of items (in my app it's a sqlite db table); the first view displays items in a certain state whereas the other tab display the remaining items (in my example I've used the TODO list metaphor).
Each tab has a child state which I refer to as 2nd-level state (assuming level 0 is the abstract tab state. These two 2nd-level states are defined separately but share a common controller and template.
I cannot for the life of me understand why these two states aren't being navigated to when I click on a list item from either of the two lists (1st-level state views).
NOTE: In the ionic playground no error is thrown in the console, but I can't quite tell what is going on in terms of state URLs. But when I test my actual app (where the problem is the same) in a browser I can see the URL changing to #/tab/tasks/xxxx or #/tab/completed/xxxx but template is not loading. Upon googling I came across several SO questions:
Ui-router URL changes, nested view not loading
In Angular ui-router nested state url changes,but template is not loading
UI-Router: URL changes, but view is not loaded
Angular Router - Url changes but view does not load
URL changes but view does not hcange
Angular UI-Router : URL changed but view isn't loaded
but the answers provided therein haven't worked for me (tried, as per the last one I listed, to add the # sign after the view name in the child states, but to no avail).
Kinda stuck, would really appreciate some input! Cheers.
Managed to get it working following this answer; I had previously tried simply appending the # character after the view name in nested states but it turns out the trick was to append #tab, where tab is the name of the top-level abstract state. I updated my fiddle on ionic playground. Cheers to you all.

Which approach to use MVVM or Static

Im pretty new in using the MVVM architecture and looking for some advice on the "correct" to approach this task.
2 page app.
Page 1 displays the alphabet.
Page 2 displays the selected character's details.
Example - Select "A" and screen 2 displays apple, Apricot, Aprium. Select "B" screen 2 displays Banana, Blackberry, Blackcurrant, Blueberry.
Data is being retrieved from a web service everytime the user selects an alphabet character.
Would the correct approach be to create a static menu for screen 1 (as you would never have anything else other than the alphabet characters) and on the click event load the second screen with the items as above using the MVVM approach (i.e. pass in the selected character to the LoadItems method). Or is there a simpler way to do this using a MVVM structure?
Ive read around and its not very clear on when to use which approach but then again as i say im new with MVVM too and would like to learn the correct/preferred way so i can get a better understanding.
Another approach which maybe more in-keeping with the Windows Phone experience would be to have a single page containing a LongListSelector. Fruit bound to this view could then be grouped by letter. Implementing a JumpList would allow users to quickly navigate this list by jumping between groups. You can find a sample implementation here- http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj244365(v=vs.105).aspx
Microsoft actually prefers that when you use a list in windows phone it is always better to display it in another page. So you should populate the list in another page. And if you are selecting some thing to show then pass them as parameters using the NavigationService.Navigate or store the data in Phone Application State if you have to use app wide. Phone.Application.Resources . Its good that you are going through Mvvm You'll know Xaml, WP7,8, Get Metro Application Idea also Silverlight.
Heres a toolkit that might help you. It also displays the same way in a new Windows Not a popup
Long List Selector

GWT MVP - maintaining multiple displays that are separate of one another

I have a GWT App and I am using GWT MVP with Places / Activities.
My application layout is something like
MENU | CONTENT
The Menu and the Content displays will change dynamically and one changes separately from the other. What I mean by this is that when the Content display changes I do not want to have to update the Menu display and vice versa. Both displays need to be able to respond to PlaceChangeEvents and update themselves when these occur. The problem is that each display should only update in response to certain PlaceChangeEvents, ignoring PlaceChangeEvents that are directed at the other display. However this does not work using the 'standard' GWT MVP pattern because even when each display has it's own ActivityManager they will automatically pick up ALL PlaceChangeEvents because there is a single PlaceController listening on a single EventBus. The only way I can see to do this is by having two EventBus's and two PlaceControllers - one for the Menu and one for the Content. So my question is whether this is a good solution or is there a simpler/better way that I am missing? One problem with this solution is that the PlaceHistoryHandler can only be registered with one of the EventBus's.
Place changes are actually controlled by ActivityMappers. They get a Place and return the corresponding Activity. This is where you control how Places are mapped to Activities:
You need to create two ActivityMappers (MenuActivityMapper, ContentActivityMapper) and then instantiate two ActivityManagers each with it's own ActivityMappers. Then for each ActivityManager you call setDisplay(AcceptsOneWidget display) where for each you pass in an area (display) where it will show it's content.
For menu you will probably only use one Activity, since it's available in all Places. So MenuActivityMapper.getActivity() will always return the same instance of the MenuActivity. To enable MenuActivity to still adapt it's look based on place changes, MenuActivity should listen to PlaceChangeEvents.

Discover which (if any) route will match a given URL from within Controller in ASP.NET MVC2 app

In my master page I have a placeholder where a Html.RenderPartial() will render a collection of (bread)crumbs which are effectively a list of links I build up using action, controller names and RouteValueDictionary's.
I have an action that is called from multiple places to view a short-list and so when building the list of breadcrumbs for this actions view to display. Ideally I'd like to use Request.UrlReferer as the penultimate crumb.
Before unconditionally using this URL I want to check that it will actually match at least 1 route so I can be sure if the user clicks it they will get a view from my app and if they don't I will simply use the home page instead.
Any suggestions how I would go about this?
Take a look at this post http://haacked.com/archive/2007/12/17/testing-routes-in-asp.net-mvc.aspx