Fix: Employee was not saving because of isStarred, added that functionality to employee

This commit is contained in:
tanshu 2018-07-14 10:52:39 +05:30
parent 9f4eb334d7
commit 29b81cbd21
5 changed files with 20 additions and 7 deletions

View File

@ -1,5 +1,5 @@
from datetime import date
import uuid
from datetime import date
from sqlalchemy import (
UniqueConstraint,
@ -16,8 +16,8 @@ from sqlalchemy import (
)
from sqlalchemy.orm import relationship
from .meta import Base
from brewman.models.guidtype import GUID
from .meta import Base
class Product(Base):
@ -332,15 +332,15 @@ class Employee(AccountBase):
attendances = relationship('Attendance', backref='employee', cascade=None, cascade_backrefs=False)
fingerprints = relationship('Fingerprint', backref='employee', cascade=None, cascade_backrefs=False)
def __init__(self, code=None, name=None, is_active=None, cost_centre_id=None, designation=None, salary=None,
service_points=None, joining_date=None, leaving_date=None):
def __init__(self, code=None, name=None, is_starred=None, is_active=None, cost_centre_id=None, designation=None,
salary=None, service_points=None, joining_date=None, leaving_date=None):
self.designation = designation
self.salary = salary
self.service_points = service_points
self.joining_date = joining_date
self.leaving_date = leaving_date
super().__init__(code=code, name=name, type=10, is_active=is_active, is_reconcilable=False,
cost_centre_id=cost_centre_id)
super().__init__(code=code, name=name, type=10, is_starred=is_starred, is_active=is_active,
is_reconcilable=False, cost_centre_id=cost_centre_id)
def create(self, dbsession):
code = dbsession.query(func.max(AccountBase.code)).filter(AccountBase.type == self.type).one()[0]

View File

@ -53,6 +53,7 @@ def save(request):
except (ValueError, KeyError, TypeError):
raise ValidationError("Joining Date is not a valid date")
is_starred = request.json_body['isStarred']
is_active = request.json_body['isActive']
try:
if is_active:
@ -64,7 +65,7 @@ def save(request):
except (ValueError, KeyError, TypeError):
raise ValidationError("Leaving Date is not a valid date")
item = Employee(0, name, is_active, cost_centre_id, designation, salary, service_points, joining_date,
item = Employee(0, name, is_starred, is_active, cost_centre_id, designation, salary, service_points, joining_date,
leaving_date).create(request.dbsession)
transaction.commit()
return employee_info(item.id, request.dbsession)
@ -102,6 +103,7 @@ def update(request):
except (ValueError, KeyError, TypeError):
raise ValidationError("Joining Date is not a valid date")
item.is_starred = request.json_body['isStarred']
item.is_active = request.json_body['isActive']
try:
if item.is_active:

View File

@ -0,0 +1,7 @@
.gold {
color: gold;
}
.pointer {
cursor: pointer;
}

View File

@ -1,6 +1,9 @@
<mat-card>
<mat-card-title-group>
<mat-card-title>Employee</mat-card-title>
<mat-icon matSuffix (click)="item.isStarred = !item.isStarred" class="pointer" [class.gold]="item.isStarred">
{{ item.isStarred ? 'star' : 'star_border' }}
</mat-icon>
</mat-card-title-group>
<mat-card-content>
<form [formGroup]="form" fxLayout="column">

View File

@ -4,6 +4,7 @@ export class Employee {
id: string;
code: number;
name: string;
isStarred: boolean;
isActive: boolean;
designation: string;
salary: number;