Web: allow deselection of jobs
This ensures that deselecting a job also removes it from the job details column.
This commit is contained in:
parent
78a3e5faf0
commit
84e1ca9c67
@ -55,6 +55,11 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// UI component event handlers:
|
// UI component event handlers:
|
||||||
onSelectedJobChanged(jobSummary) {
|
onSelectedJobChanged(jobSummary) {
|
||||||
|
if (!jobSummary) { // There is no selected job.
|
||||||
|
this.selectedJob = {}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const jobsAPI = new API.JobsApi(this.apiClient);
|
const jobsAPI = new API.JobsApi(this.apiClient);
|
||||||
this._wrap(jobsAPI.fetchJob(jobSummary.id))
|
this._wrap(jobsAPI.fetchJob(jobSummary.id))
|
||||||
.then((job) => {
|
.then((job) => {
|
||||||
|
@ -50,6 +50,7 @@ export default {
|
|||||||
window.jobsTableVue = this;
|
window.jobsTableVue = this;
|
||||||
this.tabulator = new Tabulator('#flamenco_job_list', this.options);
|
this.tabulator = new Tabulator('#flamenco_job_list', this.options);
|
||||||
this.tabulator.on("rowSelected", this.onRowSelected);
|
this.tabulator.on("rowSelected", this.onRowSelected);
|
||||||
|
this.tabulator.on("rowDeselected", this.onRowDeselected);
|
||||||
this.fetchAllJobs();
|
this.fetchAllJobs();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -74,10 +75,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onJobsFetched(data) {
|
onJobsFetched(data) {
|
||||||
// "Down-cast" to JobUpdate to only get those fields, just for debugging things.
|
// "Down-cast" to JobUpdate to only get those fields, just for debugging things:
|
||||||
// data.jobs = data.jobs.map((j) => API.JobUpdate.constructFromObject(j));
|
// data.jobs = data.jobs.map((j) => API.JobUpdate.constructFromObject(j));
|
||||||
this.tabulator.setData(data.jobs);
|
this.tabulator.setData(data.jobs);
|
||||||
this.restoreRowSelection();
|
this._restoreRowSelection();
|
||||||
},
|
},
|
||||||
processJobUpdate(jobUpdate) {
|
processJobUpdate(jobUpdate) {
|
||||||
// updateData() will only overwrite properties that are actually set on
|
// updateData() will only overwrite properties that are actually set on
|
||||||
@ -91,17 +92,20 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Selection handling.
|
// Selection handling.
|
||||||
onRowSelected(row) {
|
onRowSelected(selectedRow) {
|
||||||
this.storeRowSelection();
|
const selectedData = selectedRow.getData();
|
||||||
const rowData = row.getData();
|
this._storeRowSelection([selectedData]);
|
||||||
this.$emit("selectedJobChange", rowData);
|
this.$emit("selectedJobChange", selectedData);
|
||||||
},
|
},
|
||||||
storeRowSelection() {
|
onRowDeselected(deselectedRow) {
|
||||||
const selectedData = this.tabulator.getSelectedData();
|
this._storeRowSelection([]);
|
||||||
|
this.$emit("selectedJobChange", null);
|
||||||
|
},
|
||||||
|
_storeRowSelection(selectedData) {
|
||||||
const selectedJobIDs = selectedData.map((row) => row.id);
|
const selectedJobIDs = selectedData.map((row) => row.id);
|
||||||
localStorage.setItem("selectedJobIDs", selectedJobIDs);
|
localStorage.setItem("selectedJobIDs", selectedJobIDs);
|
||||||
},
|
},
|
||||||
restoreRowSelection() {
|
_restoreRowSelection() {
|
||||||
const selectedJobIDs = localStorage.getItem('selectedJobIDs');
|
const selectedJobIDs = localStorage.getItem('selectedJobIDs');
|
||||||
if (!selectedJobIDs) {
|
if (!selectedJobIDs) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user