Merge branch 'MOHEMM-Q2-DEV' into umar-q2-branch

MOHEMM-SFH-COLORS
umasoodch 4 years ago
commit b91f0a8044

@ -37,17 +37,18 @@ export class HomeComponent implements OnInit {
balance: any;
ACCRUAL_NET_ENTITLEMENT: any;
ACCRUAL_USED_ENTITLEMENT: any;
ACCRUAL_YEARLY_ENTITLEMENT: any;
totalnumber: any;
public direction: string;
ACCRUAL_YEARLY_ENTITLEMENT: any;
totalnumber: any;
public direction: string;
public options = {
cutoutPercentage: 80,
tooltips: { enabled: false },
legend: { display: false }};
gaugeType = "full";
// gaugeValue = 11.200;
// gaugeLabel = "";
legend: { display: false }
};
gaugeType = "full";
// gaugeValue = 11.200;
// gaugeLabel = "";
constructor(
public common: CommonService,
@ -58,23 +59,23 @@ export class HomeComponent implements OnInit {
public authService: AuthenticationService
) {
this.direction = TranslatorService.getCurrentDirection();
// this.userData =this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA,false);
// this.userData =this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA,false);
}
ngOnInit() {
this.Sdate = new Date().toISOString();
this.getUserDetails();
this.getAccrualBalance();
}
private getUserDetails(){
private getUserDetails() {
this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => {
if (user) {
// this.emp_no=user.EMPLOYEE_NUMBER;
// this.getAccrualBalance();
}
});
if (user) {
// this.emp_no=user.EMPLOYEE_NUMBER;
// this.getAccrualBalance();
}
});
@ -102,36 +103,36 @@ export class HomeComponent implements OnInit {
this.accrualNet = this.leaveAccrualBalance.ACCRUAL_NET_ENTITLEMENT;
this.accrualUsed = this.leaveAccrualBalance.ACCRUAL_USED_ENTITLEMENT;
this.accrualYearly = this.leaveAccrualBalance.ACCRUAL_YEARLY_ENTITLEMENT;
this.totalnumber= this.accrualNet + this.accrualUsed + this.accrualYearly;
this.totalnumber= this.totalnumber.toFixed(3);
this.totalnumber = this.accrualNet + this.accrualUsed + this.accrualYearly;
this.totalnumber = this.totalnumber.toFixed(3);
this.request = this.common.sharedService.getSharedData('leaveAccrualBalanceDate', false);
console.log("this.request" + this.request.P_EFFECTIVE_DATE);
this.effectiveDate = this.request.P_EFFECTIVE_DATE;
this.data = {
// labels: ['earingTotal', 'deductionTotal'],
datasets: [
// { data: [this.accrualNet,this.accrualYearly,this.accrualUsed],
{
data: [this.accrualNet,this.accrualUsed],
backgroundColor: [
// '#1FA269',
// '#CB3232',],
'#269DB8',
'#b60c0c',],
borderWidth: 1
}
]
};
// { data: [this.accrualNet,this.accrualYearly,this.accrualUsed],
{
data: [this.accrualNet, this.accrualUsed],
backgroundColor: [
// '#1FA269',
// '#CB3232',],
'#269DB8',
'#b60c0c',],
borderWidth: 1
}
]
};
this.getAbsenceTransaction();
}
AccrualBalances() {
AccrualBalances() {
this.common.openAccuralPage();
}
AttachmentDocuments(id) {
AttachmentDocuments(id) {
const request = {
P_ABSENCE_ATTENDANCE_ID: id
};
@ -159,7 +160,7 @@ AttachmentDocuments(id) {
//this.GetAbsenceTransactionList =result.GetAbsenceTransactionList;
}
}
getAbsenceTransaction() {
getAbsenceTransaction() {
this.IsReachEnd = false;
const request = {
P_SELECTED_EMPLOYEE_NUMBER: this.selEmp,
@ -173,7 +174,7 @@ getAbsenceTransaction() {
});
}
handleAbsListResult(result) {
handleAbsListResult(result) {
if (this.common.validResponse(result)) {
if (this.common.hasData(result.GetAbsenceTransactionList)) {
this.GetAbsenceTransactionList = result.GetAbsenceTransactionList;
@ -190,7 +191,7 @@ getAbsenceTransaction() {
}
}
}
doInfinite(event: any) {
doInfinite(event: any) {
if (!this.IsReachEnd) {
// this.P_PAGE_NUM++;
const request = {
@ -230,11 +231,11 @@ doInfinite(event: any) {
}
}
}
createAbsence() {
createAbsence() {
this.common.openSubmitAbsencePage();
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
getAccrualBalance() {
if (this.Sdate) {
let today = new Date(this.Sdate);
@ -255,31 +256,32 @@ createAbsence() {
});
}
}
handleAccrualResult(result) {
if (this.common.validResponse(result)) {
this.balance = result.GetAccrualBalancesList;
}
if(this.balance){
this.accrualNet = this.balance[0].ACCRUAL_NET_ENTITLEMENT;
this.accrualUsed = this.balance[0].ACCRUAL_USED_ENTITLEMENT;
// this.accrualYearly = this.balance[0].ACCRUAL_YEARLY_ENTITLEMENT;
// this.totalnumber= this.accrualNet + this.accrualUsed + this.accrualYearly;
this.totalnumber= this.accrualNet + this.accrualUsed;
this.totalnumber= this.totalnumber.toFixed(3);
this.data = {
// labels: ['earingTotal', 'deductionTotal'],
datasets: [
// { data: [this.accrualNet,this.accrualYearly,this.accrualUsed],
{ data: [this.accrualNet,this.accrualUsed],
backgroundColor: [
'#269DB8',
'#b60c0c',],
borderWidth: 1
}
]
};
}
if (this.balance) {
this.accrualNet = this.balance[0].ACCRUAL_NET_ENTITLEMENT;
this.accrualUsed = this.balance[0].ACCRUAL_USED_ENTITLEMENT;
// this.accrualYearly = this.balance[0].ACCRUAL_YEARLY_ENTITLEMENT;
// this.totalnumber= this.accrualNet + this.accrualUsed + this.accrualYearly;
this.totalnumber = this.accrualNet + this.accrualUsed;
this.totalnumber = this.totalnumber.toFixed(3);
this.data = {
// labels: ['earingTotal', 'deductionTotal'],
datasets: [
// { data: [this.accrualNet,this.accrualYearly,this.accrualUsed],
{
data: [this.accrualNet, this.accrualUsed],
backgroundColor: [
'#269DB8',
'#b60c0c',],
borderWidth: 1
}
]
};
}
}
}
}

@ -18,20 +18,22 @@ import { ApplyActionModalComponent } from '../apply-action-modal/apply-action-mo
export class WorkListMainItgComponent implements OnInit {
@ViewChild('slides') slides: IonSlides;
public static APPROVAL = "Services/COCWS.svc/REST/ITGApproveRequest"
public static REJECT = 'Services/COCWS.svc/REST/ITGRejectRequest'
// tslint:disable: member-ordering
public static APPROVAL = 'Services/COCWS.svc/REST/ITGApproveRequest';
public static REJECT = 'Services/COCWS.svc/REST/ITGRejectRequest';
public static DELEGATE = 'Services/COCWS.svc/REST/ITGDelegateRequest';
public static REQUEST_INFORMATION = 'Services/COCWS.svc/REST/ITGRequestInformation';
public static ANSWER = 'Services/COCWS.svc/REST/ITGAnswer';
public static GRANT = 'Services/COCWS.svc/REST/ITGGrantAccess';
// tslint:disable: variable-name
public request_info: any;
public request_name: any;
public all_request: any;
public all_request_names: any;
public is_all_items_sents: any;
public request = new itgRequest();
public activeSegment: any = "info";
public activeSegment: any = 'info';
public request_details: any;
public segmentsArray: { name: string, number: number }[] = [];
public segmentData: { name: string, data: any }[] = [];
@ -44,7 +46,7 @@ export class WorkListMainItgComponent implements OnInit {
public replcamentID: string;
public actionSelected: any;
public options: any;
public index: number = 0;
public index = 0;
public grantDATA: any;
public grantInfo: any;
public grantFieldsConditionalValue: any = [];
@ -67,7 +69,7 @@ export class WorkListMainItgComponent implements OnInit {
public modalCtrl: ModalController) { }
ngOnInit() {
this.direction = TranslatorService.getCurrentLanguageName()
this.direction = TranslatorService.getCurrentLanguageName();
this.request_info = this.common.sharedService.getSharedData(HomeComponent.REQUSET_INFO);
this.request_name = this.common.sharedService.getSharedData(HomeComponent.REQUSET_NAME);
this.all_request = this.common.sharedService.getSharedData(HomeComponent.ALL_REQUEST);
@ -90,19 +92,14 @@ export class WorkListMainItgComponent implements OnInit {
this.workListService.getITGFormDetails(this.request).subscribe((result: any) => {
this.request_details = result.ITGRequest;
this.grantInfo = result.ITGRequest.GrantFields;
let count = 0;
for (let i = 0; i < result.ITGRequest.FieldGoups.length; i++) {
this.segmentsArray[i] = { name: result.ITGRequest.FieldGoups[i].Title, number: i };
this.segmentData[i] = { name: result.ITGRequest.FieldGoups[i].Title, data: result.ITGRequest.FieldGoups[i].Fields }
this.segmentData[i] = { name: result.ITGRequest.FieldGoups[i].Title, data: result.ITGRequest.FieldGoups[i].Fields };
// tslint:disable: prefer-for-of
for (let j = 0; j < this.segmentData[i].data.length; j++) {
if (this.segmentData[i].data[j].Type === "table") {
this.dataLabelAndValue.push(JSON.parse(this.segmentData[i].data[j].Value))
if (this.segmentData[i].data[j].Type === 'table') {
this.dataLabelAndValue.push(JSON.parse(this.segmentData[i].data[j].Value));
}
// if (this.segmentData[i].data[j].TableValue){
// this.requestDetailsData[count] ={ name:this.segmentData[i].data[j].TableValue.Header,
// data: this.segmentData[i].data[j].TableValue.Rows}
// count++;
// }
}
}
this.segmentsArray[this.segmentsArray.length] = { name: 'Approval Level', number: this.segmentsArray.length };
@ -135,62 +132,56 @@ export class WorkListMainItgComponent implements OnInit {
}
}
}
//result.ITGRequest.FieldGoups.Fields
});
}
imageURL(actionName) {
if (actionName == "Approve") {
return "../assets/imgs/mohemm-action/Approve.png"
if (actionName === 'Approve') {
return '../assets/imgs/mohemm-action/Approve.png';
}
if (actionName == "Reject") {
return "../assets/imgs/mohemm-action/Reject.png"
if (actionName === 'Reject') {
return '../assets/imgs/mohemm-action/Reject.png';
}
if (actionName == "RequestInformation") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'RequestInformation') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "Grant") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'Grant') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "Delegate") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'Delegate') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "Answer") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'Answer') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "ReportGenerated") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'Question') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "Doable") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'ReportGenerated') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "NotDoable") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'Doable') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName == "DataCorrected") {
return "../assets/imgs/mohemm-action/info.png"
if (actionName === 'NotDoable') {
return '../assets/imgs/mohemm-action/info.png';
}
if (actionName === 'DataCorrected') {
return '../assets/imgs/mohemm-action/info.png';
}
}
public segmentChangedClick(event: any) {
if (event.detail.value === "Request Details") {
if (event.detail.value === 'Request Details') {
this.slides.slideTo(0);
this.activeSegment = event.detail.value;
}
else if (event.detail.value === "Approval Level") {
} else if (event.detail.value === 'Approval Level') {
this.slides.slideTo(1);
this.activeSegment = event.detail.value;
}
else if (event.detail.value === "Requester Details") {
} else if (event.detail.value === 'Requester Details') {
this.slides.slideTo(2);
this.activeSegment = event.detail.value;
}
// for(let i=0; i< this.segmentsArray.length; i++){
// if(this.segmentsArray[i].name === event.detail.value){
// this.slides.slideTo(i);
// this.activeSegment = event.detail.value;
// }
// }
}
slideChanged(event: any) {
@ -224,11 +215,9 @@ export class WorkListMainItgComponent implements OnInit {
}
}
}
}
//if user clicked on spicific type of ITG request
else {
} else { // if user clicked on spicific type of ITG request
for (let i = 0; i < this.all_request.length; i++) { // search for the request that clicked on all request
if (this.request_info.ID == this.all_request[i].ID) { // check if the ID for the request is found.
if (this.request_info.ID === this.all_request[i].ID) { // check if the ID for the request is found.
this.index = i + 1;
if (this.index !== this.all_request.length) { // check if its last one to redirecte to home otherwise to next request.
this.clearDataArray();
@ -240,11 +229,6 @@ export class WorkListMainItgComponent implements OnInit {
return;
}
}
// else {
// this.common.sharedService.setSharedData(true, 'loadWorkList');
// this.common.openNotificationPage();
// return;
// }
}
}
this.common.sharedService.setSharedData(true, 'loadWorkList');
@ -266,7 +250,7 @@ export class WorkListMainItgComponent implements OnInit {
actionService(action, comments?, grantRequests?) {
let url: string;
let request = new itgRequest();
const request = new itgRequest();
request.RequestType = this.request_name;
request.ItemID = this.request_info.ItemID;
request.TaskID = this.request_info.ID;
@ -276,14 +260,14 @@ export class WorkListMainItgComponent implements OnInit {
request.NewUserEMPId = this.replcamentID;
this.common.confirmAlertDialogAction(
() => {
if (action == 1) { //approved
if (action === 1) { // approved
url = WorkListMainItgComponent.APPROVAL;
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
} else if (result.MessageStatus == 1) {
} else if (result.MessageStatus === 1) {
this.messageSuccess = true;
setTimeout(() => {
this.messageSuccess = false;
@ -293,26 +277,24 @@ export class WorkListMainItgComponent implements OnInit {
}, 2000);
}
});
} else if (action == 2) {//reject
} else if (action === 2) {// reject
url = WorkListMainItgComponent.REJECT;
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
} else if (result.MessageStatus == 1) {
} else if (result.MessageStatus === 1) {
setTimeout(() => {
this.messageSuccess = true;
this.common.sharedService.setSharedData(true, 'loadWorkList');
// this.common.presentAlert(this.ts.trPK('worklistMain', 'Tran_Succ'));
// this.common.sharedService.setSharedData(true, 'loadWorkList');
this.confirmMsg(2);
this.skip();
this.messageSuccess = false;
}, 2000);
}
});
} else if (action == 3) {//request more info
} else if (action === 3) {// request more info
request.NewUserEMPId = this.replcamentID;
url = WorkListMainItgComponent.REQUEST_INFORMATION;
if (!comments) {
@ -321,12 +303,11 @@ export class WorkListMainItgComponent implements OnInit {
request.Comments = comments;
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
//this.common.presentAlert(result.Message);
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
}
if (result.MessageStatus == 1) {
if (result.MessageStatus === 1) {
this.messageSuccess = true;
setTimeout(() => {
this.messageSuccess = false;
@ -339,15 +320,15 @@ export class WorkListMainItgComponent implements OnInit {
}
});
}
} else if (action == 4) {//delegate
} else if (action === 4) {// delegate
request.NewUserEMPId = this.replcamentID;
url = WorkListMainItgComponent.DELEGATE;
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
} else if (result.MessageStatus == 1) {
} else if (result.MessageStatus === 1) {
this.messageSuccess = true;
setTimeout(() => {
this.messageSuccess = false;
@ -359,17 +340,17 @@ export class WorkListMainItgComponent implements OnInit {
}, 2000);
}
});
} else if (action == 5) { //answer
} else if (action === 5) { // answer
url = WorkListMainItgComponent.ANSWER;
if (!comments) {
this.common.presentAlert(this.ts.trPK('worklist', 'empty-comment'));
} else {
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
} else if (result.MessageStatus == 1) {
} else if (result.MessageStatus === 1) {
this.messageSuccess = true;
setTimeout(() => {
this.messageSuccess = false;
@ -382,20 +363,19 @@ export class WorkListMainItgComponent implements OnInit {
}
});
}
} else if (action == 6) { //grant
} else if (action === 6) { // grant
url = WorkListMainItgComponent.GRANT;
if (!comments) {
this.common.presentAlert(this.ts.trPK('worklist', 'empty-comment'));
}
else {
} else {
if (this.grantRequest) {
request.AdditionalFields = this.grantRequest;
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
} else if (result.MessageStatus == 1) {
} else if (result.MessageStatus === 1) {
this.messageSuccess = true;
setTimeout(() => {
this.messageSuccess = false;
@ -412,16 +392,16 @@ export class WorkListMainItgComponent implements OnInit {
}
}
} else if (action == 7) { //grant
} else if (action === 7) { // grant
url = WorkListMainItgComponent.GRANT;
if (this.grantRequest) {
request.AdditionalFields = this.grantRequest;
this.workListService.getITGActionRequest(request, url)
.subscribe((result: any) => {
if (result.MessageStatus != 1) {
if (result.MessageStatus !== 1) {
this.common.presentAlert(this.ts.trPK('general', 'error-itg'));
} else if (result.MessageStatus == 1) {
} else if (result.MessageStatus === 1) {
this.messageSuccess = true;
setTimeout(() => {
this.messageSuccess = false;
@ -476,13 +456,13 @@ export class WorkListMainItgComponent implements OnInit {
selectAtion(actionSelected) {
this.actionSelected = actionSelected;
if (this.actionSelected == "Answer") {
this.actionService(5, this.commentText)
if (this.actionSelected === 'Answer') {
this.actionService(5, this.commentText);
}
if (this.actionSelected == "Approve") {
if (this.actionSelected === 'Approve') {
this.actionService(1, this.commentText);
}
if (this.actionSelected == "Delegate") {
if (this.actionSelected === 'Delegate') {
this.presentModal(4);
}
if (this.actionSelected === 'Doable') {
@ -495,6 +475,7 @@ export class WorkListMainItgComponent implements OnInit {
this.actionService(2, this.commentText);
}
if (this.actionSelected === 'Question') {
this.actionService(5, this.commentText);
}
if (this.actionSelected === 'Reject') {
this.actionService(2, this.commentText);
@ -522,9 +503,9 @@ export class WorkListMainItgComponent implements OnInit {
.then((data) => {
this.replcamentID = data.data.empData.USER_NAME;
this.commentText = data.data.comments;
if (actionNumber == 3) {
if (actionNumber === 3) {
this.actionService(3, this.commentText);
} else if (actionNumber == 4) {
} else if (actionNumber === 4) {
this.actionService(4);
}

@ -1,24 +1,22 @@
<ion-content>
<div class="head-title">
<app-generic-header
showImage="false"
showBack="true"
[headerText]="'itemforsale,offersdiscount' | translate">
</app-generic-header>
<app-generic-header showImage="false" showBack="true" [headerText]="'itemforsale,offersdiscount' | translate">
</app-generic-header>
</div>
<div class="header"></div>
<div class="bottom"></div>
<div class="sales-items" *ngIf="segment =='1'">
<ion-grid>
<ion-row>
<ion-col size="12">
<ion-item lines="none" class="SearchtextBox">
<ion-input [placeholder]="'itemforsale,search-items'| translate" [(ngModel)]="searchText" (ionInput)="search($event.target.value)"></ion-input>
</ion-item>
<ion-item lines="none" class="SearchtextBox">
<ion-input [placeholder]="'itemforsale,search-items'| translate" [(ngModel)]="searchText"
(ionInput)="search($event.target.value)"></ion-input>
</ion-item>
</ion-col>
</ion-row>
<ion-row>
@ -29,60 +27,66 @@
<img class='filter' src="assets/imgs/itemsforsale/filter.svg">
</ion-col>
</ion-row>
</ion-grid>
<div class="container-icon" *ngIf="categories.length>0">
<div class="box-icon" *ngFor="let key of categories">
<div class="sale-icon" (click)="filterOffers(key)" [ngClass]="{'active':activeClass==key.categoryName_en }">
<div class="top">
<!-- <ion-icon name="images"></ion-icon> -->
<img [src]="key.content" />
</div>
<div class="bottom-icon">
<p *ngIf="direction =='ltr'">{{key.categoryName_en}}</p>
<p *ngIf="direction =='rtl'">{{key.categoryName_ar}}</p>
</div>
</div>
</ion-grid>
<div class="container-icon" *ngIf="categories.length>0">
<div class="box-icon" *ngFor="let key of categories">
<div class="sale-icon" (click)="filterOffers(key)" [ngClass]="{'active':activeClass==key.categoryName_en }">
<div class="top">
<!-- <ion-icon name="images"></ion-icon> -->
<img [src]="key.content" />
</div>
<div class="bottom-icon">
<p *ngIf="direction =='ltr'">{{key.categoryName_en}}</p>
<p *ngIf="direction =='rtl'">{{key.categoryName_ar}}</p>
</div>
</div>
</div>
</div>
<div class="grid-container">
<ion-row>
<ion-col size="6" *ngFor="let item of offersData" (click)="openDetails(item)">
<ion-card class="offers-discount-card">
<ion-card-header>
<!-- <img [src]="item.Banner_Image" /> -->
<div class="header-img" [ngStyle]="{'background-image': 'url(' + item.Banner_Image + ')'}" ></div>
<ion-card-title>{{item.Title}}</ion-card-title>
</ion-card-header>
<ion-card-content>
<div [innerHTML]="getDotted(item.Description)"></div>
<div class="dark offers-title">
{{item.Discount}}
</div>
<ion-row [class]="checkDate(item['End Date']) ==true ? 'green' : 'red'">
<ion-col size="10" *ngIf="checkDate(item['End Date']) ==true">
<p class="offer-valid">{{ts.trPK('general','offer-valid')}}</p>
</ion-col>
<ion-col size="10" *ngIf="checkDate(item['End Date']) ==false">
<p class="offer-valid"> {{ts.trPK('general','expired')}}</p>
</ion-col>
<ion-col size="2" >
<img src="assets/imgs/itemsforsale/arrow.svg">
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
</div>
<ion-row>
<ion-col size="6" *ngFor="let item of offersData" (click)="openDetails(item)">
<ion-card class="offers-discount-card">
<ion-card-header>
<!-- <img [src]="item.Banner_Image" /> -->
<div class="header-img" [ngStyle]="{'background-image': 'url(' + item.Banner_Image + ')'}"></div>
<ion-card-title>{{item.Title}}</ion-card-title>
</ion-card-header>
<ion-card-content>
<div [innerHTML]="getDotted(item.Description)"></div>
<div class="dark offers-title">
{{item.Discount}}
</div>
<ion-row [class]="checkDate(item['End Date']) ==true ? 'green' : 'red'">
<ion-col size="10" *ngIf="checkDate(item['End Date']) ==true">
<p class="offer-valid">{{ts.trPK('general','offer-valid')}}</p>
</ion-col>
<ion-col size="10" *ngIf="checkDate(item['End Date']) ==false">
<p class="offer-valid"> {{ts.trPK('general','expired')}}</p>
</ion-col>
<ion-col size="2">
<img src="assets/imgs/itemsforsale/arrow.svg">
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
</div>
</div>
</ion-content>
<ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content
loadingSpinner="bubbles"
loadingText="Loading more data...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>

@ -1,11 +1,10 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ModalController } from '@ionic/angular';
import { connectableObservableDescriptor } from 'rxjs/internal/observable/ConnectableObservable';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { FilterComponent } from '../filter/filter.component';
import { OfferDiscountService } from '../services/service';
import { IonInfiniteScroll } from '@ionic/angular';
@Component({
selector: 'app-home',
@ -13,6 +12,9 @@ import { OfferDiscountService } from '../services/service';
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements AfterViewInit {
@ViewChild(IonInfiniteScroll) infiniteScroll: IonInfiniteScroll;
segment: any = '1';
categoriesObj: any;
categories: any = [];
@ -21,8 +23,15 @@ export class HomeComponent implements AfterViewInit {
tempSearch: any = [];
searchText: String;
direction: any;
itemCounter = 1;
itemType: any;
// categories:any = [];
constructor(public ts: TranslatorService, public modalController: ModalController, public cs: CommonService, public offersService: OfferDiscountService, public route: ActivatedRoute) {
constructor(
public ts: TranslatorService,
public modalController: ModalController,
public cs: CommonService,
public offersService: OfferDiscountService,
public route: ActivatedRoute) {
this.route
.params.subscribe(val => {
@ -35,8 +44,10 @@ export class HomeComponent implements AfterViewInit {
ngAfterViewInit(): void {
this.getOfferDiscount();
}
ionEnter() {
this.direction = TranslatorService.getCurrentDirection();
console.log(this.direction);
let activeClass = this.cs.sharedService.getSharedData(OfferDiscountService.selected_filters);
if (activeClass) {
this.filterOffers(activeClass);
@ -45,8 +56,8 @@ export class HomeComponent implements AfterViewInit {
}
getCategories() {
this.offersService.getCategories().subscribe((result) => {
this.categories = result.result.data;
this.offersService.getCategories({}).subscribe((result) => {
this.categories = JSON.parse(result.Mohemm_ITG_ResponseItem).result.data; //result.result.data;
this.cs.sharedService.setSharedData(this.categories, OfferDiscountService.categories);
});
}
@ -58,60 +69,54 @@ export class HomeComponent implements AfterViewInit {
this.cs.navigateForward('/offersdiscount/offer-details');
}
getOfferDiscount() {
getOfferDiscount(pageNo?, categoryId?) {
this.cs.startLoading();
this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry')).subscribe((res) => {
var data = JSON.parse(res['Mohemm_ITG_ResponseItem']);
this.cs.stopLoading();
if (data['result'])
this.displayOffers(data['result']);
});
if (categoryId) {
this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry'),pageNo, categoryId).subscribe((res) => {
var data = JSON.parse(res['Mohemm_ITG_ResponseItem']);
this.cs.stopLoading();
if (data['result'])
this.displayOffers(data['result']);
});
} else {
this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry')).subscribe((res) => {
var data = JSON.parse(res['Mohemm_ITG_ResponseItem']);
this.cs.stopLoading();
if (data['result'])
this.displayOffers(data['result']);
});
}
}
displayOffers(data) {
if (data['data']) {
var parseJSON = data['data'];
var offers = JSON.parse(parseJSON);
this.offersData = offers;
// this.categoriesObj = this.groupBy(offers, TranslatorService.getCurrentDirection() == 'ltr' ? 'categoryName_en' : 'categoryName_ar');
// = Object.keys(this.categoriesObj);
// for (var x in this.categoriesObj) {
// for (var y in offers) {
// if (x == offers[y].categoryName_en && this.categories.filter(item => item.name.includes(x)) == false) {
// this.categories.push({
// name: x,
// icon: offers[y].icon
// })
// }
// }
// }
//this.filterOffers(this.categories[0]);
}
}
// groupBy(xs, key) {
// return xs.reduce((rv, x) => {
// (rv[x[key.trim()]] = rv[x[key]] || []).push(x);
// return rv
// }, {});
// };
filterOffers(key) {
this.activeClass = key.categoryName_en;
this.offersData = this.categoriesObj[key.name];
// this.tempSearch = JSON.parse(JSON.stringify(this.offersData));
if(this.direction === 'ltr') {
this.activeClass = key.categoryName_en;
}else {
this.activeClass = key.categoryName_ar
}
this.itemType = key.id;
this.getOfferDiscount(1,this.itemType)
}
checkDate(date) {
return new Date(date) >= new Date()
}
getDotted(temp) {
temp = this.stripHtml(temp);
return temp.substring(0, 70) + " ...";
}
stripHtml(html) {
var temporalDivElement = document.createElement("div");
@ -119,14 +124,15 @@ export class HomeComponent implements AfterViewInit {
return temporalDivElement.textContent || temporalDivElement.innerText || "";
}
search(t) {
search(t) {
this.offersData = this.tempSearch.filter((post, index) => {
if (post.Title.toLowerCase().indexOf(t.toLowerCase()) > -1)
return true;
});
}
async openModel() {
// const modal = await this.modalController.create({
// component: FilterComponent,
@ -136,4 +142,45 @@ export class HomeComponent implements AfterViewInit {
// modal.present();
this.cs.navigateForward('/offersdiscount/filter-page');
}
loadData(event) {
const counter = 1;
this.itemCounter += counter;
console.log(this.itemType);
if (this.itemType) {
setTimeout(() => {
event.target.complete();
console.log(this.itemCounter);
this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry'), this.itemCounter, this.itemType).subscribe((res) => {
const data = JSON.parse(res['Mohemm_ITG_ResponseItem']);
if (data['result']){
const allItem = JSON.parse(data.result['data']);
if (allItem) {
allItem.forEach(element => {
this.offersData.push(element);
});
}
}
});
// event.target.disabled = true;
}, 1000);
} else {
setTimeout(() => {
event.target.complete();
console.log(this.itemCounter);
this.offersService.getOffers({}, () => { }, this.ts.trPK('general', 'retry'), this.itemCounter).subscribe((res) => {
const data = JSON.parse(res['Mohemm_ITG_ResponseItem']);
if (data['result']){
const allItem = JSON.parse(data.result['data']);
if (allItem) {
allItem.forEach(element => {
this.offersData.push(element);
});
}
}
});
// event.target.disabled = true;
}, 1000);
}
}
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save