Fix: Issue form had stopped working

Feature: Employee-list search saves query string on navigation.
This commit is contained in:
Tanshu 2013-10-06 13:09:10 +05:30
parent d3e3584e9b
commit 8bb1579c1b
3 changed files with 25 additions and 13 deletions

View File

@ -1,6 +1,7 @@
'use strict';
var EmployeeListCtrl = ['$scope', 'employees', function ($scope, employees) {
var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'employees', function ($scope, $location, $routeParams, employees) {
$scope.search = $routeParams.q || '';
$scope.info = employees;
var re = /((([^ ]+):\s*('[^':]+'|"[^":]+"|[^ ]+))|[^ ]+[^: '"]*)/g;
@ -11,7 +12,18 @@ var EmployeeListCtrl = ['$scope', 'employees', function ($scope, employees) {
});
};
$scope.getEmployees = _.memoize(function (q) {
$scope.getEmployees = function (q) {
if (q !== $scope._search) {
$scope._search = q;
if (angular.isUndefined(q) || q === '') {
$location.path('/Employees').search('q', null).replace();
} else {
$location.path('/Employees').search({'q': q}).replace();
}
}
return $scope.doFilter(q);
};
$scope.doFilter = _.memoize(function (q) {
var matches = [], i, len;
if (angular.isUndefined(q) || q === '') {
return $scope.info;

View File

@ -69,7 +69,7 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
when('/Account', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl, resolve: AccountCtrl.resolve}).
when('/Account/:id', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl, resolve: AccountCtrl.resolve}).
when('/Employees', {templateUrl: '/partial/employee-list.html', controller: EmployeeListCtrl, resolve: EmployeeListCtrl.resolve}).
when('/Employees', {templateUrl: '/partial/employee-list.html', controller: EmployeeListCtrl, resolve: EmployeeListCtrl.resolve, reloadOnSearch:false}).
when('/Employee', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}).
when('/Employee/:id', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}).

View File

@ -219,16 +219,7 @@ def blank_voucher(info):
elif type == 'Purchase Return':
json_voucher['Journals'].append({'Ledger': LedgerBase.local_purchase(), 'Amount': 0, 'Debit': 1})
elif type == 'Issue':
if info is None:
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
'Amount': 0,
'Debit': -1,
'CostCenter': {'CostCenterID': CostCenter.cost_center_purchase()}})
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
'Amount': 0,
'Debit': 1,
'CostCenter': {'CostCenterID': CostCenter.cost_center_kitchen()}})
elif 'Source' in info and 'Destination' in info:
if 'Source' in info and 'Destination' in info:
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
'Amount': 0,
'Debit': -1,
@ -237,6 +228,15 @@ def blank_voucher(info):
'Amount': 0,
'Debit': 1,
'CostCenter': {'CostCenterID': info['Destination']}})
elif 'Journals' not in info:
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
'Amount': 0,
'Debit': -1,
'CostCenter': {'CostCenterID': CostCenter.cost_center_purchase()}})
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
'Amount': 0,
'Debit': 1,
'CostCenter': {'CostCenterID': CostCenter.cost_center_kitchen()}})
else:
json_voucher['Date'] = info['Date']
for item in info['Journals']: