Skip to content

Commit

Permalink
feat(calendar): Adding a template for igxCalendar #333
Browse files Browse the repository at this point in the history
  • Loading branch information
dafo committed Aug 9, 2018
1 parent a5c2be5 commit e281fe0
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div igxLayout igxLayoutDir="columns" igxLayoutItemAlign="center">
<p>igx-calendar component</p>
<p>You can read more about configuring the igx-calendar component in the
<a href="https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/calendar/README.md" target="_blank">README</a> or the
<a href="https://www.infragistics.com/products/ignite-ui-angular/angular/components/calendar.html" target="_blank">official documentation</a>.</p>
<igx-calendar $(selectionType)></igx-calendar>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { async, TestBed, ComponentFixture } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { $(ClassName)Component } from './$(filePrefix).component';
import { IgxCalendarModule } from 'igniteui-angular';

describe('$(ClassName)Component', () => {
let component: $(ClassName)Component;
let fixture: ComponentFixture<$(ClassName)Component>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [$(ClassName)Component],
imports: [ IgxCalendarModule, NoopAnimationsModule]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent($(ClassName)Component);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'app-$(filePrefix)',
templateUrl: './$(filePrefix).component.html',
styleUrls: ['./$(filePrefix).component.css'],
encapsulation: ViewEncapsulation.None
})
export class $(ClassName)Component implements OnInit {

constructor() { }

public ngOnInit(): void {}
}
60 changes: 60 additions & 0 deletions templates/angular/igx-ts/calendar/default/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { IgniteUIForAngularTemplate } from "../../../../../lib/templates/IgniteUIForAngularTemplate";

class IgxCalendarTemplate extends IgniteUIForAngularTemplate {
private userExtraConfiguration: {} = {};
constructor() {
super(__dirname);
this.components = ["Calendar"];
this.controlGroup = "Scheduling";
this.listInComponentTemplates = true;
this.id = "calendar";
this.projectType = "igx-ts";
this.name = "Calendar";
this.description = "IgxCalendar with single selection";
this.dependencies = [
{ import: "IgxCalendarModule", from: "igniteui-angular" }
];

this.hasExtraConfiguration = true;
}

public setExtraConfiguration(extraConfigKeys: {}) {
this.userExtraConfiguration = extraConfigKeys;
}

public getExtraConfiguration(): ControlExtraConfiguration[] {
return [{
choices: ["Single selection", "Multi selection", "Range selection"],
default: "Single selection",
key: "selectionType",
message: "Choose selection type for the igx-calendar",
type: Enumerations.ControlExtraConfigType.Choice
}];
}

public generateFiles(projectPath: string, name: string, ...options: any[]): Promise<boolean> {
let selectionType = "";

if (this.userExtraConfiguration["selectionType"]) {
const type = this.userExtraConfiguration["selectionType"] as string;
switch (type) {
case "Single selection":
selectionType = "";
break;
case "Multi selection":
selectionType = 'selection="multi"';
break;
case "Range selection":
selectionType = 'selection="range"';
break;
}
}

const extraConfig = {
"$(selectionType)": selectionType
};

return super.generateFiles(projectPath, name, { extraConfig });
}
}
module.exports = new IgxCalendarTemplate();
14 changes: 14 additions & 0 deletions templates/angular/igx-ts/calendar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import { BaseComponent } from "../../../../lib/BaseComponent";

class IgxCalendarComponent extends BaseComponent {
/**
*
*/
constructor() {
super(__dirname);
this.name = "Calendar";
this.group = "Scheduling";
}
}
module.exports = new IgxCalendarComponent();

0 comments on commit e281fe0

Please sign in to comment.