File

src/app/manage-learn/shared/components/footer-buttons/footer-buttons.component.ts

Implements

OnChanges

Metadata

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

constructor(utils: UtilsService, translate: TranslateService, toast: ToastService)
Parameters :
Name Type Optional
utils UtilsService No
translate TranslateService No
toast ToastService No

Inputs

completedQuestionCount
Type : number
Default value : 0
data
Type : any
enableGps
Type : any
isFirst
Type : boolean
isLast
Type : boolean
isStartBTNEnabled
Type : boolean
isSubmitted
Type : any
questionCount
Type : number
Default value : 0
showStartButton
Type : boolean
Default value : false
showSubmit
Type : any
updatedData
Type : any
viewOnly
Type : boolean
Default value : false

Outputs

allowStart
Type : EventEmitter
backAction
Type : EventEmitter
nextAction
Type : EventEmitter
openSheetAction
Type : EventEmitter
startAction
Type : EventEmitter

Methods

allowStartingObservation
allowStartingObservation()
Returns : void
back
back()
Returns : void
gpsFlowChecks
gpsFlowChecks(action, status)
Parameters :
Name Optional
action No
status No
Returns : void
next
next(status?: string)
Parameters :
Name Type Optional
status string Yes
Returns : void
ngOnChanges
ngOnChanges()
Returns : void
openAction
openAction()
Returns : void
startBtnAction
startBtnAction()
Returns : void

Properties

_data
percentage
Type : number
Default value : 0
text
Type : string

Accessors

data
getdata()
setdata(data)
Parameters :
Name Optional
data No
Returns : void
import {
  Component,
  Input,
  Output,
  EventEmitter,
  OnChanges,
} from "@angular/core";
import { UtilsService,ToastService } from '@app/app/manage-learn/core';
import { TranslateService } from "@ngx-translate/core";

@Component({
  selector: 'app-footer-buttons',
  templateUrl: './footer-buttons.component.html',
  styleUrls: ['./footer-buttons.component.scss'],
})
export class FooterButtonsComponent implements OnChanges {

  text: string;
  _data;

  @Input() updatedData;
  @Input()
  get data() {
    return this._data;
  }
  set data(data) {
    this._data = JSON.parse(JSON.stringify(data));
  }
  @Input() isFirst: boolean;
  @Input() isStartBTNEnabled:boolean;
  @Input() showStartButton : boolean = false;
  @Input() isLast: boolean;
  @Output() nextAction = new EventEmitter();
  @Output() backAction = new EventEmitter();
  @Output() openSheetAction = new EventEmitter();
  @Output() startAction = new EventEmitter();
  @Output() allowStart = new EventEmitter();
  @Input() completedQuestionCount = 0;
  @Input() questionCount = 0;
  @Input() isSubmitted;
  @Input() enableGps;
  @Input() showSubmit;
  @Input() viewOnly:boolean = false;

  percentage: number = 0;

  constructor(
    private utils: UtilsService,
    private translate: TranslateService,
    private toast : ToastService
  ) {}
  ngOnChanges() {
    if (this.completedQuestionCount > 0) {
      this.percentage = this.questionCount ? (this.completedQuestionCount / this.questionCount) * 100 : 0;
      this.percentage = Math.trunc(this.percentage);
    } else {
      this.percentage = this.isSubmitted ? 100 : 0;
      this.completedQuestionCount = this.isSubmitted ? this.questionCount : 0;
    }
  }
  next(status?: string): void {
    this.nextAction.emit(status);
  }

  back(): void {
    this.backAction.emit();
  }

  gpsFlowChecks(action, status) {
    if (this.updatedData.responseType.toLowerCase() === "slider") {
      if (
        !this.updatedData.gpsLocation ||
        JSON.stringify(this._data.value) !== JSON.stringify(this.updatedData.value)
      ) {
      } else if (JSON.stringify(this._data.value) === JSON.stringify(this.updatedData.value)) {
        if (action === "next") {
          this.next(status);
        } else {
          this.back();
        }
      }
    } else if (this.updatedData.responseType.toLowerCase() === "pagequestions") {
      if (
        JSON.stringify(this._data.pageQuestions) !== JSON.stringify(this.updatedData.pageQuestions)
        // &&
        // this.utils.isPageQuestionComplete(this.updatedData)
      ) {
      } else {
        if (action === "next") {
          this.next(status);
        } else {
          this.back();
        }
      }
    } else if (JSON.stringify(this._data.value) !== JSON.stringify(this.updatedData.value)) {
    } else {
      if (action === "next") {
        this.next(status);
      } else {
        this.back();
      }
    }
  }

