Fix: Employee was not saving because of isStarred, added that functionality to employee
This commit is contained in:
parent
9f4eb334d7
commit
29b81cbd21
@ -1,5 +1,5 @@
|
|||||||
from datetime import date
|
|
||||||
import uuid
|
import uuid
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
UniqueConstraint,
|
UniqueConstraint,
|
||||||
@ -16,8 +16,8 @@ from sqlalchemy import (
|
|||||||
)
|
)
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .meta import Base
|
|
||||||
from brewman.models.guidtype import GUID
|
from brewman.models.guidtype import GUID
|
||||||
|
from .meta import Base
|
||||||
|
|
||||||
|
|
||||||
class Product(Base):
|
class Product(Base):
|
||||||
@ -332,15 +332,15 @@ class Employee(AccountBase):
|
|||||||
attendances = relationship('Attendance', backref='employee', cascade=None, cascade_backrefs=False)
|
attendances = relationship('Attendance', backref='employee', cascade=None, cascade_backrefs=False)
|
||||||
fingerprints = relationship('Fingerprint', 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,
|
def __init__(self, code=None, name=None, is_starred=None, is_active=None, cost_centre_id=None, designation=None,
|
||||||
service_points=None, joining_date=None, leaving_date=None):
|
salary=None, service_points=None, joining_date=None, leaving_date=None):
|
||||||
self.designation = designation
|
self.designation = designation
|
||||||
self.salary = salary
|
self.salary = salary
|
||||||
self.service_points = service_points
|
self.service_points = service_points
|
||||||
self.joining_date = joining_date
|
self.joining_date = joining_date
|
||||||
self.leaving_date = leaving_date
|
self.leaving_date = leaving_date
|
||||||
super().__init__(code=code, name=name, type=10, is_active=is_active, is_reconcilable=False,
|
super().__init__(code=code, name=name, type=10, is_starred=is_starred, is_active=is_active,
|
||||||
cost_centre_id=cost_centre_id)
|
is_reconcilable=False, cost_centre_id=cost_centre_id)
|
||||||
|
|
||||||
def create(self, dbsession):
|
def create(self, dbsession):
|
||||||
code = dbsession.query(func.max(AccountBase.code)).filter(AccountBase.type == self.type).one()[0]
|
code = dbsession.query(func.max(AccountBase.code)).filter(AccountBase.type == self.type).one()[0]
|
||||||
|
@ -53,6 +53,7 @@ def save(request):
|
|||||||
except (ValueError, KeyError, TypeError):
|
except (ValueError, KeyError, TypeError):
|
||||||
raise ValidationError("Joining Date is not a valid date")
|
raise ValidationError("Joining Date is not a valid date")
|
||||||
|
|
||||||
|
is_starred = request.json_body['isStarred']
|
||||||
is_active = request.json_body['isActive']
|
is_active = request.json_body['isActive']
|
||||||
try:
|
try:
|
||||||
if is_active:
|
if is_active:
|
||||||
@ -64,7 +65,7 @@ def save(request):
|
|||||||
except (ValueError, KeyError, TypeError):
|
except (ValueError, KeyError, TypeError):
|
||||||
raise ValidationError("Leaving Date is not a valid date")
|
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)
|
leaving_date).create(request.dbsession)
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
return employee_info(item.id, request.dbsession)
|
return employee_info(item.id, request.dbsession)
|
||||||
@ -102,6 +103,7 @@ def update(request):
|
|||||||
except (ValueError, KeyError, TypeError):
|
except (ValueError, KeyError, TypeError):
|
||||||
raise ValidationError("Joining Date is not a valid date")
|
raise ValidationError("Joining Date is not a valid date")
|
||||||
|
|
||||||
|
item.is_starred = request.json_body['isStarred']
|
||||||
item.is_active = request.json_body['isActive']
|
item.is_active = request.json_body['isActive']
|
||||||
try:
|
try:
|
||||||
if item.is_active:
|
if item.is_active:
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
.gold {
|
||||||
|
color: gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-title-group>
|
<mat-card-title-group>
|
||||||
<mat-card-title>Employee</mat-card-title>
|
<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-title-group>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<form [formGroup]="form" fxLayout="column">
|
<form [formGroup]="form" fxLayout="column">
|
||||||
|
@ -4,6 +4,7 @@ export class Employee {
|
|||||||
id: string;
|
id: string;
|
||||||
code: number;
|
code: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
isStarred: boolean;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
designation: string;
|
designation: string;
|
||||||
salary: number;
|
salary: number;
|
||||||
|
Loading…
Reference in New Issue
Block a user