Skip to content

Commit 2739ad4

Browse files
authored
Merge pull request #1265 from NASA-IMPACT/1251-column-sorting-issue-curated-urls-count-sorts-by-delta-urls-count
1251 column sorting issue curated urls count sorts by delta urls count
2 parents e6addfb + e563b87 commit 2739ad4

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,9 @@ For each PR made, an entry should be added to this changelog. It should contain
137137
- Description: The feedback form API was throwing CORS errors and to rectify that, we need to add the apt https link for sde-lrm.
138138
- Changes:
139139
- Added `https://sde-lrm.nasa-impact.net` to `CORS_ALLOWED_ORIGINS` in the base settings.
140+
141+
- 1251-column-sorting-issue-curated-urls-count-sorts-by-delta-urls-count
142+
- Description: Fixed incorrect sorting behavior in Collections table where sorting by Curated URLs column was not working as expected.
143+
- Changes:
144+
- Added `data-order` attribute to URL count columns for proper numeric sorting
145+
- Updated SearchPane comparisons to use `@data-order` values instead of string-based loose equality checks to ensure correct numeric filtering

sde_indexing_helper/static/js/collection_list.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,43 +138,47 @@ let table = $("#collection_table").DataTable({
138138
{
139139
label: "0 URLs",
140140
value: function (rowData, rowIdx) {
141-
return $(rowData[COLUMNS.DELTA_URLS]).text() == 0;
141+
return parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']) === 0;
142142
},
143143
},
144144
{
145145
label: "1 solo URL",
146146
value: function (rowData, rowIdx) {
147-
return $(rowData[COLUMNS.DELTA_URLS]).text() == 1;
147+
return parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']) === 1;
148148
},
149149
},
150150
{
151151
label: "1 to 100 URLs",
152152
value: function (rowData, rowIdx) {
153-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 100 && $(rowData[COLUMNS.DELTA_URLS]).text() > 1;
153+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
154+
return value > 1 && value <= 100;
154155
},
155156
},
156157
{
157158
label: "100 to 1,000 URLs",
158159
value: function (rowData, rowIdx) {
159-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 1000 && $(rowData[COLUMNS.DELTA_URLS]).text() > 100;
160+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
161+
return value > 100 && value <= 1000;
160162
},
161163
},
162164
{
163165
label: "1,000 to 10,000 URLs",
164166
value: function (rowData, rowIdx) {
165-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 10000 && $(rowData[COLUMNS.DELTA_URLS]).text() > 1000;
167+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
168+
return value > 1000 && value <= 10000;
166169
},
167170
},
168171
{
169172
label: "10,000 to 100,000 URLs",
170173
value: function (rowData, rowIdx) {
171-
return $(rowData[COLUMNS.DELTA_URLS]).text() <= 100000 && $(rowData[COLUMNS.DELTA_URLS]).text() > 10000;
174+
const value = parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']);
175+
return value > 10000 && value <= 100000;
172176
},
173177
},
174178
{
175179
label: "Over 100,000 URLs",
176180
value: function (rowData, rowIdx) {
177-
return $(rowData[COLUMNS.DELTA_URLS]).text() > 100000;
181+
return parseInt(rowData[COLUMNS.DELTA_URLS]['@data-order']) > 100000;
178182
},
179183
},
180184
],
@@ -189,43 +193,47 @@ let table = $("#collection_table").DataTable({
189193
{
190194
label: "0 URLs",
191195
value: function (rowData, rowIdx) {
192-
return $(rowData[COLUMNS.CURATED_URLS]).text() == 0;
196+
return parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']) === 0;
193197
},
194198
},
195199
{
196200
label: "1 solo URL",
197201
value: function (rowData, rowIdx) {
198-
return $(rowData[COLUMNS.CURATED_URLS]).text() == 1;
202+
return parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']) === 1;
199203
},
200204
},
201205
{
202206
label: "1 to 100 URLs",
203207
value: function (rowData, rowIdx) {
204-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 100 && $(rowData[COLUMNS.CURATED_URLS]).text() > 1;
208+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
209+
return value > 1 && value <= 100;
205210
},
206211
},
207212
{
208213
label: "100 to 1,000 URLs",
209214
value: function (rowData, rowIdx) {
210-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 1000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 100;
215+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
216+
return value > 100 && value <= 1000;
211217
},
212218
},
213219
{
214220
label: "1,000 to 10,000 URLs",
215221
value: function (rowData, rowIdx) {
216-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 10000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 1000;
222+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
223+
return value > 1000 && value <= 10000;
217224
},
218225
},
219226
{
220227
label: "10,000 to 100,000 URLs",
221228
value: function (rowData, rowIdx) {
222-
return $(rowData[COLUMNS.CURATED_URLS]).text() <= 100000 && $(rowData[COLUMNS.CURATED_URLS]).text() > 10000;
229+
const value = parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']);
230+
return value > 10000 && value <= 100000;
223231
},
224232
},
225233
{
226234
label: "Over 100,000 URLs",
227235
value: function (rowData, rowIdx) {
228-
return $(rowData[COLUMNS.CURATED_URLS]).text() > 100000;
236+
return parseInt(rowData[COLUMNS.CURATED_URLS]['@data-order']) > 100000;
229237
},
230238
},
231239
],

sde_indexing_helper/templates/sde_collections/collection_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ <h2 class="title">Welcome back!</h2>
151151
<td class="whiteText noBorder">{{ collection.get_division_display }}</td>
152152

153153
<!-- Delta URLs Column - Shows count and links if >= 0 -->
154-
<td class="noBorder centerAlign">
154+
<td class="noBorder centerAlign" data-order="{{ collection.num_delta_urls }}">
155155
<a href=" {% if collection.num_delta_urls >= 0 %} {% url 'sde_collections:delta_urls' collection.pk %} {% endif %} "
156156
class="btn btn-sm {% if collection.num_delta_urls >= 0 %}btn-primary {% else %}disabled{% endif %}candidateCount"
157157
role="button">{{ collection.num_delta_urls|intcomma }}</a>
158158
</td>
159159

160160
<!-- Curated URLs Column - Shows count and links if >= 0 -->
161-
<td class="noBorder centerAlign">
161+
<td class="noBorder centerAlign" data-order="{{ collection.num_curated_urls }}">
162162
<a href=" {% if collection.num_curated_urls >= 0 %} {% url 'sde_collections:delta_urls' collection.pk %} {% endif %} "
163163
class="btn btn-sm {% if collection.num_curated_urls >= 0 %}btn-primary {% else %}disabled{% endif %}candidateCount"
164164
role="button">{{ collection.num_curated_urls|intcomma }}</a>

0 commit comments

Comments
 (0)