trust checkboxes now in object
This commit is contained in:
parent
c49a350298
commit
9bdd2aa23d
2 changed files with 43 additions and 77 deletions
|
|
@ -19,41 +19,54 @@ class TrustCheckboxes {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const labelsAndVars = [
|
const checkboxesDetails = [
|
||||||
{
|
{
|
||||||
id: 'my-trusted',
|
id: 'my-trusted',
|
||||||
label: 'Mis confiados',
|
label: 'Mis confiados',
|
||||||
containerProperty: 'myTrustedContainer',
|
containerProperty: 'myTrustedContainer',
|
||||||
checkboxProperty: 'myTrustedCheckboxElement',
|
checkboxProperty: 'myTrustedCheckboxElement',
|
||||||
|
defaultChecked: true,
|
||||||
|
isDisabled: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'my-trusted-trusted',
|
id: 'my-trusted-trusted',
|
||||||
label: 'Los confiados de mis confiados',
|
label: 'Los confiados de mis confiados',
|
||||||
containerProperty: 'myTrustedTrustedContainer',
|
containerProperty: 'myTrustedTrustedContainer',
|
||||||
checkboxProperty: 'myTrustedTrustedCheckboxElement',
|
checkboxProperty: 'myTrustedTrustedCheckboxElement',
|
||||||
|
defaultChecked: true,
|
||||||
|
isDisabled: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'all-members',
|
id: 'all-members',
|
||||||
label: 'Todos los miembros',
|
label: 'Todos los miembros',
|
||||||
containerProperty: 'allMembersContainer',
|
containerProperty: 'allMembersContainer',
|
||||||
checkboxProperty: 'allMembersCheckboxElement',
|
checkboxProperty: 'allMembersCheckboxElement',
|
||||||
|
defaultChecked: false,
|
||||||
|
isDisabled: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const labelAndVar of labelsAndVars) {
|
for (const checkboxDetails of checkboxesDetails) {
|
||||||
this[labelAndVar.containerProperty] = this.buildCheckbox({
|
this[checkboxDetails.containerProperty] = this.buildCheckbox({
|
||||||
id: labelAndVar.id,
|
id: checkboxDetails.id,
|
||||||
label: labelAndVar.label,
|
label: checkboxDetails.label,
|
||||||
});
|
});
|
||||||
|
|
||||||
this[labelAndVar.checkboxProperty] =
|
this[checkboxDetails.checkboxProperty] =
|
||||||
this[labelAndVar.containerProperty].querySelector('input');
|
this[checkboxDetails.containerProperty].querySelector('input');
|
||||||
|
|
||||||
this[labelAndVar.checkboxProperty].addEventListener('click', () => {
|
this[checkboxDetails.checkboxProperty].addEventListener('click', () => {
|
||||||
this.applyTrustCheckboxConstraints(this[labelAndVar.checkboxProperty]);
|
this.applyTrustCheckboxConstraints(
|
||||||
|
this[checkboxDetails.checkboxProperty]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.parentElement.appendChild(this[labelAndVar.containerProperty]);
|
this[checkboxDetails.checkboxProperty].checked =
|
||||||
|
checkboxDetails.defaultChecked;
|
||||||
|
this[checkboxDetails.checkboxProperty].disabled =
|
||||||
|
checkboxDetails.isDisabled;
|
||||||
|
|
||||||
|
this.parentElement.appendChild(this[checkboxDetails.containerProperty]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +93,6 @@ class TrustCheckboxes {
|
||||||
|
|
||||||
applyTrustCheckboxConstraints(pressedCheckbox) {
|
applyTrustCheckboxConstraints(pressedCheckbox) {
|
||||||
if (pressedCheckbox === this.myTrustedTrustedCheckboxElement) {
|
if (pressedCheckbox === this.myTrustedTrustedCheckboxElement) {
|
||||||
console.log('first case!');
|
|
||||||
if (
|
if (
|
||||||
!this.myTrustedTrustedCheckboxElement.checked &&
|
!this.myTrustedTrustedCheckboxElement.checked &&
|
||||||
this.allMembersCheckboxElement.checked
|
this.allMembersCheckboxElement.checked
|
||||||
|
|
@ -90,7 +102,6 @@ class TrustCheckboxes {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressedCheckbox === this.allMembersCheckboxElement) {
|
if (pressedCheckbox === this.allMembersCheckboxElement) {
|
||||||
console.log('second case!');
|
|
||||||
if (
|
if (
|
||||||
!this.myTrustedTrustedCheckboxElement.checked &&
|
!this.myTrustedTrustedCheckboxElement.checked &&
|
||||||
this.allMembersCheckboxElement.checked
|
this.allMembersCheckboxElement.checked
|
||||||
|
|
@ -100,12 +111,16 @@ class TrustCheckboxes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get isOnchainAccepted() {
|
get showOfferToTrusted() {
|
||||||
return this.onchainCheckboxElement.checked;
|
return this.myTrustedCheckboxElement.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isLightningAccepted() {
|
get showOfferToTrustedTrusted() {
|
||||||
return this.lightningCheckboxElement.checked;
|
return this.myTrustedTrustedCheckboxElement.checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
get showOfferToAllMembers() {
|
||||||
|
return this.allMembersCheckboxElement.checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,6 +194,13 @@ function offersPage() {
|
||||||
});
|
});
|
||||||
|
|
||||||
btcMethodCheckboxes.render();
|
btcMethodCheckboxes.render();
|
||||||
|
|
||||||
|
const trustCheckboxes = new TrustCheckboxes({
|
||||||
|
parentElement: document.getElementById('trusted-checkboxes-area'),
|
||||||
|
});
|
||||||
|
|
||||||
|
trustCheckboxes.render();
|
||||||
|
|
||||||
// -----------
|
// -----------
|
||||||
const navbuttonHome = document.getElementById('navbutton-home');
|
const navbuttonHome = document.getElementById('navbutton-home');
|
||||||
const navbuttonOffers = document.getElementById('navbutton-offers');
|
const navbuttonOffers = document.getElementById('navbutton-offers');
|
||||||
|
|
@ -201,12 +223,6 @@ function offersPage() {
|
||||||
);
|
);
|
||||||
const viewMyOffersRoot = document.getElementById('view-my-offers-root');
|
const viewMyOffersRoot = document.getElementById('view-my-offers-root');
|
||||||
|
|
||||||
const myTrustedCheckbox = document.getElementById('my-trusted-checkbox');
|
|
||||||
const myTrustedTrustedCheckbox = document.getElementById(
|
|
||||||
'my-trusted-trusted-checkbox'
|
|
||||||
);
|
|
||||||
const allMembersCheckbox = document.getElementById('all-members-checkbox');
|
|
||||||
|
|
||||||
const bigNotesAcceptedCheckbox = document.getElementById(
|
const bigNotesAcceptedCheckbox = document.getElementById(
|
||||||
'large-bills-checkbox'
|
'large-bills-checkbox'
|
||||||
);
|
);
|
||||||
|
|
@ -229,22 +245,6 @@ function offersPage() {
|
||||||
viewMyOffersRoot.style.display === 'block' ? 'none' : 'block';
|
viewMyOffersRoot.style.display === 'block' ? 'none' : 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTrustCheckboxConstraints(pressedCheckbox) {
|
|
||||||
if (pressedCheckbox === myTrustedTrustedCheckbox) {
|
|
||||||
console.log('first case!');
|
|
||||||
if (!myTrustedTrustedCheckbox.checked && allMembersCheckbox.checked) {
|
|
||||||
allMembersCheckbox.checked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pressedCheckbox === allMembersCheckbox) {
|
|
||||||
console.log('second case!');
|
|
||||||
if (!myTrustedTrustedCheckbox.checked && allMembersCheckbox.checked) {
|
|
||||||
myTrustedTrustedCheckbox.checked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function publishOffer() {
|
async function publishOffer() {
|
||||||
const wants = buyOrSellButtonGroup.wants();
|
const wants = buyOrSellButtonGroup.wants();
|
||||||
|
|
||||||
|
|
@ -254,9 +254,10 @@ function offersPage() {
|
||||||
const time_availability_details = timeInput.inputText;
|
const time_availability_details = timeInput.inputText;
|
||||||
const is_onchain_accepted = btcMethodCheckboxes.isOnchainAccepted;
|
const is_onchain_accepted = btcMethodCheckboxes.isOnchainAccepted;
|
||||||
const is_lightning_accepted = btcMethodCheckboxes.isLightningAccepted;
|
const is_lightning_accepted = btcMethodCheckboxes.isLightningAccepted;
|
||||||
const show_offer_to_trusted = myTrustedCheckbox.checked;
|
const show_offer_to_trusted = trustCheckboxes.showOfferToTrusted;
|
||||||
const show_offer_to_trusted_trusted = myTrustedTrustedCheckbox.checked;
|
const show_offer_to_trusted_trusted =
|
||||||
const show_offer_to_all_members = allMembersCheckbox.checked;
|
trustCheckboxes.showOfferToTrustedTrusted;
|
||||||
|
const show_offer_to_all_members = trustCheckboxes.showOfferToAllMembers;
|
||||||
const are_big_notes_accepted = bigNotesAcceptedCheckbox.checked;
|
const are_big_notes_accepted = bigNotesAcceptedCheckbox.checked;
|
||||||
|
|
||||||
const offerDetails = {
|
const offerDetails = {
|
||||||
|
|
@ -741,14 +742,6 @@ function offersPage() {
|
||||||
toggleCreateOfferModal();
|
toggleCreateOfferModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
myTrustedTrustedCheckbox.addEventListener('click', () => {
|
|
||||||
applyTrustCheckboxConstraints(myTrustedTrustedCheckbox);
|
|
||||||
});
|
|
||||||
|
|
||||||
allMembersCheckbox.addEventListener('click', () => {
|
|
||||||
applyTrustCheckboxConstraints(allMembersCheckbox);
|
|
||||||
});
|
|
||||||
|
|
||||||
const myOffers = new MyOffers(ownOffersContainer);
|
const myOffers = new MyOffers(ownOffersContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,34 +53,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="trust-area" class="create-offer-step">
|
<div id="trust-area" class="create-offer-step">
|
||||||
<h3>¿Quién puede ver la oferta?</h3>
|
<h3>¿Quién puede ver la oferta?</h3>
|
||||||
<div id="trusted-checboxes-area">
|
<div id="trusted-checkboxes-area"></div>
|
||||||
<div id="my-trusted-area" class="checkbox-row">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="my-trusted"
|
|
||||||
id="my-trusted-checkbox"
|
|
||||||
checked
|
|
||||||
disabled
|
|
||||||
/><label for="my-trusted">Mis confiados</label>
|
|
||||||
</div>
|
|
||||||
<div id="my-trusted-trusted-area" class="checkbox-row">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="my-trusted-trusted"
|
|
||||||
id="my-trusted-trusted-checkbox"
|
|
||||||
checked
|
|
||||||
/><label for="my-trusted-trusted"
|
|
||||||
>Los confiados de mis confiados</label
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div id="all-members-area" class="checkbox-row">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
name="all-members"
|
|
||||||
id="all-members-checkbox"
|
|
||||||
/><label for="all-members">Todos los miembros</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="other-area" class="create-offer-step">
|
<div id="other-area" class="create-offer-step">
|
||||||
<h3>Extras</h3>
|
<h3>Extras</h3>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue