Unverified Commit 77effc90 authored by Ruslan Konviser's avatar Ruslan Konviser Committed by GitHub
Browse files

Merge pull request #1203 from ever-co/fix/language-enum

fix: add language enum
parents 99d678ed 6cc1142d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -182,11 +182,11 @@
			}}</label>
			<div class="col-sm-9">
				<select class="form-control" formControlName="locale">
					<option value="en-US">{{ 'ENGLISH' | translate }}</option>
					<option value="he-IL">{{ 'HEBREW' | translate }}</option>
					<option value="ru-RU">{{ 'RUSSIAN' | translate }}</option>
					<option value="bg-BG">{{ 'BULGARIAN' | translate }}</option>
					<option value="es-ES">{{ 'SPANISH' | translate }}</option>
					<option
						[value]="getLanguageCode(lang)"
						*ngFor="let lang of languages"
						>{{ lang | translate }}</option
					>
				</select>
			</div>
		</div>
+10 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ import _ from 'lodash';
import isUrl from 'is-url';
import { takeUntil, first } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core';
import {
	LanguageCodesEnum,
	LanguagesEnum,
} from '@modules/server.common/interfaces/ILanguage';

@Component({
	selector: 'ea-product-basic-info-form',
@@ -73,6 +77,8 @@ export class BasicInfoFormComponent implements OnDestroy, OnInit {
	private onLocaleChanges: any;
	private images: IProductImage[] = [];

	public languages = Object.keys(LanguageCodesEnum);

	static hasValidImage(images) {
		if (images) {
			let imageUrls = images.toString().split(/\s+/);
@@ -177,6 +183,10 @@ export class BasicInfoFormComponent implements OnDestroy, OnInit {
		this._ngDestroy$.complete();
	}

	getLanguageCode(language: LanguagesEnum) {
		return LanguageCodesEnum[language];
	}

	deleteImg(image) {
		this.images = this.images.filter((i) => i.url !== image);

+16 −0
Original line number Diff line number Diff line
@@ -2,3 +2,19 @@
type ILanguage = 'he-IL' | 'en-US' | 'ru-RU' | 'bg-BG' | 'es-ES';

export default ILanguage;

export enum LanguageCodesEnum {
	ENGLISH = 'en-US',
	HEBREW = 'he-IL',
	RUSSIAN = 'ru-RU',
	BULGARIAN = 'bg-BG',
	SPANISH = 'es-ES',
}

export enum LanguagesEnum {
	ENGLISH = 'ENGLISH',
	HEBREW = 'HEBREW',
	RUSSIAN = 'RUSSIAN',
	BULGARIAN = 'BULGARIAN',
	SPANISH = 'SPANISH',
}
+5 −15
Original line number Diff line number Diff line
@@ -12,21 +12,11 @@
				<ion-item>
					<ion-label>Language</ion-label>
					<ion-select formControlName="locale" okText="Okay">
						<ion-select-option value="en-US">{{
							'ENGLISH' | translate
						}}</ion-select-option>
						<ion-select-option value="he-IL">{{
							'HEBREW' | translate
						}}</ion-select-option>
						<ion-select-option value="ru-RU">{{
							'RUSSIAN' | translate
						}}</ion-select-option>
						<ion-select-option value="bg-BG">{{
							'BULGARIAN' | translate
						}}</ion-select-option>
						<ion-select-option value="es-ES">{{
							'SPANISH' | translate
						}}</ion-select-option>
						<ion-select-option
							*ngFor="let lang of languages"
							[value]="getLanguageCode(lang)"
							>{{ lang | translate }}</ion-select-option
						>
					</ion-select>
				</ion-item>
			</ion-col>
+10 −0
Original line number Diff line number Diff line
@@ -10,6 +10,10 @@ import { takeUntil } from 'rxjs/operators';
import { WarehouseProductsRouter } from '@modules/client.common.angular2/routers/warehouse-products-router.service';
import IProduct from '@modules/server.common/interfaces/IProduct';
import { ProductLocalesService } from '@modules/client.common.angular2/locale/product-locales.service';
import {
	LanguageCodesEnum,
	LanguagesEnum,
} from '@modules/server.common/interfaces/ILanguage';

@Component({
	selector: 'basic-info-form',
@@ -23,6 +27,8 @@ export class BasicInfoFormComponent implements OnInit, OnDestroy {
	@Input()
	promotionData: IPromotion;

	public languages = Object.keys(LanguageCodesEnum);

	availableProducts: Partial<IProduct>[] = [];
	displayProducts: { id: string; title: string; image: string }[];

@@ -90,6 +96,10 @@ export class BasicInfoFormComponent implements OnInit, OnDestroy {
		return basicInfoValue as IPromotionCreateObject;
	}

	getLanguageCode(language: LanguagesEnum) {
		return LanguageCodesEnum[language];
	}

	private _setValue() {
		if (!this.promotion) return;