Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding project while team create #6862

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<label class="label" *ngIf="label">{{ label | translate }}</label>
<ng-template
[ngIf]="!multiple"
[ngIfElse]="multipleSelect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class ProjectSelectorComponent
@Input() shortened = false;
@Input() disabled = false;
@Input() multiple = false;
@Input() label = null;

private _projectId: string | string[];
get projectId(): string | string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ <h5 class="title mr-3 ml-3">
</div>
<div class="row mb-3">
<div class="form-group col-12">
<ga-project-selector formControlName="projects" [skipGlobalChange]="true" [multiple]="true" [showAllOption]="false"
[placeholder]="'FORM.PLACEHOLDERS.ADD_REMOVE_PROJECTS' | translate" [defaultSelected]="false" [label]="'FORM.PLACEHOLDERS.ADD_REMOVE_PROJECTS' | translate"
(onChanged)="onProjectsSelected($event)"></ga-project-selector>
</div>
<div class="form-group col-12">
<ga-employee-multi-select
[label]="'FORM.LABELS.ADD_REMOVE_MANAGERS' | translate"
[placeholder]="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { filter, tap } from 'rxjs/operators';
import { IEmployee, IImageAsset, IOrganization, IOrganizationTeam, ITag } from '@gauzy/contracts';
import { IEmployee, IOrganization, IImageAsset, IOrganizationProject, IOrganizationTeam, ITag } from '@gauzy/contracts';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { distinctUntilChange, isNotEmpty } from '@gauzy/common-angular';
import { Store } from '../../../@core/services';
Expand All @@ -16,6 +16,7 @@ import { DUMMY_PROFILE_IMAGE, ToastrService } from '../../../@core';
export class TeamsMutationComponent implements OnInit {

@Input() employees: IEmployee[] = [];
@Input() projects: IOrganizationProject[] = [];
@Input() team?: IOrganizationTeam;
@Output() canceled = new EventEmitter();
@Output() addOrEditTeam = new EventEmitter();
Expand All @@ -32,6 +33,7 @@ export class TeamsMutationComponent implements OnInit {
name: [null, Validators.required],
memberIds: [null, Validators.required],
managerIds: [],
projects: [],
tags: [],
imageUrl: [
{ value: null, disabled: true }
Expand All @@ -40,6 +42,7 @@ export class TeamsMutationComponent implements OnInit {
});
form.get('memberIds').setValue([]);
form.get('managerIds').setValue([]);
form.get('projects').setValue([]);
form.get('tags').setValue([]);
return form;
}
Expand Down Expand Up @@ -84,13 +87,15 @@ export class TeamsMutationComponent implements OnInit {
if (this.team) {
const selectedEmployees = this.team.members.map((member) => member.id);
const selectedManagers = this.team.managers.map((manager) => manager.id);

this.form.patchValue({
name: this.team.name,
tags: this.team.tags,
memberIds: selectedEmployees,
managerIds: selectedManagers,
imageUrl: this.team.image?.fullUrl,
imageId: this.team.image?.id
imageId: this.team.image?.id,
projects: this.team.projects.map((project: IOrganizationProject) => project.id),
});
}
}
Expand All @@ -101,9 +106,9 @@ export class TeamsMutationComponent implements OnInit {
}
const { id: organizationId } = this.organization;
const { tenantId } = this.store.user;

this.addOrEditTeam.emit({
...this.form.getRawValue(),
projects: this.form.get('projects').value.map((id) => this.projects.find((p) => p.id === id)).filter((p) => !!p),
organizationId,
tenantId,
});
Expand All @@ -129,6 +134,16 @@ export class TeamsMutationComponent implements OnInit {
this.form.get('managerIds').updateValueAndValidity();
}

/**
* On Selected Projects Handler
*
* @param projects
*/
onProjectsSelected(projects: IOrganizationProject[]) {
this.form.get('projects').setValue(projects);
this.form.get('projects').updateValueAndValidity();
}

cancel() {
this.canceled.emit();
}
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/app/pages/teams/teams.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h4>
<ga-teams-mutation
[employees]="employees"
[team]="selectedTeam"
[projects]="projects"
(canceled)="clearItem()"
(addOrEditTeam)="addOrEditTeam($event)"
></ga-teams-mutation>
Expand Down
44 changes: 44 additions & 0 deletions apps/gauzy/src/app/pages/teams/teams.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
RolesEnum,
ComponentLayoutStyleEnum,
ISelectedEmployee,
IOrganizationProject,
PermissionsEnum,
} from '@gauzy/contracts';
import { NbDialogRef, NbDialogService } from '@nebular/theme';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -39,6 +41,7 @@ import {
} from '../../@shared/table-components';
import {
EmployeesService,
OrganizationProjectsService,
OrganizationTeamsService,
Store,
ToastrService
Expand All @@ -65,6 +68,7 @@ export class TeamsComponent extends PaginationFilterBaseComponent
teams: IOrganizationTeam[] = [];
employees: IEmployee[] = [];
tags: ITag[] = [];
projects: IOrganizationProject[] = [];

viewComponentName: ComponentEnum;
dataLayoutStyle = ComponentLayoutStyleEnum.TABLE;
Expand All @@ -77,6 +81,8 @@ export class TeamsComponent extends PaginationFilterBaseComponent
public organization: IOrganization;
teams$: Subject<any> = this.subject$;
employees$: Subject<any> = new Subject();
projects$: Subject<any> = new Subject();

selected = {
team: null,
state: false
Expand All @@ -94,6 +100,7 @@ export class TeamsComponent extends PaginationFilterBaseComponent
constructor(
private readonly organizationTeamsService: OrganizationTeamsService,
private readonly employeesService: EmployeesService,
private readonly projectService: OrganizationProjectsService,
private readonly toastrService: ToastrService,
private readonly dialogService: NbDialogService,
private readonly store: Store,
Expand Down Expand Up @@ -134,6 +141,15 @@ export class TeamsComponent extends PaginationFilterBaseComponent
)
.subscribe();

this.projects$
.pipe(
debounceTime(300),
tap(() => this._refresh$.next(true)),
tap(() => this.loadOrganizationProjects()),
untilDestroyed(this)
)
.subscribe();

const storeOrganization$ = this.store.selectedOrganization$;
const storeEmployee$ = this.store.selectedEmployee$;
combineLatest([storeOrganization$, storeEmployee$])
Expand All @@ -147,6 +163,7 @@ export class TeamsComponent extends PaginationFilterBaseComponent
tap(() => this._refresh$.next(true)),
tap(() => this.teams$.next(true)),
tap(() => this.employees$.next(true)),
tap(() => this.projects$.next(true)),
untilDestroyed(this)
)
.subscribe();
Expand All @@ -158,6 +175,7 @@ export class TeamsComponent extends PaginationFilterBaseComponent
),
tap(() => this.teams$.next(true)),
tap(() => this.employees$.next(true)),
tap(() => this.projects$.next(true)),
debounceTime(1000),
tap(() => this.openDialog(this.addEditTemplate, false)),
untilDestroyed(this)
Expand Down Expand Up @@ -315,6 +333,31 @@ export class TeamsComponent extends PaginationFilterBaseComponent
this.employees = items;
}

