Skip to content

Commit

Permalink
Merge pull request #165 from wantero/master
Browse files Browse the repository at this point in the history
adicionado facilitador na edição de livro
  • Loading branch information
raffacabofrio authored Dec 27, 2018
2 parents e9bb138 + c1b8cfd commit 064652d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/components/book/form/form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ <h1 class="text-center display-4">{{pageTitle}}</h1>
</div>
</div>

<div class="form-group col-md-8 mb-4" *ngIf="userProfile === 'Administrator' && itsEditMode">
<label class="col-form-label" for="userIdFacilitator">Facilitador</label>
<select class="form-control" formControlName="userIdFacilitator">
<option value=""></option>
<option *ngFor="let facilitator of facilitators" value="{{facilitator.id}}">{{facilitator.name}}</option>
</select>
<div *ngIf="formGroup.controls['userIdFacilitator'].touched && !formGroup.controls['userIdFacilitator'].valid">
<small class="form-text text-danger" *ngIf="formGroup.controls['userIdFacilitator'].hasError('required')">
Informe o facilitador do livro.
</small>
</div>
</div>

<div class="form-group col-md-8">
<div class="custom-file">
<input type="file" class="custom-file-input" formControlName="imageName" imageUpload (imageSelected)="onConvertImageToBase64($event)" [allowedExtensions]="['jpg','jpeg','png']">
Expand Down
7 changes: 7 additions & 0 deletions src/app/components/book/form/form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class FormComponent implements OnInit {
formGroup: FormGroup;
freightOptions: FreightOptions[] = [];
categories: Category[] = [];
facilitators: User[] = [];
isSaved: Boolean;

userProfile: string;
Expand Down Expand Up @@ -65,6 +66,10 @@ export class FormComponent implements OnInit {
this._scCategory.getAll().subscribe(data =>
this.categories = data
);

this._scUser.getAllFacilitators().subscribe(data =>
this.facilitators = data
);
}

createFormGroup() {
Expand All @@ -73,6 +78,7 @@ export class FormComponent implements OnInit {
title: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(200)]],
author: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(200)]],
categoryId: ['', [Validators.required]],
userIdFacilitator: ['', [Validators.required]],
userId: ['', [Validators.required]],
freightOption: ['', [Validators.required]],
imageBytes: [''],
Expand Down Expand Up @@ -115,6 +121,7 @@ export class FormComponent implements OnInit {
title: x.title,
author: x.author,
categoryId: x.categoryId,
userIdFacilitator: x.userIdFacilitator,
userId: x.userId,
freightOption: x.freightOption,
imageBytes: '',
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/models/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export class Book {
userId: string;
categoryId: string;
user: User;
userIdFacilitator: string;
userFacilitator: User;
category: Category;
approved: boolean;
// bookUsers
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/services/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ export class UserService {
getProfile() {
return this._http.get<Profile>(`${this.config.apiEndpoint}/account/profile`);
}

getAllFacilitators() {
return this._http.get<User[]>(`${this.config.apiEndpoint}/Account/ListFacilitators`);
}
}

0 comments on commit 064652d

Please sign in to comment.