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

added mentions legales to technical settings / tenant front #3397

Open
wants to merge 3 commits into
base: master-qa
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions src/app/pages/organization/organization.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { AccountBillingComponent } from 'shared/component/account-billing/account-billing.component';
import { PricingDefinitionsModule } from 'shared/pricing-definitions/pricing-definitions.module';

import { MaterialModule } from '../../app.module';
import { AddressModule } from '../../shared/address/address.module';
import { AccountBillingComponent } from '../../shared/component/account-billing/account-billing.component';
import { ComponentModule } from '../../shared/component/component.module';
import { DialogsModule } from '../../shared/dialogs/dialogs.module';
import { PricingDefinitionsModule } from '../../shared/pricing-definitions/pricing-definitions.module';
import { TableModule } from '../../shared/table/table.module';
import { TenantSupportModule } from '../../shared/tenant-support/tenant-support.module';
import { CompanyLogoFormatterCellComponent } from './companies/cell-components/company-logo-formatter-cell.component';
import { CompanyDialogComponent } from './companies/company/company-dialog.component';
import { CompanyComponent } from './companies/company/company.component';
Expand Down Expand Up @@ -45,7 +46,6 @@ import { SiteComponent } from './sites/site/site.component';

@NgModule({
imports: [
AddressModule,
CommonModule,
FormsModule,
AddressModule,
Expand All @@ -57,6 +57,7 @@ import { SiteComponent } from './sites/site/site.component';
RouterModule.forChild(OrganizationRoutes),
ComponentModule,
PricingDefinitionsModule,
TenantSupportModule,
],
declarations: [
OrganizationComponent,
Expand Down
143 changes: 128 additions & 15 deletions src/app/pages/settings-technical/data/tenant-data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,45 @@
<mat-icon>save</mat-icon><span>{{ "general.save" | translate }}</span>
</button>
</div>
<!-- business information -->
<div class="card">
<div class="card-header card-header-icon card-header-primary">
<div class="card-icon">
<mat-icon>business</mat-icon>
</div>
<h3 class="card-title">{{ "technical_settings.tabs.organization" | translate }}</h3>
<h3 class="card-title">{{ "technical_settings.business.title" | translate }}</h3>
</div>
<div class="card-body">
<div class="row">
<div class="form-group col-md-3">
<mat-form-field>
<input [formControl]="name" appAutofocus matInput placeholder="{{'technical_settings.tenant.public_name' | translate}}" required
type="text">
<mat-error *ngIf="name.errors?.required">{{"general.mandatory_field" | translate}}</mat-error>
<mat-error *ngIf="name.errors?.maxlength">
<div [translateParams]="{length: 100}" [translate]="'general.error_max_length'"></div>
</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-3">
<mat-form-field>
<input [formControl]="email" matInput placeholder="{{'technical_settings.tenant.email' | translate}}" required type="text">
<mat-error *ngIf="email.errors?.required">{{"general.mandatory_field" | translate}}</mat-error>
<mat-error *ngIf="email.errors?.email">{{"authentication.invalid_email" | translate}}</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-6">
<mat-form-field>
<input [formControl]="website" matInput placeholder="{{'technical_settings.tenant.website' | translate}}" type="text">
<mat-error *ngIf="website.errors?.pattern">{{"general.error_url_pattern" | translate}}</mat-error>
</mat-form-field>
</div>
</div>
<div class="row">
<div class="col-md-3 my-auto">
<div class="rotating-card-container img-fluid" [ngStyle]="{ 'pointer-events': 'all' }">
<div class="card card-rotate card-background app-small-image m-0">
<div class="front front-background"
[ngStyle]="{'background-image': 'url(' + logo + ')', 'background-size' : 'contain', 'background-repeat': 'no-repeat'}">
<div class="front front-background" [ngStyle]="{'background-image': 'url(' + logo + ')', 'background-size' : 'contain', 'background-repeat': 'no-repeat'}">
<div class="card-body">
</div>
</div>
Expand All @@ -43,27 +68,99 @@ <h3 class="card-title">{{ "technical_settings.tabs.organization" | translate }}<
</div>
</div>
<div class="col-md-9">
<div class="col-md-12">
<div class="form-group">
<div class="row">
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="legalStatus" appAutofocus matInput placeholder="{{'technical_settings.business.legal_status' | translate}}" type="text" (input)="toUpperCase(legalStatus)">
<mat-error *ngIf="legalStatus.errors?.maxlength">
<div [translateParams]="{length: 100}" [translate]="'general.error_max_length'"></div>
</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-8">
<mat-form-field>
<input [formControl]="name" appAutofocus matInput placeholder="{{'tenants.name' | translate}}" required
type="text">
<mat-error *ngIf="name.errors?.required">{{"general.mandatory_field" | translate}}</mat-error>
<mat-error *ngIf="name.errors?.maxlength">
<input [formControl]="corporateName" appAutofocus matInput placeholder="{{'technical_settings.business.corporate_name' | translate}}" type="text">
<mat-error *ngIf="corporateName.errors?.maxlength">
<div [translateParams]="{length: 100}" [translate]="'general.error_max_length'"></div>
</mat-error>
</mat-form-field>
</div>
</div>
<div class="form-group col-md-12">
<mat-form-field>
<input [formControl]="email" matInput placeholder="{{'tenants.email' | translate}}" required type="text">
<mat-error *ngIf="email.errors?.required">{{"general.mandatory_field" | translate}}</mat-error>
<mat-error *ngIf="email.errors?.email">{{"authentication.invalid_email" | translate}}</mat-error>
</mat-form-field>
<div class="row">
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="rcs" matInput placeholder="{{'technical_settings.business.rcs' | translate}}" type="text" (input)="toUpperCase(rcs)">
<mat-error *ngIf="rcs.errors?.pattern">
<div [translate]="'general.error_number_pattern'"></div>
</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="capital" appAutofocus matInput placeholder="{{'technical_settings.business.capital' | translate}}" type="text">
<mat-error *ngIf="capital.errors?.pattern">
<div [translate]="'general.error_number_pattern'"></div>
</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="siret" matInput placeholder="{{'technical_settings.business.siret' | translate}}" type="text">
<mat-error *ngIf="siret.errors?.pattern">
<div [translate]="'technical_settings.business.error_siret_pattern'"></div>
</mat-error>
</mat-form-field>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- tenant information -->
<!-- <div class="card">
<div class="card-header card-header-icon card-header-primary">
<div class="card-icon">
<mat-icon>business</mat-icon>
</div>
<h3 class="card-title">{{ "technical_settings.tenant.title" | translate }}</h3>
</div>
<div class="card-body">
<div class="row">
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="name" appAutofocus matInput placeholder="{{'technical_settings.tenant.public_name' | translate}}" required
type="text">
<mat-error *ngIf="name.errors?.required">{{"general.mandatory_field" | translate}}</mat-error>
<mat-error *ngIf="name.errors?.maxlength">
<div [translateParams]="{length: 100}" [translate]="'general.error_max_length'"></div>
</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="email" matInput placeholder="{{'technical_settings.tenant.email' | translate}}" required type="text">
<mat-error *ngIf="email.errors?.required">{{"general.mandatory_field" | translate}}</mat-error>
<mat-error *ngIf="email.errors?.email">{{"authentication.invalid_email" | translate}}</mat-error>
</mat-form-field>
</div>
<div class="form-group col-md-4">
<mat-form-field>
<input [formControl]="website" matInput placeholder="{{'technical_settings.tenant.website' | translate}}" type="text">
<mat-error *ngIf="website.errors?.pattern">{{"general.error_url_pattern" | translate}}</mat-error>
</mat-form-field>
</div>
</div>
</div>
</div> -->
<!-- address information -->
<div class="card">
<div class="card-header card-header-icon card-header-primary">
<div class="card-icon">
<mat-icon>edit_location_alt</mat-icon>
</div>
<h3 class="card-title">{{ "general.address" | translate }}</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<app-address [address]="address" [formGroup]="formGroup" componentName="{{'tenants.title' | translate}}"
Expand All @@ -72,4 +169,20 @@ <h3 class="card-title">{{ "technical_settings.tabs.organization" | translate }}<
</div>
</div>
</div>
<!-- support information -->
<div class="card">
<div class="card-header card-header-icon card-header-primary">
<div class="card-icon">
<mat-icon>contact_support</mat-icon>
</div>
<h3 class="card-title">{{ "technical_settings.support.title" | translate }}</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<app-tenant-support [tenantSupport]="tenantSupport" [formGroup]="formGroup"></app-tenant-support>
</div>
</div>
</div>
</div>
</form>
79 changes: 70 additions & 9 deletions src/app/pages/settings-technical/data/tenant-data.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { Component, Input, OnChanges, OnInit } from '@angular/core';
import { AbstractControl, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { StatusCodes } from 'http-status-codes';
import { CentralServerService } from 'services/central-server.service';
import { ConfigService } from 'services/config.service';
import { MessageService } from 'services/message.service';
import { SpinnerService } from 'services/spinner.service';
import { Address } from 'types/Address';
import { RestResponse } from 'types/GlobalType';
import { Tenant } from 'types/Tenant';
import { Constants } from 'utils/Constants';
import { Utils } from 'utils/Utils';

import { CentralServerService } from '../../../services/central-server.service';
import { ConfigService } from '../../../services/config.service';
import { MessageService } from '../../../services/message.service';
import { SpinnerService } from '../../../services/spinner.service';
import { Address } from '../../../types/Address';
import { RestResponse } from '../../../types/GlobalType';
import { Tenant } from '../../../types/Tenant';
import { TenantSupport } from '../../../types/TenantSupport';
import { Constants } from '../../../utils/Constants';
import { Utils } from '../../../utils/Utils';

@Component({
selector: 'app-tenant-data',
Expand All @@ -22,11 +24,18 @@ export class TenantDataComponent implements OnInit, OnChanges {
public initialized = false;
public formGroup!: UntypedFormGroup;
public name!: AbstractControl;
public legalStatus!: AbstractControl;
public corporateName!: AbstractControl;
public website!: AbstractControl;
public email!: AbstractControl;
public rcs!: AbstractControl;
public capital!: AbstractControl;
public siret!: AbstractControl;
public logo = Constants.NO_IMAGE;
public logoHasChanged = false;
public logoMaxSize: number;
public address: Address = {} as Address;
public tenantSupport: TenantSupport = {} as TenantSupport;
public tenant: Tenant;

public constructor(
Expand Down Expand Up @@ -54,9 +63,43 @@ export class TenantDataComponent implements OnInit, OnChanges {
Validators.email,
]))
);
this.formGroup.addControl('corporateName', new UntypedFormControl('',
Validators.compose([
Validators.maxLength(100),
]))
);
this.formGroup.addControl('website', new UntypedFormControl('',
Validators.compose([
Validators.pattern(Constants.URL_PATTERN)
]))
);
this.formGroup.addControl('rcs', new UntypedFormControl('',
Validators.compose([
]))
);
this.formGroup.addControl('capital', new UntypedFormControl('',
Validators.compose([
Validators.pattern('^[0-9]*$')
]))
);
this.formGroup.addControl('siret', new UntypedFormControl('',
Validators.compose([
Validators.pattern('^[0-9]{14}$')
]))
);
this.formGroup.addControl('legalStatus', new UntypedFormControl('',
Validators.compose([
]))
);
// Assign
this.name = this.formGroup.controls['name'];
this.email = this.formGroup.controls['email'];
this.legalStatus = this.formGroup.controls['legalStatus'];
this.corporateName = this.formGroup.controls['corporateName'];
this.website = this.formGroup.controls['website'];
this.rcs = this.formGroup.controls['rcs'];
this.capital = this.formGroup.controls['capital'];
this.siret = this.formGroup.controls['siret'];
this.initialized = true;
this.loadTenant();
}
Expand All @@ -70,9 +113,18 @@ export class TenantDataComponent implements OnInit, OnChanges {
this.centralServerService.getTenant(this.centralServerService.getLoggedUser().tenantID).subscribe((tenant) => {
this.name.setValue(tenant.name);
this.email.setValue(tenant.email);
this.legalStatus.setValue(tenant.legalStatus);
this.corporateName.setValue(tenant.corporateName);
this.website.setValue(tenant.website);
this.rcs.setValue(tenant.rcs);
this.capital.setValue(tenant.capital);
this.siret.setValue(tenant.siret);
if (tenant.address) {
this.address = tenant.address;
}
if (tenant.support) {
this.tenantSupport = tenant.support;
}
this.tenant = tenant;
this.formGroup.markAsPristine();
// Get Tenant logo
Expand All @@ -91,6 +143,10 @@ export class TenantDataComponent implements OnInit, OnChanges {
}
}
});
// Update form group
this.formGroup.updateValueAndValidity();
this.formGroup.markAsPristine();
this.formGroup.markAllAsTouched();
});
}

Expand All @@ -116,6 +172,10 @@ export class TenantDataComponent implements OnInit, OnChanges {
}
}

