Skip to content

Commit

Permalink
feat: sort label column filters (NUWCDIVNPT#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
cd-rite authored Jul 29, 2024
1 parent 46d165d commit 66abb10
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions client/src/js/SM/AssetSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ SM.AssetSelection.GridPanel = Ext.extend(Ext.grid.GridPanel, {
filter: {
type: 'values',
collectionId: this.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, _this.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/js/SM/CollectionAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ SM.CollectionAssetGrid = Ext.extend(Ext.grid.GridPanel, {
filter: {
type: 'values',
collectionId: me.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, me.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value, metadata) {
Expand Down
9 changes: 9 additions & 0 deletions client/src/js/SM/CollectionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ SM.CollectionPanel.AggGrid = Ext.extend(Ext.grid.GridPanel, {
filter: {
type: 'values',
collectionId: _this.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, _this.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value, metadata) {
Expand Down Expand Up @@ -338,6 +341,9 @@ SM.CollectionPanel.AggGrid = Ext.extend(Ext.grid.GridPanel, {
filter: {
type: 'values',
collectionId: _this.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, _this.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value, metadata) {
Expand Down Expand Up @@ -570,6 +576,9 @@ SM.CollectionPanel.UnaggGrid = Ext.extend(Ext.grid.GridPanel, {
filter: {
type: 'values',
collectionId: _this.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, _this.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value, metadata) {
Expand Down
7 changes: 6 additions & 1 deletion client/src/js/SM/ColumnFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ SM.ColumnFilters.CompareFns = {
},
labels: (a, b) => {

}
},
labelIds: (a, b, collectionId) => {
if (a === "") return -1;
if (b === "") return 1;
return SM.Cache.getCollectionLabel(collectionId, a).name.localeCompare(SM.Cache.getCollectionLabel(collectionId, b).name)
},
}

SM.ColumnFilters.Renderers = {
Expand Down
3 changes: 3 additions & 0 deletions client/src/js/SM/FindingsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ SM.FindingsChildGrid = Ext.extend(Ext.grid.GridPanel, {
filter: {
type: 'values',
collectionId: me.panel.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, me.panel.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value, metadata) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/js/collectionReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,9 @@ async function addCollectionReview ( params ) {
filter: {
type: 'values',
collectionId: apiCollection.collectionId,
comparer: function (a, b) {
return SM.ColumnFilters.CompareFns.labelIds(a, b, apiCollection.collectionId)
},
renderer: SM.ColumnFilters.Renderers.labels
},
renderer: function (value, metadata) {
Expand Down

0 comments on commit 66abb10

Please sign in to comment.