app.js 1.79 KB
Newer Older
François C. committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic', 'ui.router', 'odoo'])

.run(function($ionicPlatform) {
    $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the 
        //accessory bar above the keyboard for form inputs)
        if(window.StatusBar) {
            StatusBar.styleDefault();
        }
    });
})
.run(['jsonRpc', '$state', '$rootScope', function (jsonRpc, $state, $rootScope) {
    jsonRpc.errorInterceptors.push(function (a) {
        if (a.title === 'session_expired')
            $state.go('login');
    });
    $rootScope.logout = function() {
        $state.go('logout');
    };
}])
.config(['$stateProvider','$urlRouterProvider' , function ($stateProvider, $urlRouterProvider) {
  $stateProvider.state(
    'login', {
        url: '/login?db&username&password',
        templateUrl: 'views/v_login.html',
        controller: 'LoginCtrl'
  }).state(
    'logout', {
        url: '/logout',
        templateUrl: 'views/v_login.html',
        controller: 'LoginCtrl'
  }).state(
    'partner_search', {
        url: '/partner_search',
        templateUrl: 'views/v_partner_search.html',
        controller: 'PartnerSearchCtrl'
  }).state(
    'partner_list', {
        url: '/partner_list:partner_ids',
        templateUrl: 'views/v_partner_list.html',
        controller: 'PartnerListCtrl'
  }).state(
    'partner_form', {
        url: '/partner_form/:partner_id',
        templateUrl: 'views/v_partner_form.html',
        controller: 'PartnerFormCtrl'
  });
  $urlRouterProvider.otherwise('login');
}]);