Skip to content

Commit 6540524

Browse files
committed
fix some bug and add loading handle create org
1 parent 69ccde9 commit 6540524

File tree

2 files changed

+87
-83
lines changed

2 files changed

+87
-83
lines changed

src/app/features/organization/pages/org-blocks/org-blocks.component.html

Lines changed: 77 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,25 @@ <h3>Danh sách khối trong tổ chức ({{ blocks.length }})</h3>
88
<!-- Danh sách block -->
99
<div class="blocks-list" appScrollEnd (appScrollEnd)="onScrollEnd()">
1010
@for (block of blocks; track block) {
11-
<div
12-
class="block-card"
13-
(click)="goToBlock(block.id)"
14-
>
15-
<div class="head-meta">
16-
<h4>{{ block.name }} ({{ block.code }})</h4>
17-
<div class="icons">
18-
<i class="fa fa-edit" (click)="openUpdateModal(block, $event)"></i>
19-
<i
20-
class="fa fa-trash"
21-
(click)="openModalDelete(block.id, $event)"
22-
></i>
23-
</div>
24-
</div>
25-
<p>{{ block.description }}</p>
26-
<small>Tạo lúc: {{ block.createdAt | date : "short" }}</small>
27-
<div class="members-info">
28-
<b>Thành viên:</b> {{ block.members.totalElements }}
11+
<div class="block-card" (click)="goToBlock(block.id)">
12+
<div class="head-meta">
13+
<h4>{{ block.name }}</h4>
14+
<div class="icons">
15+
<i class="fa fa-edit" (click)="openUpdateModal(block, $event)"></i>
16+
<i
17+
class="fa fa-trash"
18+
(click)="openModalDelete(block.id, $event)"
19+
></i>
2920
</div>
3021
</div>
31-
}
32-
33-
@if (isLoading) {
34-
<div class="loading">Đang tải...</div>
22+
<p>{{ block.description }}</p>
23+
<small>Tạo lúc: {{ block.createdAt | date : "short" }}</small>
24+
<div class="members-info">
25+
<b>Thành viên:</b> {{ block.members.totalElements }}
26+
</div>
27+
</div>
28+
} @if (isLoading) {
29+
<div class="loading">Đang tải...</div>
3530
}
3631
</div>
3732
</div>
@@ -52,66 +47,66 @@ <h2>Thêm block</h2>
5247
[(ngModel)]="newBlock.name"
5348
name="blockName"
5449
placeholder="Tên block"
55-
/>
56-
<input
57-
[(ngModel)]="newBlock.code"
58-
name="blockCode"
59-
placeholder="Mã block"
60-
/>
61-
<textarea
62-
[(ngModel)]="newBlock.description"
63-
name="blockDesc"
64-
placeholder="Mô tả"
65-
></textarea>
50+
/>
51+
<input
52+
[(ngModel)]="newBlock.code"
53+
name="blockCode"
54+
placeholder="Mã block"
55+
/>
56+
<textarea
57+
[(ngModel)]="newBlock.description"
58+
name="blockDesc"
59+
placeholder="Mô tả"
60+
></textarea>
6661

67-
<div class="modal-actions">
68-
<button type="button" class="btn-cancel" (click)="closeModal()">
69-
Đóng
70-
</button>
71-
<button type="submit" class="btn-submit" (click)="createBlock()">
72-
Tạo
73-
</button>
74-
</div>
75-
</form>
62+
<div class="modal-actions">
63+
<button type="button" class="btn-cancel" (click)="closeModal()">
64+
Đóng
65+
</button>
66+
<button type="submit" class="btn-submit" (click)="createBlock()">
67+
Tạo
68+
</button>
7669
</div>
77-
</div>
70+
</form>
71+
</div>
72+
</div>
7873

79-
<!-- backdrop update block -->
80-
<div
81-
class="modal-backdrop"
82-
[class.show-modal]="showUpdateModal"
83-
(click)="closeUpdateModal()"
84-
></div>
85-
<!-- modal update block -->
86-
<div class="modal" [class.show-modal]="showUpdateModal">
87-
<div class="modal-content">
88-
<h2>Cập nhật block</h2>
89-
@if (editingBlock) {
90-
<form>
91-
<input
92-
[(ngModel)]="editingBlock.name"
93-
name="editName"
94-
placeholder="Tên block"
95-
/>
96-
<input
97-
[(ngModel)]="editingBlock.code"
98-
name="editCode"
99-
placeholder="Mã block"
100-
/>
101-
<textarea
102-
[(ngModel)]="editingBlock.description"
103-
name="editDesc"
104-
placeholder="Mô tả"
105-
></textarea>
106-
<div class="modal-actions">
107-
<button type="button" class="btn-cancel" (click)="closeUpdateModal()">
108-
Đóng
109-
</button>
110-
<button type="submit" class="btn-submit" (click)="saveUpdateBlock()">
111-
Lưu
112-
</button>
113-
</div>
114-
</form>
115-
}
116-
</div>
117-
</div>
74+
<!-- backdrop update block -->
75+
<div
76+
class="modal-backdrop"
77+
[class.show-modal]="showUpdateModal"
78+
(click)="closeUpdateModal()"
79+
></div>
80+
<!-- modal update block -->
81+
<div class="modal" [class.show-modal]="showUpdateModal">
82+
<div class="modal-content">
83+
<h2>Cập nhật block</h2>
84+
@if (editingBlock) {
85+
<form>
86+
<input
87+
[(ngModel)]="editingBlock.name"
88+
name="editName"
89+
placeholder="Tên block"
90+
/>
91+
<input
92+
[(ngModel)]="editingBlock.code"
93+
name="editCode"
94+
placeholder="Mã block"
95+
/>
96+
<textarea
97+
[(ngModel)]="editingBlock.description"
98+
name="editDesc"
99+
placeholder="Mô tả"
100+
></textarea>
101+
<div class="modal-actions">
102+
<button type="button" class="btn-cancel" (click)="closeUpdateModal()">
103+
Đóng
104+
</button>
105+
<button type="submit" class="btn-submit" (click)="saveUpdateBlock()">
106+
Lưu
107+
</button>
108+
</div>
109+
</form>
110+
}
111+
</div>
112+
</div>

src/app/features/organization/pages/organization-management/organization-management.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,21 @@ export class OrganizationManagementComponent implements OnInit, OnDestroy {
234234
}
235235

236236
submitCreate(req: CreateOrgRequest) {
237+
Promise.resolve().then(() => {
238+
this.store.dispatch(
239+
setLoading({ isLoading: true, content: 'Đang tạo, xin chờ...' })
240+
);
241+
});
237242
this.orgService.createOrg(req).subscribe({
238243
next: () => {
239244
this.refreshTokenAfterCreatedOrg();
240245
setTimeout(() => {
246+
this.store.dispatch(clearLoading());
241247
this.loadOrgs();
242-
}, 2000);
248+
}, 1000);
249+
},
250+
error: () => {
251+
this.store.dispatch(clearLoading());
243252
},
244253
});
245254
}

0 commit comments

Comments
 (0)