# NewProject

**Kind:** Class

**Source:** `Frontend/src/app/components/market/projects/newProject.ts` (line 52)

**Part of:** [Frontend](subsystem-frontend-src-app)

`NewProject` manages the new market project workflow in the projects area. It handles component lifecycle setup, tracks data changes, checks branch state, opens related library or registration documents, and submits a new project through `AddNew()`.

**Implements:** `OnInit`, `AfterViewInit`, `ComponentCanDeactivate`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `DataChanged` | `DataChanged()` | `void` |
| `ifSameBranch` | `ifSameBranch()` | `boolean` |
| `ngOnInit` | `ngOnInit()` | `void` |
| `ngAfterViewInit` | `ngAfterViewInit()` | `void` |
| `getRecord` | `getRecord()` | `void` |
| `getOpenedTabs` | `getOpenedTabs()` | `void` |
| `selectText` | `selectText(e: undefined)` | `void` |
| `openLibrary` | `openLibrary()` | `void` |
| `openRegistrationDocs` | `openRegistrationDocs(reg: ProjectsSuppliersRegisteration)` | `void` |
| `AddNew` | `AddNew(e: undefined, type: undefined)` | `void` |
| `validate` | `validate(e: undefined)` | `void` |
| `GetAuthorizationAccess` | `GetAuthorizationAccess(url: string)` | `void` |
| `checkAllowedToEdit` | `checkAllowedToEdit()` | `boolean` |
| `getClass` | `getClass(status: string)` | `string` |
| `addNewPerson` | `addNewPerson()` | `void` |
| `AddNewContact` | `AddNewContact(ID: undefined)` | `void` |
| `EmitRemoveContact` | `EmitRemoveContact(ID: undefined)` | `void` |
| `AddContact` | `AddContact(e: undefined)` | `void` |
| `RemoveContact` | `RemoveContact(e: undefined)` | `void` |
| `newOf` | `newOf()` | `void` |
| `updateContactPersonImg` | `updateContactPersonImg()` | `void` |
| `preview2` | `preview2()` | `void` |
| `addnewContactPersonContact` | `addnewContactPersonContact(type: undefined)` | `void` |
| `deletePersonContactinfo` | `deletePersonContactinfo(i: number)` | `void` |
| `resestPerson` | `resestPerson()` | `void` |
| `geturl` | `geturl(path: undefined)` | `void` |
| `setperson` | `setperson(e: undefined)` | `void` |
| `deletePerson` | `deletePerson(e: undefined)` | `void` |
| `EditPerson` | `EditPerson()` | `void` |
| `preview3` | `preview3()` | `void` |
| `EditContactPersonImg` | `EditContactPersonImg()` | `void` |
| `makeFileRequest` | `makeFileRequest(url: string, params: Array<string>, files: Array<File>)` | `void` |
| `setPerson2` | `setPerson2(e: any)` | `void` |
| `gridItem_KeyPress_Number` | `gridItem_KeyPress_Number(event: undefined)` | `void` |
| `addnewShareholder` | `addnewShareholder()` | `void` |
| `onExpectedCompletionDateChanged` | `onExpectedCompletionDateChanged(e: undefined)` | `void` |
| `onCreatedAtChanged` | `onCreatedAtChanged(e: undefined)` | `void` |
| `onSalesResponsibleChange` | `onSalesResponsibleChange(e: undefined)` | `void` |
| `onSalesResponsibleRemove` | `onSalesResponsibleRemove()` | `void` |
| `matchSalesResposibleWithTeams` | `matchSalesResposibleWithTeams()` | `void` |
| `currencyChange` | `currencyChange(e: any)` | `void` |
| `getMarketSegments` | `getMarketSegments()` | `void` |
| `setSelectedRegistration` | `setSelectedRegistration(e: undefined)` | `void` |
| `getRegistrationStatus` | `getRegistrationStatus()` | `void` |
| `getRegistrationData` | `getRegistrationData()` | `void` |
| `formatCells` | `formatCells(e: undefined)` | `void` |
| `OpenReg` | `OpenReg(e: undefined)` | `void` |
| `editnewRegistreation` | `editnewRegistreation()` | `void` |
| `addnewRegistreation` | `addnewRegistreation()` | `void` |
| `updateRegistreation` | `updateRegistreation(newOrUpdate: string, Registreation: ProjectsSuppliersRegisteration)` | `void` |

## Properties

