From 86b5beaa0d6e72c1f18489ea84c1ddafeaaa5daf Mon Sep 17 00:00:00 2001 From: Tanshu Date: Thu, 30 May 2013 16:52:51 +0530 Subject: [PATCH] Added new styles based and layout Update home list style to use widgets from the unicorn theme. Creation Date is now formatted using filter to show local time. --- brewman/brewman/static/css/style.css | 103 +++++++++++++++++- brewman/brewman/static/offline.appcache | 2 +- brewman/brewman/static/partial/home.html | 27 +++-- .../brewman/static/scripts/angular_filter.js | 56 ++++++++++ .../static/scripts/salary-deduction.js | 70 ++++++------ brewman/brewman/views/messaging.py | 4 +- 6 files changed, 214 insertions(+), 48 deletions(-) diff --git a/brewman/brewman/static/css/style.css b/brewman/brewman/static/css/style.css index 97051830..02c65190 100644 --- a/brewman/brewman/static/css/style.css +++ b/brewman/brewman/static/css/style.css @@ -61,4 +61,105 @@ font-size: 15px; line-height: 1.7; color: #333333; -} \ No newline at end of file +} + + +.widget-box { + background: none repeat scroll 0 0 #F9F9F9; + border-top: 1px solid #CDCDCD; + border-left: 1px solid #CDCDCD; + border-right: 1px solid #CDCDCD; + clear: both; + margin-top: 16px; + margin-bottom: 16px; + position: relative; +} +/* widgets from unicorn theme from http://wbpreview.com/previews/WB0F35928/widgets.html */ +.widget-title, .modal-header, .table th, div.dataTables_wrapper .ui-widget-header, .ui-dialog .ui-dialog-titlebar { + background-color: #efefef; + background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea)); + background-image: -webkit-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%); + border-bottom: 1px solid #CDCDCD; + height: 36px; +} +.widget-title .nav-tabs { + border-bottom: 0 none; +} +.widget-title .nav-tabs li a { + border-bottom: medium none !important; + border-left: 1px solid #DDDDDD; + border-radius: 0 0 0 0; + border-right: 1px solid #DDDDDD; + border-top: medium none; + color: #999999; + margin: 0; + outline: medium none; + padding: 9px 10px 8px; + font-weight: bold; + text-shadow: 0 1px 0 #FFFFFF; +} +.widget-title .nav-tabs li:first-child a{ + border-left: medium none !important; +} +.widget-title .nav-tabs li a:hover { + background-color: transparent !important; + border-color: #D6D6D6; + border-width: 0 1px; + color: #666666; +} +.widget-title .nav-tabs li.active a { + background-color: #F9F9F9 !important; + color: #444444; +} +.widget-title span.icon { + border-right: 1px solid #cdcdcd; + padding: 9px 10px 7px 11px; + float: left; + opacity: .7; +} +.widget-title h5 { + color: #666666; + text-shadow: 0 1px 0 #ffffff; + float: left; + font-size: 12px; + font-weight: bold; + padding: 12px; + line-height: 12px; + margin: 0; +} +.widget-title .buttons { + float: right; + margin: 8px 10px 0 0; +} +.widget-title .label { + padding: 3px 5px 2px; + float: right; + margin: 9px 15px 0 0; + box-shadow: 0 1px 2px rgba(0,0,0,0.3) inset, 0 1px 0 #ffffff; +} +.widget-content { + padding: 12px 15px; + border-bottom: 1px solid #cdcdcd; +} +.widget-box.widget-plain .widget-content { + padding: 12px 0 0; +} +.widget-box.collapsible .collapse.in .widget-content { + border-bottom: 1px solid #CDCDCD; +} + +.nopadding { + padding: 0 !important; +} +.nopadding .table { + margin-bottom: 0; +} +.nopadding .table-bordered { + border: 0; +} + +.user-info { + color: #666666; + font-size: 11px; +} + diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index c41531cd..42341d27 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2013-05-28.1 +# version 2013-05-29.1 CACHE: /partial/404.html diff --git a/brewman/brewman/static/partial/home.html b/brewman/brewman/static/partial/home.html index 0be559f6..1feaf25b 100644 --- a/brewman/brewman/static/partial/home.html +++ b/brewman/brewman/static/partial/home.html @@ -1,12 +1,21 @@ Messages Add - - - - - - +
+
+ +
+
+
- {{item.Title}} - {{tag}} -
+ + + + + + + +
+ +

