diff --git a/Mohem/src/app/app.component.html b/Mohem/src/app/app.component.html index b9e9c73a..22efebdf 100644 --- a/Mohem/src/app/app.component.html +++ b/Mohem/src/app/app.component.html @@ -175,6 +175,26 @@ {{ts.trPK('userProfile','HR-Request')}} +
+ + + + + + + {{menu.MENU_NAME}} + + +
+ + + + + + + {{ts.trPK('general','pending-transaction')}} + + diff --git a/Mohem/src/app/eit/home/home.component.ts b/Mohem/src/app/eit/home/home.component.ts index e1b4c534..b3fd95e5 100644 --- a/Mohem/src/app/eit/home/home.component.ts +++ b/Mohem/src/app/eit/home/home.component.ts @@ -46,7 +46,7 @@ export class HomeComponent implements OnInit { this.selectedMenu = index; } } - if (page['FUNCTION_NAME'] == 'HR_TERM_SS') { + if (page['FUNCTION_NAME'] == 'HR_TERM_SS' || page['FUNCTION_NAME'] == 'HR_TERM_EMP_SS') { this.cs.sharedService.setSharedData(page, TerminationServiceService.TERMINATION_PAGE); this.cs.openTermination(); diff --git a/Mohem/src/app/hmg-common/hmg-common.module.ts b/Mohem/src/app/hmg-common/hmg-common.module.ts index d0aa318e..3928d676 100644 --- a/Mohem/src/app/hmg-common/hmg-common.module.ts +++ b/Mohem/src/app/hmg-common/hmg-common.module.ts @@ -114,6 +114,9 @@ import { CardCalendarComponent } from './ui/card-calendar/card-calendar.componen import { WorklistSettingComponent } from '../notification/worklist-setting/worklist-setting.component'; import { SubmitAddressModalComponent } from '../profile/submit-eit-modal/submit-address-modal.component'; import { FileOpener } from '@ionic-native/file-opener/ngx'; +import { FilePath } from '@ionic-native/file-path/ngx'; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { IOSFilePicker } from '@ionic-native/file-picker/ngx'; @NgModule({ imports: [ CommonModule, @@ -310,7 +313,10 @@ import { FileOpener } from '@ionic-native/file-opener/ngx'; OpenNativeSettings, BarcodeScanner, BackgroundGeolocation, - FileOpener + FileOpener, + FilePath, + FileChooser, + IOSFilePicker ], entryComponents: [DateInfoModalComponent, WorklistSettingComponent], }) diff --git a/Mohem/src/app/hmg-common/services/common/common.service.ts b/Mohem/src/app/hmg-common/services/common/common.service.ts index 677f6a8e..b38053f4 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -1376,6 +1376,9 @@ export class CommonService { public openCreateitems() { this.nav.navigateForward('/itemforsale/home'); } + public filterItemforSale() { + this.nav.navigateForward('/itemforsale/filter'); + } public navigatePage(path) { this.nav.navigateForward([path]); } @@ -1584,7 +1587,9 @@ export class CommonService { return this.totalCounter; } setTotalNumberOfWorklistRequest() { - this.totalCounter -= 1; + if (this.totalCounter > 0) { + this.totalCounter -= 1; + } this.sharedService.setSharedData(this.totalCounter, 'total-count'); } diff --git a/Mohem/src/app/hmg-common/services/connector/connector.service.ts b/Mohem/src/app/hmg-common/services/connector/connector.service.ts index 5a1959c6..f472cb49 100644 --- a/Mohem/src/app/hmg-common/services/connector/connector.service.ts +++ b/Mohem/src/app/hmg-common/services/connector/connector.service.ts @@ -27,8 +27,8 @@ export class ConnectorService { public static retryTimes = 0; public static timeOut = 180 * 1000; - // public static host = 'https://uat.hmgwebservices.com/'; - public static host = 'https://hmgwebservices.com/'; + public static host = 'https://uat.hmgwebservices.com/'; + // public static host = 'https://hmgwebservices.com/'; constructor(public httpClient: HttpClient, public cs: CommonService, diff --git a/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.html b/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.html index 5e4d2dac..f91aece1 100644 --- a/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.html +++ b/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.html @@ -1,13 +1,40 @@ - - - - {{'general,select-attachment' | translate}} - + -
- -

{{file.name}}

-

-
-
\ No newline at end of file + + + + {{'general,select-attachment' | translate}} + + + + + + + + + + +
+
+
X
+ +
+ +
+
+ +
+
+
+
+ +
+ {{errorMsg}} +
\ No newline at end of file diff --git a/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.scss b/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.scss index 56325173..6b308e7b 100644 --- a/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.scss +++ b/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.scss @@ -2,4 +2,21 @@ width: .7cm; height: .6cm; vertical-align: middle; +} +.closed{ + position: absolute; + right: 0; + font-size: 14px; + color: #fff; + top: -5px; + right: -10px; + font-weight: bolder; + background: red; + padding: 6px; + border-radius: 50%; + text-align: center; + line-height: .7; +} +.image-container{ + margin-top: 10px; } \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.ts b/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.ts index 9df5a0c8..1a96a9e0 100644 --- a/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.ts +++ b/Mohem/src/app/hmg-common/ui/file-uploader/file-uploader.component.ts @@ -1,100 +1,288 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { CommonService } from 'src/app/hmg-common/services/common/common.service'; -import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; -import { AlertController } from '@ionic/angular'; +import { Component, OnInit, Input, Output, EventEmitter, NgZone } from "@angular/core"; +import { CommonService } from "src/app/hmg-common/services/common/common.service"; +import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; +import { AlertController, ActionSheetController, Platform } from "@ionic/angular"; +import { + Camera, + CameraOptions, + PictureSourceType +} from "@ionic-native/Camera/ngx"; +import { FileChooser } from "@ionic-native/file-chooser/ngx"; +import { File } from "@ionic-native/file/ngx"; +import { FilePath } from "@ionic-native/file-path/ngx"; +import { Base64 } from "@ionic-native/base64/ngx"; +import { IOSFilePicker } from '@ionic-native/file-picker/ngx'; +import { Location } from '@angular/common'; +import { DomSanitizer, SafeUrl } from "@angular/platform-browser"; -export interface CustomWindow extends Window { - File: any; - FileReader: any; -} -declare let window: CustomWindow; - @Component({ - selector: 'file-uploader', - templateUrl: './file-uploader.component.html', - styleUrls: ['./file-uploader.component.scss'] + selector: "file-uploader", + templateUrl: "./file-uploader.component.html", + styleUrls: ["./file-uploader.component.scss"] }) export class FileUploaderComponent implements OnInit { @Input() multiupload = false; - @Input() attachmentname = 'attachment-loader'; + @Input() attachmentname = "attachment-loader"; public attachmentData: string; - @Input() maxFileSize = 10 * 1024 * 1024; + public errorMsg: string; + public selectedOpn: number = 1; + public allowdType: any = ["jpg", "jpeg", "png", "gif", "pdf", "doc", "docx"]; + @Input() maxFileSize = 5 * 1024 * 1024; @Output() fileSelected = new EventEmitter(); public inputFiles: any = []; - public attachmentImg = 'assets/icon/attachment.png'; - public deleteImg = 'assets/icon/delete.png'; + public attachmentImg = "assets/icon/attachment.png"; + public deleteImg = "assets/icon/delete.png"; + public nativePath: any; + public actionSheet: any; + public isActionSheetShown: boolean = false; + @Input() selectedAttachment = []; constructor( public cs: CommonService, public ts: TranslatorService, - public alertController: AlertController - ) { - } + public alertController: AlertController, + private cameraController: Camera, + private actionSheetController: ActionSheetController, + private fileChooser: FileChooser, + private file: File, + private filePath: FilePath, + public base64: Base64, + public platform: Platform, + private iOSfilePicker: IOSFilePicker, + public ngzone: NgZone, + public loc: Location, + public sanitizer: DomSanitizer + ) { } ngOnInit() { + this.platform.backButton.subscribeWithPriority(9999, () => { + // You decide what happens + if (this.isActionSheetShown) + this.actionSheet.dismiss(); + else + this.loc.back(); + }); + this.inputFiles = this.selectedAttachment; } - - public loadAttachment(changeEvent) { - const fileInput = this.getFileElement(); - if (this.isFileSupported()) { - if (fileInput.files != null && fileInput.files.length > 0) { - const file = fileInput.files[0]; - const reader = new FileReader(); - if (file.size <= this.maxFileSize) { - reader.onload = (data) => { - if (this.multiupload) { - this.inputFiles.push({name: file.name, data: data.target['result']}); - } else { - this.inputFiles = [{name: file.name, data: data.target['result']}]; - } - this.fileSelected.emit( { - name: file.name , - data: data.target['result'], - inputFiles: this.inputFiles - }); - }; - reader.readAsDataURL(file); - } else { - this.attachmentData = null; - changeEvent.target.value = ''; // remove current selection - this.showFileExceededMaxSize(); - } - } else { - this.attachmentData = null; - } - } + ngOnDestroy(): void { } + async openFile() { + if (this.platform.is('ios')) + this.openiOSActionSheet(); + else + this.openAndroidActionSheet(); + //this.openiOSActionSheet(); - private isFileSupported() { - return (window.FileReader && window.File); } + async openAndroidActionSheet() { + this.actionSheet = await this.actionSheetController.create({ + header: this.ts.trPK("itemforsale", "slect-source-file"), //"Select Image file", - private showFileExceededMaxSize() { - this.cs.presentConfirmDialog( - this.ts.trPK('general', 'large-file'), - () => { - this.openFile(); - }, - () => { - } - ); + buttons: [ + { + text: this.ts.trPK("itemforsale", "from-library"), + handler: () => { + this.takePictureiOS(); + } + }, + { + text: this.ts.trPK("itemforsale", "from-camera"), + handler: () => { + this.takePicture(this.cameraController.PictureSourceType.CAMERA); + } + }, + { + text: this.ts.trPK("general", "cancel"), + role: "cancel" + } + ] + }); + this.isActionSheetShown = true; + await this.actionSheet.present(); } - private getFileElement(): HTMLInputElement { - return document.getElementById(this.attachmentname) as HTMLInputElement; + async openiOSActionSheet() { + this.actionSheet = await this.actionSheetController.create({ + header: this.ts.trPK("itemforsale", "slect-source-file"), //"Select Image file", + buttons: [ + { + text: this.ts.trPK("itemforsale", "from-library"), + handler: () => { + this.takePictureiOS(); + } + }, + { + text: this.ts.trPK("itemforsale", "from-camera"), + handler: () => { + this.takePicture(this.cameraController.PictureSourceType.CAMERA); + } + }, + + { + text: this.ts.trPK("itemforsale", "from-icloud"), + handler: () => { + this.takePicture(this.cameraController.PictureSourceType.PHOTOLIBRARY); + } + }, + { + text: this.ts.trPK("general", "cancel"), + role: "cancel" + } + ] + }); + this.isActionSheetShown = true; + await this.actionSheet.present(); } - public openFile() { - const fileInput = this.getFileElement(); - fileInput.click(); + public takePictureiOS() { + const options: CameraOptions = { + quality: 60, + sourceType: this.cameraController.PictureSourceType.PHOTOLIBRARY, + destinationType: this.cameraController.DestinationType.DATA_URL, + encodingType: this.cameraController.EncodingType.JPEG, + mediaType: this.cameraController.MediaType.PICTURE, + correctOrientation: true, + } + this.cameraController.getPicture(options).then((imageData) => { + const data = "data:image/jpeg;base64," + imageData; + this.pushFiles(this.getFileName(), data); + }, (err) => { + }); } + public deleteFiles(index: number) { this.inputFiles.splice(index, 1); - this.fileSelected.emit( { + this.fileSelected.emit({ name: null, - data: '', + data: "", inputFiles: this.inputFiles }); + this.errorMsg = null; + } + public switchOptions($event) { + this.selectedOpn = $event; + } + public takePicture(sourceType: PictureSourceType) { + const options: CameraOptions = { + quality: 50, + destinationType: this.cameraController.DestinationType.DATA_URL, + encodingType: this.cameraController.EncodingType.JPEG, + sourceType: sourceType, + mediaType: this.cameraController.MediaType.PICTURE, + correctOrientation: true + }; + if (sourceType === this.cameraController.PictureSourceType.PHOTOLIBRARY) { + if (this.platform.is('android')) { + this.fileChooser + .open() + .then(uri => { + this.readFile(uri); + }) + .catch(e => { }); + } else { + this.iOSfilePicker.pickFile(['public.content']).then(uri => { + + let correctPath = uri.substr(0, uri.lastIndexOf('/') + 1); + let currentName = uri.substring(uri.lastIndexOf('/') + 1); + this.nativePath = uri; + + this.file.readAsDataURL("file:///" + correctPath, currentName).then(result => { + this.pushFiles(currentName, result); + }).catch(e => { }); + }).catch(e => { }); + } + } else { + this.cameraController.getPicture(options).then(imageData => { + const data = "data:image/jpeg;base64," + imageData; + this.pushFiles(this.getFileName(), data); + }); + } + } + pushFiles(name, files) { + this.ngzone.run(() => { + if (this.multiupload) { + this.inputFiles.push({ name: name, data: files }); + } else { + this.inputFiles = [{ name: name, data: files }]; + } + this.fileSelected.emit({ + name: name, + data: files, + inputFiles: this.inputFiles + }); + }); + } + readFile(fileUrl: any) { + this.filePath.resolveNativePath(fileUrl).then(filePathResult => { + this.nativePath = filePathResult; + this.file.resolveLocalFilesystemUrl(this.nativePath).then(entry => { + entry.getMetadata(metadata => { + if (metadata.size <= this.maxFileSize) { + this.errorMsg = null; + this.encodeFiles(entry); + } else { + this.errorMsg = this.ts.trPK("general", "large-file"); + } + }, (error) => { + console.log(error) + }); + }); + }); + } + getImgContent(imgFile, data): SafeUrl { + console.log(imgFile); + return this.sanitizer.bypassSecurityTrustUrl(imgFile); + } + + checkDuplicate(name: string) { + return this.inputFiles.filter(a => { + return a.name === name; + }); + } + encodeFiles(entry) { + let fileName = entry.nativeURL.split('/').pop(); + let path = entry.nativeURL.substring(0, entry.nativeURL.lastIndexOf("/") + 1); + + this.file.readAsDataURL(path, fileName) + .then(base64File => { + }) + .catch((err) => { + console.log('Error reading file', err); + }) + this.base64.encodeFile(this.nativePath).then( + (base64File: string) => { + const type = this.nativePath.substr( + this.nativePath.lastIndexOf(".") + 1 + ); + if (this.allowdType.includes(type.toLowerCase())) { + if (this.checkDuplicate(entry.name).length === 0) { + this.pushFiles(entry.name, base64File); + this.errorMsg = null; + } else { + this.errorMsg = this.ts.trPK("general", "file-name-exist"); + } + } else { + this.attachmentData = null; + this.errorMsg = this.ts.trPK("general", "not-supported"); + } + }, + err => { + console.log(err); + } + ); + } + getFileName() { + const date = new Date().valueOf(); + let text = ""; + const possibleText = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + for (let i = 0; i < 5; i++) { + text += possibleText.charAt( + Math.floor(Math.random() * possibleText.length) + ); + } + const imageName = date + "." + text + ".jpeg"; + return imageName; } } diff --git a/Mohem/src/app/itemforsale/filter/filter.component.html b/Mohem/src/app/itemforsale/filter/filter.component.html new file mode 100644 index 00000000..4b1df28c --- /dev/null +++ b/Mohem/src/app/itemforsale/filter/filter.component.html @@ -0,0 +1,35 @@ + + + + + +
+ + + + {{key.title}} + + + {{key.title_ar}} + + +
+
+
+ + +
+ + +
+ + {{ts.trPK('general','apply-filters')}} + +
+
+
\ No newline at end of file diff --git a/Mohem/src/app/itemforsale/filter/filter.component.scss b/Mohem/src/app/itemforsale/filter/filter.component.scss new file mode 100644 index 00000000..2375e2ef --- /dev/null +++ b/Mohem/src/app/itemforsale/filter/filter.component.scss @@ -0,0 +1,38 @@ +ion-label{ + font-size: 14px !important; +} +ion-thumbnail img{ + width: 40px; + height: 40px; + margin: 10px; +} +.active::before{ + position: absolute; + right: 10px; + top: 15px; + padding: 0px; + background: #3cc353; + padding: 3px 2px 1px 3px; + border-radius: 60%; + font-size: 12px; + color: #fff; + content: '✓'; + width: 20px; + height: 20px; + text-align: center; + z-index: 2; +} +ion-item{ + border-bottom: 1px solid #ccc; + --padding-start: 0px; + margin: 0 20px 4px 20px; +} + +.footer-button{ + background: var(--newgreen)!important;border-radius: 10px; --background: transparent; + width: 80%; +} +ion-footer{ + position: fixed; + bottom: 0; +} \ No newline at end of file diff --git a/Mohem/src/app/itemforsale/filter/filter.component.spec.ts b/Mohem/src/app/itemforsale/filter/filter.component.spec.ts new file mode 100644 index 00000000..ff6002ba --- /dev/null +++ b/Mohem/src/app/itemforsale/filter/filter.component.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FilterComponent } from './filter.component'; + +describe('FilterComponent', () => { + let component: FilterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FilterComponent ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FilterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/itemforsale/filter/filter.component.ts b/Mohem/src/app/itemforsale/filter/filter.component.ts new file mode 100644 index 00000000..ddfdc0ce --- /dev/null +++ b/Mohem/src/app/itemforsale/filter/filter.component.ts @@ -0,0 +1,56 @@ +import { AfterViewInit, Component, OnInit } from '@angular/core'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { ModalController } from '@ionic/angular'; +import { OfferDiscountService } from 'src/app/offersdiscount/services/service'; +import { ItemForSaleService } from '../services/service.service'; +@Component({ + selector: 'app-filter', + templateUrl: './filter.component.html', + styleUrls: ['./filter.component.scss'], +}) +export class FilterComponent implements AfterViewInit { + + segment: any = '1'; + categoriesObj: any; + categories: any = []; + offersData: any = []; + activeClass: any; + tempSearch: any = []; + searchText: String; + public activeKey = {} + direction: any; + + constructor(public ts: TranslatorService, public modalController: ModalController, public cs: CommonService, public offersService: OfferDiscountService) { } + + ngAfterViewInit(): void { + this.direction = TranslatorService.getCurrentDirection(); + this.categories = this.cs.sharedService.getSharedData(OfferDiscountService.categories, false); + + + // this.getOfferDiscount(); + } + + + openDetails(offer) { + // this.cs.sharedService.setSharedData(offer, OfferDiscountService.selected_offers); + + // var related = this.offersData.filter((res) => res.rowID != offer.rowID); + // this.cs.sharedService.setSharedData(related, OfferDiscountService.related_offers); + + // this.cs.navigateForward('/offersdiscount/offer-details'); + } + + + filterOffers(key) { + this.activeKey = key + this.activeClass = key.title; + + } + + + applyFilters() { + this.cs.sharedService.setSharedData(this.activeKey, ItemForSaleService.selected_filters); + this.cs.back(); + } +} diff --git a/Mohem/src/app/itemforsale/home/home.component.html b/Mohem/src/app/itemforsale/home/home.component.html index 7b21c88b..7ae95d62 100644 --- a/Mohem/src/app/itemforsale/home/home.component.html +++ b/Mohem/src/app/itemforsale/home/home.component.html @@ -128,7 +128,7 @@

{{ts.trPK('itemforsale','item-price')}}

- +
@@ -138,29 +138,14 @@
- - + + + +
- - - - - - -
-
-
X
- -
- -
-
- -
-
-
-
+
@@ -190,7 +175,7 @@ - + @@ -223,7 +208,7 @@
- + {{ts.trPK('general','cancel')}} @@ -233,9 +218,9 @@
- + {{ts.trPK('general','cancel')}} - + {{ts.trPK('general','next')}} diff --git a/Mohem/src/app/itemforsale/home/home.component.ts b/Mohem/src/app/itemforsale/home/home.component.ts index 1806a353..cb4b10fe 100644 --- a/Mohem/src/app/itemforsale/home/home.component.ts +++ b/Mohem/src/app/itemforsale/home/home.component.ts @@ -19,6 +19,7 @@ export class HomeComponent implements OnInit { public selectedFile: any; indexLastObj: any = 0; addAttachRequest: any = []; + selectedPicture = []; selectedCategory: any; filterAllowedType: any = [ "image/jpeg", @@ -37,6 +38,7 @@ export class HomeComponent implements OnInit { ngOnInit() { this.direction = TranslatorService.getCurrentDirection(); this.categories = this.cs.sharedService.getSharedData(ItemForSaleService.CATEGORIES, false); + this.categories.shift(); this.getRegion(); this.editItem = this.cs.sharedService.getSharedData(ItemForSaleService.EDIT_ITEMS); if (this.editItem) { @@ -86,59 +88,59 @@ export class HomeComponent implements OnInit { - onFileSelected(input) { - if (!(this.filterAllowedType.indexOf(input.target.files[0].type) > -1)) { - let msg: string = ""; - msg = this.ts.trPK("general", "notSupportFile"); - this.cs.presentAlert(msg); - return; - } // todo: show alert that you tried uploading wrong files - else { - const file = input.target.files[0]; - this.selectedFile = input.target.files; + // onFileSelected(input) { + // if (!(this.filterAllowedType.indexOf(input.target.files[0].type) > -1)) { + // let msg: string = ""; + // msg = this.ts.trPK("general", "notSupportFile"); + // this.cs.presentAlert(msg); + // return; + // } // todo: show alert that you tried uploading wrong files + // else { + // const file = input.target.files[0]; + // this.selectedFile = input.target.files; - this.getBase64(file).then(data => - this.pushObject(data, file.name, file.type) - ); - } - } + // this.getBase64(file).then(data => + // this.pushObject(data, file.name, file.type) + // ); + // } + // } - getBase64(file) { - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = () => resolve(reader.result); - reader.onerror = error => reject(error); - }); - } + // getBase64(file) { + // return new Promise((resolve, reject) => { + // const reader = new FileReader(); + // reader.readAsDataURL(file); + // reader.onload = () => resolve(reader.result); + // reader.onerror = error => reject(error); + // }); + // } - pushObject(fileData, name, type) { + // pushObject(fileData, name, type) { - this.indexLastObj++; - try { - let array = name.split("."); - let attachType: string = array[array.length - 1]; + // this.indexLastObj++; + // try { + // let array = name.split("."); + // let attachType: string = array[array.length - 1]; - this.addAttachRequest.push({ - AttachmentID: this.indexLastObj, - ContentType: 'image/' + attachType, //type.split('/')[1], - Base64Data: fileData.split(",")[1], - FileName: name, //.split('.')[0], + // this.addAttachRequest.push({ + // AttachmentID: this.indexLastObj, + // ContentType: 'image/' + attachType, //type.split('/')[1], + // Base64Data: fileData.split(",")[1], + // FileName: name, //.split('.')[0], - }); - } catch (e) { } - } + // }); + // } catch (e) { } + // } removeFile(objectitem) { - let objIndex1 = this.uploader.queue.findIndex(item => item == objectitem); - this.uploader.queue.splice(objIndex1, 1); + let objIndex = this.addAttachRequest.findIndex( item => item.AttachmentID == objectitem.AttachmentID ); this.addAttachRequest.splice(objIndex, 1); } getImgContent(imgFile): SafeUrl { + return this.sanitizer.bypassSecurityTrustUrl(imgFile); } @@ -205,17 +207,17 @@ export class HomeComponent implements OnInit { this.itemPrice = this.editItem.quotePrice; this.regionID = this.editItem.regionID; this.itemCondition = this.editItem.status.toLowerCase(); - this.addAttachRequest = this.getAttachment(this.editItem.itemAttachments); + this.selectedPicture = this.getAttachment(this.editItem.itemAttachments); } getAttachment(itemsArray) { let item = []; itemsArray.forEach(element => { item.push({ - attachmentId: element.attachmentId, - ContentType: element.contentType, - Base64Data: element.content, - FileName: element.fileName, + // attachmentId: element.attachmentId, + // ContentType: element.contentType, + data: 'data:image/png;base64,' + element.content, + name: element.fileName, }); }); @@ -262,4 +264,52 @@ export class HomeComponent implements OnInit { }) } + cancelItem() { + if (this.step == 2 || this.step == 3) { + this.step = 1; + } else { + this.cs.back(); + } + + } + validate() { + if (!this.validateChar(this.itemInfo) || !this.itemDescription || !this.itemPrice || !this.itemCondition) { + return false; + } else { + return true; + } + } + validateChar(text) { + var regExp = /^[a-zA-Z]*$/ + if ((!regExp.test(text) && !this.hasArabicCharacters(text)) || !text) { + return false; + } + else { + return true; + } + } + hasArabicCharacters(text) { + var regex = new RegExp("[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufc3f]|[\ufe70-\ufefc]"); + return regex.test(text); + } + public attachmentSelected(event: any) { + try { + this.addAttachRequest = event.inputFiles.map((res: any) => { + let array = res.name.split("."); + let attachType: string = array[array.length - 1]; + this.indexLastObj++; + return { AttachmentID: this.indexLastObj, FileName: res.name, Base64Data: res.data.split(",")[1], ContentType: 'image/' + attachType }; + }); + + + + + + + + + + + } catch (e) { } + } } diff --git a/Mohem/src/app/itemforsale/item-details/item-details.component.html b/Mohem/src/app/itemforsale/item-details/item-details.component.html index 00a52680..981c2446 100644 --- a/Mohem/src/app/itemforsale/item-details/item-details.component.html +++ b/Mohem/src/app/itemforsale/item-details/item-details.component.html @@ -12,6 +12,7 @@
+ diff --git a/Mohem/src/app/itemforsale/itemforsale.module.ts b/Mohem/src/app/itemforsale/itemforsale.module.ts index e8833935..cba071d8 100644 --- a/Mohem/src/app/itemforsale/itemforsale.module.ts +++ b/Mohem/src/app/itemforsale/itemforsale.module.ts @@ -13,6 +13,7 @@ import { MyAdsComponent } from './my-ads/my-ads.component'; import { HmgCommonModule } from '../hmg-common/hmg-common.module'; import { ItemForSaleService } from './services/service.service'; import { SanitizeHtmlPipe } from './services/domsafe'; +import { FilterComponent } from './filter/filter.component'; const routes: Routes = [ { @@ -34,6 +35,10 @@ const routes: Routes = [ { path: 'my-ads', component: MyAdsComponent + }, + { + path: 'filter', + component: FilterComponent } ], } @@ -47,7 +52,7 @@ const routes: Routes = [ HmgCommonModule, RouterModule.forChild(routes) ], - declarations: [ItemforsalePage, HomeComponent, ItemsComponent, ItemDetailsComponent, MyAdsComponent, SanitizeHtmlPipe], + declarations: [ItemforsalePage, HomeComponent, ItemsComponent, ItemDetailsComponent, MyAdsComponent, SanitizeHtmlPipe, FilterComponent], providers: [ItemForSaleService], exports: [SanitizeHtmlPipe] }) diff --git a/Mohem/src/app/itemforsale/items/items.component.html b/Mohem/src/app/itemforsale/items/items.component.html index 26778eb1..e17dacd4 100644 --- a/Mohem/src/app/itemforsale/items/items.component.html +++ b/Mohem/src/app/itemforsale/items/items.component.html @@ -37,7 +37,7 @@

{{ts.trPK('itemforsale','browse-categories')}}

- + @@ -63,7 +63,7 @@
- + diff --git a/Mohem/src/app/itemforsale/items/items.component.ts b/Mohem/src/app/itemforsale/items/items.component.ts index a96d2a9e..a98e1105 100644 --- a/Mohem/src/app/itemforsale/items/items.component.ts +++ b/Mohem/src/app/itemforsale/items/items.component.ts @@ -22,13 +22,28 @@ export class ItemsComponent implements OnInit { pageNo: number = 1; tempSearch: any = []; itemsByEmployee: any = []; + allCategory = { + categoryID: 0, + content: '', + isActive: true, + title: "All", + title_Ar: "الجميع", + } constructor(public ts: TranslatorService, public route: ActivatedRoute, private sanitizer: DomSanitizer, public cs: CommonService, private itemService: ItemForSaleService, private authService: AuthenticationService) { this.route .params.subscribe(val => { setTimeout(() => { this.cs.startLoading(); - this.getItemsCategories(); - this.getItemsByEmployee(); + var selectedFilter = this.cs.sharedService.getSharedData(ItemForSaleService.selected_filters); + if (selectedFilter) { + this.selectCategory(selectedFilter); + } + else { + this.getItemsCategories(); + this.getItemsByEmployee(); + } + + }, 100); }); @@ -43,6 +58,7 @@ export class ItemsComponent implements OnInit { this.itemService.getCategories({}, () => { }, this.ts.trPK('general', 'retry')).subscribe((result) => { this.categories = this.itemService.parser(result); + this.categories.unshift(this.allCategory); this.cs.sharedService.setSharedData(this.categories, ItemForSaleService.CATEGORIES); }) this.itemService.getItems({ pageNo: this.pageNo }, () => { }, this.ts.trPK('general', 'retry')).subscribe((result) => { @@ -149,4 +165,7 @@ export class ItemsComponent implements OnInit { } }) } + openModel() { + this.cs.filterItemforSale(); + } } diff --git a/Mohem/src/app/itemforsale/services/service.service.ts b/Mohem/src/app/itemforsale/services/service.service.ts index 62ce6e9b..80f4c644 100644 --- a/Mohem/src/app/itemforsale/services/service.service.ts +++ b/Mohem/src/app/itemforsale/services/service.service.ts @@ -17,6 +17,7 @@ export class ItemForSaleService { public static ITEMS_SELECTED = 'item-selected'; public static CATEGORIES = 'categories'; public static EDIT_ITEMS = 'edit-items'; + public static selected_filters = 'selected_filter'; constructor( public con: ConnectorService, private authService: AuthenticationService, diff --git a/Mohem/src/app/profile/home/home.component.ts b/Mohem/src/app/profile/home/home.component.ts index 5bfbba0b..8aba0e1c 100644 --- a/Mohem/src/app/profile/home/home.component.ts +++ b/Mohem/src/app/profile/home/home.component.ts @@ -323,7 +323,7 @@ export class HomeComponent implements OnInit { } else if (allowVal == 'contact') { this.openContact() - } else if ('add-update-contact') { + } else if (allowVal == 'add-update-contact') { this.transactionNo++; this.cs.sharedService.setSharedData({ dirfromNotificationPage: false, submitEITObjList: undefined, transNo: this.transactionNo }, 'AddEITData'); this.cs.openAddUpdateContact(); diff --git a/Mohem/src/app/reports/concurrent-report/concurrent-report.component.ts b/Mohem/src/app/reports/concurrent-report/concurrent-report.component.ts index 456a45c8..8fb275f0 100644 --- a/Mohem/src/app/reports/concurrent-report/concurrent-report.component.ts +++ b/Mohem/src/app/reports/concurrent-report/concurrent-report.component.ts @@ -48,7 +48,7 @@ export class ConcurrentReportComponent implements OnInit { private validEitTransactionTbl: any = []; eitSubmitAction: number = 0; updatedValues: any = []; - comtransNo: any = 0; + comtransNo: any = 1; programList: any = []; public template: any; constructor(public cs: CommonService, private elementRef: ElementRef, public reports: ReportServiceService, public ts: TranslatorService, public eitService: EitService) { } diff --git a/Mohem/src/assets/icon/select-all.svg b/Mohem/src/assets/icon/select-all.svg new file mode 100644 index 00000000..f053110b --- /dev/null +++ b/Mohem/src/assets/icon/select-all.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index ed25d049..2c05fc99 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -3213,6 +3213,22 @@ } }, "itemforsale": { + "slect-source-file": { + "en": "Select source file", + "ar": "حدد مصدر الملف" + }, + "from-camera": { + "en": "Use Camera", + "ar": "استخدام الكاميرا" + }, + "from-library": { + "en": "From Library", + "ar": "من ملفات الجهاز" + }, + "from-icloud": { + "en": "From iCloud Drive", + "ar": "من iCloud Drive" + }, "warning": { "en": "This ad will be valid for 2 week after approval", "ar": "هذا الإعلان ساري المفعول لمدة أسبوعين بعد الموافقة"