Skip to content

Commit 6a4fa3c

Browse files
author
John M. Horan
committed
Merge 'develop' into branch 91 #91
Signed-off-by: John M. Horan <[email protected]>
2 parents 9b9f3d5 + ff30297 commit 6a4fa3c

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

assets/js/aboutCodeDataTables.js

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#
1515
*/
1616

17+
const HAS_A_VALUE = "about_code_data_table_has_a_value";
18+
1719
class AboutCodeDataTable {
1820
constructor(tableID, aboutCodeDB) {
1921
this.aboutCodeDB = aboutCodeDB;
@@ -75,10 +77,21 @@ class AboutCodeDataTable {
7577
for (let i = 0; i < dataTablesInput.columns.length; i++) {
7678
let columnSearch = dataTablesInput.columns[i].search.value;
7779
if (columnSearch) {
78-
// Column 0 is the "path", which should only match wildcards
79-
// at the end of the path.
80-
query.where.$and[dataTablesInput.columns[i].name] = {
81-
$like: i === 0 ? `${columnSearch}%` : `%${columnSearch}%`
80+
// Return all non empty values
81+
if (columnSearch === HAS_A_VALUE) {
82+
query.where.$and[dataTablesInput.columns[i].name] = {
83+
$and: [
84+
{ $ne: "[]" },
85+
{ $ne: "" },
86+
{ $ne: "{}" }
87+
]
88+
}
89+
} else {
90+
// Column 0 is the "path", which should only match wildcards
91+
// at the end of the path.
92+
query.where.$and[dataTablesInput.columns[i].name] = {
93+
$like: i === 0 ? `${columnSearch}%` : `%${columnSearch}%`
94+
}
8295
}
8396
}
8497
}
@@ -166,38 +179,47 @@ class AboutCodeDataTable {
166179
<option value=""></option></select>`)
167180
.appendTo(footer)
168181
.on("click", () => {
169-
let where = {};
170-
where[columnName] = {$ne: null};
171-
172-
that.aboutCodeDB.FlattenedFile.findAll({
173-
attributes: [Sequelize.fn("TRIM",
174-
Sequelize.col(columnName)), columnName],
175-
group: [columnName],
176-
where: where,
177-
order: [columnName]
182+
let where = {};
183+
where[columnName] = {$ne: null};
184+
185+
that.aboutCodeDB.FlattenedFile.findAll({
186+
attributes: [Sequelize.fn("TRIM",
187+
Sequelize.col(columnName)), columnName],
188+
group: [columnName],
189+
where: where,
190+
order: [columnName]
191+
})
192+
.then((rows) => {
193+
let filterValues = $.map(rows, (row) => {
194+
return row[columnName];
178195
})
179-
.then((rows) => {
180-
let filterValues = $.map(rows, (row) => {
181-
return row[columnName];
182-
})
183-
.map(filterValue => (filterValue).toString())
184-
.filter((filterValue) => filterValue.length > 0);
185-
186-
filterValues = $.map(filterValues, (filterValue) => filterValue);
187-
filterValues.forEach((filterValue) => {
188-
filterValue.trim();
189-
});
190-
filterValues = $.unique(filterValues).sort();
191-
192-
const select = $(`select#clue-${columnName}`);
193-
let val = select.find("option:selected");
194-
195-
select.empty().append(`<option value=""></option>`);
196-
$.each(filterValues, function ( i, filterValue ) {
197-
select.append(`<option value="${filterValue}">${filterValue}</option>`)
198-
});
199-
select.val(val);
196+
.map(filterValue => (filterValue).toString())
197+
.filter((filterValue) => filterValue.length > 0);
198+
199+
filterValues = $.map(filterValues, (filterValue) => filterValue);
200+
filterValues.forEach((filterValue) => {
201+
filterValue.trim();
202+
});
203+
filterValues = $.unique(filterValues).sort();
204+
205+
const select = $(`select#clue-${columnName}`);
206+
let val = select.find("option:selected");
207+
208+
select.empty().append(`<option value=""></option>`);
209+
210+
/**
211+
* Add Has a Value option to dropdown menu to show all rows
212+
* that contain a detected ScanCode value.
213+
*/
214+
if (filterValues.length > 0) {
215+
select.append(`<option value="${HAS_A_VALUE}">Has a Value</option>`);
216+
}
217+
218+
$.each(filterValues, function ( i, filterValue ) {
219+
select.append(`<option value="${filterValue}">${filterValue}</option>`)
200220
});
221+
select.val(val);
222+
});
201223
})
202224
.on( "change", function () {
203225
// Get dropdown element selected value

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</button>
6868
</li>
6969
<li>
70-
<button class="btn btn-sidebar" id="save-file" data-toggle="tooltip" title="Save SQLite File">
70+
<button class="btn btn-sidebar" id="save-file" data-toggle="tooltip" title="Save As New SQLite File">
7171
<i class="fa fa-floppy-o" aria-hidden="true"></i>
7272
</button>
7373
</li>

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function getTemplate() {
5050
}
5151
},
5252
{
53-
label: "Save SQLite File",
53+
label: "Save As New SQLite File",
5454
accelerator: 'CmdOrCtrl+S',
5555
click: function (menuItem, currentWindow) {
5656
currentWindow.webContents.send('save-SQLite')

0 commit comments

Comments
 (0)