{{item.Title}}

+ {{tag}} +
diff --git a/brewman/brewman/static/scripts/angular_filter.js b/brewman/brewman/static/scripts/angular_filter.js index 70e74277..07452e1c 100644 --- a/brewman/brewman/static/scripts/angular_filter.js +++ b/brewman/brewman/static/scripts/angular_filter.js @@ -45,3 +45,59 @@ overlord_filter.filter('journalDebit', function () { return list; }; }); + +overlord_filter.filter('localTime', function () { + var months = { + Jan: 1, + Feb: 2, + Mar: 3, + Apr: 4, + May: 5, + Jun: 6, + Jul: 7, + Aug: 8, + Sep: 9, + Oct: 10, + Nov: 11, + Dec: 12 + } + var months_reverse = { + 1: 'Jan', + 2: 'Feb', + 3: 'Mar', + 4: 'Apr', + 5: 'May', + 6: 'Jun', + 7: 'Jul', + 8: 'Aug', + 9: 'Sep', + 10: 'Oct', + 11: 'Nov', + 12: 'Dec' + } + + function padNumber(input, length) { + if (typeof input == 'number'){ + input = '' + input; + } + if (typeof length === 'undefined' || !length) { + length = 2; + } + while (input.length < length) { + input = '0' + input; + } + return input; + } + + return function (input) { + var d = input.match(/(\w+)/g); + if (d.length !== 5) { + return input; + } + var date = new Date(parseInt(d[2]), months[d[1]] - 1, parseInt(d[0]), parseInt(d[3]), parseInt(d[4])).getTime(); + date = new Date(date - (new Date().getTimezoneOffset() * 60000)); + var output = padNumber(date.getDate()) + '-' + months_reverse[date.getMonth() + 1] + '-' + date.getFullYear() + ' ' + padNumber(date.getHours()) + ':' + padNumber(date.getMinutes()); + return output; + }; +}); + diff --git a/brewman/brewman/static/scripts/salary-deduction.js b/brewman/brewman/static/scripts/salary-deduction.js index 6dd4a241..3c33a016 100644 --- a/brewman/brewman/static/scripts/salary-deduction.js +++ b/brewman/brewman/static/scripts/salary-deduction.js @@ -14,18 +14,18 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'voucher', function ($scope, $ function daysInMonthFunction(date) { var months = { - Jan:1, - Feb:2, - Mar:3, - Apr:4, - May:5, - Jun:6, - Jul:7, - Aug:8, - Sep:9, - Oct:10, - Nov:11, - Dec:12 + Jan: 1, + Feb: 2, + Mar: 3, + Apr: 4, + May: 5, + Jun: 6, + Jul: 7, + Aug: 8, + Sep: 9, + Oct: 10, + Nov: 11, + Dec: 12 } if (!date.match(/^\d{2}-[\w]{3}-[\d]{4}$/g)) { return; @@ -40,7 +40,7 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'voucher', function ($scope, $ employer_rate = .0475; var employee = (grossSalary > limit) ? 0 : Math.ceil(employee_rate * grossSalary * daysWorked / daysInMonth) var employer = (grossSalary > limit) ? 0 : Math.ceil(employer_rate * grossSalary * daysWorked / daysInMonth) - return {ee:employee, er:employer, both:employee + employer}; + return {ee: employee, er: employer, both: employee + employer}; } function getPf(grossSalary, daysWorked, daysInMonth) { @@ -49,7 +49,7 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'voucher', function ($scope, $ employer_rate = .12 + .011 + .005 + .0001; var employee = (grossSalary > limit) ? 0 : Math.ceil(employee_rate * grossSalary * daysWorked / daysInMonth) var employer = (grossSalary > limit) ? 0 : Math.ceil(employer_rate * grossSalary * daysWorked / daysInMonth) - return {ee:employee, er:employer, both:employee + employer}; + return {ee: employee, er: employer, both: employee + employer}; } $scope.add = function () { @@ -61,17 +61,17 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'voucher', function ($scope, $ pf = getPf(grossSalary, daysWorked, daysInMonth); if (typeof oldJournal !== 'undefined') { - $scope.toasts.push({Type:'Error', Message:'Employee has already been added!'}); + $scope.toasts.push({Type: 'Error', Message: 'Employee has already been added!'}); } else { this.voucher.SalaryDeductions.push( { - Journal:{Ledger:$scope.employee}, - GrossSalary:grossSalary, - DaysWorked:daysWorked, - EsiEmployee:esi.ee, - PfEmployee:pf.ee, - EsiEmployer:esi.er, - PfEmployer:pf.er + Journal: {Ledger: $scope.employee}, + GrossSalary: grossSalary, + DaysWorked: daysWorked, + EsiEmployee: esi.ee, + PfEmployee: pf.ee, + EsiEmployer: esi.er, + PfEmployer: pf.er } ) ; @@ -103,43 +103,43 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'voucher', function ($scope, $ }; $scope.get = function (voucherid) { - $scope.voucher = Voucher.get({VoucherID:voucherid}, function (u, putResponseHeaders) { - $scope.toasts.push({Type:'Success', Message:''}); + $scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) { + $scope.toasts.push({Type: 'Success', Message: ''}); }, function (data, status) { - $scope.toasts.push({Type:'Error', Message:data.data}); + $scope.toasts.push({Type: 'Error', Message: data.data}); }); }; $scope.save = function () { - $scope.voucher.$save({type:'Salary Deduction'}, function (u, putResponseHeaders) { - $scope.toasts.push({Type:'Success', Message:''}); + $scope.voucher.$save({type: 'Salary Deduction'}, function (u, putResponseHeaders) { + $scope.toasts.push({Type: 'Success', Message: ''}); $location.path('/SalaryDeduction/' + u.VoucherID); }, function (data, status) { - $scope.toasts.push({Type:'Error', Message:data.data}); + $scope.toasts.push({Type: 'Error', Message: data.data}); }); }; $scope.delete = function () { $scope.voucher.$delete(function (u, putResponseHeaders) { - $scope.toasts.push({Type:'Success', Message:''}); + $scope.toasts.push({Type: 'Success', Message: ''}); $location.path('/SalaryDeduction').replace(); }, function (data, status) { - $scope.toasts.push({Type:'Error', Message:data.data}); + $scope.toasts.push({Type: 'Error', Message: data.data}); }); }; $scope.post = function () { $scope.voucher.$post(function (u, putResponseHeaders) { - $scope.toasts.push({Type:'Success', Message:''}); + $scope.toasts.push({Type: 'Success', Message: ''}); }, function (data, status) { - $scope.toasts.push({Type:'Error', Message:data.data}); + $scope.toasts.push({Type: 'Error', Message: data.data}); }); }; }] SalaryDeductionCtrl.resolve = { - voucher:['$q', '$route', 'Voucher', function ($q, $route, Voucher) { + voucher: ['$q', '$route', 'Voucher', function ($q, $route, Voucher) { var deferred = $q.defer(); var id = $route.current.params.id; @@ -149,9 +149,9 @@ SalaryDeductionCtrl.resolve = { }; if (typeof id === 'undefined') { - Voucher.get({type:'Salary Deduction'}, successCb); + Voucher.get({type: 'Salary Deduction'}, successCb); } else { - Voucher.get({id:id}, successCb); + Voucher.get({id: id}, successCb); } return deferred.promise; }] diff --git a/brewman/brewman/views/messaging.py b/brewman/brewman/views/messaging.py index 38bd629f..c987bdf9 100644 --- a/brewman/brewman/views/messaging.py +++ b/brewman/brewman/views/messaging.py @@ -97,8 +97,8 @@ def show_list(request): threads = [] for item in list: thread = {'ThreadID': item.id, 'Title': item.title, - 'CreationDate': item.creation_date.strftime('%d-%b-%Y %H:%M'), - 'User': item.user.name, 'Priority': item.priority, 'Public': item.public, 'Tags': [], 'Posts': []} + 'CreationDate': item.creation_date.strftime('%d-%b-%Y %H:%M'), 'User': item.user.name, + 'Priority': item.priority, 'Public': item.public, 'Tags': [], 'Posts': []} threads.append(thread) for tag in item.tags: thread['Tags'].append(tag.name)