Don't render full input witness if user does not press "show all"
This commit is contained in:
		
							parent
							
								
									f840ac951b
								
							
						
					
					
						commit
						77d42bfdbb
					
				@ -114,22 +114,33 @@
 | 
				
			|||||||
                        <td i18n="transactions-list.witness">Witness</td>
 | 
					                        <td i18n="transactions-list.witness">Witness</td>
 | 
				
			||||||
                        <td style="text-align: left;">
 | 
					                        <td style="text-align: left;">
 | 
				
			||||||
                          <ng-container *ngFor="let witness of vin.witness; index as i">
 | 
					                          <ng-container *ngFor="let witness of vin.witness; index as i">
 | 
				
			||||||
                            <input type="checkbox" [id]="'tx' + vindex + 'witness' + i" style="display: none;">
 | 
					                            <p class="witness-item">
 | 
				
			||||||
                            <p class="witness-item" [class.accordioned]="witness.length > 1000">
 | 
					                              @if (witness.length > 1000) {
 | 
				
			||||||
                              <ng-template [ngIf]="witness" [ngIfElse]="emptyWitnessItem">
 | 
					                                @if (!showFullWitness[vindex][i]) {
 | 
				
			||||||
 | 
					                                  {{ witness | slice:0:1000 }}
 | 
				
			||||||
 | 
					                                } @else {
 | 
				
			||||||
 | 
					                                  {{ witness }}
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                              } @else if (witness) {
 | 
				
			||||||
                                {{ witness }}
 | 
					                                {{ witness }}
 | 
				
			||||||
                              </ng-template>
 | 
					                              } @else {
 | 
				
			||||||
                              <ng-template #emptyWitnessItem>
 | 
					 | 
				
			||||||
                                <empty>
 | 
					                                <empty>
 | 
				
			||||||
                              </ng-template>
 | 
					                              }
 | 
				
			||||||
                            </p>
 | 
					                            </p>
 | 
				
			||||||
                            <div class="witness-toggle" *ngIf="witness.length > 1000">
 | 
					                            @if (witness.length > 1000) {
 | 
				
			||||||
                              <span  class="ellipsis">...</span>
 | 
					                              <div style="display: flex;">
 | 
				
			||||||
                              <label [for]="'tx' + vindex + 'witness' + i" class="btn btn-sm btn-primary mt-2">
 | 
					                                @if (!showFullWitness[vindex][i]) {
 | 
				
			||||||
                                <span class="show-all" i18n="show-all">Show all</span>
 | 
					                                  <span>...</span>
 | 
				
			||||||
                                <span class="show-less" i18n="show-less">Show less</span>
 | 
					                                }
 | 
				
			||||||
                              </label>
 | 
					                                <label class="btn btn-sm btn-primary mt-2" (click)="toggleShowFullWitness(vindex, i)" style="margin-left: auto;">
 | 
				
			||||||
                            </div>
 | 
					                                  @if (!showFullWitness[vindex][i]) {
 | 
				
			||||||
 | 
					                                    <span i18n="show-all">Show all</span>
 | 
				
			||||||
 | 
					                                  } @else {
 | 
				
			||||||
 | 
					                                    <span i18n="show-less">Show less</span>
 | 
				
			||||||
 | 
					                                  }
 | 
				
			||||||
 | 
					                                </label>
 | 
				
			||||||
 | 
					                              </div>
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                          </ng-container>
 | 
					                          </ng-container>
 | 
				
			||||||
                        </td>
 | 
					                        </td>
 | 
				
			||||||
                      </tr>
 | 
					                      </tr>
 | 
				
			||||||
 | 
				
			|||||||
@ -172,42 +172,7 @@ h2 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.vin-witness {
 | 
					.vin-witness {
 | 
				
			||||||
	.witness-item.accordioned {
 | 
						.witness-item {
 | 
				
			||||||
		max-height: 300px;
 | 
					 | 
				
			||||||
		overflow: hidden;	
 | 
							overflow: hidden;	
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	input:checked + .witness-item.accordioned {
 | 
					 | 
				
			||||||
		max-height: none;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	.witness-toggle {
 | 
					 | 
				
			||||||
		display: flex;
 | 
					 | 
				
			||||||
		flex-direction: row;
 | 
					 | 
				
			||||||
		align-items: flex-start;
 | 
					 | 
				
			||||||
		justify-content: space-between;
 | 
					 | 
				
			||||||
		margin-bottom: 1em;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		.show-all {
 | 
					 | 
				
			||||||
			display: inline;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		.show-less {
 | 
					 | 
				
			||||||
			display: none;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		.ellipsis {
 | 
					 | 
				
			||||||
			visibility: visible;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	input:checked ~ .witness-toggle {
 | 
					 | 
				
			||||||
		.show-all {
 | 
					 | 
				
			||||||
			display: none;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		.show-less {
 | 
					 | 
				
			||||||
			display: inline;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		.ellipsis {
 | 
					 | 
				
			||||||
			visibility: hidden;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -49,6 +49,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
 | 
				
			|||||||
  inputRowLimit: number = 12;
 | 
					  inputRowLimit: number = 12;
 | 
				
			||||||
  outputRowLimit: number = 12;
 | 
					  outputRowLimit: number = 12;
 | 
				
			||||||
  showFullScript: { [vinIndex: number]: boolean } = {};
 | 
					  showFullScript: { [vinIndex: number]: boolean } = {};
 | 
				
			||||||
 | 
					  showFullWitness: { [vinIndex: number]: { [witnessIndex: number]: boolean } } = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    public stateService: StateService,
 | 
					    public stateService: StateService,
 | 
				
			||||||
@ -302,8 +303,16 @@ export class TransactionsListComponent implements OnInit, OnChanges {
 | 
				
			|||||||
    if (this.showDetails$.value === true) {
 | 
					    if (this.showDetails$.value === true) {
 | 
				
			||||||
      this.showDetails$.next(false);
 | 
					      this.showDetails$.next(false);
 | 
				
			||||||
      this.showFullScript = {};
 | 
					      this.showFullScript = {};
 | 
				
			||||||
 | 
					      this.showFullWitness = {};
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      this.showFullScript = this.transactions[0] ? this.transactions[0].vin.reduce((acc, _, i) => ({...acc, [i]: false}), {}) : {};
 | 
					      this.showFullScript = this.transactions[0] ? this.transactions[0].vin.reduce((acc, _, i) => ({...acc, [i]: false}), {}) : {};
 | 
				
			||||||
 | 
					      this.showFullWitness = this.transactions[0] ? this.transactions[0].vin.reduce((acc, vin, vinIndex) => {
 | 
				
			||||||
 | 
					        acc[vinIndex] = vin.witness ? vin.witness.reduce((witnessAcc, _, witnessIndex) => {
 | 
				
			||||||
 | 
					          witnessAcc[witnessIndex] = false;
 | 
				
			||||||
 | 
					          return witnessAcc;
 | 
				
			||||||
 | 
					        }, {}) : {};
 | 
				
			||||||
 | 
					        return acc;
 | 
				
			||||||
 | 
					      }, {}) : {};
 | 
				
			||||||
      this.showDetails$.next(true);
 | 
					      this.showDetails$.next(true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -359,6 +368,10 @@ export class TransactionsListComponent implements OnInit, OnChanges {
 | 
				
			|||||||
    this.showFullScript[vinIndex] = !this.showFullScript[vinIndex];
 | 
					    this.showFullScript[vinIndex] = !this.showFullScript[vinIndex];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  toggleShowFullWitness(vinIndex: number, witnessIndex: number): void {
 | 
				
			||||||
 | 
					    this.showFullWitness[vinIndex][witnessIndex] = !this.showFullWitness[vinIndex][witnessIndex];
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ngOnDestroy(): void {
 | 
					  ngOnDestroy(): void {
 | 
				
			||||||
    this.outspendsSubscription.unsubscribe();
 | 
					    this.outspendsSubscription.unsubscribe();
 | 
				
			||||||
    this.currencyChangeSubscription?.unsubscribe();
 | 
					    this.currencyChangeSubscription?.unsubscribe();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user