Skip to content

Commit

Permalink
Merge branch 'master' into hwi-help-msg
Browse files Browse the repository at this point in the history
  • Loading branch information
k9ert authored Jan 25, 2022
2 parents 158643a + 7e86741 commit 1036946
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
24 changes: 5 additions & 19 deletions src/cryptoadvance/specter/templates/includes/coin_selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,17 @@
if (this.coinselectionDiv.style.display === 'block') {
this.coinselectionDiv.style.display = 'none';
this.toggler.innerHTML = `{{ _("Coin selection") }} ▶`;
if (this.isCoinSelectionActive()) {
toggleExpand();
}
this.removeSelection()
} else {
this.coinselectionDiv.style.display = 'block';
this.toggler.innerHTML = `{{ _("Coin selection") }} ▼`;
}
}

/*
* Removes all coin_selection if it's no longer active
*/
toggleExpand() {
if (this.isCoinSelectionActive()) {
setVisibility('coinselection', 'none');
} else {
setVisibility('coinselection', 'block');

let coins = document.getElementsByClassName('coin_select_checkbox');
// unselect all choices
for(var i = 0; i < coins.length; i++){
coins[i].checked = false;
}
}
this.fireChangeEvent();
removeSelection() {
this.txtable.unselect_all()
// We also need to update the Light DOM
this.updateLd()
}

shouldSelectMoreCoins(unit, amount) {
Expand Down
18 changes: 18 additions & 0 deletions src/cryptoadvance/specter/templates/includes/fee-selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
constructor() {
super();
var shadow = this.attachShadow({mode: 'open'});
this.wholeTemplate = shadow
var template_content = document.getElementById('fee-selection').content;
var clone = template_content.cloneNode(true);

Expand Down Expand Up @@ -342,6 +343,23 @@
}
}

// Adds line breaks at the end of the component
addLineBreaks(number) {
for (let i = 0; i < number; i++) {
this.wholeTemplate.appendChild(document.createElement('br'))
}
}

// Removes all added line breaks again
removeLineBreaks() {
var allLineBreaks = this.wholeTemplate.querySelectorAll('br')
for (let i = 0; i < allLineBreaks.length; i++) {
// 11 is the nodeType of the Shadow Root
if (allLineBreaks[i].parentNode.nodeType == 11) {
this.wholeTemplate.removeChild(allLineBreaks[i])
}
}
}
}

customElements.define('fee-selection', FeeSelection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,15 @@
FeeSelectionComponent.addEventListener("subtractClick", (event) => {
if ((amounts.length > 1 || !document.getElementById('ui-radio-btn').checked) && document.getElementById('subtract').checked) {
FeeSelectionComponent.showSubtractFrom(true)
if (!document.getElementById('ui-radio-btn').checked) {
FeeSelectionComponent.addLineBreaks(2)
}
}
else {
FeeSelectionComponent.showSubtractFrom(false)
if (!document.getElementById('ui-radio-btn').checked) {
FeeSelectionComponent.removeLineBreaks()
}
}
})
Expand Down Expand Up @@ -563,6 +569,7 @@
function toggleSendUIType(radioBtn) {
if (radioBtn.value == 'ui') {
FeeSelectionComponent.removeLineBreaks()
setVisibility('recipients', 'block');
setVisibility('add-recipient', 'flex');
setVisibility('recipients-txt-container', 'none');
Expand All @@ -579,8 +586,11 @@
setVisibility('remove-recipient', 'none');
setVisibility('recipients-txt-container', 'block');
// Assumes that text is always used for multiple recipients
FeeSelectionComponent.showSubtractFrom(true)
if (document.getElementById('subtract').checked) {
FeeSelectionComponent.showSubtractFrom(true)
// Adds two line breaks after the RBF checkbox, since it gets crowded
FeeSelectionComponent.addLineBreaks(2)
}
}
}
Expand Down

0 comments on commit 1036946

Please sign in to comment.