save modes
This commit is contained in:
@@ -8,5 +8,5 @@
|
|||||||
## TODO
|
## TODO
|
||||||
[] readme
|
[] readme
|
||||||
[x] handle images
|
[x] handle images
|
||||||
[] save modes
|
[x] save modes
|
||||||
[] remove empty values from available data
|
[] remove empty values from available data
|
||||||
@@ -142,8 +142,14 @@ let app = {
|
|||||||
if (results.errors.length) {
|
if (results.errors.length) {
|
||||||
this.error = 'CSV file contains errors';
|
this.error = 'CSV file contains errors';
|
||||||
} else {
|
} else {
|
||||||
|
const url = new URL(window.location);
|
||||||
this.columns = results.data.shift();
|
this.columns = results.data.shift();
|
||||||
this.modes = this.columns.map((_, i) => i);
|
this.modes = this.columns.map((_, i) => i);
|
||||||
|
if (url.searchParams.get('modes')) {
|
||||||
|
try {
|
||||||
|
this.modes = JSON.parse(url.searchParams.get('modes')).filter(m => m < this.columns.length);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
this.available = results.data;
|
this.available = results.data;
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
@@ -173,9 +179,14 @@ let app = {
|
|||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
const url = new URL(window.location);
|
const url = new URL(window.location);
|
||||||
if (url.searchParams.get('url') !== this.url || url.searchParams.get('title') !== this.title) {
|
if (
|
||||||
|
url.searchParams.get('url') !== this.url ||
|
||||||
|
url.searchParams.get('title') !== this.title ||
|
||||||
|
url.searchParams.get('modes') !== JSON.stringify(this.modes)
|
||||||
|
) {
|
||||||
url.searchParams.set('url', this.url);
|
url.searchParams.set('url', this.url);
|
||||||
url.searchParams.set('title', this.title);
|
url.searchParams.set('title', this.title);
|
||||||
|
url.searchParams.set('modes', JSON.stringify(this.modes));
|
||||||
window.history.pushState({}, '', url);
|
window.history.pushState({}, '', url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user