2 * Created by rc2122 on 8/15/2017.
5 * ============LICENSE_START=======================================================
7 * ================================================================================
8 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
23 import { Component, ElementRef, forwardRef, Inject, Input, ViewChild, ViewContainerRef, ComponentRef} from "@angular/core";
24 import {trigger, state, style, transition, animate} from '@angular/animations';
25 import {StepModel} from "app/models";
26 import {ModalService} from "../../../services/modal.service";
27 import {ModalComponent} from "../modal/modal.component";
28 import {WizardHeaderBaseComponent} from "./multi-steps-wizard-header-base.component";
32 selector: 'multi-steps-wizard',
33 templateUrl: './multi-steps-wizard.component.html',
34 styleUrls: ['./../modal/modal.component.less','./multi-steps-wizard.component.less'],
36 trigger('displayLineAnimation', [
40 state('false', style({
43 transition('* => *', animate('500ms')),
47 export class MultiStepsWizardComponent extends ModalComponent {
49 @Input() steps:Array<StepModel>;
50 @Input() callback: Function;
52 @Input() dynamicHeader: ComponentRef<WizardHeaderBaseComponent>;
54 @ViewChild('dynamicHeaderContainer', { read: ViewContainerRef }) dynamicHeaderContainer: ViewContainerRef;
55 constructor(@Inject(forwardRef(() => ModalService)) public modalService: ModalService, el: ElementRef ) {
59 private currentStepIndex:number = 0;
61 nextStep = ():void => {
62 if(this.currentStepIndex + 1 < this.steps.length){
63 this.currentStepIndex++;
64 this.modalService.addDynamicContentToModal(this.modalService.currentModal, this.steps[this.currentStepIndex].component);
65 this.dynamicHeader.instance.currentStepIndex = this.currentStepIndex;
69 prevStep = ():void => {
70 if(this.currentStepIndex > 0){
71 this.currentStepIndex--;
72 this.modalService.addDynamicContentToModal(this.modalService.currentModal, this.steps[this.currentStepIndex].component);
73 this.dynamicHeader.instance.currentStepIndex = this.currentStepIndex;