sorter and search fixes:

- sorter: ensure sort settings are remembered
- sorter: remoe default attrs, just bind to 'sortKey' and 'sortDesc' to set the defaults
- pages: override sort order by best match when doing a text search, back to by date when showing page list
- page entries: fix date sorting, normalize page.timestamp and page.date on all page results
- url resources: fix 'contains' search, add highlighting to search results
- ensure textIndex cache is deleted when collection is removed
- bump electron to 10.1.3
- bump version to 1.1.1
This commit is contained in:
Ilya Kreymer
2020-09-30 12:40:44 -07:00
parent 4315a54263
commit 83ac63d0d8
8 changed files with 99 additions and 88 deletions
+18 -34
View File
@@ -16,21 +16,15 @@ class Sorter extends LitElement
this.numResults = DEFAULT_RESULTS;
this.sortKey = null;
this.sortKey = null
this.sortDesc = null;
this.defaultKey = "";
this.defaultDesc = false;
}
static get properties() {
return {
id: { type: String },
defaultKey: {type: String },
defaultDesc: { type: Boolean },
//numResults: {type: Number},
numResults: {type: Number},
data: { type: Array },
sortedData: { type: Array },
@@ -40,45 +34,35 @@ class Sorter extends LitElement
}
}
// firstUpdated() {
// if (this.sortKey === null && this.defaultKey) {
// this.sortKey = localStorage.getItem(`${this.id}:sortKey`) || this.defaultKey;
// }
// const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
// if (this.sortDesc === null) {
// this.sortDesc = !sortDesc ? this.defaultDesc : sortDesc === "1";
// }
// }
firstUpdated() {
if (this.id) {
const sortKey = localStorage.getItem(`${this.id}:sortKey`);
if (sortKey !== null) {
this.sortKey = sortKey;
}
const sortDesc = localStorage.getItem(`${this.id}:sortDesc`);
if (sortDesc !== null) {
this.sortDesc = sortDesc === "1";
}
}
}
updated(changedProperties) {
const keyChanged = changedProperties.has("sortKey");
const descChanged = changedProperties.has("sortDesc");
const dataChanged = changedProperties.has("data");
const numResultsChanged = changedProperties.has("numResults");
if (changedProperties.has("defaultKey")) {
this.sortKey = this.defaultKey;
}
if (changedProperties.has("defaultDesc")) {
this.sortDesc = this.defaultDesc;
}
if (keyChanged) {
if (keyChanged && this.sortKey !== null) {
localStorage.setItem(`${this.id}:sortKey`, this.sortKey);
}
if (descChanged) {
if (descChanged && this.sortDesc !== null) {
localStorage.setItem(`${this.id}:sortDesc`, this.sortDesc ? "1" : "0");
}
if (keyChanged || descChanged || dataChanged) {
this.sortData();
}
if (dataChanged) {
}
//if (numResultsChanged && !dataChanged) {
//this.sendSortChanged();
//}
}
sortData() {