Skip to content

Commit

Permalink
form validators
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytakis committed Jan 26, 2021
1 parent 0a28777 commit 7cedac5
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 42 deletions.
52 changes: 32 additions & 20 deletions src/app/core/services/static-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ import { GeneralList } from '../interfaces/general-list.interface';
})
export class StaticDataService {

/**
* Site Title
*/
siteTitle: string = " - Synergy.gr | Εμπορική Κοινότητα Συνεργατικών";

public get getSiteTitle(): string {
return this.siteTitle;
};

/**
* Payments List
*/
* Payments List
*/
paymentsList: PaymentList[] = [
{
bic: 'ETHNGRAA',
Expand Down Expand Up @@ -66,6 +73,10 @@ export class StaticDataService {
}
];

public get getPaymentsList(): PaymentList[] {
return this.paymentsList;
};

/**
* Sectors List
*/
Expand Down Expand Up @@ -104,6 +115,10 @@ export class StaticDataService {
}
];

public get getSectorsList(): GeneralList[] {
return this.sectorsList;
};

/**
* Contacts List
*/
Expand Down Expand Up @@ -163,10 +178,20 @@ export class StaticDataService {
},
];

public get getContactsList(): ContactList[] {
return this.contactsList;
};

/**
* Form Validators
*/
* Form Validators
*/
validators = {
user: {
email: {
minLength: 4,
maxLength: 256
}
},
contact: {
sender: {
minLength: 4,
Expand All @@ -179,26 +204,13 @@ export class StaticDataService {
}
};

public get getSiteTitle(): string {
return this.siteTitle;
};

public get getPaymentsList(): PaymentList[] {
return this.paymentsList;
};

public get getSectorsList(): GeneralList[] {
return this.sectorsList;
};

public get getContactsList(): ContactList[] {
return this.contactsList;
};

public get getValidators() {
return this.validators;
}

/**
* Carousel Owl Options
*/
owlOptions = {
loop: true,
mouseDrag: true,
Expand Down
24 changes: 13 additions & 11 deletions src/app/views/pages/offer-archive/offer-archive.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ <h1>{{ 'PAGE_TITLES.offers-title' | translate }}</h1>
</div>
<pagination-controls autoHide="true" (pageChange)="p = $event"></pagination-controls>
</div>
<pagination-controls autoHide="true" (pageChange)="p = $event"></pagination-controls>
</div>


<!-- <div>
<!-- <div>
<div class="offer row">
<div class="col-md-4" *ngFor="let offer of offers | paginate: { itemsPerPage: 9, currentPage: p }"> -->
<!-- <mat-card class="item-card offer-card">
<!-- <mat-card class="item-card offer-card">
<mat-card-content> -->

<!--begin::Content-->
<!-- <a class="item row" [routerLink]="['/offer/'+ offer.partner_slug + '/' + offer.offer_slug]">
<!--begin::Content-->
<!-- <a class="item row" [routerLink]="['/offer/'+ offer.partner_slug + '/' + offer.offer_slug]">
<div class="col-sm-12 item-img-container">
<div class="item-img">
<img src={{offer.offer_imageURL}} alt={{offer.title}} />
Expand All @@ -43,19 +46,18 @@ <h1>{{ 'PAGE_TITLES.offers-title' | translate }}</h1>
</div>
<div class="item-info">
<div class="">
<div class="item-subtitle"><span class="mdi mdi-shopping"></span>{{offer.partner_name}}</div>
<!-- <div class="item-subtitle"><span class="mdi mdi-pin"></span>{{offer.expiresAt}}</div> -->
<!-- </div>
<div class="item-subtitle"><span class="mdi mdi-shopping"></span>{{offer.partner_name}}</div>-->
<!-- <div class="item-subtitle"><span class="mdi mdi-pin"></span>{{offer.expiresAt}}</div> -->
<!-- </div>
</div>
</div>
</a> -->
<!--end::Content-->
<!--end::Content-->

<!-- </mat-card-content>
<!-- </mat-card-content>
</mat-card>
</div>
</div> -->
<pagination-controls autoHide="true" (pageChange)="p = $event"></pagination-controls>
</div>

<!-- </div> -->
22 changes: 17 additions & 5 deletions src/app/views/pages/offer-archive/offer-archive.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import { Component, OnInit, OnDestroy, ChangeDetectorRef, Input } from '@angular/core';
import { Router } from '@angular/router';

import { Subject } from 'rxjs';
import { tap, takeUntil, finalize } from 'rxjs/operators';
import { Router } from '@angular/router';

import { OpenDataService } from '../../../core/services/open-data.service';
/**
* Models & Interfaces
*/
import { Offer } from '../../../core/models/offer.model';

/**
* Services
*/
import { OpenDataService } from '../../../core/services/open-data.service';

@Component({
selector: 'app-offer-archive',
templateUrl: './offer-archive.component.html',
styleUrls: ['./offer-archive.component.scss']
})
export class OfferArchiveComponent implements OnInit {
export class OfferArchiveComponent implements OnInit, OnDestroy {

public offers: Offer[];

p: number = 1;
loading: boolean = false;

private unsubscribe: Subject<any>;
offers: Offer[];
loading: boolean = false;

constructor(
private cdRef: ChangeDetectorRef,
private openDataService: OpenDataService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<strong>{{ 'AUTH.VALIDATION.INVALID_FIELD' | translate }}</strong>
</mat-error>
<mat-error *ngIf="isRegistrationControlHasError('email','minLength')">
<strong>{{ 'AUTH.VALIDATION.MIN_LENGTH_FIELD' | translate }} 3</strong>
<strong>{{ 'AUTH.VALIDATION.MIN_LENGTH_FIELD' | translate }}: {{validator.email.minLength}}</strong>
</mat-error>
<mat-error *ngIf="isRegistrationControlHasError('email','maxLength')">
<strong>{{ 'AUTH.VALIDATION.MAX_LENGTH_FIELD' | translate }} 320</strong>
<strong>{{ 'AUTH.VALIDATION.MAX_LENGTH_FIELD' | translate }}: {{validator.email.maxLength}}</strong>
</mat-error>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class SupportWindowComponent {
campaign_id: string;
registrationForm: FormGroup;
supportingForm: FormGroup;
validator: any;

private routeSubscription: any;
loading: boolean = false;
private unsubscribe: Subject<any>;
Expand All @@ -59,6 +61,7 @@ export class SupportWindowComponent {
private openDataService: OpenDataService,
private staticDataService: StaticDataService,
) {
this.validator = this.staticDataService.getValidators.user;
this.paymentsList = this.staticDataService.getPaymentsList;
this.unsubscribe = new Subject();
}
Expand Down Expand Up @@ -94,8 +97,8 @@ export class SupportWindowComponent {
email: ['', Validators.compose([
Validators.required,
Validators.email,
Validators.minLength(3),
Validators.maxLength(320)
Validators.minLength(this.validator.email.minLength),
Validators.maxLength(this.validator.email.maxLength)
])
],
});
Expand Down
4 changes: 2 additions & 2 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

export const environment = {
production: false,
apiUrl: 'http://localhost:3000',
// apiUrl: 'https://api.synergatika.gr',
// apiUrl: 'http://localhost:3000',
apiUrl: 'https://api.synergatika.gr',
// apiUrl: 'http://192.168.1.160:3000',
// apiUrl: 'http://192.168.1.9:3000',
appUrl: 'https://app.synergatika.gr',
Expand Down

0 comments on commit 7cedac5

Please sign in to comment.