diff --git a/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts b/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts index d197e33..72ead85 100644 --- a/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts +++ b/src/app/admin/userList/input-interests-admin/input-interests-admin.component.ts @@ -25,6 +25,7 @@ export class InputInterestsAdminComponent implements OnInit allInterests: string[] = []; @Output() eventEmitter = new EventEmitter(); @ViewChild('tagInput') tagInput: ElementRef; + interestsNotSelected: string[] = []; constructor( private messageService: MessageService ) {} @@ -34,7 +35,7 @@ export class InputInterestsAdminComponent implements OnInit { this.filteredInterests = this.formControl.valueChanges.pipe( startWith(null), - map((fruit: string | null) => fruit ? this._filter(fruit) : this.allInterests.slice())); + map((fruit: string | null) => fruit ? this._filter(fruit) : this.interestsNotSelected.slice())); this.messageService .get("misc/getInterests") @@ -45,8 +46,11 @@ export class InputInterestsAdminComponent implements OnInit } else { this.allInterests = []; - for(let elt of retour.data) this.allInterests.push(elt.interest); - this.allInterests.sort(); + for(let elt of retour.data) + { + this.allInterests.push(elt.interest); + this.interestsNotSelected.push(elt.interest); + } } }); } @@ -55,28 +59,53 @@ export class InputInterestsAdminComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allInterests.indexOf(value) !== -1) && (!this.myInterests.includes(value))) + const index = this.interestsNotSelected.indexOf(value); + if (value && (index !== -1) && (!this.myInterests.includes(value))) { this.myInterests.push(value); event.chipInput!.clear(); this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); + this.interestsNotSelected.splice(index, 1); } } - remove(tag: string): void + remove(interest: string): void { - const index = this.myInterests.indexOf(tag); + // supprimer 'interest' de 'myInterest' + const index = this.myInterests.indexOf(interest); if (index >= 0) this.myInterests.splice(index, 1); this.eventEmitter.emit(this.myInterests); + + // remmettre 'interest' dans 'interestsNotSelected' + if(!this.interestsNotSelected.includes(interest)) + { + const indexOfAutres = this.interestsNotSelected.indexOf("Autres"); + if(indexOfAutres !== -1) + { + this.interestsNotSelected.splice(indexOfAutres, 1); + if(interest !== "Autres") this.interestsNotSelected.push(interest); + this.interestsNotSelected.sort(); + this.interestsNotSelected.push("Autres"); + } + else { + this.interestsNotSelected.push(interest); + if(interest !== "Autres") this.interestsNotSelected.sort(); + } + } } selected(event: MatAutocompleteSelectedEvent): void { const value = event.option.viewValue; - if(!this.myInterests.includes(value))this.myInterests.push(value); + if(!this.myInterests.includes(value)) + { + this.myInterests.push(value); + const index = this.interestsNotSelected.indexOf(value); + this.interestsNotSelected.splice(index, 1); + } this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); @@ -86,7 +115,7 @@ export class InputInterestsAdminComponent implements OnInit private _filter(value: string): string[] { const filterValue = value.toLowerCase(); - return this.allInterests.filter(fruit => fruit.toLowerCase().includes(filterValue)); + return this.interestsNotSelected.filter(fruit => fruit.toLowerCase().includes(filterValue)); } } diff --git a/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts b/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts index 8c4de43..e626bef 100644 --- a/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts +++ b/src/app/advertiser/adList/drag-and-drop/drag-and-drop.component.ts @@ -38,6 +38,7 @@ export class DragAndDropComponent return; } this.files.splice(index, 1); + this.eventEmitter.emit(this.files); } /** diff --git a/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html index 8df4522..6def6c2 100644 --- a/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html +++ b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.html @@ -9,18 +9,18 @@ - {{tag}} + (removed)="remove(interest)"> + {{interest}} - - {{tag}} + + {{interest}} diff --git a/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts index be873b4..617cc43 100644 --- a/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts +++ b/src/app/advertiser/adList/input-interests-ad/input-interests-ad.component.ts @@ -20,11 +20,12 @@ export class InputInterestsAdComponent implements OnInit removable = true; separatorKeysCodes: number[] = [ENTER, COMMA]; formControl = new FormControl(); - filteredTags: Observable; - @Input() myTags: string[] = []; - allTags: string[] = []; + filteredInterests: Observable; + @Input() myInterests: string[] = []; + allInterests: string[] = []; @Output() eventEmitter = new EventEmitter(); @ViewChild('tagInput') tagInput: ElementRef; + interestsNotSelected: string[] = []; constructor( private messageService: MessageService ) {} @@ -32,9 +33,9 @@ export class InputInterestsAdComponent implements OnInit ngOnInit(): void { - this.filteredTags = this.formControl.valueChanges.pipe( + this.filteredInterests = this.formControl.valueChanges.pipe( startWith(null), - map((fruit: string | null) => fruit ? this._filter(fruit) : this.allTags.slice())); + map((fruit: string | null) => fruit ? this._filter(fruit) : this.interestsNotSelected.slice())); this.messageService .get("misc/getInterests") @@ -44,8 +45,12 @@ export class InputInterestsAdComponent implements OnInit console.log(retour); } else { - this.allTags = retour.data.map(x => x.interest) - this.allTags.sort(); + this.allInterests = []; + for(let elt of retour.data) + { + this.allInterests.push(elt.interest); + this.interestsNotSelected.push(elt.interest); + } } }); } @@ -54,38 +59,63 @@ export class InputInterestsAdComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allTags.indexOf(value) !== -1) && (!this.myTags.includes(value))) + const index = this.interestsNotSelected.indexOf(value); + if (value && (index !== -1) && (!this.myInterests.includes(value))) { - this.myTags.push(value); + this.myInterests.push(value); event.chipInput!.clear(); this.formControl.setValue(null); - this.eventEmitter.emit(this.myTags); + this.eventEmitter.emit(this.myInterests); + this.interestsNotSelected.splice(index, 1); } } - remove(tag: string): void + remove(interest: string): void { - const index = this.myTags.indexOf(tag); - if (index >= 0) this.myTags.splice(index, 1); - this.eventEmitter.emit(this.myTags); + // supprimer 'interest' de 'myInterest' + const index = this.myInterests.indexOf(interest); + if (index >= 0) this.myInterests.splice(index, 1); + this.eventEmitter.emit(this.myInterests); + + // remmettre 'interest' dans 'interestsNotSelected' + if(!this.interestsNotSelected.includes(interest)) + { + const indexOfAutres = this.interestsNotSelected.indexOf("Autres"); + if(indexOfAutres !== -1) + { + this.interestsNotSelected.splice(indexOfAutres, 1); + if(interest !== "Autres") this.interestsNotSelected.push(interest); + this.interestsNotSelected.sort(); + this.interestsNotSelected.push("Autres"); + } + else { + this.interestsNotSelected.push(interest); + if(interest !== "Autres") this.interestsNotSelected.sort(); + } + } } selected(event: MatAutocompleteSelectedEvent): void { const value = event.option.viewValue; - if(!this.myTags.includes(value))this.myTags.push(value); + if(!this.myInterests.includes(value)) + { + this.myInterests.push(value); + const index = this.interestsNotSelected.indexOf(value); + this.interestsNotSelected.splice(index, 1); + } this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); - this.eventEmitter.emit(this.myTags); + this.eventEmitter.emit(this.myInterests); } private _filter(value: string): string[] { const filterValue = value.toLowerCase(); - return this.allTags.filter(fruit => fruit.toLowerCase().includes(filterValue)); + return this.interestsNotSelected.filter(fruit => fruit.toLowerCase().includes(filterValue)); } } diff --git a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts index 7810130..ca072a5 100644 --- a/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts +++ b/src/app/advertiser/adList/page-ad-list-advertiser/page-ad-list-advertiser.component.ts @@ -124,7 +124,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit { const config = { width: '75%', - height: '80%', + //height: '80%', panelClass: 'custom-dialog-container', data: { action: "add", @@ -146,7 +146,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit else { this.tabAdvertWithCountViews.push(this.advertToAdvertWithCountViews(advertAdded)); this.onFilter(); - message = "L'annoonce a bien été ajoutée ✔" ; + message = "L'annonce a bien été ajoutée ✔" ; } this.snackBar.open( message, "", config); }); @@ -157,7 +157,7 @@ export class PageAdListAdvertiserComponent implements AfterViewInit { const config = { width: '75%', - height: '80%', + //height: '80%', panelClass: 'custom-dialog-container', data: { action: "update", diff --git a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html index f461435..e3b7986 100644 --- a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html +++ b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.html @@ -15,24 +15,24 @@
- + Titre annonce - + - + Commentaire - +
URL - +
diff --git a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss index 2221b39..3bb2eed 100644 --- a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss +++ b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.scss @@ -31,6 +31,9 @@ h1 { // ------------------------------------------------------------------------- +.titleContainer { + width: 100%; +} .commentContainer { width: 100%; diff --git a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts index 8601e49..32831f9 100644 --- a/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts +++ b/src/app/advertiser/adList/popup-add-or-update-ad/popup-add-or-update-ad.component.ts @@ -56,6 +56,7 @@ export class PopupAddOrUpdateAdComponent implements OnInit if(this.data.action === "add") { this.advert = Object.assign({}, ADVERT_VIDE); + this.advert.images = []; this.advert.interests = []; this.title = "Ajouter annonce" ; } @@ -103,12 +104,15 @@ export class PopupAddOrUpdateAdComponent implements OnInit checkField() { if(this.advert.title.length === 0) { - this.errorMessage = "Veuillez remplir le champ 'titre'" ; + this.errorMessage = "Veuillez remplir le champ 'titre'." ; this.hasError = true; } - else if(this.allTitle.includes(this.advert.title)) - { - this.errorMessage = "Ce titre est déjà pris" ; + else if(this.allTitle.includes(this.advert.title)) { + this.errorMessage = "Ce titre est déjà pris." ; + this.hasError = true; + } + else if((this.advert.images.length === 0) && (this.tabOfNewImagesName.length === 0)) { + this.errorMessage = "Veuillez uploader au moins une image." ; this.hasError = true; } else { diff --git a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts index 1a2395b..537cf45 100644 --- a/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts +++ b/src/app/beforeConnexion/register/input-interests-register/input-interests-register.component.ts @@ -25,6 +25,7 @@ export class InputInterestsRegisterComponent implements OnInit allInterests: string[] = []; @Output() eventEmitter = new EventEmitter(); @ViewChild('tagInput') tagInput: ElementRef; + interestsNotSelected: string[] = []; constructor( private messageService: MessageService ) {} @@ -34,7 +35,7 @@ export class InputInterestsRegisterComponent implements OnInit { this.filteredInterests = this.formControl.valueChanges.pipe( startWith(null), - map((fruit: string | null) => fruit ? this._filter(fruit) : this.allInterests.slice())); + map((fruit: string | null) => fruit ? this._filter(fruit) : this.interestsNotSelected.slice())); this.messageService .get("misc/getInterests") @@ -45,8 +46,11 @@ export class InputInterestsRegisterComponent implements OnInit } else { this.allInterests = []; - for(let elt of retour.data) this.allInterests.push(elt.interest); - this.allInterests.sort(); + for(let elt of retour.data) + { + this.allInterests.push(elt.interest); + this.interestsNotSelected.push(elt.interest); + } } }); } @@ -55,28 +59,53 @@ export class InputInterestsRegisterComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allInterests.indexOf(value) !== -1) && (!this.myInterests.includes(value))) + const index = this.interestsNotSelected.indexOf(value); + if (value && (index !== -1) && (!this.myInterests.includes(value))) { this.myInterests.push(value); event.chipInput!.clear(); this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); + this.interestsNotSelected.splice(index, 1); } } - remove(tag: string): void + remove(interest: string): void { - const index = this.myInterests.indexOf(tag); + // supprimer 'interest' de 'myInterest' + const index = this.myInterests.indexOf(interest); if (index >= 0) this.myInterests.splice(index, 1); this.eventEmitter.emit(this.myInterests); + + // remmettre 'interest' dans 'interestsNotSelected' + if(!this.interestsNotSelected.includes(interest)) + { + const indexOfAutres = this.interestsNotSelected.indexOf("Autres"); + if(indexOfAutres !== -1) + { + this.interestsNotSelected.splice(indexOfAutres, 1); + if(interest !== "Autres") this.interestsNotSelected.push(interest); + this.interestsNotSelected.sort(); + this.interestsNotSelected.push("Autres"); + } + else { + this.interestsNotSelected.push(interest); + if(interest !== "Autres") this.interestsNotSelected.sort(); + } + } } selected(event: MatAutocompleteSelectedEvent): void { const value = event.option.viewValue; - if(!this.myInterests.includes(value))this.myInterests.push(value); + if(!this.myInterests.includes(value)) + { + this.myInterests.push(value); + const index = this.interestsNotSelected.indexOf(value); + this.interestsNotSelected.splice(index, 1); + } this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); @@ -86,7 +115,7 @@ export class InputInterestsRegisterComponent implements OnInit private _filter(value: string): string[] { const filterValue = value.toLowerCase(); - return this.allInterests.filter(fruit => fruit.toLowerCase().includes(filterValue)); + return this.interestsNotSelected.filter(fruit => fruit.toLowerCase().includes(filterValue)); } } diff --git a/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts b/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts index 228b6fc..8ceb7c1 100644 --- a/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts +++ b/src/app/user/myProfil/input-interests-profil/input-interests-profil.component.ts @@ -25,6 +25,7 @@ export class InputInterestsProfilComponent implements OnInit allInterests: string[] = []; @Output() eventEmitter = new EventEmitter(); @ViewChild('tagInput') tagInput: ElementRef; + interestsNotSelected: string[] = []; constructor( private messageService: MessageService ) {} @@ -34,7 +35,7 @@ export class InputInterestsProfilComponent implements OnInit { this.filteredInterests = this.formControl.valueChanges.pipe( startWith(null), - map((fruit: string | null) => fruit ? this._filter(fruit) : this.allInterests.slice())); + map((fruit: string | null) => fruit ? this._filter(fruit) : this.interestsNotSelected.slice())); this.messageService .get("misc/getInterests") @@ -45,8 +46,11 @@ export class InputInterestsProfilComponent implements OnInit } else { this.allInterests = []; - for(let elt of retour.data) this.allInterests.push(elt.interest); - this.allInterests.sort(); + for(let elt of retour.data) + { + this.allInterests.push(elt.interest); + this.interestsNotSelected.push(elt.interest); + } } }); } @@ -55,28 +59,53 @@ export class InputInterestsProfilComponent implements OnInit add(event: MatChipInputEvent): void { const value = (event.value || '').trim(); - if (value && (this.allInterests.indexOf(value) !== -1) && (!this.myInterests.includes(value))) + const index = this.interestsNotSelected.indexOf(value); + if (value && (index !== -1) && (!this.myInterests.includes(value))) { this.myInterests.push(value); event.chipInput!.clear(); this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); + this.interestsNotSelected.splice(index, 1); } } - remove(tag: string): void + remove(interest: string): void { - const index = this.myInterests.indexOf(tag); + // supprimer 'interest' de 'myInterest' + const index = this.myInterests.indexOf(interest); if (index >= 0) this.myInterests.splice(index, 1); this.eventEmitter.emit(this.myInterests); + + // remmettre 'interest' dans 'interestsNotSelected' + if(!this.interestsNotSelected.includes(interest)) + { + const indexOfAutres = this.interestsNotSelected.indexOf("Autres"); + if(indexOfAutres !== -1) + { + this.interestsNotSelected.splice(indexOfAutres, 1); + if(interest !== "Autres") this.interestsNotSelected.push(interest); + this.interestsNotSelected.sort(); + this.interestsNotSelected.push("Autres"); + } + else { + this.interestsNotSelected.push(interest); + if(interest !== "Autres") this.interestsNotSelected.sort(); + } + } } selected(event: MatAutocompleteSelectedEvent): void { const value = event.option.viewValue; - if(!this.myInterests.includes(value))this.myInterests.push(value); + if(!this.myInterests.includes(value)) + { + this.myInterests.push(value); + const index = this.interestsNotSelected.indexOf(value); + this.interestsNotSelected.splice(index, 1); + } this.tagInput.nativeElement.value = ''; this.formControl.setValue(null); this.eventEmitter.emit(this.myInterests); @@ -86,7 +115,7 @@ export class InputInterestsProfilComponent implements OnInit private _filter(value: string): string[] { const filterValue = value.toLowerCase(); - return this.allInterests.filter(fruit => fruit.toLowerCase().includes(filterValue)); + return this.interestsNotSelected.filter(fruit => fruit.toLowerCase().includes(filterValue)); } }