  // getGpsLocation(action, status) {
  //   this.utils.startLoader();
  //   this.ngps
  //     .getGpsStatus()
  //     .then((success) => {
  //       this.updatedData.gpsLocation = success;
  //       this.utils.stopLoader();
  //       if (action === "next") {
  //         this.next(status);
  //       } else {
  //         this.back();
  //       }
  //     })
  //     .catch((error) => {
  //       this.utils.stopLoader();
  //     });
  // }

  openAction() {
    this.openSheetAction.emit()
  }

  allowStartingObservation(){
    this.allowStart.emit();
  }

  startBtnAction(){
   if(!this.isStartBTNEnabled){
    let msg;
    this.translate.get(['FRMELEMENTS_MSG_FOR_NONTARGETED_USERS_QUESTIONNAIRE']).subscribe((translations) => {
      msg = translations['FRMELEMENTS_MSG_FOR_NONTARGETED_USERS_QUESTIONNAIRE'];
      this.toast.openToast(msg,'','top');
    });
   } else{
     // TODO navigate to observation details page.
     this.startAction.emit();
   }
  }
}
<ion-footer no-shadow>
  <ion-toolbar position="bottom">
    <ion-row>
      <ion-col>
        <ion-button icon-start color="light" (click)="enableGps ? gpsFlowChecks('back') :back()" class="custom-btn-txt-transform-none"
          *ngIf="!isFirst">
          <ion-icon role="button" aria-label="back" name="arrow-back" color="primary"></ion-icon>{{'FRMELEMENTS_BTN_BACK'| translate}}
        </ion-button>
      </ion-col>
      <ion-col style=" margin: auto;">
        <!-- {{completedQuestionCount}} {{questionCount}} -->
        <progress-bar [progress]="percentage" [total]="questionCount" [showTracker]="true"
          [completed]="completedQuestionCount" class="_full-width" *ngIf="completedQuestionCount!=questionCount && !showStartButton && !viewOnly">
        </progress-bar>
        <ion-button  round small class="custom-btn-txt-transform-none " *ngIf="showSubmit &&completedQuestionCount==questionCount" (click)="next('completed')">{{'FRMELEMNTS_BTN_SUBMIT'| translate}}
          <ion-icon name="chevron-up-circle" style="padding: 0 9px;" color="primary"></ion-icon></ion-button>
        <div class="_flex-box _justify-content-center">
          <ion-button round small *ngIf="showStartButton" (click)="startBtnAction()" class="custom-btn-txt-transform-none"
            [ngClass]="{'btn-disabled': !isStartBTNEnabled}">{{'FRMELEMNTS_BTN_START'| translate}}
          </ion-button>
        </div>
        <div *ngIf="viewOnly && showStartButton === undefined" class="_flex-box _justify-content-center">
          <ion-button round small (click)="allowStartingObservation()" class=" custom-btn-txt-transform-none"
            >{{'FRMELEMNTS_BTN_START'| translate}}
          </ion-button>
        </div>

      </ion-col>
      <ion-col>
        <ion-button  icon-end class="ion-float-right custom-btn-txt-transform-none" color="light" aria-label="Next" (click)="next()"
          *ngIf="!isLast">{{'FRMELEMENTS_BTN_NEXT'|
          translate}} <ion-icon name="arrow-forward" color="primary"></ion-icon></ion-button>
        <ion-button  icon-start class="ion-float-right custom-btn-txt-transform-none" color="light"
          (click)="next('completed')" *ngIf="isLast && !showStartButton">
          <ion-icon name="save" class="ion-margin-end" color="primary"></ion-icon>{{'SAVE'| translate}}
        </ion-button>
      </ion-col>
    </ion-row>
  </ion-toolbar>
</ion-footer>

./footer-buttons.component.scss

.btn-disabled{
    --background: #999999 !important;
    --border-color: #999999 !important;
  }
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""