/**
* load organization projects
*
* @returns
*/
private async loadOrganizationProjects(): Promise<IOrganizationProject[]> {
if (!this.organization || !this.store.hasAnyPermission(
PermissionsEnum.ALL_ORG_VIEW,
PermissionsEnum.ORG_PROJECT_VIEW
)) {
return;
}

const { tenantId } = this.store.user;
const { id: organizationId } = this.organization;

this.projects = (await this.projectService.getAll(
[],
{
organizationId,
tenantId
}
)).items;
}

public getTagsByEmployeeId(id: string) {
const employee = this.employees.find((empl) => empl.id === id);
return employee ? employee.tags : [];
Expand All @@ -340,6 +383,7 @@ export class TeamsComponent extends PaginationFilterBaseComponent
'members.role',
'members.employee.user',
'tags',
'projects'
],
where: {
organizationId,
Expand Down
2 changes: 2 additions & 0 deletions apps/gauzy/src/app/pages/teams/teams.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { EmployeeMultiSelectModule } from '../../@shared/employee/employee-multi
import { GauzyButtonActionModule } from '../../@shared/gauzy-button-action/gauzy-button-action.module';
import { PaginationModule } from '../../@shared/pagination/pagination.module';
import { ImageUploaderModule } from '../../@shared/image-uploader/image-uploader.module';
import { ProjectSelectModule } from '../../@shared/project-select/project-select.module';

@NgModule({
imports: [
Expand All @@ -54,6 +55,7 @@ import { ImageUploaderModule } from '../../@shared/image-uploader/image-uploader
TranslateModule,
HeaderTitleModule,
EmployeeMultiSelectModule,
ProjectSelectModule,
PaginationModule,
GauzyButtonActionModule,
CommonModule,
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
"REMOVE_IMAGE": "Премахни снимка",
"UPLOADER_PLACEHOLDER": "Снимка",
"UPLOADER_DOCUMENT_PLACEHOLDER": "URL",
"ADD_REMOVE_PROJECTS": "Добавяне или премахване на проекти",
"ADD_REMOVE_EMPLOYEES": "Добави или премахни служители",
"ADD_REMOVE_CANDIDATE": "Add Candidate",
"ADD_REMOVE_EMPLOYEE": "Add Interviewer",
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@
"UPLOADER_PLACEHOLDER": "Image",
"UPLOADER_DOCUMENT_PLACEHOLDER": "URL",
"ADD_REMOVE_EMPLOYEES": "Add or Remove Employees",
"ADD_REMOVE_PROJECTS": "Add or Remove Projects",
"ADD_REMOVE_CANDIDATE": "Add Candidate",
"ADD_REMOVE_EMPLOYEE": "Add Interviewer",
"ADD_REMOVE_INTERVIEWER": "Select interviewer",
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@
"UPLOADER_PLACEHOLDER": "Imagen",
"UPLOADER_DOCUMENT_PLACEHOLDER": "URL (Uniform Resource Locator)",
"ADD_REMOVE_EMPLOYEES": "Agregar o eliminar empleados.",
"ADD_REMOVE_PROJECTS": "Agregar o quitar proyecto",
"ADD_REMOVE_CANDIDATE": "Agregar candidato",
"ADD_REMOVE_EMPLOYEE": "Añadir entrevistador",
"ADD_REMOVE_INTERVIEWER": "Seleccionar entrevistador",
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@
"UPLOADER_PLACEHOLDER": "Image",
"UPLOADER_DOCUMENT_PLACEHOLDER": "URL (Uniform Resource Locator)",
"ADD_REMOVE_EMPLOYEES": "Ajouter ou Supprimer des Employés",
"ADD_REMOVE_PROJECTS": "Ajouter ou supprimer un projet",
"ADD_REMOVE_CANDIDATE": "Ajouter un candidat",
"ADD_REMOVE_EMPLOYEE": "Ajouter un intervieweur",
"ADD_REMOVE_INTERVIEWER": "Sélectionnez l'intervieweur",
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/assets/i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
"UPLOADER_PLACEHOLDER": "תמונה",
"UPLOADER_DOCUMENT_PLACEHOLDER": "URL",
"ADD_REMOVE_EMPLOYEES": "Add or Remove Employees",
"ADD_REMOVE_PROJECTS": "הוסף או הסר פרויקט",
"ADD_REMOVE_CANDIDATE": "Add Candidate",
"ADD_REMOVE_EMPLOYEE": "Add Interviewer",
"ADD_REMOVE_INTERVIEWER": "Select interviewer",
Expand Down
1 change: 1 addition & 0 deletions apps/gauzy/src/assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
"UPLOADER_PLACEHOLDER": "Изображение",
"UPLOADER_DOCUMENT_PLACEHOLDER": "URL",
"ADD_REMOVE_EMPLOYEES": "Добавление или удаление сотрудников",
"ADD_REMOVE_PROJECTS": "Добавить или удалить проект",
"ADD_REMOVE_CANDIDATE": "Добавить Кандидата",
"ADD_REMOVE_EMPLOYEE": "Добавить интервьюера",
"ADD_REMOVE_INTERVIEWER": "Выбрать интервьюера",
Expand Down
7 changes: 4 additions & 3 deletions packages/contracts/src/organization-team.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IOrganizationProject } from './organization-projects.model';

export interface IOrganizationTeam
extends IBasePerTenantAndOrganizationEntityModel,
IRelationalImageAsset {
IRelationalImageAsset {
name: string;
color?: string;
emoji?: string;
Expand All @@ -21,13 +21,14 @@ export interface IOrganizationTeam
profile_link?: string;
members?: IOrganizationTeamEmployee[];
managers?: IOrganizationTeamEmployee[];
projects?: IOrganizationProject[];
tags?: ITag[];
tasks?: ITask[];
}

export interface IOrganizationTeamFindInput
extends IBasePerTenantAndOrganizationEntityModel,
IRelationalEmployee {
IRelationalEmployee {
name?: string;
prefix?: string;
public?: boolean;
Expand All @@ -36,7 +37,7 @@ export interface IOrganizationTeamFindInput

export interface IOrganizationTeamCreateInput
extends IBasePerTenantAndOrganizationEntityModel,
IRelationalImageAsset {
IRelationalImageAsset {
name: string;
emoji?: string;
teamSize?: string;
Expand Down