Skip to content

Commit 3743bb8

Browse files
Merge pull request #3919 from ita-social-projects/fix/ui-bugs
Fix/Mobile UI bugs and form handling issues
2 parents 5676181 + a58a369 commit 3743bb8

File tree

6 files changed

+36
-27
lines changed

6 files changed

+36
-27
lines changed

src/app/ubs/ubs-admin/components/ubs-admin-employee/ubs-admin-employee-edit-form/ubs-admin-employee-edit-form.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('UbsAdminEmployeeEditFormComponent', () => {
202202
component.selectedFile = 'fake';
203203
component.removeImage();
204204

205-
expect(component.imageURL).toBe(null);
205+
expect(component.imageURL).toBe(component.defaultPhotoURL);
206206
expect(component.imageName).toBe(null);
207207
expect(component.selectedFile).toBe(null);
208208
});
@@ -337,7 +337,7 @@ describe('UbsAdminEmployeeEditFormComponent', () => {
337337
component.imageName = 'my-image.jpg';
338338
component.selectedFile = new File([''], 'my-image.jpg');
339339
component.removeImage();
340-
expect(component.imageURL).toBeNull();
340+
expect(component.imageURL).toBe(component.defaultPhotoURL);
341341
expect(component.imageName).toBeNull();
342342
expect(component.selectedFile).toBeNull();
343343
});

src/app/ubs/ubs-admin/components/ubs-admin-employee/ubs-admin-employee-edit-form/ubs-admin-employee-edit-form.component.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,14 @@ export class UbsAdminEmployeeEditFormComponent implements OnInit, OnDestroy {
241241
return initialSorted.some((value, index) => value !== currentSorted[index]);
242242
}
243243

