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

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

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

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