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

Stickers adding sticker support for entitities #3497

Draft
wants to merge 2 commits into
base: master-qa
Choose a base branch
from
Draft
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
40 changes: 24 additions & 16 deletions src/app/pages/users/user/miscs/user-miscs.component.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
<div class="row">
<div class="col-md-6">
<div class="form-group">
<mat-form-field>
<input [formControl]="iNumber" matInput
placeholder="{{'users.inumber' | translate}}" type="text">
</mat-form-field>
<div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<mat-form-field>
<input [formControl]="iNumber" matInput
placeholder="{{'users.inumber' | translate}}" type="text">
</mat-form-field>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<mat-form-field>
<input [formControl]="costCenter" matInput
placeholder="{{'users.cost_center' | translate}}" type="text">
<mat-error *ngIf="costCenter.errors?.pattern">
{{"general.invalid_value" | translate}}
</mat-error>
</mat-form-field>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<mat-form-field>
<input [formControl]="costCenter" matInput
placeholder="{{'users.cost_center' | translate}}" type="text">
<mat-error *ngIf="costCenter.errors?.pattern">
{{"general.invalid_value" | translate}}
</mat-error>
</mat-form-field>
<div class="row">
<div class="col-md-12">
<app-stickers></app-stickers>
</div>
</div>
</div>

2 changes: 2 additions & 0 deletions src/app/pages/users/users.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { StickersModule } from 'shared/stickers/stickers.module';

import { MaterialModule } from '../../app.module';
import { AddressModule } from '../../shared/address/address.module';
Expand Down Expand Up @@ -50,6 +51,7 @@ import { UserRoutes } from './users.routing';
DialogsModule,
CommonDirectivesModule,
FormattersModule,
StickersModule,
],
declarations: [
UserStatusFormatterComponent,
Expand Down
18 changes: 18 additions & 0 deletions src/app/shared/stickers/stickers.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div>
<mat-form-field appearance="none">
<mat-chip-list #chipList aria-label="Stickers" class="chip-list">
<mat-chip *ngFor="let sticker of stickers" (removed)="remove(sticker)" class="single-chip">
{{sticker}}
<button matChipRemove>
<mat-icon>cancel</mat-icon>
</button>
</mat-chip>
</mat-chip-list>
</mat-form-field>
<mat-form-field class="example-chip-list" appearance="fill">
<mat-label>Stickers</mat-label>
<input matInput [placeholder]="placeholderText"
[(ngModel)]="newSticker"
(keyup.enter)="add()"/>
</mat-form-field>
</div>
8 changes: 8 additions & 0 deletions src/app/shared/stickers/stickers.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.single-chip {
margin-right: 5px !important;
min-width: 5px !important;
}

.chip-list .mat-chip-list-wrapper {
justify-content: left !important;
}
38 changes: 38 additions & 0 deletions src/app/shared/stickers/stickers.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {COMMA, ENTER} from '@angular/cdk/keycodes';
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'app-stickers',
templateUrl: 'stickers.component.html',
styleUrls: ['stickers.component.scss']
})
export class StickersComponent {
public stickers: string[] = ['VIP', 'ZEN'];
public newSticker = '';
public readonly separatorKeysCodes = [ENTER, COMMA] as const;
public placeholderText = '';

public constructor(
public translateService: TranslateService
) {
this.placeholderText = this.translateService.instant('general.add_new_sticker');
}

public add(): void {
if (this.newSticker) {
console.log(this.newSticker);
this.stickers.push(this.newSticker);
}
console.log(this.stickers);
this.newSticker = '';
}

public remove(sticker: string): void {
const index = this.stickers.indexOf(sticker);

if (index >= 0) {
this.stickers.splice(index, 1);
}
}
}
25 changes: 25 additions & 0 deletions src/app/shared/stickers/stickers.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';

import { MaterialModule } from '../../app.module';
import { StickersComponent } from './stickers.component';

@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
FormsModule,
TranslateModule,
MaterialModule,
],
declarations: [
StickersComponent,
],
exports: [
StickersComponent,
],
})
export class StickersModule {
}
1 change: 1 addition & 0 deletions src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "Poskytnutý soubor je neplatný",
"invalid_file_csv_header_error": "Přinejmenším jedno z požadovaných záhlaví není poskytnuto v souboru CSV, akce byla přerušena",
"import_already_ongoing": "Během importu nelze nahrát karty/čipy",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Ovládací panel",
"charging_stations": "Nabíjecí stanice",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "Die bereitgestellte Datei ist ungültig",
"invalid_file_csv_header_error": "Mindestens ein erforderlicher Header wurde nicht in der CSV-Datei bereitgesellt, der Vorgang wurde abgebrochen.",
"import_already_ongoing": "Badges können nicht hochgeladen werden, während ein Import stattfindet",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Dashboard",
"charging_stations": "Ladestationen",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "The provided file is invalid",
"invalid_file_csv_header_error": "At least one of the required header was not provided in the CSV file, operation has been aborted",
"import_already_ongoing": "Cannot upload the RFID cards while an import is ongoing",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Dashboard",
"charging_stations": "Charging Stations",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "El archivo es inválido",
"invalid_file_csv_header_error": "Al menos uno de los campos requeridos no fue proporcionado en el archivo CSV, operación anulada",
"import_already_ongoing": "Impossibile cargar las insignias durante el proceso de importación",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Tablero",
"charging_stations": "Estaciones de carga",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "Le fichier fourni est invalide",
"invalid_file_csv_header_error": "Au moins un des champs obligatoire n'a pas été fourni dans l'en-tête du fichier CSV, l'opération a été annulée",
"import_already_ongoing": "Impossible de transférer les badges pendant qu'un import est en cours",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Tableau de bord",
"charging_stations": "Bornes",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "Il file non è valido",
"invalid_file_csv_header_error": "Almeno uno dei campi obbligatori non è stato aggiunto nel file CSV, l'operazione è stata annullata",
"import_already_ongoing": "Impossibile caricare un badge se un caricamento è già in corso",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Cruscotto",
"charging_stations": "Stazioni di Ricarica",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"invalid_file_error": "The provided file is invalid",
"invalid_file_csv_header_error": "At least one of the required header was not provided in the CSV file, operation has been aborted",
"import_already_ongoing": "Cannot upload the badges while an import is ongoing",
"add_new_sticker": "Type here to add new sticker",
"menu": {
"dashboard": "Painel de Controlo",
"charging_stations": "Estações de Carga",
Expand Down