244-
async prepareEmployeeDataToSend(dto: string, image?: string | ArrayBuffer): Promise<FormData> {
244+
async prepareEmployeeDataToSend(dto: string): Promise<FormData> {
245245
this.isUploading = true;
246246
const selectedTariffs = this.filteredTariffs.filter((it) => it.selected);
247247
this.employeeDataToSend = {
248248
employeeDto: {
249249
...this.employeeForm.value,
250-
employeePositionIds: this.employeePositionIds
250+
employeePositionIds: this.employeePositionIds,
251+
image: this.selectedFile ? undefined : this.imageURL
251252
},
252253
tariffs: selectedTariffs.map((tariff) => {
253254
return { tariffId: tariff.id, hasChat: tariff.hasChat };
@@ -256,16 +257,11 @@ export class UbsAdminEmployeeEditFormComponent implements OnInit, OnDestroy {
256257
if (this.isUpdatingEmployee) {
257258
this.employeeDataToSend.employeeDto.id = this.data.id;
258259
}
259-
if (image) {
260-
this.employeeDataToSend.employeeDto.image = image;
261-
}
262-
const formData: FormData = new FormData();
263-
const stringifiedDataToSend = JSON.stringify(this.employeeDataToSend);
264-
formData.append(dto, stringifiedDataToSend);
260+
const formData = new FormData();
261+
formData.append(dto, JSON.stringify(this.employeeDataToSend));
265262

266-
if (this.imageURL && this.imageURL !== this.defaultPhotoURL) {
267-
const blob = await fetch(this.imageURL as string).then((res) => res.blob());
268-
formData.append('image', blob, this.imageName);
263+
if (this.selectedFile) {
264+
formData.append('image', this.selectedFile, this.selectedFile.name);
269265
}
270266
return formData;
271267
}
@@ -284,14 +280,12 @@ export class UbsAdminEmployeeEditFormComponent implements OnInit, OnDestroy {
284280
}
285281

286282
async updateEmployee(): Promise<void> {
287-
const image = !this.selectedFile ? this.defaultPhotoURL : this.imageURL;
288-
const dataToSend = await this.prepareEmployeeDataToSend('employee', image);
283+
const dataToSend = await this.prepareEmployeeDataToSend('employee');
289284
this.store.dispatch(UpdateEmployee({ data: dataToSend, employee: this.employeeDataToSend }));
290285
}
291286

292287
async createEmployee(): Promise<void> {
293-
const image = !this.selectedFile ? this.defaultPhotoURL : this.imageURL;
294-
const dataToSend = await this.prepareEmployeeDataToSend('employee', image);
288+
const dataToSend = await this.prepareEmployeeDataToSend('employee');
295289
this.store.dispatch(AddEmployee({ data: dataToSend, employee: this.employeeDataToSend }));
296290
}
297291

@@ -355,7 +349,7 @@ export class UbsAdminEmployeeEditFormComponent implements OnInit, OnDestroy {
355349
}
356350

357351
removeImage() {
358-
this.imageURL = null;
352+
this.imageURL = this.defaultPhotoURL;
359353
this.imageName = null;
360354
this.selectedFile = null;
361355
if (this.editMode) {

src/app/ubs/ubs-user/components/ubs-user-order-details/ubs-user-order-details.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
.recipient {
1919
grid-column: 1 / -1;
2020
}
21+
22+
.recipient p {
23+
overflow-wrap: break-word;
24+
word-break: normal;
25+
max-width: 800px;
26+
}
2127
}
2228

2329
.table_of_details {

src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ small.text-message.ng-star-inserted {
8686

8787
.radio-btn {
8888
margin-left: -6px;
89+
display: flex;
90+
flex-direction: column;
8991
}
9092

9193
.checkmark {
@@ -126,7 +128,7 @@ small.text-message.ng-star-inserted {
126128
}
127129

128130
.custom-radio-btn {
129-
display: block;
131+
display: flex;
130132
position: relative;
131133
padding-left: 28px;
132134
margin-bottom: 0;

src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ <h5>{{ 'order-details.question-certificate' | translate }}</h5>
9696
<div class="bottom">
9797
<h3>{{ 'order-details.eco-shop' | translate }}</h3>
9898
<h5 class="shop-order-question">{{ 'order-details.shop-order-question' | translate }}</h5>
99+
<div class="bottom-text">
100+
<p class="p-text">{{ 'order-details.cant-found-order' | translate }}</p>
101+
</div>
99102
<div class="form-group shop-submit">
100103
<div class="shop-submit-box">
101104
<div class="inputs-box">
@@ -123,9 +126,6 @@ <h5 class="shop-order-question">{{ 'order-details.shop-order-question' | transla
123126
</div>
124127
</div>
125128
</div>
126-
<div class="bottom-text">
127-
<p class="p-text">{{ 'order-details.cant-found-order' | translate }}</p>
128-
</div>
129129
</div>
130130
<button
131131
*ngIf="isCanAddEcoShopOrderNumber()"

src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.scss

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ input[type='number'] {
333333
max-width: 455px;
334334
}
335335

336+
.bottom-text {
337+
width: 360px;
338+
}
339+
336340
.custom-control {
337341
padding-left: 1.4rem;
338342
}
@@ -517,11 +521,6 @@ h5 {
517521
}
518522
}
519523

520-
.bottom-text {
521-
width: 360px;
522-
padding: 26px 0 0 16px;
523-
}
524-
525524
.comment {
526525
background: var(--ubs-primary-white);
527526
}
@@ -634,6 +633,14 @@ li {
634633
background: transparent;
635634
border: 1px solid var(--ubs-quaternary-dark-grey);
636635
border-radius: 4px;
636+
637+
&:disabled {
638+
background: var(--ubs-quintynary-light-grey);
639+
border-color: var(--ubs-quintynary-light-grey);
640+
color: var(--ubs-primary-light-grey);
641+
cursor: not-allowed;
642+
opacity: 0.6;
643+
}
637644
}
638645

639646
.bottom_comment {

0 commit comments

Comments
 (0)