forked from hyperledger-archives/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix expand resources (hyperledger-archives#1242)
Fixed animation Fixed problem with only showing first 1000px of height
- Loading branch information
Showing
5 changed files
with
218 additions
and
52 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
...es/composer-playground/src/app/directives/check-overflow/check-overflow.directive.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
/* tslint:disable:no-unused-expression */ | ||
/* tslint:disable:no-var-requires */ | ||
/* tslint:disable:max-classes-per-file */ | ||
import { ComponentFixture, TestBed, async, fakeAsync, tick, inject } from '@angular/core/testing'; | ||
import { Component, Renderer, } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import * as sinon from 'sinon'; | ||
import * as chai from 'chai'; | ||
import { CheckOverFlowDirective } from './check-overflow.directive'; | ||
|
||
let should = chai.should(); | ||
|
||
@Component({ | ||
selector: 'test', | ||
template: ` | ||
<div checkOverFlow [changed]="changed" | ||
[expanded]="expanded" (hasOverFlow)=hasOverFlow($event)> | ||
<pre #resourcedata>bob</pre> | ||
</div>` | ||
}) | ||
|
||
class TestComponent { | ||
|
||
changed: boolean = false; | ||
expanded: boolean = false; | ||
|
||
overflow: boolean = false; | ||
|
||
hasOverFlow(overflow: boolean) { | ||
this.overflow = overflow; | ||
} | ||
|
||
} | ||
|
||
describe('CheckOverFlowDirective', () => { | ||
|
||
let component: TestComponent; | ||
let fixture: ComponentFixture<TestComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TestComponent, CheckOverFlowDirective], | ||
providers: [Renderer] | ||
}) | ||
|
||
.compileComponents(); | ||
})); | ||
|
||
it('should create the directive', async(fakeAsync(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
|
||
tick(); | ||
|
||
component.should.be.ok; | ||
}))); | ||
|
||
describe('checkOverFlow', () => { | ||
it('should set max height to be 100px when not expanded', async(fakeAsync(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
|
||
let de = fixture.debugElement.query(By.css('pre')); | ||
let el = de.nativeElement; | ||
el.style.maxHeight.should.equal('100px'); | ||
|
||
tick(); | ||
|
||
component.overflow.should.equal(false); | ||
}))); | ||
|
||
it('should set max height to be scroll height when expanded', async(fakeAsync(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
component.expanded = true; | ||
fixture.detectChanges(); | ||
|
||
let de = fixture.debugElement.query(By.css('pre')); | ||
let el = de.nativeElement; | ||
|
||
el.style.maxHeight.should.equal(el.scrollHeight + 'px'); | ||
|
||
tick(); | ||
|
||
component.overflow.should.equal(true); | ||
}))); | ||
}); | ||
|
||
describe('inputs', () => { | ||
it('should update when content changes', async(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
let directiveEl = fixture.debugElement.query(By.directive(CheckOverFlowDirective)); | ||
let directiveInstance = directiveEl.injector.get(CheckOverFlowDirective); | ||
|
||
let checkOverFlowMock = sinon.stub(directiveInstance, 'checkOverFlow'); | ||
|
||
component.changed = true; | ||
|
||
fixture.detectChanges(); | ||
|
||
checkOverFlowMock.should.have.been.called; | ||
})); | ||
|
||
it('should update when expanded changes', async(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
let directiveEl = fixture.debugElement.query(By.directive(CheckOverFlowDirective)); | ||
let directiveInstance = directiveEl.injector.get(CheckOverFlowDirective); | ||
|
||
let checkOverFlowMock = sinon.stub(directiveInstance, 'checkOverFlow'); | ||
|
||
component.expanded = true; | ||
|
||
fixture.detectChanges(); | ||
|
||
checkOverFlowMock.should.have.been.called; | ||
})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 48 additions & 44 deletions
92
packages/composer-playground/src/app/registry/registry.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,54 @@ | ||
<div *ngIf="_registry" class="resource-header"> | ||
<div class="resource-header-left"> | ||
<h1>{{_registry.name}}</h1> | ||
</div> | ||
<div *ngIf="!isTransactionRegistry()"> | ||
<button type="button" class="registry" (click)="openNewResourceModal()"> | ||
<span>+ Create New {{_registry.registryType}}</span> | ||
</button> | ||
</div> | ||
<div class="resource-header-left"> | ||
<h1>{{_registry.name}}</h1> | ||
</div> | ||
<div *ngIf="!isTransactionRegistry()"> | ||
<button type="button" class="registry" (click)="openNewResourceModal()"> | ||
<span>+ Create New {{_registry.registryType}}</span> | ||
</button> | ||
</div> | ||
</div> | ||
<div *ngIf="_registry" class="resource-list"> | ||
<div class="title" [ngClass]="{'resource-empty' : !resources || resources.length === 0}"> | ||
<div class="id">ID</div> | ||
<div class="data">Data</div> | ||
</div> | ||
<div *ngFor="let resource of resources" class="resource-container"> | ||
<div class="resource-content" [ngClass]="{'expanded' : resource.getIdentifier() === expandedResource}"> | ||
<div class="id">{{resource.getIdentifier()}}</div> | ||
<pre checkOverFlow [changed]="resource.getIdentifier()" (hasOverFlow)=hasOverFlow($event) | ||
[ngClass]="{'gradient' : resource.getIdentifier() !== expandedResource && showExpand, 'tiny-gradient' : resource.getIdentifier() === expandedResource || !showExpand}" | ||
class="data">{{serialize(resource)}}</pre> | ||
<div *ngIf="!isTransactionRegistry()" class="resource-icon"> | ||
<button type="button" class="icon" (click)="editResource(resource)"> | ||
<svg class="ibm-icon" aria-hidden="true"> | ||
<use xlink:href="#icon-edit_32"></use> | ||
</svg> | ||
</button> | ||
</div> | ||
<div *ngIf="!isTransactionRegistry()" class="resource-icon"> | ||
<button type="button" class="icon" (click)="openDeleteResourceModal(resource)"> | ||
<svg class="ibm-icon" aria-hidden="true"> | ||
<use xlink:href="#icon-trash_32"></use> | ||
</svg> | ||
<div class="title" [ngClass]="{'resource-empty' : !resources || resources.length === 0}"> | ||
<div class="id">ID</div> | ||
<div class="data">Data</div> | ||
</div> | ||
<div *ngFor="let resource of resources" class="resource-container"> | ||
<div checkOverFlow [changed]="resource.getIdentifier()" [expanded]="resource.getIdentifier() === expandedResource" (hasOverFlow)=hasOverFlow($event) | ||
class="resource-content" [ngClass]="{'expanded' : resource.getIdentifier() === expandedResource}"> | ||
<div class="id">{{resource.getIdentifier()}}</div> | ||
<pre #resourcedata | ||
[ngClass]="{'gradient' : resource.getIdentifier() !== expandedResource && showExpand, 'tiny-gradient' : resource.getIdentifier() === expandedResource || !showExpand}" | ||
class="data">{{serialize(resource)}}</pre> | ||
<div *ngIf="!isTransactionRegistry()" class="resource-icon"> | ||
<button type="button" class="icon" (click)="editResource(resource)"> | ||
<svg class="ibm-icon" aria-hidden="true"> | ||
<use xlink:href="#icon-edit_32"></use> | ||
</svg> | ||
</button> | ||
</div> | ||
<div *ngIf="!isTransactionRegistry()" class="resource-icon"> | ||
<button type="button" class="icon" (click)="openDeleteResourceModal(resource)"> | ||
<svg class="ibm-icon" aria-hidden="true"> | ||
<use xlink:href="#icon-trash_32"></use> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
<button *ngIf="showExpand" class="expand" type="button" (click)="expandResource(resource)"> | ||
{{resource.getIdentifier() === expandedResource ? 'Collapse' : 'Show All'}} | ||
</button> | ||
</div> | ||
</div> | ||
<button *ngIf="showExpand" class="expand" type="button" (click)="expandResource(resource)"> | ||
{{resource.getIdentifier() === expandedResource ? 'Collapse' : 'Show All'}} | ||
</button> | ||
</div> | ||
<div *ngIf="!resources || resources.length === 0" class="no-resources"> | ||
<svg class="ibm-icon" aria-hidden="true"> | ||
<use xlink:href="#icon-Emptiness"></use> | ||
</svg> | ||
<h3>This registry is empty!</h3> | ||
<p *ngIf="_registry.registryType!='Transaction'">To create resources in this registry click create new at the top of | ||
this page</p> | ||
<p *ngIf="_registry.registryType=='Transaction'">Submit a Transaction via the side menu</p> | ||
</div> | ||
|
||
|
||
<div *ngIf="!resources || resources.length === 0" class="no-resources"> | ||
<svg class="ibm-icon" aria-hidden="true"> | ||
<use xlink:href="#icon-Emptiness"></use> | ||
</svg> | ||
<h3>This registry is empty!</h3> | ||
<p *ngIf="_registry.registryType!='Transaction'">To create resources in this registry click create new at the | ||
top of | ||
this page</p> | ||
<p *ngIf="_registry.registryType=='Transaction'">Submit a Transaction via the side menu</p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters