Fix: Issue form had stopped working
Feature: Employee-list search saves query string on navigation.
This commit is contained in:
parent
d3e3584e9b
commit
8bb1579c1b
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'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;
|
$scope.info = employees;
|
||||||
var re = /((([^ ]+):\s*('[^':]+'|"[^":]+"|[^ ]+))|[^ ]+[^: '"]*)/g;
|
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;
|
var matches = [], i, len;
|
||||||
if (angular.isUndefined(q) || q === '') {
|
if (angular.isUndefined(q) || q === '') {
|
||||||
return $scope.info;
|
return $scope.info;
|
||||||
|
|
|
@ -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', {templateUrl: '/partial/account-detail.html', controller: AccountCtrl, resolve: AccountCtrl.resolve}).
|
||||||
when('/Account/:id', {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', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}).
|
||||||
when('/Employee/:id', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}).
|
when('/Employee/:id', {templateUrl: '/partial/employee-detail.html', controller: EmployeeCtrl, resolve: EmployeeCtrl.resolve}).
|
||||||
|
|
||||||
|
|
|
@ -219,16 +219,7 @@ def blank_voucher(info):
|
||||||
elif type == 'Purchase Return':
|
elif type == 'Purchase Return':
|
||||||
json_voucher['Journals'].append({'Ledger': LedgerBase.local_purchase(), 'Amount': 0, 'Debit': 1})
|
json_voucher['Journals'].append({'Ledger': LedgerBase.local_purchase(), 'Amount': 0, 'Debit': 1})
|
||||||
elif type == 'Issue':
|
elif type == 'Issue':
|
||||||
if info is None:
|
if 'Source' in info and 'Destination' 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()}})
|
|
||||||
elif 'Source' in info and 'Destination' in info:
|
|
||||||
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
|
json_voucher['Journals'].append({'Ledger': {'LedgerID': LedgerBase.all_purchases()},
|
||||||
'Amount': 0,
|
'Amount': 0,
|
||||||
'Debit': -1,
|
'Debit': -1,
|
||||||
|
@ -237,6 +228,15 @@ def blank_voucher(info):
|
||||||
'Amount': 0,
|
'Amount': 0,
|
||||||
'Debit': 1,
|
'Debit': 1,
|
||||||
'CostCenter': {'CostCenterID': info['Destination']}})
|
'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:
|
else:
|
||||||
json_voucher['Date'] = info['Date']
|
json_voucher['Date'] = info['Date']
|
||||||
for item in info['Journals']:
|
for item in info['Journals']:
|
||||||
|
|
Loading…
Reference in New Issue