Skip to content

Commit 57dd288

Browse files
committed
fix(admin): WB-3183 remove position addconfirmation + call user update
1 parent 9e1379e commit 57dd288

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

admin/src/main/resources/i18n/fr.json

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@
189189
"user-position.input-name": "Nom de la fonction",
190190
"user-position.input-name-placeholder": "Saisissez le nom de la fonction",
191191
"user-position.input-name.not-found": "Cette fonction n’est pas répertoriée, souhaitez-vous l’ajouter ?",
192+
"user-position.confirm.remove.title": "Enlever la fonction",
193+
"user-position.confirm.remove.text": "Êtes vous sûr de vouloir enlever la fonction {{name}} ?",
192194

193195
"management.message.flash": "Message Flash",
194196
"management.message.flash.edit": "Éditer un message flash",
@@ -1053,6 +1055,8 @@
10531055
"notify.user-position.assign.success.content": "Les fonctions ont été assignées.",
10541056
"notify.user-position.assign.error.content": "Les fonctions n'ont pas pu être assignées.",
10551057
"notify.user-position.assign.error.title": "Erreur lors de la sauvegarde",
1058+
"notify.user-position.remove.error.content": "La fonction n'a pas pu être enlevée.",
1059+
"notify.user-position.remove.success.content": "La fonction a été enlevée.",
10561060
"notify.user-position.create.success.content": "La fonction a été créée.",
10571061
"notify.user-position.create.error.title": "Erreur lors de la création",
10581062
"notify.user-position.create.error.content": "La fonction {{position}} n'a pas pu être créée.",

admin/src/main/ts/src/app/users/details/sections/user-positions/user-positions-section.component.html

+28-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99

1010
<ul class="actions-list">
1111
<li *ngFor="let userPosition of userPositions">
12-
<span>{{ userPosition.name }} - <s5l>user-position.source.{{ userPosition.source }}</s5l></span>
13-
<i class="fa fa-times action" (click)="removeUserPosition(userPosition)"
14-
[title]="'user-position.remove' | translate"></i>
12+
<span
13+
>{{ userPosition.name }} -
14+
<s5l>user-position.source.{{ userPosition.source }}</s5l></span
15+
>
16+
<i
17+
class="fa fa-times action"
18+
(click)="removeUserPosition(userPosition)"
19+
[title]="'user-position.remove' | translate"
20+
></i>
1521
</li>
1622
</ul>
1723

@@ -30,13 +36,16 @@ <h3><s5l>user-position.select</s5l></h3>
3036
(filteredListChange)="filteredListChange($event)"
3137
></ode-user-position-list>
3238
<div *ngIf="showEmptyScreen" class="empty-screen">
33-
<img height="100" src="/admin/public/img/user-position-empty-screen.svg" />
39+
<img
40+
height="100"
41+
src="/admin/public/img/user-position-empty-screen.svg"
42+
/>
3443
<s5l>user-position.input-name.not-found</s5l>
3544
<button (click)="openUserPositionCreationModal()">
3645
<s5l>user-position.add</s5l>
3746
<i class="fa fa-plus-circle is-size-5"></i>
3847
</button>
39-
</div>
48+
</div>
4049
</div>
4150
</ode-lightbox>
4251

@@ -47,4 +56,18 @@ <h3><s5l>user-position.select</s5l></h3>
4756
(onClose)="addUserPositionToList($event)"
4857
>
4958
</ode-user-position-modal>
59+
60+
<ode-lightbox-confirm
61+
*ngIf="positionToRemove"
62+
[show]="showConfirmRemovePosition"
63+
lightboxTitle="user-position.confirm.remove.title"
64+
(onCancel)="removeUserPositionCancel()"
65+
(onConfirm)="removeUserPositionConfirmed()"
66+
>
67+
<p>
68+
<s5l [s5l-params]="{ name: positionToRemove.name }"
69+
>user-position.confirm.remove.text</s5l
70+
>
71+
</p>
72+
</ode-lightbox-confirm>
5073
</ode-panel-section>

admin/src/main/ts/src/app/users/details/sections/user-positions/user-positions-section.component.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export class UserPositionsSectionComponent
3232
showUserPositionCreationLightbox: boolean = false;
3333
showEmptyScreen: boolean = false;
3434

35+
showConfirmRemovePosition: boolean = false;
36+
positionToRemove: UserPosition;
37+
3538
/** Truthy when detecting user's positions changes */
3639
get hasUserPositionsChanged(): boolean {
3740
return (!this.details.userPositions && this.userPositions.length > 0) ||
@@ -134,7 +137,18 @@ export class UserPositionsSectionComponent
134137
}
135138

136139
removeUserPosition(position: UserPosition) {
137-
this.userPositions = this.userPositions.filter((p) => p.id !== position.id);
140+
this.positionToRemove = position;
141+
this.showConfirmRemovePosition = true;
142+
}
143+
144+
removeUserPositionCancel() {
145+
this.showConfirmRemovePosition = false;
146+
}
147+
148+
removeUserPositionConfirmed() {
149+
this.userPositions = this.userPositions.filter((p) => p.id !== this.positionToRemove.id);
150+
this.saveUpdate(true);
151+
this.showConfirmRemovePosition = false;
138152
}
139153

140154
openUserPositionCreationModal() {
@@ -150,7 +164,7 @@ export class UserPositionsSectionComponent
150164
this.showUserPositionCreationLightbox = false;
151165
}
152166

153-
saveUpdate() {
167+
saveUpdate(removePosition = false) {
154168
if( this.userPositions && this.userPositions.length>0) {
155169
this.details.userPositions = [...this.userPositions];
156170
} else {
@@ -160,14 +174,14 @@ export class UserPositionsSectionComponent
160174
.perform('portal-content', this.details.updateUserPositions())
161175
.then(() => {
162176
this.ns.success(
163-
'notify.user-position.assign.success.content',
177+
removePosition ? 'notify.user-position.remove.success.content' :'notify.user-position.assign.success.content',
164178
'notify.user-position.success.title'
165179
);
166180
this.userInfoService.setState(this.details);
167181
})
168182
.catch(err => {
169183
this.ns.error(
170-
'notify.user-position.assign.error.content',
184+
removePosition ? 'notify.user-position.remove.error.content': 'notify.user-position.assign.error.content',
171185
'notify.user-position.assign.error.title',
172186
err
173187
);

0 commit comments

Comments
 (0)