Skip to content

Commit

Permalink
chore(edit-content): add loading in nodes #28645
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobytes committed Jun 7, 2024
1 parent a9e75f1 commit f75b1a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
<ng-template let-node pTemplate="default">
<span>{{ node.label | truncatePath }}</span>
</ng-template>
<ng-template pTemplate="triggericon">
@if (sitesStatus() === 'loading') {
<i class="pi pi-spin pi-spinner"></i>
} @else {
<i class="pi pi-chevron-down"></i>
}
</ng-template>
</p-treeSelect>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { DotCMSContentTypeField } from '@dotcms/dotcms-models';

import { DotEditContentFieldSingleSelectableDataTypes } from '../../models/dot-edit-content-field.type';
import {
StatusRequest,
TreeNodeItem,
TreeNodeSelectItem
} from '../../models/dot-edit-content-host-folder-field.interface';
Expand Down Expand Up @@ -43,12 +44,20 @@ export class DotEditContentHostFolderFieldComponent implements OnInit {
readonly #editContentService = inject(DotEditContentService);

options = signal<TreeNodeItem[]>([]);
sitesStatus = signal<StatusRequest>('init');
pathControl = new FormControl();

ngOnInit() {
this.#editContentService.getSitesTreePath().subscribe((options) => {
this.options.set(options);
this.getInitialValue();
this.sitesStatus.set('loading');
this.#editContentService.getSitesTreePath().subscribe({
next: (options) => {
this.options.set(options);
this.getInitialValue();
this.sitesStatus.set('success');
},
error: () => {
this.sitesStatus.set('failed');
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export type TreeNodeData = { type: 'site' | 'folder'; path: string; hostname: st

export type TreeNodeItem = TreeNode<TreeNodeData>;

export type StatusRequest = 'init' | 'loading' | 'success' | 'failed';

export type TreeNodeSelectItem = TreeNodeSelectEvent<TreeNodeData>;

export interface TreeNodeSelectEvent<T> {
Expand Down

0 comments on commit f75b1a2

Please sign in to comment.