Feature: Created a tanClick directive which disables button on click while loading

Fix: Could not change the main ledger in payment/receipt edit
Fix: Added try/catch to client delete
This commit is contained in:
Amritanshu 2013-11-20 18:24:38 +05:30
parent d1a4fc1164
commit 536bf27403
11 changed files with 38 additions and 27 deletions

View File

@ -260,6 +260,7 @@ class Batch(Base):
def suspense(cls):
return uuid.UUID('a955790e-93cf-493c-a816-c7d92b127383')
class Attendance(Base):
__tablename__ = 'entities_attendances'
@ -296,7 +297,7 @@ class Attendance(Base):
def create(self):
old = DBSession.query(Attendance).filter(Attendance.date == self.date) \
.filter(Attendance.employee_id == self.employee_id) \
.filter(Attendance.is_valid == True).first()
.filter(Attendance.is_valid is True).first()
if old is None or old.attendance_type != self.attendance_type:
if old is not None:
old.is_valid = False

View File

@ -68,7 +68,7 @@
</table>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button ng-click="save()" ng-disabled="isClean() || form.$invalid" class="btn btn-primary">Save</button>
<button tan-click="save()" ng-disabled="isClean() || form.$invalid" class="btn btn-primary">Save</button>
</div>
</div>
</form>

View File

@ -14,7 +14,7 @@
</div>
</div>
<div class="col-md-2">
<button class="btn btn-block btn-success" ng-click="creditSalary()">Credit <i
<button class="btn btn-block btn-success" tan-click="creditSalary()">Credit <i
class="glyphicon glyphicon-screenshot"></i>
</button>
</div>

View File

@ -173,4 +173,30 @@ overlord_directive.directive('tanSse', ['$parse', function ($parse) {
}, false);
}
};
}]);
}]);
overlord_directive.directive('tanClick', ['$parse', '$timeout', function ($parse, $timeout) {
return {
compile: function ($element, attr) {
var fn = $parse(attr.tanClick);
return function (scope, element, attr) {
element.on('click', function (event) {
scope.$apply(function () {
var disabled = attr.ngDisabled ? $parse(attr.ngDisabled) : angular.noop;
attr.$set('disabled', true);
var v = fn(scope, {$event: event}) || angular.noop;
if (v && v.then) {
v.finally(function () {
attr.$set('disabled', !!disabled(scope) || false);
});
} else {
$timeout(function () {
attr.$set('disabled', !!disabled(scope) || false);
}, 5000);
}
});
});
};
}
};
}]);

View File

@ -28,7 +28,7 @@ var EmployeeAttendanceCtrl = ['$scope', '$location', '$routeParams', 'dateFilter
};
$scope.save = function () {
$scope.info.$save(function (u, putResponseHeaders) {
return $scope.info.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: 'Saved!'});
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});

View File

@ -7,7 +7,7 @@ var EmployeeFunctionsCtrl = ['$scope', '$http', 'dateFilter', function ($scope,
return;
}
var salary_month = dateFilter($scope.salaryMonth, 'dd-MMM-yyyy');
$http.
return $http.
post('/api/CreditSalary', {Month: salary_month}).
success(function (data) {
$scope.toasts.push({Type: 'Success', Message: data.message});

View File

@ -11,10 +11,10 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
when('/Journal/:id', {templateUrl: '/partial/journal.html', controller: JournalCtrl, resolve: JournalCtrl.resolve}).
when('/Payment', {templateUrl: '/partial/payment.html', controller: PaymentCtrl, resolve: PaymentCtrl.resolve, reloadOnSearch:false}).
when('/Payment/:id', {templateUrl: '/partial/payment.html', controller: PaymentCtrl, resolve: PaymentCtrl.resolve}).
when('/Payment/:id', {templateUrl: '/partial/payment.html', controller: PaymentCtrl, resolve: PaymentCtrl.resolve, reloadOnSearch:false}).
when('/Receipt', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl, resolve: ReceiptCtrl.resolve, reloadOnSearch:false}).
when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl, resolve: ReceiptCtrl.resolve}).
when('/Receipt/:id', {templateUrl: '/partial/receipt.html', controller: ReceiptCtrl, resolve: ReceiptCtrl.resolve, reloadOnSearch:false}).
when('/Purchase', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl, resolve: PurchaseCtrl.resolve}).
when('/Purchase/:id', {templateUrl: '/partial/purchase.html', controller: PurchaseCtrl, resolve: PurchaseCtrl.resolve}).

View File

@ -45,7 +45,7 @@ var PaymentCtrl = ['$scope', '$location', 'dateFilter', '$modal', 'voucher', 'le
var j = _.find(journals,{'Debit': -1});
j.Amount = amount;
if (_.find(oldValue, {'Debit': -1}).Ledger.LedgerID !== j.Ledger.LedgerID) {
$location.path('/Payment').search({a: j.Ledger.LedgerID}).replace();
$location.search({a: j.Ledger.LedgerID}).replace();
}
}, true);

View File

@ -45,7 +45,7 @@ var ReceiptCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', '$modal'
var j = _.find(journals, {'Debit': 1});
j.Amount = amount;
if (_.find(oldValue, {'Debit': 1}).Ledger.LedgerID !== j.Ledger.LedgerID) {
$location.path('/Receipt').search({a: j.Ledger.LedgerID}).replace();
$location.search({a: j.Ledger.LedgerID}).replace();
}
}, true);

View File

@ -15,7 +15,6 @@
## <link rel="stylesheet" type="text/css" media="screen" href="/css/bootstrap-theme.min-3.0.0.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/table.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/spinner.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/chosen.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/loading-bar.min.css"/>
<style type="text/css">
@ -43,11 +42,6 @@
<script src="/js/angular-sanitize.min-1.2.0.js"></script>
<script src="/js/loading-bar.min.js"></script>
## <script src="/js/angular-1.0.8.js"></script>
## <script src="/js/angular-resource.min-1.0.8.js"></script>
## <script src="/js/angular-cookies.min-1.0.8.js"></script>
## <script src="/js/angular-sanitize.min-1.0.8.js"></script>
<script src="/script/overlord.js"></script>
<script src="/script/angular_directive.js"></script>
<script src="/script/angular_filter.js"></script>
@ -216,17 +210,6 @@
to-close="clearToast(toast)">
<strong>{{toast.Type}}!</strong> {{toast.Message}}
</div>
<div id="spinner" class="row col-md-4 col-md-offset-4">
<div id="circleG">
<div id="circleG_1" class="circleG">
</div>
<div id="circleG_2" class="circleG">
</div>
<div id="circleG_3" class="circleG">
</div>
</div>
</div>
<ng-view></ng-view>
<hr>

View File

@ -29,6 +29,7 @@ def update(request):
@view_config(request_method='DELETE', route_name='api_client_id', renderer='json', permission='Clients')
@TryCatchFunction
def delete(request):
id = request.matchdict.get('id', None)
if id is None: