Skip to content

Commit

Permalink
Adds the ability to sort chatbot by name
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Lanzilotto committed Mar 18, 2024
1 parent 19f951a commit 2d885b5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/bots/bots-list/bots-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="order-by-selected-value" *ngIf="orderBylastUpdated">Last updates </span>
<span class="order-by-selected-value" *ngIf="orderByCreationDate">Creation date </span>
<span class="order-by-selected-value" *ngIf="orderByChatbotName">Name </span>
<span class="caret dropdown-caret"
[ngClass]="{'caret-rotate-0': is0penDropDown === false, 'caret-rotate-180': is0penDropDown === true}"></span>
</a>
Expand All @@ -90,6 +91,11 @@
Creation date
</a>
</li>
<li>
<a (click)="orderBy('botname')">
Name
</a>
</li>
</ul>
</div>
</div>
Expand Down
22 changes: 21 additions & 1 deletion src/app/bots/bots-list/bots-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class BotListComponent extends PricingBaseComponent implements OnInit, On

orderBylastUpdated: boolean = true;
orderByCreationDate: boolean = false;
orderByChatbotName: boolean = false;
pageName: string;

// editBotName: boolean = false;
Expand Down Expand Up @@ -536,12 +537,18 @@ export class BotListComponent extends PricingBaseComponent implements OnInit, On
if (sortfor === 'lastUpdates') {
this.orderBylastUpdated = true;
this.orderByCreationDate = false;
this.orderByChatbotName = false;
this.getFaqKbByProjectId()
} else if (sortfor === 'creationDate') {
this.orderBylastUpdated = false;
this.orderByCreationDate = true;
this.orderByChatbotName = false;
this.getFaqKbByProjectId()
} else if (sortfor === 'botname') {
this.orderBylastUpdated = false;
this.orderByCreationDate = false;
this.orderByChatbotName = true;
this.getFaqKbByProjectId()

}
}

Expand Down Expand Up @@ -586,6 +593,19 @@ export class BotListComponent extends PricingBaseComponent implements OnInit, On
return 0;
});
}

if (this.orderByChatbotName) {
this.logger.log('[BOTS-LIST] - orderByChatbotName Here yes');
this.faqkbList.sort(function compare(a: Chatbot, b: Chatbot) {
if (a['name'].toLowerCase() < b['name'].toLowerCase()) {
return -1;
}
if (a['name'].toLowerCase() > b['name'].toLowerCase()) {
return 1;
}
return 0;
});
}

this.faqkbList.forEach(bot => {
this.logger.log('[BOTS-LIST] getFaqKbByProjectId bot ', bot)
Expand Down

0 comments on commit 2d885b5

Please sign in to comment.