Skip to content

Commit

Permalink
fix(quicknote): Fixing quick note demo and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ndickerson authored and jgodi committed Jun 19, 2017
1 parent da09b47 commit 305550a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 25 deletions.
3 changes: 3 additions & 0 deletions demo/main.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ColorComponent, CompositionComponent, TypographyComponent, IconographyC
import {
ButtonDemoComponent,
RadioDemoComponent,
CustomQuickNoteResults,
QuickNoteDemoComponent,
ModalDemoComponent,
FormDemoComponent,
Expand Down Expand Up @@ -62,6 +63,7 @@ import './demo.scss';
IconographyComponent,
ButtonDemoComponent,
RadioDemoComponent,
CustomQuickNoteResults,
QuickNoteDemoComponent,
ModalDemoComponent,
FormDemoComponent,
Expand Down Expand Up @@ -134,6 +136,7 @@ import './demo.scss';
ImageCell,
ActionsCell,
CustomPickerResults,
CustomQuickNoteResults,
CustomDemoComponent
],
bootstrap: [DemoComponent]
Expand Down
2 changes: 1 addition & 1 deletion demo/pages/elements/form/FormDemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class FormDemoComponent {
},
options: {
tags: ['First', 'Second'],
references: ['Third', 'Forth'],
references: ['Third', 'Fourth'],
boos: ['Test']
},
renderer: {
Expand Down
6 changes: 6 additions & 0 deletions demo/pages/elements/quick-note/QuickNoteDemo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
div.data {
padding: 10px;
}
quick-note-results,
.quick-note-results {
novo-list {
width: 100%;
}
}
}
22 changes: 12 additions & 10 deletions demo/pages/elements/quick-note/QuickNoteDemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ import { QuickNoteResults } from './../../../../index';
},
template: `
<novo-loading theme="line" *ngIf="isLoading && !matches.length"></novo-loading>
<ul *ngIf="matches.length > 0">
<li
<novo-list *ngIf="matches.length > 0">
<novo-list-item
*ngFor="let match of matches"
(click)="selectMatch($event)"
[class.active]="match===activeMatch"
(mouseenter)="selectActive(match)">
**CUSTOM** <b [innerHtml]="highlight(match.label, term)"></b>
</li>
</ul>
<item-content>
**CUSTOM** <b [innerHtml]="highlight(match.label, term)"></b>
</item-content>
</novo-list-item>
</novo-list>
<p class="picker-error" *ngIf="hasError">Oops! An error occured.</p>
<p class="picker-null" *ngIf="!isLoading && !matches.length && !hasError">No results to display...</p>
`
Expand Down Expand Up @@ -60,24 +62,24 @@ export class QuickNoteDemoComponent {
private CustomQuickNoteDemoTpl:string = CustomQuickNoteDemoTpl;
private CustomQuickNoteResultsDemoTpl:string = CustomQuickNoteResultsDemoTpl;
private placeholder:string = 'Enter your note text here. Reference people and distribution lists using @ (eg. @John Smith). Reference other records using # (e.g. #Project Manager)';
private config:any;
private basic:any;
private custom:any;
private custom2:any;
private customResults:any;

constructor() {
let customData = {
tags: [{ id: 1, name: 'OH YA!', test: 'TWO' }, { id: 2, name: 'TAGGING!', test: 'ONE' }],
references: [{ id: 1, title: 'Awesome Reference' }, { id: 2, title: 'Angular2' }]
};
this.config = {
this.basic = {
triggers: {
tags: '@',
references: '#',
boos: '^'
},
options: {
tags: ['First', 'Second'],
references: ['Third', 'Forth'],
references: ['Third', 'Fourth'],
boos: ['Test']
},
renderer: {
Expand Down Expand Up @@ -126,7 +128,7 @@ export class QuickNoteDemoComponent {
}
}
};
this.custom2 = {
this.customResults = {
resultsTemplate: CustomQuickNoteResults,
triggers: {
names: '@',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<novo-quick-note [(ngModel)]="note" [placeholder]="placeholder" [config]="config"></novo-quick-note>
<novo-quick-note [(ngModel)]="note" [placeholder]="placeholder" [config]="basic"></novo-quick-note>
<div class="data">
<p>Note: {{note | json}}</p>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<novo-quick-note [(ngModel)]="note3" [placeholder]="placeholder" [config]="custom2"></novo-quick-note>
<novo-quick-note [(ngModel)]="note3" [placeholder]="placeholder" [config]="customResults"></novo-quick-note>
<div class="data">
<p>Note: {{note3 | json}}</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,23 @@ export class BasePickerResults {
return this.element.nativeElement;
}

getChildenOfListElement() {
let list = this.getListElement();
return list.children;
getChildrenOfListElement() {
let children = [];
if (this.getListElement()) {
children = this.getListElement().children;
}
return children;
}

scrollToActive() {
let list = this.getListElement();
let items = this.getChildenOfListElement();
let items = this.getChildrenOfListElement();
let index = this.matches.indexOf(this.activeMatch);
let item = items[index];
if (item) {
list.scrollTop = item.offsetTop;
} else {
console.warn('BasePickerResults - could not find result item to scroll to, try overriding getListElement() or getChildenOfListElement() in your PickerResults Component'); // tslint: disable-line
console.warn('BasePickerResults - could not find result item to scroll to, try overriding getListElement() or getChildrenOfListElement() in your PickerResults Component'); // tslint: disable-line
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TestBed, async } from '@angular/core/testing';
import { QuickNoteResults } from './QuickNoteResults';
import { NovoLabelService } from '../../../../services/novo-label-service';
import { NovoLoadingElement } from '../../../loading/Loading';
import { NovoListElement, NovoListItemElement, NovoItemContentElement } from '../../../list/List';

describe('Elements: QuickNoteResults', () => {
describe('Extras: ', () => {
Expand All @@ -14,7 +15,10 @@ describe('Elements: QuickNoteResults', () => {
TestBed.configureTestingModule({
declarations: [
QuickNoteResults,
NovoLoadingElement
NovoLoadingElement,
NovoListElement,
NovoListItemElement,
NovoItemContentElement
],
providers: [
{ provide: NovoLabelService, useClass: NovoLabelService }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ import { NovoLabelService } from '../../../../services/novo-label-service';
},
template: `
<novo-loading theme="line" *ngIf="isLoading && !matches.length"></novo-loading>
<ul *ngIf="matches.length > 0">
<li
<novo-list *ngIf="matches.length > 0">
<novo-list-item
*ngFor="let match of matches"
(click)="selectMatch($event)"
[class.active]="match===activeMatch"
(mouseenter)="selectActive(match)">
<span [innerHtml]="highlight(match.label, term)"></span>
</li>
</ul>
<item-content>
<p [innerHtml]="highlight(match.label, term)"></p>
</item-content>
</novo-list-item>
</novo-list>
<p class="picker-error" *ngIf="hasError">{{ labels.quickNoteError }}</p>
<p class="picker-null" *ngIf="!isLoading && !matches.length && !hasError">{{ labels.quickNoteEmpty }}</p>
`
Expand Down Expand Up @@ -110,7 +112,6 @@ export class QuickNoteResults extends PickerResults {
});
}


/**
* @name selectMatch
* @param event
Expand Down

0 comments on commit 305550a

Please sign in to comment.