diff --git a/projects/poweredsoft/ngx-bootstrap/package.json b/projects/poweredsoft/ngx-bootstrap/package.json
index 30b4df8..ec56a3b 100644
--- a/projects/poweredsoft/ngx-bootstrap/package.json
+++ b/projects/poweredsoft/ngx-bootstrap/package.json
@@ -1,6 +1,6 @@
{
"name": "@poweredsoft/ngx-bootstrap",
- "version": "0.0.7",
+ "version": "0.0.8",
"description": "an internal use libary for handling data souces grid filtering sorting, add commands etc",
"keywords": [
"angular",
diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts
index cc7edf0..c8ebf6d 100644
--- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts
+++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/directives/command-modal.directive.ts
@@ -53,6 +53,4 @@ export class CommandModalDirective {
});
}
-
-
}
diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.html b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.html
index b9e62bb..f020445 100644
--- a/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.html
+++ b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.html
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.ts
index 1b57287..0426245 100644
--- a/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.ts
+++ b/projects/poweredsoft/ngx-bootstrap/src/lib/data-source-sorting/ds-sorting/data-source-sorting.component.ts
@@ -10,25 +10,38 @@ export class DataSourceSortingComponent implements OnInit {
@Input() dataSource : IDataSource;
@Input() path:string;
- isSorting: boolean =false;
- isAscending:boolean = false;
+
+
+ get sort() {
+ return this.dataSource.sorts.find(t => t.path == this.path);
+ }
+
+ get isSorting() {
+ return this.sort ? true : false;
+ }
+
+ get isAscending() {
+ return !this.isSorting ? true : this.sort.ascending;
+ }
+
constructor() { }
ngOnInit(): void {
}
sorting(){
- this.isSorting = true;
- this.isAscending = !this.isAscending;
- const existingSort = this.dataSource.sorts.find(t => t.path == this.path);
- if (existingSort){
- existingSort.ascending = (this.isAscending)? true : false;
- }else{
+
+ if (!this.isSorting) {
this.dataSource.sorts.push({
path: this.path,
- ascending: (this.isAscending)? true : false
- })
+ ascending: true
+ });
+ } else if(this.isSorting && this.isAscending) {
+ this.sort.ascending = false;
+ } else {
+ this.dataSource.sorts = this.dataSource.sorts.filter(t => t.path != this.path);
}
+
this.dataSource.query({
sorts: this.dataSource.sorts,
page: 1