| Property | Type |
|---|---|
| `marketSegments` | `MarketSegment[]` |
| `firstInitialized` | `boolean` |
| `_passIdAsInput` | `number` |
| `grid` | `DxDataGridComponent` |
| `grid2` | `DxDataGridComponent` |
| `sharedPopup` | `SharedPopupComponent` |
| `DataValidator` | `DxValidationGroupComponent` |
| `RegistrationValidator` | `DxValidationGroupComponent` |
| `EditeRegistrationValidator` | `DxValidationGroupComponent` |
| `printOptionsValidator` | `DxValidationGroupComponent` |
| `FileLibrary` | `FilesComponent` |
| `attachedDropdown` | `SharedAttachedDocsComponent` |
| `attachedProjectRegistrationDropdown` | `SharedAttachedDocsComponent` |
| `contactList` | `ContactsComponent` |
| `logHistoryComponent` | `LogHistoryComponent` |
| `environment` | `any` |
| `popup` | `any` |
| `selectedDocs` | `FileData[]` |
| `project` | `Project` |
| `oldData` | `Project` |
| `supplierList` | `Account[]` |
| `dataTypes` | `any` |
| `List1` | `string[]` |
| `List2` | `string[]` |
| `List3` | `string[]` |
| `List4` | `string[]` |
| `List5` | `string[]` |
| `List6` | `string[]` |
| `users` | `Person[]` |
| `errorMessage` | `string` |
| `NoChange_CanLeave` | `boolean` |
| `Change_Saved_CanLeave` | `boolean` |
| `Change_NoSave_WantLeave` | `boolean` |
| `pendingNavigationUrl` | `RouterStateSnapshot` |
| `RelatedToTypes` | `any` |
| `ModuleEnumId` | `any` |
| `LogModuleId` | `any` |
| `projectStatuList` | `ProjectStatus[]` |
| `TempName` | `string` |
| `selectedRegisted` | `Account[]` |
| `TempPercntage` | `number` |
| `projectJobs` | `ProjectJobs[]` |
| `ClientsList` | `any[]` |
| `Comment` | `string` |
| `Reply` | `string` |
| `currenFeature` | `number` |
| `subscriptionNotInclude` | `boolean` |
| `registerationFeatureId` | `number` |
| `registerationFeatureNotInclude` | `boolean` |
| `subscription` | `Subscription` |

## Where it refuses work

- `NewProject` stops the work with an early return when `this.project && this.project.CompanyBranchID == this.auth.User.CompanyBranchID`.
- `NewProject` stops the work with an early return when `this.allowedtoEdit`.
- `NewProject` stops the work with an early return when `this.allowedtoNew`.
- `NewProject` stops the work with an early return when `!path || path.length < 1`.
- `NewProject` stops the work with an early return when `!this.EditeRegistrationValidator.instance.validate().isValid`.
- `NewProject` stops the work with an early return when `!this.RegistrationValidator.instance.validate().isValid`.

## Diagram

```mermaid
graph LR
  Init[ngOnInit] --> Load[getRecord]
  Init --> Tabs[getOpenedTabs]
  ViewInit[ngAfterViewInit] --> Select[selectText]
  Change[DataChanged] --> Branch[ifSameBranch]
  Branch --> Add[AddNew]
  Library[openLibrary] --> Docs[Project library]
  Registration[openRegistrationDocs] --> Docs
```

## Usage

```ts
import { NewProject } from './newProject';

export class ProjectHostComponent {
  newProject!: NewProject;

  submitProject(): void {
    this.newProject.DataChanged();

    if (this.newProject.ifSameBranch()) {
      this.newProject.AddNew();
    }
  }

  showReferenceMaterial(): void {
    this.newProject.openLibrary();
  }

  showRegistrationDocuments(): void {
    this.newProject.openRegistrationDocs();
  }
}
```

## AI Coding Instructions

- Keep initialization work in `ngOnInit()` and view-dependent work in `ngAfterViewInit()`.
- Call `DataChanged()` when editable project data changes so the component can update its pending state.
- Check `ifSameBranch()` before calling `AddNew()` when project creation depends on branch selection.
- Use `openLibrary()` and `openRegistrationDocs()` for their respective navigation actions rather than duplicating document-opening logic.

## Relationships

- IMPORTS → `Shareholder`
- IMPORTS → `AppSettings`
- IMPORTS → `DataTypes`
- IMPORTS → `PermissionForSheetResponce`
- IMPORTS → `SubscriptionPackagesEnum`
- IMPORTS → `PrintOption`
- IMPORTS → `AuthService`
- IMPORTS → `ListOfNewResponse`
- IMPORTS → `Project`
- IMPORTS → `ProjectJobs`
- IMPORTS → `ProjectImportanceEnum`
- IMPORTS → `ProjectService`
- IMPORTS → `ProjectStatusService`
- IMPORTS → `RelatedToTypes`
- IMPORTS → `ContactInfo`
- IMPORTS → `PersonService`
- IMPORTS → `Account`
- IMPORTS → `AccountsService`
- IMPORTS → `Person`
- IMPORTS → `Departments`
- IMPORTS → `MarketSegmentService`
- IMPORTS → `MarketSegment`
- IMPORTS → `ContactPersons`
- IMPORTS → `ProjectsSuppliersRegisteration`
- IMPORTS → `ContactPersonService`
- IMPORTS → `RegistrationStatus`
- IMPORTS → `PreviousPageService`
- IMPORTS → `AlertsService`
- IMPORTS → `SharedPopupComponent`
- IMPORTS → `SharedAttachedDocsComponent`
- IMPORTS → `File`
- IMPORTS → `GeneralListView`
- IMPORTS → `FilesComponent`
- IMPORTS → `ContactsComponent`
- IMPORTS → `FilesPortService`
- IMPORTS → `FilesService`
- IMPORTS → `ComponentCanDeactivate`
- IMPORTS → `RecentlyOpenedService`
- IMPORTS → `checkChanges`
- IMPORTS → `environment`
- IMPORTS → `ModuleEnumId`
- IMPORTS → `LogHistoryModulesEnum`
- IMPORTS → `LogHistoryComponent`
- IMPORTS → `RegisterationsData`
- IMPORTS → `NewJobService`

## Used by

3 references from 3 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (3)

- `MarketComponentsModule` — `Frontend/src/app/components/market/market-components.module.ts`:1
- `MarketModule` — `Frontend/src/app/components/market/market.module.ts`:1
- `ProjectsModule` — `Frontend/src/app/components/market/projects.module.ts`:1
