-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
582 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './module'; |
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,38 @@ | ||
import { NgModule, ModuleWithProviders } from '@angular/core'; | ||
|
||
import { IgoSharedModule } from '../shared'; | ||
|
||
import { PrintComponent, PrintBindingDirective } from './print'; | ||
import { PrintFormComponent } from './print-form'; | ||
import { PrintService } from './shared'; | ||
|
||
|
||
@NgModule({ | ||
imports: [ | ||
IgoSharedModule | ||
], | ||
exports: [ | ||
PrintComponent, | ||
PrintBindingDirective, | ||
PrintFormComponent | ||
], | ||
declarations: [ | ||
PrintComponent, | ||
PrintBindingDirective, | ||
PrintFormComponent | ||
] | ||
}) | ||
export class IgoPrintModule { | ||
static forRoot(): ModuleWithProviders { | ||
return { | ||
ngModule: IgoPrintModule, | ||
providers: [ | ||
PrintService | ||
] | ||
}; | ||
} | ||
} | ||
|
||
export * from './shared'; | ||
export * from './print'; | ||
export * from './print-form'; |
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 @@ | ||
export * from './print-form.component'; |
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,41 @@ | ||
<form [formGroup]="form"> | ||
|
||
<div class="igo-input-container"> | ||
<md-select | ||
formControlName="format" | ||
placeholder="{{'igo.format' | translate}}"> | ||
<md-option *ngFor="let format of formats | keyvalue " [value]="format.key"> | ||
{{format.value}} | ||
</md-option> | ||
</md-select> | ||
</div> | ||
|
||
<div class="igo-input-container"> | ||
<md-select | ||
formControlName="resolution" | ||
placeholder="{{'igo.resolution' | translate}}"> | ||
<md-option *ngFor="let resolution of resolutions | keyvalue " [value]="resolution.key"> | ||
{{resolution.value + ' PPI'}} | ||
</md-option> | ||
</md-select> | ||
</div> | ||
|
||
<div class="igo-input-container"> | ||
<md-radio-group formControlName="orientation" class="horizontal"> | ||
<md-radio-button *ngFor="let orientation of orientations | keyvalue " [value]="orientation.key"> | ||
{{('igo.' + orientation.value) | translate}} | ||
</md-radio-button> | ||
</md-radio-group> | ||
</div> | ||
|
||
<div class="igo-form-button-group"> | ||
<button | ||
md-raised-button | ||
type="button" | ||
[disabled]="!form.valid" | ||
(click)="handleFormSubmit(form.value, form.valid)"> | ||
{{'igo.print' | translate}} | ||
</button> | ||
</div> | ||
|
||
</form> |
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,32 @@ | ||
import { async, TestBed } from '@angular/core/testing'; | ||
// import { ComponentFixture } from '@angular/core/testing'; | ||
|
||
import { IgoSharedModule } from '../../shared'; | ||
|
||
import { PrintFormComponent } from './print-form.component'; | ||
|
||
describe('PrintFormComponent', () => { | ||
// let component: PrintFormComponent; | ||
// let fixture: ComponentFixture<PrintFormComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
IgoSharedModule, | ||
], | ||
declarations: [ PrintFormComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
/* | ||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PrintFormComponent); | ||
component = fixture.componentInstance; | ||
}); | ||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
*/ | ||
}); |
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 @@ | ||
@require '../../../style/var.styl'; |
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,79 @@ | ||
import { Component, Input, Output, EventEmitter } from '@angular/core'; | ||
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; | ||
|
||
import { PrintOptions, PrintFormat, PrintOrientation, | ||
PrintResolution } from '../shared'; | ||
|
||
@Component({ | ||
selector: 'igo-print-form', | ||
templateUrl: './print-form.component.html', | ||
styleUrls: ['./print-form.component.styl'] | ||
}) | ||
export class PrintFormComponent { | ||
|
||
public form: FormGroup; | ||
public submitted: boolean; | ||
|
||
public formats = PrintFormat; | ||
public orientations = PrintOrientation; | ||
public resolutions = PrintResolution; | ||
|
||
@Input() | ||
get format(): PrintFormat { return this.formatField.value; } | ||
set format(value: PrintFormat) { | ||
this.formatField.setValue(value || PrintFormat.A4, { | ||
onlySelf: true | ||
}); | ||
} | ||
|
||
@Input() | ||
get orientation(): PrintOrientation { return this.orientationField.value; } | ||
set orientation(value: PrintOrientation) { | ||
this.orientationField.setValue(value || PrintOrientation.landscape, { | ||
onlySelf: true | ||
}); | ||
} | ||
|
||
@Input() | ||
get resolution(): PrintResolution { return this.resolutionField.value; } | ||
set resolution(value: PrintResolution) { | ||
this.resolutionField.setValue(value || PrintResolution['72'], { | ||
onlySelf: true | ||
}); | ||
} | ||
|
||
get formatField () { | ||
return (<FormControl>this.form.controls['format']); | ||
} | ||
|
||
get orientationField () { | ||
return (<FormControl>this.form.controls['orientation']); | ||
} | ||
|
||
get resolutionField () { | ||
return (<FormControl>this.form.controls['resolution']); | ||
} | ||
|
||
@Output() submit: EventEmitter<PrintOptions> = new EventEmitter(); | ||
|
||
constructor(private formBuilder: FormBuilder) { | ||
this.form = this.formBuilder.group({ | ||
format: ['', [ | ||
Validators.required | ||
]], | ||
resolution: ['', [ | ||
Validators.required | ||
]], | ||
orientation: ['', [ | ||
Validators.required | ||
]] | ||
}); | ||
} | ||
|
||
handleFormSubmit(data: PrintOptions, isValid: boolean) { | ||
this.submitted = true; | ||
if (isValid) { | ||
this.submit.emit(data); | ||
} | ||
} | ||
} |
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,2 @@ | ||
export * from './print.component'; | ||
export * from './print-binding.directive'; |
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,14 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
describe('PrintBindingDirective', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [], | ||
providers: [] | ||
}); | ||
}); | ||
|
||
it('should create an instance', () => { | ||
expect(true).toBeTruthy(); | ||
}); | ||
}); |
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,23 @@ | ||
import { Directive, Self, OnInit } from '@angular/core'; | ||
|
||
import { MapService } from '../../map'; | ||
import { PrintComponent } from './print.component'; | ||
|
||
|
||
@Directive({ | ||
selector: '[igoPrintBinding]' | ||
}) | ||
export class PrintBindingDirective implements OnInit { | ||
|
||
private component: PrintComponent; | ||
|
||
constructor(@Self() component: PrintComponent, | ||
private mapService: MapService) { | ||
this.component = component; | ||
} | ||
|
||
ngOnInit() { | ||
this.component.map = this.mapService.getMap(); | ||
} | ||
|
||
} |
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,6 @@ | ||
<igo-print-form | ||
[format]="format" | ||
[orientation]="orientation" | ||
[resolution]="resolution" | ||
(submit)="handleFormSubmit($event)"> | ||
</igo-print-form> |
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,40 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { IgoTestModule } from '../../../test/module'; | ||
import { IgoSharedModule } from '../../shared'; | ||
|
||
import { PrintService } from '../shared'; | ||
import { PrintFormComponent } from '../print-form'; | ||
import { PrintComponent } from './print.component'; | ||
|
||
|
||
describe('PrintComponent', () => { | ||
let component: PrintComponent; | ||
let fixture: ComponentFixture<PrintComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
IgoTestModule, | ||
IgoSharedModule, | ||
], | ||
declarations: [ | ||
PrintComponent, | ||
PrintFormComponent | ||
], | ||
providers: [ | ||
PrintService | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PrintComponent); | ||
component = fixture.componentInstance; | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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 @@ | ||
@require '../../../style/var.styl'; |
Oops, something went wrong.