public toUpperCase(control: AbstractControl) {
control.setValue(control.value.toUpperCase());
}

public clearLogo() {
// Clear
this.logo = Constants.NO_IMAGE;
Expand All @@ -142,6 +202,7 @@ export class TenantDataComponent implements OnInit, OnChanges {
this.spinnerService.show();
this.updateTenantLogo(tenant);
tenant.id = this.centralServerService.getLoggedUser().tenantID;
// forthis.tenantSupport
this.centralServerService.updateTenantData(tenant).subscribe({
next: (response) => {
this.spinnerService.hide();
Expand Down
6 changes: 4 additions & 2 deletions src/app/pages/settings-technical/settings-technical.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { AddressModule } from 'shared/address/address.module';

import { MaterialModule } from '../../app.module';
import { AddressModule } from '../../shared/address/address.module';
import { DialogsModule } from '../../shared/dialogs/dialogs.module';
import { CommonDirectivesModule } from '../../shared/directives/directives.module';
import { FormattersModule } from '../../shared/formatters/formatters.module';
import { TableModule } from '../../shared/table/table.module';
import { TenantSupportModule } from '../../shared/tenant-support/tenant-support.module';
import { SettingsCryptoKeyComponent } from './crypto/crypto-key/settings-crypto-key.component';
import { SettingsCryptoComponent } from './crypto/settings-crypto.component';
import { TenantDataComponent } from './data/tenant-data.component';
Expand All @@ -36,7 +37,8 @@ import { SettingsUserComponent } from './users/settings-user.component';
TableModule,
FormsModule,
ReactiveFormsModule,
AddressModule
AddressModule,
TenantSupportModule,
]
})
export class SettingsTechnicalModule { }
2 changes: 2 additions & 0 deletions src/app/pages/tenants/tenants.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AddressModule } from '../../shared/address/address.module';
import { DialogsModule } from '../../shared/dialogs/dialogs.module';
import { CommonDirectivesModule } from '../../shared/directives/directives.module';
import { TableModule } from '../../shared/table/table.module';
import { TenantSupportModule } from '../../shared/tenant-support/tenant-support.module';
import { TenantLogoFormatterCellComponent } from './cell-components/tenant-logo-formatter-cell.component';
import { TenantsListTableDataSource } from './list/tenants-list-table-data-source';
import { TenantsListComponent } from './list/tenants-list.component';
Expand All @@ -30,6 +31,7 @@ import { TenantsRoutes } from './tenants.routing';
CommonDirectivesModule,
DialogsModule,
AddressModule,
TenantSupportModule
],
declarations: [
TenantsListComponent,
Expand Down
Loading