From 1c97e6310bde9003e19d5603a0256f99fb005561 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Thu, 24 Mar 2016 11:44:38 +0100 Subject: [PATCH] feat: ui-router for routing This commit adds in ui-router to the bower dependencies, removes ngRoute, and adjusts the code to work with ui-router. --- bower.json | 5 +- client/src/index.html | 2 +- client/src/js/app.js | 499 +++++++++--------- client/src/partials/cash/cash.js | 6 +- client/src/partials/patients/edit/edit.js | 6 +- .../e2e/debtor_groups/debtorGroups.spec.js | 6 +- .../sectors_management.spec.js | 14 +- gulpfile.js | 12 +- server/models/test/data.sql | 6 +- 9 files changed, 264 insertions(+), 292 deletions(-) diff --git a/bower.json b/bower.json index 4c15916f1a..3265832843 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,6 @@ "dependencies": { "angular": "^1.5.0", "angular-bootstrap": "^1.2.1", - "angular-route": "^1.5.0", "angular-sanitize": "^1.5.0", "angular-translate": "^2.10.0", "angular-translate-loader-static-files": "^2.10.0", @@ -26,13 +25,15 @@ "ng-file-upload": "^12.0.1", "ng-file-upload-shim": "^12.0.1", "angular-ui-grid": "^3.1.1", + "angular-ui-router": "^0.2.18", "bootstrap": "~3.3.6", "angular-moment": "^1.0.0", "moment": "^2.11.2", "angular-dynamic-locale": "~0.1.29", "angular-messages": "^1.5.0", "ngstorage": "^0.3.10", - "angular-ui-router": "^0.2.18" + "Chart.js": "^1.0.2", + "angular-chart.js": "^0.9.0" }, "resolutions": { "angular": "^1.5.0" diff --git a/client/src/index.html b/client/src/index.html index 5b6c12162f..2f3ba6f060 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -82,7 +82,7 @@

{{AppCtrl.projectName}}

-
+
diff --git a/client/src/js/app.js b/client/src/js/app.js index d5e4462c0f..2304e49671 100644 --- a/client/src/js/app.js +++ b/client/src/js/app.js @@ -1,58 +1,67 @@ var bhima = angular.module('bhima', [ - 'bhima.controllers', 'bhima.services', 'bhima.directives', 'bhima.filters', 'bhima.components', 'ngRoute', + 'bhima.controllers', 'bhima.services', 'bhima.directives', 'bhima.filters', 'bhima.components', 'ui.router', 'ui.bootstrap', 'pascalprecht.translate', 'ngStorage', 'chart.js', 'tmh.dynamicLocale', 'ngFileUpload', 'ui.grid', 'ui.grid.selection', 'ui.grid.autoResize', 'ui.grid.resizeColumns', 'angularMoment', 'ngMessages', 'ui.grid.pagination', 'ui.grid.moveColumns', 'ui.grid.grouping' ]); -function bhimaconfig($routeProvider) { - // TODO: Dynamic routes loaded from unit database? - +function bhimaConfig($stateProvider, $urlRouterProvider) { /* misc routes */ - $routeProvider - .when('/', { + $stateProvider + .state('index', { + url : '/', controller : 'HomeController as HomeCtrl', templateUrl : 'partials/home/home.html' }) - .when('/login', { + .state('login', { + url : '/login', controller : 'LoginController as LoginCtrl', templateUrl : 'partials/login/login.html' }) - .when('/permissions', { + .state('permissions', { + url : '/permissions', controller: 'PermissionsController as PermissionsCtrl', templateUrl: 'partials/permissions/permissions.html' }) - .when('/enterprises', { + .state('enterprises', { + url : '/enterprises', controller: 'EnterpriseController as EnterpriseCtrl', templateUrl: 'partials/enterprises/enterprises.html' }) - .when('/projects', { + .state('projects', { + url : '/projects', controller : 'ProjectController as ProjectCtrl', templateUrl : 'partials/projects/projects.html' }) - .when('/fiscal', { + .state('fiscal', { + url : '/fiscal', controller: 'FiscalController as FiscalCtrl', templateUrl: 'partials/fiscal/fiscal.html' }) - .when('/exchange', { + .state('exchange', { + url : '/exchange', controller : 'ExchangeRateController as ExchangeCtrl', templateUrl: 'partials/exchange/exchange.html' }) - .when('/settings/:route?', { + .state('settings', { + url : '/settings', controller: 'settings as SettingsCtrl', templateUrl: 'partials/settings/settings.html' }) - .when('/services', { + .state('services', { + url : '/services', controller : 'ServicesController as ServicesCtrl', templateUrl : 'partials/services/services.html' }) - .when('/caution', { + .state('caution', { + url : '/caution', controller : 'CautionController as CautionCtrl', templateUrl : 'partials/caution/caution.html' }) - .when('/extra_payment', { + .state('extra_payment', { + url : '/extra_payment', controller : 'ExtraPaymentController as PaymentCtrl', templateUrl : 'partials/cash/extra_payment/extra_payment.html' }) @@ -61,133 +70,166 @@ function bhimaconfig($routeProvider) { * @fixme - this is to allow end to end testing of the patient invoice module * @todo - replace this with a real receipt. */ - .when('/invoice/sale/:invoiceId', { + .state('invoiceMessage', { + url : '/invoice/sale/:invoiceId', template: '
Successfully created a patient invoice!
' }) - .when('/invoice/:originId/:invoiceId', { + .state('invoice', { + url : '/invoice/:originId/:invoiceId', controller: 'receipts', templateUrl: 'partials/receipts/receipts.html' }) - .when('/cash_discard/:receiptId?', { + .state('/cash_discard/:receiptId?', { controller: 'cashDiscard', templateUrl: 'partials/cash/discard/discard.html' }) - .when('/section_bilan', { + .state('configBilan', { + url: '/section_bilan', controller : 'sectionBilanController as sectionBilanCtrl', templateUrl : 'partials/section_bilan/section_bilan.html' }) - .when('/section_resultat', { + .state('configResultat', { + url : '/section_resultat', controller : 'sectionResultatController as sectionResultatCtrl', templateUrl : 'partials/section_resultat/section_resultat.html' }) - .when('/variation_exploitation', { + .state('/variation_exploitation', { controller : 'variationExploitationController as variationCtrl', templateUrl : 'partials/reports_proposed/variation_exploitation/variation_exploitation.html' }) - .when('/group_invoice', { + .state('groupInvoice', { + url : '/group_invoice', controller : 'GroupInvoiceController as InvoiceCtrl', templateUrl : 'partials/group_invoice/group_invoice.html' }) - .when('/support/:id?', { + .state('support', { + url : '/support/:id?', controller : 'support', templateUrl : 'partials/support/support.html' }) - .when('/accounts', { + .state('accounts', { + url : '/accounts', controller: 'AccountsController as AccountsCtrl', templateUrl: 'partials/accounts/accounts.html' }) - .when('/dashboards/finance', { + .state('dashboards/finance', { + url : '/dashboards/finance', templateUrl : 'partials/dashboard/finance.html' }) - .when('/config_accounting', { + .state('/config_accounting', { controller: 'ConfigAccountingController as ConfigAccountCtrl', templateUrl: 'partials/payroll/config_accounting/config_accounting.html' }) - .when('/subsidies', { + .state('subsidies', { + url : '/subsidies', controller : 'SubsidyController as SubsidyCtrl', templateUrl : 'partials/subsidies/subsidies.html' }) - .when('/report/invoice/:target', { + .state('/report/invoice/:target', { controller : 'configureInvoice', templateUrl : 'partials/reports_proposed/invoice/invoice.html' }) /* Admin : depot management */ - .when('/depots_management', { + .state('/depots_management', { + url : '/depots_management', controller : 'DepotManagementController as DepotCtrl', templateUrl : 'partials/depots_management/depots_management.html' }) /* Admin : debtor group management */ - .when('/debtor_groups', { + .state('debtor_groups', { + url : '/debtor_groups', controller : 'DebtorGroupsController as DebtorGroupCtrl', templateUrl : 'partials/debtor_groups/debtor_groups.html' }) /* employees routes */ - .when('/employees', { + .state('employees', { + url : '/employees', controller : 'EmployeeController as EmployeeCtrl', templateUrl : 'partials/employees/employees.html' }) - .when('/employees/fonction', { + .state('/employees/fonction', { controller : 'FonctionController', templateUrl : 'partials/employees/fonction/fonction.html' }) - .when('/employees/grades', { + .state('/employees/grades', { controller : 'EmployeeGradeController', templateUrl : 'partials/employees/grades/grades.html' }) - .when('/employees/offdays', { + .state('/employees/offdays', { controller : 'OffdayController as OffdayCtrl', templateUrl : 'partials/employees/offdays/offdays.html' }) - .when('/employees/holidays', { + .state('/employees/holidays', { controller : 'HolidayController as HolidayCtrl', templateUrl : 'partials/employees/holidays/holidays.html' }) /* location routes */ - .when('/locations', { + .state('/locations', { + url : '/locations', controller : 'LocationController as LocationCtrl', templateUrl: 'partials/locations/locations.html' }) - .when('/locations/village', { + .state('locations/village', { + url : '/locations/village', controller : 'VillageController as VillageCtrl', templateUrl: 'partials/locations/village/village.html' }) - .when('/locations/sector', { + .state('locations/sector', { + url : '/locations/sector', controller : 'SectorController as SectorCtrl', templateUrl: 'partials/locations/sector/sector.html' }) - .when('/locations/province', { + .state('locations/province', { + url : '/locations/province', controller : 'ProvinceController as ProvinceCtrl', templateUrl: 'partials/locations/province/province.html' }) - .when('/locations/country', { + .state('locations/country', { + url : '/locations/country', controller : 'CountryController as CountryCtrl', templateUrl: 'partials/locations/country/country.html' }) /* budget routes */ - .when('/budgets/create', { + .state('/budgets/create', { controller: 'NewBudgetController as BudgetCtrl', templateUrl: 'partials/budget/create/create.html' }) - .when('/budgets/update', { + .state('/budgets/update', { controller: 'editAccountBudget', templateUrl: 'partials/budget/update/update.html' }) - .when('/budgets/analysis', { + .state('/budgets/analysis', { controller: 'AnalysisBudgetController as BudgetCtrl', templateUrl: 'partials/budget/analysis/analysis.html' }) - .when('/budgets/:accountID?', { + .state('/budgets/:accountID?', { controller: 'budget', templateUrl: 'partials/budget/budget.html' }) - .when('/vouchers/simple', { + + /* journal routes */ + + .state('/journal', { + controller: 'journal.grid', + templateUrl:'partials/journal/journal.html' + }) + .state('/journal/print', { + controller : 'journal.print', + templateUrl : 'partials/journal/print.html' + }) + .state('/journal/voucher', { + controller: 'JournalVoucherController as JournalVoucherCtrl', + templateUrl: 'partials/journal/voucher/voucher.html' + }) + .state('simpleVouchers', { + url : '/vouchers/simple', controller: 'SimpleJournalVoucherController as SimpleVoucherCtrl', templateUrl: 'partials/vouchers/simple.html' }) @@ -200,102 +242,97 @@ function bhimaconfig($routeProvider) { /* debtors routes */ - .when('/debtors/groups', { + .state('debtors/groups', { + url : '/debtors/groups', controller : 'DebtorGroupController as GroupCtrl', templateUrl: 'partials/debtors/groups.html' }) /* references routes */ - .when('/references', { + .state('references', { + url : '/references', controller: 'ReferenceController', templateUrl: 'partials/references/references.html' }) - .when('/references/groups', { + .state('/references/groups', { controller: 'ReferenceGroupController as ReferenceGroupCtrl', templateUrl: 'partials/references/groups/groups.html' }) /* inventory routes */ - .when('/inventory', { + .state('/inventory', { controller: 'inventory', templateUrl: '/partials/inventory/inventory.html' }) - .when('/inventory/view', { + .state('/inventory/view', { controller : 'inventoryView', templateUrl:'/partials/inventory/view/view.html' }) - .when('/inventory/register', { + .state('/inventory/register', { controller: 'InventoryRegisterController', templateUrl: '/partials/inventory/register/register.html' }) - .when('/inventory/update', { + .state('/inventory/update', { controller : 'InventoryUpdateController', templateUrl : 'partials/inventory/update_item/update_item.html' }) - .when('/inventory/groups', { + .state('/inventory/groups', { controller : 'inventory.groups', templateUrl : 'partials/inventory/groups/groups.html' }) - .when('/inventory/types', { + .state('/inventory/types', { controller : 'InventoryTypeController', templateUrl : 'partials/inventory/types/types.html' }) - .when('/inventory/manifest', { + .state('/inventory/manifest', { controller : 'inventory.manifest', templateUrl : 'partials/inventory/manifest/manifest.html' }) - .when('/inventory/depot', { + .state('/inventory/depot', { controller : 'inventory.depot', templateUrl : 'partials/inventory/depot/depot.html' }) - .when('/prices', { + .state('prices', { + url : '/prices', controller: 'PriceListController as PriceListCtrl', templateUrl: 'partials/price_list/pricelist.html' }) - .when('/inventory/distribution/:depotId?', { + .state('/inventory/distribution/:depotId?', { controller : 'InventoryDistributionController', templateUrl : 'partials/inventory/distribution/distribution.html' }) /* sales routes */ - - .when('/sales', { + .state('sales', { + url : '/sales', controller: 'sales', templateUrl: '/partials/sales/sales.html' }) - .when('/sales/records/:recordID?', { - controller: 'salesRecords', - templateUrl: '/partials/records/sales_records/sales_records.html' - }) - .when('/credit_note/:invoiceId?', { - controller: 'CreditNoteController as NoteCtrl', - templateUrl: 'partials/sales/credit_note/credit_note.html' - }) /* cash routes */ - .when('/cash', { + .state('/cash', { + url : '/cash', controller: 'CashboxSelectController as CashboxSelectCtrl', templateUrl: '/partials/cash/cashboxSelect.html' }) - .when('/cash/:id', { + .state('/cash/:id', { + url : '/cash/:id', controller: 'CashController as CashCtrl', templateUrl: '/partials/cash/cash.html' }) - .when('/cash/records/:recordID?', { - controller: 'auxillaryRecords', - templateUrl: '/partials/records/auxillary_cash_records/auxillary_cash_records.html' - }) /* creditor routes */ - .when('/creditors', { + .state('creditors', { + url : '/creditors', controller: 'SupplierController as SupplierCtrl', templateUrl: '/partials/creditors/creditors.html' }) - .when('/creditors/groups', { + .state('creditors/groups', { + url : '/creditors/groups', controller: 'CreditorGroupController', templateUrl: 'partials/creditors/groups/groups.html' }) @@ -303,542 +340,479 @@ function bhimaconfig($routeProvider) { /* purchase routes */ - .when('/purchases', { + .state('purchases', { + url : '/purchases', controller : 'PurchaseController', templateUrl : 'partials/purchases/purchases.html' }) - .when('/purchases/create', { + .state('/purchases/create', { controller: 'CreatePurchaseOrderController', templateUrl: 'partials/purchases/create/purchase.html' }) - .when('/purchases/view', { + .state('/purchases/view', { controller: 'purchaseRecords as purchaseRecordsCtrl', templateUrl: 'partials/purchases/view/purchase_records.html' }) - .when('/purchases/view/:option', { + .state('/purchases/view/:option', { controller: 'purchase_view', templateUrl: 'partials/purchases/view/purchase_view.html' }) - .when('/purchases/confirm', { + .state('/purchases/confirm', { controller: 'PurchaseConfirm as purchaseConfirmCtrl', templateUrl: 'partials/purchases/confirm/confirm.html' }) - .when('/purchases/validate', { + .state('/purchases/validate', { controller: 'purchaseValidate', templateUrl: 'partials/purchases/validate/validate.html' }) - .when('/purchases/authorization', { + .state('/purchases/authorization', { controller: 'purchaseAuthorization', templateUrl: 'partials/purchases/authorization/authorization.html' }) /* cost center routes */ - .when('/cost_center', { + .state('/cost_center', { controller: 'CostCenterController as CenterCtrl', templateUrl: 'partials/cost_center/cost_center.html' }) - .when('/cost_center/center', { + .state('/cost_center/center', { controller: 'AnalysisCostCenterController as CenterCtrl', templateUrl: 'partials/cost_center/center/analysis_center.html' }) - .when('/cost_center/assigning', { + .state('/cost_center/assigning', { controller: 'CostCenterAssignmentController', templateUrl: 'partials/cost_center/assigning/assigning.html' }) - .when('/cost_center/allocation', { + .state('/cost_center/allocation', { controller: 'CostCenterAllocationController as CenterCtrl', templateUrl: 'partials/cost_center/allocation/allocation.html' }) /* profit center routes */ - .when('/profit_center', { + .state('/profit_center', { controller: 'ProfitCenterController as CenterCtrl', templateUrl: 'partials/profit_center/profit_center.html' }) - .when('/profit_center/center', { + .state('/profit_center/center', { controller: 'AnalysisProfitCenterController as CenterCtrl', templateUrl: 'partials/profit_center/center/analysis.html' }) - .when('/profit_center/allocation', { + .state('/profit_center/allocation', { controller: 'ProfitCenterAllocationController as ProfitCtrl', templateUrl: 'partials/profit_center/allocation/allocation.html' }) /* patients routes */ - .when('/patients/register', { + .state('patients/register', { + url : '/patients/register', controller: 'PatientRegistrationController as PatientRegCtrl', templateUrl: 'partials/patients/registration/registration.html' }) /* Patient Edit */ - .when('/patients/edit/', { + .state('patients/edit/', { + url : '/patients/edit', controller : 'PatientEditFind as PatientEditFindCtrl', templateUrl : 'partials/patients/edit/find.html' }) - .when('/patients/edit/:patientID', { + .state('patients/edit/:patientID', { + url : '/patients/edit/:patientID', controller: 'PatientEdit as PatientEditCtrl', templateUrl: 'partials/patients/edit/edit.html' }) /* */ - .when('/invoices/patient', { + .state('patientInvoice', { + url : '/invoices/patient', controller : 'PatientInvoiceController as PatientInvoiceCtrl', templateUrl : 'partials/patient_invoice/patientInvoice.html' }) - .when('/patients/search/:patientID?', { + .state('/patients/search/:patientID?', { controller: 'patientRecords', templateUrl: '/partials/patients/search/search.html' }) - .when('/patients/groups', { + .state('/patients/groups', { controller: 'patientGroup', templateUrl: 'partials/patients/groups/groups.html' }) - .when('/patients/groups/assignment', { + .state('/patients/groups/assignment', { controller: 'AssignPatientGroupController', templateUrl: 'partials/patients/groups/assignment.html' }) - .when('/patients/debtor', { + .state('/patients/debtor', { controller : 'group.debtor.reassignment', templateUrl : 'partials/patients/debtor/swap.html' }) - - /* primary cash routes */ - - .when('/trialbalance/print', { + .state('/trialbalance/print', { controller : 'TrialBalancePrintController as PrintCtrl', templateUrl : 'partials/journal/trialbalance/print.html' }) - /* primary cash routes */ - - .when('/primary_cash', { - controller : 'PrimaryCashController as PrimaryCtrl', - templateUrl : 'partials/primary_cash/primary.html' - }) - .when('/primary_cash/:cashbox_id/transfer', { - controller : 'PrimaryCashIncomeTransferController as TransferCtrl', - templateUrl : 'partials/primary_cash/income/transfer/transfer.html' - }) - .when('/primary_cash/:cashbox_id/convention', { - controller : 'PrimaryCashConventionController as ConventionCtrl', - templateUrl : 'partials/primary_cash/income/convention/convention.html' - }) - .when('/primary_cash/:cashbox_id/support', { - controller : 'PrimaryCashSupportController as SupportCtrl', - templateUrl : 'partials/primary_cash/income/support/support.html' - }) - .when('/primary_cash/:id/income/generic', { - controller : 'PrimaryCashIncomeGenericController as GenericIncomeCtrl', - templateUrl : 'partials/primary_cash/income/generic/generic.html' - }) - .when('/primary_cash/:id/expense/generic', { - controller : 'PrimaryCashExpenseGenericController as GenericExpenseCtrl', - templateUrl: 'partials/primary_cash/expense/generic.html' - }) - .when('/primary_cash/:cashbox/expense/purchase', { - controller : 'PurchaseOrderCashController as PurchaseCtrl', - templateUrl : 'partials/primary_cash/expense/purchase.html' - }) - .when('/primary_cash/:cashbox/expense/payroll', { - controller : 'payroll', - templateUrl : 'partials/primary_cash/expense/payroll.html' - }) - .when('/primary_cash/:cashbox/expense/refund', { - controller : 'PrimaryCashReturnController as ReturnCtrl', - templateUrl : 'partials/primary_cash/expense/cash_return.html' - }) - .when('/primary_cash/expense/multi_payroll', { - controller : 'MultiPayrollController as PayrollCtrl', - templateUrl : 'partials/primary_cash/expense/multi_payroll.html' - }) - .when('/primary_cash/:cashbox/expense/tax_payment', { - controller : 'primary_cash.tax_payment', - templateUrl : 'partials/primary_cash/expense/tax_payment.html' - }) - .when('/primary_cash/:cashbox/expense/enterprise_tax_payment', { - controller : 'primary_cash.enterprise_tax_payment', - templateUrl : 'partials/primary_cash/expense/enterprise_tax_payment.html' - }) - .when('/primary_cash/:cashbox/expense/cotisation_payment', { - controller : 'primary_cash.cotisation_payment', - templateUrl : 'partials/primary_cash/expense/cotisation_payment.html' - }) - .when('/primary_cash/:cashbox/expense/salary_payment', { - controller : 'primary_cash.salary_payment', - templateUrl : 'partials/primary_cash/expense/salary_payment.html' - }) - .when('/primary_cash/:cashbox/expense/partial_payment', { - controller : 'primary_cash.partial_payment', - templateUrl : 'partials/primary_cash/expense/partial_payment.html' - }) - .when('/primary_cash/:cashbox/expense/payday_advance', { - controller : 'primary_cash.payday_advance', - templateUrl : 'partials/primary_cash/expense/payday_advance.html' - }) - /* depot routes */ - - .when('/depots', { + .state('depots', { + url : '/depots', controller : 'DepotController as DepotCtrl', templateUrl : 'partials/depots/depots.html' }) - .when('/depots/:depotId/entry', { + .state('/depots/:depotId/entry', { controller : 'DepotEntryController', templateUrl : 'partials/depots/entry/entry.html' }) - .when('/depots/:depotId/losses', { + .state('/depots/:depotId/losses', { controller : 'DepotLossController as LossCtrl', templateUrl : 'partials/depots/loss/loss.html' }) - .when('/depots/:depotId/movements', { + .state('/depots/:depotId/movements', { controller : 'StockMovementController as MovementCtrl', templateUrl : 'partials/depots/movement/movement.html' }) - .when('/depots/:depotId/distributions/patients', { + .state('/depots/:depotId/distributions/patients', { controller : 'StockDistributionsController as StockDistributionsCtrl', templateUrl : 'partials/depots/distributions/patients/patients.html' }) - .when('/depots/:depotId/distributions/services', { + .state('/depots/:depotId/distributions/services', { controller : 'StockServiceDistributionsController as DistributionsCtrl', templateUrl : 'partials/depots/distributions/services/services.html' }) - .when('/depots/:depotId/distributions/:consumptionId/cancel', { + .state('/depots/:depotId/distributions/:consumptionId/cancel', { controller : 'DepotDistributionsCancelController as CancelCtrl', templateUrl : 'partials/depots/distributions/cancel/cancel.html' }) - .when('/depots/:depotId/integrations', { + .state('/depots/:depotId/integrations', { controller : 'stockIntegration as integrationCtrl', templateUrl : 'partials/stock/integration/integration.html' }) - .when('/depots/:uuid/search', { + .state('/depots/:uuid/search', { controller : 'DepotStockSearchController', templateUrl: 'partials/depots/stock_search/search.html' }) - .when('/depots/:depotId/reports/distributions/:type', { + .state('/depots/:depotId/reports/distributions/:type', { controller : 'DepotStockDistributionsController as DistributionsCtrl', templateUrl : 'partials/depots/reports/distributions/distributions.html' }) - .when('/stock/entry/report/:documentId?', { + .state('/stock/entry/report/:documentId?', { controller : 'stock.entry.report', templateUrl : 'partials/stock/entry/report.html' }) // TODO -- these should probably have an /inventory/ or /depot/ prefix - .when('/stock/count', { + .state('/stock/count', { controller : 'stock.count', templateUrl : 'partials/stock/count/count.html' }) - .when('/stock/expiring/:depotId', { + .state('/stock/expiring/:depotId', { controller : 'stock.expiring', templateUrl : 'partials/stock/expiring/expiring.html' }) /* donation routes */ - .when('/donors', { + .state('donors', { + url : '/donors', controller: 'DonorManagementController', templateUrl: '/partials/inventory/donors/donors.html' }) - .when('/donations/:depotId?', { + .state('/donations/:depotId?', { controller : 'DonationManagementController as DonationCtrl', templateUrl : 'partials/donations/donations.html' }) - .when('/donations/confirm', { + .state('/donations/confirm', { controller : 'ConfirmDonationController as ConfirmCtrl', templateUrl : 'partials/donations/confirm/confirm.html' }) - .when('/donations/report/:documentId', { + .state('/donations/report/:documentId', { controller : 'ReportDonationsController', templateUrl : 'partials/donations/report.html' }) // TODO -- these should be namespaced/prefixed by depot - .when('/stock/dashboard', { + .state('/stock/dashboard', { controller : 'StockDashboardController as StockDashCtrl', templateUrl : 'partials/stock/dashboard/dashboard.html' }) - .when('/stock/integration_confirm', { + .state('/stock/integration_confirm', { controller : 'ConfirmStockIntegrationController as ConfirmCtrl', templateUrl : 'partials/stock/integration/confirm_integration/confirm_integration.html' }) /* snis routes */ - .when('/snis', { + .state('/snis', { controller : 'SnisController', templateUrl : 'partials/snis/snis.html' }) - .when('/snis/create', { + .state('/snis/create', { controller : 'SnisCreateController', templateUrl : 'partials/snis/create/create.html' }) - .when('/snis/update/:id', { + .state('/snis/update/:id', { controller : 'SnisUpdateController', templateUrl : 'partials/snis/update/update.html' }) /* tax routes */ - .when('/taxes', { + .state('/taxes', { controller : 'TaxesController', templateUrl : 'partials/taxes/taxes.html' }) - .when('/taxes/create', { + .state('/taxes/create', { controller : 'CreateTaxController', templateUrl : 'partials/taxes/create/create.html' }) - .when('/taxes/ipr', { + .state('/taxes/ipr', { controller : 'taxes_management.ipr', templateUrl : 'partials/taxes/ipr/ipr.html' }) - .when('/taxes/config_tax', { + .state('/taxes/config_tax', { controller : 'config_tax', templateUrl : 'partials/taxes/config/config.html' }) /* cotisations management */ - .when('/cotisations_management', { + .state('/cotisations_management', { controller : 'cotisations_management.menu', templateUrl : 'partials/cotisation/cotisation_management.html' }) - .when('/cotisations_management/create', { + .state('/cotisations_management/create', { controller : 'cotisations_management.create', templateUrl : 'partials/cotisation/create/create_cotisation.html' }) - .when('/cotisations_management/config_cotisation', { + .state('/cotisations_management/config_cotisation', { controller : 'config_cotisation', templateUrl : 'partials/cotisation/config_cotisation/config_cotisation.html' }) - - .when('/payment_period', { + .state('/payment_period', { controller : 'PaymentPeriodController', templateUrl : 'partials/payroll/payment_period/payment_period.html' }) - - .when('/rubric_management', { + .state('/rubric_management', { controller : 'rubric_management.menu', templateUrl : 'partials/payroll/rubrics/rubrics.html' }) - .when('/rubric_management/config_rubric', { + .state('/rubric_management/config_rubric', { controller : 'config_rubric', templateUrl : 'partials/payroll/rubrics/config_rubric/config_rubric.html' }) - .when('/rubric_management/rubriques_payroll', { + .state('/rubric_management/rubriques_payroll', { controller : 'RubriquePayrollController as RubriqueCtrl', templateUrl : 'partials/payroll/rubrics/rubriques_payroll/rubriques_payroll.html' }) /* cashbox routes */ - .when('/cashboxes', { + .state('cashboxes', { + url : '/cashboxes', controller : 'CashboxController as CashCtrl', templateUrl : 'partials/cash/cashboxes/cashboxes.html' }) - .when('/cashboxes/:uuid/currencies', { + .state('cashboxes.currencies', { + url : '/cashboxes/:uuid/currencies', controller : 'cash.cashbox_account', templateUrl : 'partials/cash/cashboxes/currencies/currencies.html' }) /* reports routes */ - .when('/reports/daily_consumption', { + .state('/reports/daily_consumption', { controller : 'ReportDailyConsumptionController as ReportCtrl', templateUrl : 'partials/reports/daily_consumption/daily_consumption.html' }) - .when('/reports/distributions', { + .state('/reports/distributions', { controller : 'ReportDepotDistributionsController as ReportCtrl', templateUrl : 'partials/reports/distributions/distributions.html' }) - .when('/reports/finance', { + .state('/reports/finance', { controller: 'reportFinance', templateUrl: 'partials/reports/finance/finance_report.html' }) - .when('/reports/patient_registrations', { + .state('/reports/patient_registrations', { controller : 'reportPatientRegistrations', templateUrl : 'partials/reports/patient_registrations/patient_registrations.html' }) - .when('/reports/cash_payments', { + .state('/reports/cash_payments', { controller: 'reportCashPayments', templateUrl: 'partials/reports/cash_payments/cash_payments.html' }) - .when('/reports/summary', { + .state('/reports/summary', { controller: 'summary', templateUrl: 'partials/reports/summary/summary.html' }) - .when('/reports/patient_group/:uuid', { + .state('/reports/patient_group/:uuid', { controller : 'report.patientGroup', templateUrl : 'partials/reports/patient_group/patient_group.html' }) - .when('/reports/prices', { + .state('/reports/prices', { controller : 'report.prices', templateUrl : 'partials/reports/prices/prices.html' }) - .when('/reports/transactions/account', { + .state('/reports/transactions/account', { controller : 'report.transactions.account', templateUrl : 'partials/reports/transactions/account.html' }) - .when('/reports/transaction_report', { + .state('/reports/transaction_report', { controller: 'reportTransaction', templateUrl: 'partials/reports/transaction_report/transaction_report.html' }) - .when('/reports/patient_standing', { + .state('/reports/patient_standing', { controller : 'reportPatientStanding', templateUrl : '/partials/reports/patient_standing/patient_standing.html' }) - .when('/reports/employee_standing', { + .state('/reports/employee_standing', { controller : 'reportEmployeeStanding', templateUrl : '/partials/reports/employee_standing/employee_standing.html' }) - .when('/reports/ledger/general_ledger', { + .state('/reports/ledger/general_ledger', { controller: 'reportGeneralLedger', templateUrl: '/partials/reports/ledger/general_ledger.html' }) - .when('/reports/payroll_report', { + .state('/reports/payroll_report', { controller : 'payroll_report', templateUrl : 'partials/reports/payroll_report/payroll_report.html' }) - .when('/reports/operating_account', { + .state('/reports/operating_account', { controller : 'OperatingAccountController as OperatingCtrl', templateUrl : 'partials/reports/operating_account/operating_account.html' }) - .when('/reports/debtor_aging', { + .state('/reports/debtor_aging', { controller: 'reportDebitorAging', templateUrl: 'partials/reports/debtor_aging/debtor_aging.html' }) - .when('/reports/account_statement/:id?', { + .state('/reports/account_statement/:id?', { controller: 'accountStatement', templateUrl: 'partials/reports/account_statement/account_statement.html' }) - .when('/reports/income_expensive', { + .state('/reports/income_expensive', { controller: 'reportIncomeExpensive', templateUrl: 'partials/reports/income_expensive/income_expensive.html' }) - .when('/reports/service_exploitation', { + .state('/reports/service_exploitation', { controller: 'report.service_exploitation', templateUrl: 'partials/reports/service_exploitation/service_exploitation.html' }) - .when('/reports/global_transaction', { + .state('/reports/global_transaction', { controller: 'ReportGlobalTransactionController as ReportCtrl', templateUrl: 'partials/reports/global_transaction/global_transaction.html' }) - .when('/reports/balance_mensuelle', { + .state('/reports/balance_mensuelle', { controller: 'ReportBalanceMensuelleController as ReportCtrl', templateUrl: 'partials/reports/balance_mensuelle/balance_mensuelle.html' }) - .when('/reports/donation', { + .state('/reports/donation', { controller: 'ReportDonationController as ReportCtrl', templateUrl: 'partials/reports/donation/donation.html' }) - .when('/reports/chart_of_accounts', { + .state('/reports/chart_of_accounts', { controller: 'ReportChartOfAccountsController', templateUrl: 'partials/reports/chart_of_accounts/chart.html' }) - .when('/reports/all_transactions', { + .state('/reports/all_transactions', { controller : 'allTransactions', templateUrl : 'partials/reports/all_transactions/all_transactions.html' }) - .when('/reports/expiring', { + .state('/reports/expiring', { controller : 'ReportStockExpirationsController as ReportCtrl', templateUrl : 'partials/reports/expiring_stock/expiring_stock.html' }) - .when('/reports/stock_store/:depotId', { + .state('/reports/stock_store/:depotId', { controller : 'stock_store', templateUrl : 'partials/reports/stock_store/stock_store.html' }) - .when('/reports/purchase_order', { + .state('/reports/purchase_order', { controller : 'purchase_order', templateUrl : 'partials/reports/purchase_order/purchase_order.html' }) - .when('/reports/donation_confirmation', { + .state('/reports/donation_confirmation', { controller : 'donation_confirmation', templateUrl : 'partials/reports/donation_confirmation/donation_confirmation.html' }) - .when('/reports/stock_integration', { + .state('/reports/stock_integration', { controller : 'ReportStockIntegrationController as ReportCtrl', templateUrl : 'partials/reports/stock_integration/stock_integration.html' }) - .when('/reports/stock_movement', { + .state('/reports/stock_movement', { controller : 'stock_movement', templateUrl : 'partials/reports/stock_movement/stock_movement.html' }) - .when('/reports/bilan', { + .state('/reports/bilan', { controller : 'configureBilan', templateUrl : 'partials/reports_proposed/bilan/bilan.html' }) - .when('/reports/debitor_group_report', { + .state('/reports/debitor_group_report', { controller : 'DebtorGroupReportController as debtorGroupReportCtrl', templateUrl : 'partials/reports_proposed/debitor_group_report/debitor_group_report.html' }) - .when('/reports/result_account', { + .state('/reports/result_account', { controller : 'configureResult', templateUrl : 'partials/reports_proposed/result_account/result_account.html' }) - .when('/reports/balance', { + .state('/reports/balance', { controller : 'configureBalance', templateUrl : 'partials/reports_proposed/balance/balance.html' }) - .when('/reports/debtorgroup/annual', { + .state('/reports/debtorgroup/annual', { controller : 'DebtorGroupAnnualReportController as AnnualCtrl', templateUrl : 'partials/reports_proposed/debtor_group/annual.html' }) - .when('/reports/grand_livre', { + .state('/reports/grand_livre', { controller : 'configureGrandLivre', templateUrl : 'partials/reports_proposed/grand_livre/grand_livre.html' }) - .when('/reports/employee_state', { + .state('/reports/employee_state', { controller : 'configureEmployeeState', templateUrl : 'partials/reports_proposed/employee_state/employee_state.html' }) - .when('/reports/cotisation_payment', { + .state('/reports/cotisation_payment', { controller : 'cotisation_payment', templateUrl : 'partials/reports/cotisation_payment/cotisation_payment.html' }) - .when('/reports/salary_payment', { + .state('/reports/salary_payment', { controller : 'salary_payment', templateUrl : 'partials/reports/salary_payment/salary_payment.html' }) - .when('/reports/taxes_payment', { + .state('/reports/taxes_payment', { controller : 'taxes_payment', templateUrl : 'partials/reports/taxes_payment/taxes_payment.html' }) - .when('/reports/stock_status', { + .state('/reports/stock_status', { controller : 'StockStatusReportController as StatusCtrl', templateUrl : 'partials/reports/stock_status/stock_status.html' }) - .when('/reports/loss_record', { + .state('/reports/loss_record', { controller : 'loss_record', templateUrl : 'partials/reports/loss_record/loss_record.html' }) - .when('/reports/income_report', { + .state('/reports/income_report', { controller : 'primary_cash.incomeReport', templateUrl : 'partials/reports/primary_cash/income/income_report.html' }) - .when('/reports/expense_report', { + .state('/reports/expense_report', { controller : 'primary_cash.expenseReport', templateUrl : 'partials/reports/primary_cash/expense/expense_report.html' }) - .when('/reports/cash_flow/', { + .state('/reports/cash_flow/', { controller : 'cashFlowReportController as ReportCtrl', templateUrl : 'partials/reports/cash_flow/cash_flow.html' }) - .when('/reports/stock_report', { + .state('/reports/stock_report', { controller : 'stock_report', templateUrl : 'partials/reports/stock/stock_report.html' }) - .when('/reports/patient_visit_status', { + .state('/reports/patient_visit_status', { controller : 'ReportPatientVisitStatus', templateUrl : '/partials/reports/patient_visit_status/patient_visit_status.html' }) - .when('/reports/stock_entry', { + .state('/reports/stock_entry', { controller : 'ReportStockEntryController', templateUrl : 'partials/reports/stock/stock_entry/stock_entry.html' - }) - .otherwise({ redirectTo : '/' }); + }); + + $urlRouterProvider.otherwise('/'); } function translateConfig($translateProvider) { @@ -870,12 +844,15 @@ function authConfig($httpProvider) { // Redirect to login if not signed in. function startupConfig($rootScope, $location, SessionService, amMoment) { - $rootScope.$on('$routeChangeStart', function (event, next) { + $rootScope.$on('$stateChangeStart', function (event, next) { if (!SessionService.user) { $location.url('/login'); } }); + // make sure $stateChangeErrors are emitted to the console. + $rootScope.$on('$stateChangeError', console.log.bind(console)); + // TODO Hardcoded default translation/ localisation amMoment.changeLocale('fr'); } @@ -900,7 +877,7 @@ function httpConfig($httpProvider) { } // configuration -bhima.config(['$routeProvider', bhimaconfig]); +bhima.config(['$stateProvider', '$urlRouterProvider', bhimaConfig]); bhima.config(['$translateProvider', translateConfig]); bhima.config(['tmhDynamicLocaleProvider', localeConfig]); bhima.config(['$httpProvider', authConfig]); @@ -908,4 +885,4 @@ bhima.config(['$localStorageProvider', localStorageConfig]); bhima.config(['$httpProvider', httpConfig]); // run -bhima.run(['$rootScope', '$location', 'SessionService', 'amMoment', startupConfig]); \ No newline at end of file +bhima.run(['$rootScope', '$location', 'SessionService', 'amMoment', startupConfig]); diff --git a/client/src/partials/cash/cash.js b/client/src/partials/cash/cash.js index fa30968da4..807debffb6 100644 --- a/client/src/partials/cash/cash.js +++ b/client/src/partials/cash/cash.js @@ -3,7 +3,7 @@ angular.module('bhima.controllers') CashController.$inject = [ 'CashService', 'CashboxService', 'AppCache', 'CurrencyService', '$uibModal', - '$routeParams', '$location', 'PatientService', 'ExchangeRateService', 'SessionService' + '$stateParams', '$location', 'PatientService', 'ExchangeRateService', 'SessionService' ]; /** @@ -21,7 +21,7 @@ CashController.$inject = [ * * @module bhima/controllers/CashController */ -function CashController(Cash, Cashboxes, AppCache, Currencies, Modal, $routeParams, $location, Patients, Exchange, Session) { +function CashController(Cash, Cashboxes, AppCache, Currencies, Modal, $stateParams, $location, Patients, Exchange, Session) { /** @const controller view-model alias */ var vm = this; @@ -33,7 +33,7 @@ function CashController(Cash, Cashboxes, AppCache, Currencies, Modal, $routePara var cache = AppCache('CashPayments'); /** @const id of the currently select cashbox */ - var cashboxId = $routeParams.id; + var cashboxId = $stateParams.id; /** default to dots for currency symbol */ vm.currencyLabel = '...'; diff --git a/client/src/partials/patients/edit/edit.js b/client/src/partials/patients/edit/edit.js index 0031ec510c..734880ebb0 100644 --- a/client/src/partials/patients/edit/edit.js +++ b/client/src/partials/patients/edit/edit.js @@ -13,11 +13,11 @@ angular.module('bhima.controllers') .controller('PatientEdit', PatientEdit); -PatientEdit.$inject = ['$scope', '$translate', '$routeParams', '$location', '$anchorScroll', '$uibModal', 'PatientService', 'util', 'moment']; +PatientEdit.$inject = ['$scope', '$translate', '$stateParams', '$location', '$anchorScroll', '$uibModal', 'PatientService', 'util', 'moment']; -function PatientEdit($scope, $translate, $routeParams, $location, $anchorScroll, $uibModal, patients, util, moment) { +function PatientEdit($scope, $translate, $stateParams, $location, $anchorScroll, $uibModal, patients, util, moment) { var viewModel = this; - var referenceId = $routeParams.patientID; + var referenceId = $stateParams.patientID; viewModel.patient = null; viewModel.unknownId = false; diff --git a/client/test/e2e/debtor_groups/debtorGroups.spec.js b/client/test/e2e/debtor_groups/debtorGroups.spec.js index 4f55f62ca4..a5d158bdbf 100644 --- a/client/test/e2e/debtor_groups/debtorGroups.spec.js +++ b/client/test/e2e/debtor_groups/debtorGroups.spec.js @@ -1,5 +1,4 @@ -/* jshint expr: true */ -/* global element, by, inject, browser */ +/* global element, by, browser */ var chai = require('chai'); var expect = chai.expect; @@ -40,7 +39,6 @@ describe('Debtor Groups', function () { }); it('successfully creates a new Debtor Group', function () { - FormUtils.buttons.create(); /** debtor group info */ @@ -115,6 +113,7 @@ describe('Debtor Groups', function () { 'ecd22221-88ad-49e2-84b2-c8161ad39f53', // Kananga, 'f9d555de-434d-47ac-86bb-b0fcfd3bc75f' // Plateau ]; + components.locationSelect.set(locations); FormUtils.buttons.submit(); @@ -127,5 +126,4 @@ describe('Debtor Groups', function () { FormUtils.buttons.submit(); FormUtils.exists(by.id('error-feedback'), true); }); - }); diff --git a/client/test/e2e/sectors_management/sectors_management.spec.js b/client/test/e2e/sectors_management/sectors_management.spec.js index d87bbc7a58..62e9dfba1d 100644 --- a/client/test/e2e/sectors_management/sectors_management.spec.js +++ b/client/test/e2e/sectors_management/sectors_management.spec.js @@ -1,16 +1,14 @@ -/* jshint expr:true */ -/* global element, by, beforeEach, inject, browser */ +/* global element, by, browser */ var chai = require('chai'); var expect = chai.expect; var FU = require('../shared/FormUtils'); var helpers = require('../shared/helpers'); -var components = require('../shared/components'); helpers.configure(chai); -describe('Locations /Sectors Management', function () { +describe('Locations /sectors Management', function () { 'use strict'; var path = '#/locations/sector'; @@ -21,12 +19,12 @@ describe('Locations /Sectors Management', function () { var locations = { country : 'République Démocratique du Congo', - province : 'BANDUNDU' + province : 'BANDUNDU' }; var locationsUpdate = { country : 'République Démocratique du Congo', - province : 'Bas Congo' + province : 'Bas Congo' }; var defaultSector = 209; @@ -38,7 +36,7 @@ describe('Locations /Sectors Management', function () { browser.get(path); }); - it('successfully creates a new Sector', function () { + it('successfully creates a new Sector', function () { // swtich to the create form FU.buttons.create(); @@ -50,7 +48,7 @@ describe('Locations /Sectors Management', function () { // Set the Sector Name FU.input('SectorCtrl.sector.name', sector.name); - + // submit the page to the server FU.buttons.submit(); diff --git a/gulpfile.js b/gulpfile.js index 5319c31549..48b2a73769 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -68,9 +68,13 @@ var paths = { // Angular 'client/vendor/angular/angular.min.js', - 'client/vendor/angular-route/angular-route.min.js', 'client/vendor/angular-messages/angular-messages.min.js', + // Angular UI + 'client/vendor/angular-ui-router/release/angular-ui-router.min.js', + 'client/vendor/angular-bootstrap/ui-bootstrap-tpls.js', + 'client/vendor/angular-ui-grid/ui-grid.min.js', + // ChartJS 'client/vendor/Chart.js/Chart.min.js', 'client/vendor/angular-chart.js/dist/angular-chart.min.js', @@ -80,9 +84,6 @@ var paths = { 'client/vendor/angular-moment/angular-moment.js', 'client/vendor/moment/locale/fr.js', - // UI Grid - 'client/vendor/angular-ui-grid/ui-grid.min.js', - // Angular Translate 'client/vendor/angular-translate/angular-translate.min.js', 'client/vendor/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js', @@ -94,9 +95,6 @@ var paths = { // Angular File Upload 'client/vendor/ng-file-upload/ng-file-upload.min.js', - // UI Bootstrap - 'client/vendor/angular-bootstrap/ui-bootstrap-tpls.js', - // ngStorage 'client/vendor/ngstorage/ngStorage.min.js' ], diff --git a/server/models/test/data.sql b/server/models/test/data.sql index 53d3eecd74..e032acf233 100644 --- a/server/models/test/data.sql +++ b/server/models/test/data.sql @@ -14,7 +14,7 @@ INSERT INTO unit VALUES (5, 'Finance','TREE.FINANCE','The Finance Super-Category',0,'/partials/finance/','/finance'), (6, 'Account','TREE.ACCOUNT','Chart of Accounts management',30,'/partials/accounts/','/accounts'), (12, 'Hospital','TREE.HOSPITAL','The Hospital Super-Category',0,'/partials/hospital/index.html','/hospital'), - (14, 'Patient Registration','TREE.PATIENT_REGISTRATION','Register patients',12,'/partials/patient/register/','/patients/register/'), + (14, 'Patient Registration','TREE.PATIENT_REGISTRATION','Register patients',12,'/partials/patient/register/','/patients/register'), (16, 'Patient Invoice','TREE.PATIENT_INVOICE','Create an invoice for a patient',5,'/partials/patient_invoice/','/invoices/patient'), (18, 'Cash Payments','TREE.CASH_PAYMENTS','Cash payments against past or future invoices',5,'/partials/cash/','/cash'), (19, 'Register Supplier','TREE.REGISTER_SUPPLIER','',1,'/partials/creditors/','/creditors'), @@ -26,7 +26,7 @@ INSERT INTO unit VALUES (48, 'Service Management','TREE.SERVICE','',1,'partials/services/','/services'), (57, 'Payroll','TREE.PAYROLL','',0,'partials/payroll/','/payroll/'), (61, 'Employee','TREE.EMPLOYEE','Employees management',57,'partials/employees/','/employees'), - (80, 'Patient Update','TREE.EDIT_PATIENT','',12,'/partials/patient_edit/','/patients/edit/'), + (80, 'Patient Update','TREE.EDIT_PATIENT','',12,'/partials/patient_edit/','/patients/edit'), (82, 'Subsidies','TREE.SUBSIDY','Handles the subsidy situation',1,'/partials/subsidies/','/subsidies'), (105, 'Cashbox Management','TREE.CASHBOX_MANAGEMENT','',1,'/partials/cash/cashbox/','/cashboxes'), (106, 'Depot Management', 'TREE.DEPOTS_MANAGEMENT', 'Depot Management module', 1, '/partials/depots_management/', '/depots_management'), @@ -402,4 +402,4 @@ INSERT INTO `price_list` (`enterprise_id`, `uuid`, `label`) VALUES -- Depricated through redesign -- --------------------------- -- (28,'Patient Group Assignment','TREE.PATIENT_GRP_ASSIGNMENT','',12,'/partials/patient/group/assignment/','patient/group/assignment/'), --- (36,'Change Patient Group','TREE.SWAP_DEBITOR','',12,'/partials/patient/debtor/','/patient/debtor/'), \ No newline at end of file +-- (36,'Change Patient Group','TREE.SWAP_DEBITOR','',12,'/partials/patient/debtor/','/patient/debtor/'),