Skip to content

Commit

Permalink
[#134] added listener for catch event change form for update sla
Browse files Browse the repository at this point in the history
  • Loading branch information
Павел Ахметчанов authored and Павел Ахметчанов committed Jan 29, 2022
1 parent d1136d1 commit c5d4fdb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/charts/AddSlaLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,16 @@ export default class extends PageModification {

let slaValue = Number(value);

window.onpopstate = () => {
const renderSlaLineByQeryParam = () => {
const slaQueryParam = this.getSearchParam(SLA_QUERY_PARAMETER);
if (slaQueryParam !== null) {
document.getElementById(SLA_INPUT_FIELD_ID).value = slaQueryParam;
renderSlaLine(slaValue, chartElement, Number(slaQueryParam));
}
};

window.onpopstate = renderSlaLineByQeryParam;

const slaQueryParam = this.getSearchParam(SLA_QUERY_PARAMETER);
let changingValue = slaQueryParam !== null ? Number(slaQueryParam) : slaValue;

Expand All @@ -316,5 +318,20 @@ export default class extends PageModification {
renderSlaLine(slaValue, chartElement, changingValue);
},
});

this.addEventListener(document.querySelector('#ghx-chart-content'), 'change', e => {
if (/jira-helper/.test(e.target.getAttribute('id'))) {
return;
}

// eslint-disable-next-line no-console
console.log('Event chages:', e);
const slaInput = document.getElementById(SLA_INPUT_FIELD_ID);
const event = new Event('input', {
bubbles: true,
cancelable: true,
});
slaInput.dispatchEvent(event);
});
}
}

0 comments on commit c5d4fdb

Please sign in to comment.