Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mix of named and not named views
Message
De
26/03/2015 11:32:50
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01617276
Message ID:
01617283
Vues:
23
>>>>>
>>>>> .state('edit.invoices', {
>>>>>                url: '/invoices:invoiceId?accountNameHash?isNew',
>>>>>                views: {
>>>>>                    'invoices': {
>>>>>                        templateUrl: '/CustomerAccounts/accounts/EditAccountInvoices',
>>>>>                        controller: 'invoicesSearchController'
>>>>>                    },
>>>>>                    'detail': {
>>>>>                        templateUrl: '/CustomerAccounts/invoices/editForm',
>>>>>                        controller: 'invoicesCrudController'
>>>>>                    }
>>>>>                }
>>>>>            })
>>>>>
>>>>>And the SelectView method is the following:
>>>>>
>>>>>
>>>>>$scope.selectView = function (viewName) {
>>>>>              if (viewName === 'invoices') {
>>>>>                  $scope.invoicesViewActivated = true;                  
>>>>>              }
>>>>>              else
>>>>>                  $scope.invoicesViewActivated = false;
>>>>>              
>>>>>              window.console && console.log('SelectView called with the ' + viewName + ' view...');
>>>>>
>>>>>              if ($scope.isNew) {
>>>>>                  $state.go('new.' + viewName);                  
>>>>>              }
>>>>>              else {
>>>>>                 $state.go('edit.' + viewName);                
>>>>>              }
>>>>>          };
>>>>>
>>>>>So, this is what is happening when I click on the Invoices tab: the invoices view is activated, but also the details view is activated and the general page of the edit invoices view. This is not what I want to be happening as I haven't clicked on the individual invoice in the grid yet. Also, the two other tabs (Apply Fees and Pay Invoices) share the same functionality and suppose to also be able to call the invoice edit form when clicking on the invoice.
>>>>>
>>>>>So, I am a bit confused as what should I do to avoid calling unnecessary code when not needed. I don't want to activate details view and related views till I actually click on the invoice.
>>>>>
>>>>>Please see attached and note the console messages as what is happening here.
>>>>>
>>>>>Thanks a lot in advance.
>>>>
>>>>Only a quick look but it seems to me that your selectView() function is always activating either the new.x or edit.x states. Shouldn't that last state change be triggered when the invoice is selected.
>>>>
>>>>No attachment BTW
>>>
>>>There is an attachment, I re-checked. Please see at the top of my message. I am not sure I understood your point.
>>
>>You are calling selectView() from most tab selects and AFAICS that triggers $state.go to your edit/new views. If you don't want them to show up then don't go to that state until an invoice is selected.
>>
>>> The Invoices is a tab along others but defined differently than others as it has 2 named views. Other tabs are defined without named views. I also discovered yesterday that I can not always easily transition from invoices tab to other tabs, I will need to play with that to see the exact problem.
>>>
>>>I am thinking that this form will need to be re-designed as we can not safely mix named and not named views this way.
>>
>>There's nothing unsafe in using a mix of named and unnamed views.
>>BTW why are you bothering to use tabs when they have no content. Seems to me that, as they stand, they are just glorified buttons ?
>
>What do you mean by no content? The select view procedure opens a view for each tab. E.g. we have separate cshtml for each tab which is defined in the state.config (which I didn't show.

You are just showing the view *below* the tabs - normally the view would be the *content* of the tab like so:
<tabset>
                <tab heading="Tab 1"><div ui-view="View1"></div></tab>
                <tab heading="Tab 2"><div ui-view="View2"></tab>
            </tabset>
>
>So, what exactly is supposed to happen when we go to edit.invoices state which includes two views? Are both views activated?

Yes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform