Skip to content

Commit

Permalink
Merge pull request #6433 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Jun 28, 2023
2 parents 77aaa1c + a99e85b commit 900c157
Show file tree
Hide file tree
Showing 38 changed files with 1,128 additions and 571 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,120 @@
{{ 'FORM.RATES.EXPECTED_RATE' | translate }}
</nb-card-header>
<nb-card-body>
<div class="col-12">
<div class="form-group">
<label for="payPeriodsSelect" class="label">
{{ 'FORM.LABELS.PAY_PERIOD' | translate }}
</label>
<nb-select
id="payPeriodsSelect"
formControlName="payPeriod"
[placeholder]="'FORM.LABELS.PAY_PERIOD' | translate"
class="d-block"
size="medium"
fullWidth
>
<nb-option
*ngFor="let payPeriod of payPeriods"
[value]="payPeriod"
<div class="row">
<div class="col-6">
<div class="form-group">
<label
for="payPeriodsSelect"
class="label"
>
{{
payPeriod
| replace: '_':' '
| titlecase
'FORM.LABELS.PAY_PERIOD'
| translate
}}
</nb-option>
</nb-select>
</label>
<nb-select
id="payPeriodsSelect"
formControlName="payPeriod"
[placeholder]="
'FORM.LABELS.PAY_PERIOD'
| translate
"
class="d-block"
size="medium"
fullWidth
>
<nb-option
*ngFor="
let payPeriod of payPeriods
"
[value]="payPeriod"
>
{{
payPeriod
| replace : '_' : ' '
| titlecase
}}
</nb-option>
</nb-select>
</div>
</div>
</div>
<div class="col-6 float-left">
<div class="form-group">
<label class="label" for="billRateValueInput">
{{ 'FORM.LABELS.BILL_RATE' | translate }}
</label>
<input
fullWidth
id="billRateValueInput"
type="number"
[min]="0"
step="0.1"
nbInput
formControlName="billRateValue"
[placeholder]="'FORM.PLACEHOLDERS.BILL_RATE' | translate"
/>
<div class="col-6">
<ga-currency
formControlName="billRateCurrency"
(optionChange)="currencyChanged($event)"
></ga-currency>
</div>
</div>
<div class="col-6 float-left">
<ga-currency
formControlName="billRateCurrency"
(optionChange)="currencyChanged($event)"
></ga-currency>
<div class="row">
<div class="col-6">
<div class="form-group">
<label
class="label"
for="billRateValueInput"
>
{{
'FORM.LABELS.BILL_RATE'
| translate
}}
</label>
<input
fullWidth
id="billRateValueInput"
type="number"
[min]="minimumBillingRate.value || 0"
step="0.1"
nbInput
formControlName="billRateValue"
[placeholder]="
'FORM.PLACEHOLDERS.BILL_RATE'
| translate
"
/>
</div>
<div
class="caption status-danger"
*ngIf="billRateValue.errors?.['min']"
>
{{ 'FORM.RATES.ERRORS.BILL_RATE' | translate: { min:
billRateValue.errors?.['min']?.min, currency:
billRateCurrency.value } }}
</div>
</div>
<div class="col-6">
<div class="form-group">
<label
class="label"
for="minimumBillingRateInput"
>
{{
'FORM.LABELS.BILL_RATE_MIN'
| translate
}}
</label>
<input
fullWidth
id="minimumBillingRateInput"
type="number"
[min]="0"
step="0.1"
nbInput
formControlName="minimumBillingRate"
[placeholder]="
'FORM.PLACEHOLDERS.BILL_RATE_MIN'
| translate
"
/>
</div>
<div
class="caption status-danger"
*ngIf="minimumBillingRate.errors?.['min']"
>
{{ 'FORM.RATES.ERRORS.BILL_RATE_MIN' | translate: { min:
minimumBillingRate.errors?.['min']?.min, currency:
billRateCurrency.value } }}
</div>
</div>
</div>
</nb-card-body>
</nb-card>
Expand All @@ -71,20 +137,43 @@
<nb-card-body>
<div class="form-group">
<label class="label" for="reWeeklyLimitInput">
{{ 'FORM.LABELS.RECURRING_WEEKLY_LIMIT' | translate }}
{{
'FORM.LABELS.RECURRING_WEEKLY_LIMIT'
| translate
}}
</label>
<input
fullWidth
id="reWeeklyLimitInput"
nbInput
type="number"
[min]="1"
[max]="128"
[min]="0"
[max]="168"
step="0.1"
formControlName="reWeeklyLimit"
[placeholder]="'FORM.PLACEHOLDERS.RECURRING_WEEKLY_LIMIT' | translate"
[placeholder]="
'FORM.PLACEHOLDERS.RECURRING_WEEKLY_LIMIT'
| translate
"
autofocus
/>
</div>
<div
class="caption status-danger"
*ngIf="reWeeklyLimit.errors?.['max']"
>
{{
'FORM.RATES.ERRORS.LIMIT_MAX' | translate : { max: reWeeklyLimit.errors?.['max']?.max
} }}
</div>
<div
class="caption status-danger"
*ngIf="reWeeklyLimit.errors?.['min']"
>
{{
'FORM.RATES.ERRORS.LIMIT_MIN' | translate: { min: reWeeklyLimit.errors?.['min']?.min
} }}
</div>
</nb-card-body>
</nb-card>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { Component, OnDestroy, OnInit, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import {
IEmployee,
PayPeriodEnum,
ICandidate,
ICurrency
} from '@gauzy/contracts';
import { IEmployee, PayPeriodEnum, ICandidate, ICurrency } from '@gauzy/contracts';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { filter, tap } from 'rxjs';
import {
CandidateStore,
EmployeeStore,
Store
} from '../../../@core/services';
import { CandidateStore, EmployeeStore, Store } from '../../../@core/services';

@UntilDestroy({ checkProperties: true })
@Component({
Expand All @@ -21,7 +12,6 @@ import {
styleUrls: ['employee-rates.component.scss']
})
export class EmployeeRatesComponent implements OnInit, OnDestroy {

@Input() public isEmployee: boolean;
@Input() public isCandidate: boolean;

Expand All @@ -30,19 +20,16 @@ export class EmployeeRatesComponent implements OnInit, OnDestroy {
payPeriods = Object.values(PayPeriodEnum);

/*
* Employee Rates Form
*/
* Employee Rates Form
*/
public form: FormGroup = EmployeeRatesComponent.buildForm(this.fb);
static buildForm(fb: FormBuilder): FormGroup {
return fb.group({
payPeriod: [],
billRateValue: [],
billRateValue: ['', Validators.min(0)],
billRateCurrency: [],
reWeeklyLimit: ['', Validators.compose([
Validators.min(1),
Validators.max(128)
])
]
reWeeklyLimit: ['', Validators.compose([Validators.min(0), Validators.max(168)])],
minimumBillingRate: ['', Validators.min(0)]
});
}

Expand All @@ -51,21 +38,21 @@ export class EmployeeRatesComponent implements OnInit, OnDestroy {
private readonly store: Store,
private readonly employeeStore: EmployeeStore,
private readonly candidateStore: CandidateStore
) { }
) {}

ngOnInit() {
this.employeeStore.selectedEmployee$
.pipe(
filter((employee: IEmployee) => !!employee),
tap((employee: IEmployee) => this.selectedEmployee = employee),
tap((employee: IEmployee) => (this.selectedEmployee = employee)),
tap((employee: IEmployee) => this._syncRates(employee)),
untilDestroyed(this)
)
.subscribe();
this.candidateStore.selectedCandidate$
.pipe(
filter((candidate: ICandidate) => !!candidate),
tap((candidate: ICandidate) => this.selectedCandidate = candidate),
tap((candidate: ICandidate) => (this.selectedCandidate = candidate)),
tap((candidate: ICandidate) => this._syncRates(candidate)),
untilDestroyed(this)
)
Expand Down Expand Up @@ -96,14 +83,31 @@ export class EmployeeRatesComponent implements OnInit, OnDestroy {
payPeriod: user.payPeriod,
billRateValue: user.billRateValue,
billRateCurrency: user.billRateCurrency,
reWeeklyLimit: user.reWeeklyLimit
reWeeklyLimit: user.reWeeklyLimit,
minimumBillingRate: user.minimumBillingRate
});
}

/*
* On Changed Currency Event Emitter
*/
currencyChanged($event: ICurrency) { }
currencyChanged($event: ICurrency) {}

public get reWeeklyLimit() {
return this.form.get('reWeeklyLimit');
}

public get billRateValue() {
return this.form.get('billRateValue');
}

public get billRateCurrency() {
return this.form.get('billRateCurrency');
}

public get minimumBillingRate() {
return this.form.get('minimumBillingRate');
}

ngOnDestroy() { }
ngOnDestroy() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Cell, DefaultEditor } from 'ng2-smart-table';

@Component({
template: `<input
class="form-control"
[min]="0"
[type]="'number'"
[(ngModel)]="cell.newValue"
[name]="cell.getId()"
>`,
})
export class NumberEditorComponent extends DefaultEditor implements OnInit {

@Input() cell!: Cell;
@Output() onConfirm: EventEmitter<number> = new EventEmitter<number>();

constructor() {
super();
}

ngOnInit() {
if (this.cell.newValue) {
this.cell.newValue = +this.cell.newValue; // Convert the input to a number
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
NbIconModule,
NbTooltipModule,
Expand Down Expand Up @@ -40,10 +41,12 @@ import { ProjectOrganizationGridDetailsComponent } from './project-organization-
import { ProjectOrganizationEmployeesComponent } from './project-organization-employees/project-organization-employees.component';
import { PhoneUrlComponent } from './phone-url/phone-url.component';
import { AllowScreenshotCaptureComponent } from './allow-screenshot-capture/allow-screenshot-capture.component';
import { NumberEditorComponent } from './editors/number-editor.component';

@NgModule({
imports: [
CommonModule,
FormsModule,
NbIconModule,
NbTooltipModule,
NbBadgeModule,
Expand Down Expand Up @@ -83,7 +86,9 @@ import { AllowScreenshotCaptureComponent } from './allow-screenshot-capture/allo
ProjectOrganizationGridDetailsComponent,
ProjectOrganizationEmployeesComponent,
PhoneUrlComponent,
AllowScreenshotCaptureComponent
AllowScreenshotCaptureComponent,
// smart table field editor
NumberEditorComponent
],
exports: [
NotesWithTagsComponent,
Expand Down
Loading

0 comments on commit 900c157

Please sign in to comment.