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

Feature/accreditation control #77

Merged
merged 2 commits into from
May 28, 2021
Merged
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.2.2.
Angular version : 11.2.3

![home_ebad](./docs_images/ebad_home.png)


## User documentation
[User Guide - English Version](https://github.com/informatique-cdc/ebad-front/wiki/User-Guide---English)

Expand Down
Binary file added docs_images/ebad_home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class ListAccreditationRequestComponent implements OnInit, AfterViewInit,
this.dtOptions = {
language: this.constants.datatable[this.translateService.currentLang] as LanguageSettings,
stateSave: true,
stateSaveParams: function (settings, data: any) {
data.search.search = "";
stateSaveParams: (settings, data: any) => {
data.search.search = '';
},
order: [[1, 'asc']],
pagingType: 'full_numbers',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Component, OnInit} from '@angular/core';
import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap';
import {Application, CreationAccreditationRequest} from '../../core/models';
import {AccreditationRequestsService, ApplicationsService} from "../../core/services";
import {ToastService} from "../../core/services/toast.service";
import {Observable, of} from "rxjs";
import {catchError, debounceTime, distinctUntilChanged, map, switchMap, tap} from "rxjs/operators";
import {Pageable} from "../../core/models/pageable.model";
import {Application, CreationAccreditationRequest} from '../../core';
import {AccreditationRequestsService, ApplicationsService} from '../../core';
import {ToastService} from '../../core/services/toast.service';
import {Observable, of} from 'rxjs';
import {catchError, debounceTime, distinctUntilChanged, map, switchMap, tap} from 'rxjs/operators';
import {Pageable} from '../../core/models/pageable.model';
import {TranslateService} from '@ngx-translate/core';

@Component({
selector: 'ebad-modal-request',
Expand All @@ -20,7 +21,8 @@ export class ModalRequestComponent implements OnInit {
constructor(private accreditationRequestsService: AccreditationRequestsService,
private toastService: ToastService,
public activeModal: NgbActiveModal,
private applicationsService: ApplicationsService) {
private applicationsService: ApplicationsService,
private translateService: TranslateService) {
}

formatter = (result: Application) => result.name;
Expand All @@ -32,7 +34,7 @@ export class ModalRequestComponent implements OnInit {
distinctUntilChanged(),
tap(() => this.searching = true),
switchMap(term =>
this.applicationsService.search(new Pageable(0,10, 'name,asc'), term)
this.applicationsService.search(new Pageable(0, 10, 'name,asc'), term)
.pipe(
map(value => value.content),
tap(() => this.searchFailed = false),
Expand All @@ -49,13 +51,17 @@ export class ModalRequestComponent implements OnInit {

sendRequest(){
this.request.applicationId = this.model.id;
if (!this.request.wantUse && ! this.request.wantManage){
this.translateService.get('ACCREDITATION.MESSAGE.NO_RIGHT_SELECTED').subscribe((msg) => this.toastService.showError(msg));
return;
}
this.accreditationRequestsService.sendAccreditation(this.request).subscribe(
() => {
this.toastService.showSuccess(`Votre demande d'accréditation a bien été envoyée`);
this.translateService.get('ACCREDITATION.MESSAGE.CREATION_OK').subscribe((msg) => this.toastService.showSuccess(msg));
this.activeModal.close();
},
(error) => {
this.toastService.showError( `Votre demande d'accréditation n'a pas pu être envoyée : ${error}`)
this.translateService.get('ACCREDITATION.MESSAGE.CREATION_KO', {error}).subscribe((msg) => this.toastService.showError(msg));
}
);
}
Expand Down
7 changes: 6 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@
"NEW_REQUEST": "New request",
"SYNTHESIS": "Synthesis",
"LOAD_SEARCH": "search in progress...",
"SEARCH_TROUBLE": "Sorry, an error occured when search suggestions"
"SEARCH_TROUBLE": "Sorry, an error occured when search suggestions",
"MESSAGE": {
"NO_RIGHT_SELECTED": "Votre demande d'accréditation ne contient aucune demande de droits",
"CREATION_OK": "Votre demande d'accréditation a bien été envoyée",
"CREATION_KO": "Votre demande d'accréditation n'a pas pu être envoyée : {{error}}"
}
},
"TRACE": {
"TITLE": "Traces",
Expand Down
7 changes: 6 additions & 1 deletion src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@
"NEW_REQUEST": "Nouvelle demande",
"SYNTHESIS": "Synthèse",
"LOAD_SEARCH": "recherche en cours...",
"SEARCH_TROUBLE": "Désolé, les suggestions ne peuvent être chargées"
"SEARCH_TROUBLE": "Désolé, les suggestions ne peuvent être chargées",
"MESSAGE": {
"NO_RIGHT_SELECTED": "Votre demande d'accréditation ne contient aucune demande de droits",
"CREATION_OK": "Votre demande d'accréditation a bien été envoyée",
"CREATION_KO": "Votre demande d'accréditation n'a pas pu être envoyée : {{error}}"
}
},
"TRACE": {
"TITLE": "Traces",
Expand Down