Create modal view configuration

Description

There is a need to do many types of editing in a modal – and these modals should be URL addressiable and be configurable as if there were views.

: This might be useful https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state

The modalStateService has been added here - https://github.com/OpenLMIS/openlmis-ui-components/commit/da4c5d43dbbbe4fed8bb37d72acb44e05b84b081

Acceptance Criteria

  • This ticket will establish the modal view pattern using UI-Router

  • Create secondary tickets for other views that need to be updated to use a modal

QAlity Plus - Test Management

Checklists

Activity

Nikodem Graczewski 
September 19, 2017 at 10:50 PM

One more thing. AngularStrap modal doesn't support nested resolves and to add them you need to follow the pattern below. With modalStateService we're getting the default stateProvider resolve behavior as the whole boilerplate code is done by that service.

This

becomes this

Nikodem Graczewski 
September 19, 2017 at 10:45 PM

Here's the example of the service usage

vs without it

Nikodem Graczewski 
September 19, 2017 at 10:37 PM

The thing with parent resolves is that they are not supported by angularstrap, so to pass them to the modal you actually need to inject it in the onEnter method, which then uses it is the modal resolve. With my implementation you simply define the parent resolves you want to have injected into your controller without writing that boilerplate code. So, in a way, my implementation fixes that gap rather than breaks it. I was trying to inject the parent resolves into the controller without this property, but I couldn't get it done, because I didn't have parent state definitions there, you can't actually pull them from $stateProvider (sadly). Well not in an easy way at least.

Also I'm not sure what's the difference between calling a proper service and adding a 'layout' property to the state definition. We're still passing information about the markup with the route declaration. Wouldn't that be basically them but in a slightly different form?

Nick Reid 
September 19, 2017 at 10:22 PM

No worries, let's keep this ticket – and let's leave the existing implementation for now (as I don't really want to refactor working code that is DRY) – lets just not spread the implementation until later

Yes, I think adding a 'layout' property to the state definition is a solid and decoupled way to approach this

Parent resolves: Yes

Nikodem Graczewski 
September 19, 2017 at 8:07 PM

Unfortunately I don't think we'll be able to pull this ticket this Sprint.

By the route configuration approach you mean adding a 'layout' property to state definition and make it accept a 'modal' value?

About the broken functionality, do you mean the parent resolves?

Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Components

Priority

Time Assistant

Created May 3, 2017 at 11:22 PM
Updated February 8, 2023 at 1:30 PM