diff --git a/CHANGELOG.md b/CHANGELOG.md index cea672e..bb37c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +# v0.0.3 + +* Improve Feedback submission +* Improve colouring of popover screens +* Added minimum limit to submission date for receipt +* Fixes for resetting receipt form +* Better error messages on receipt submit +* Fix date format for backend server + # v0.0.2 * Reduced image quality to increase upload speed diff --git a/config.xml b/config.xml index 4c759cd..33a06bf 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + LocalLoop Tracking Local Money for Local People. Pear Trading Development Team diff --git a/src/app/app.scss b/src/app/app.scss index bace1cc..a4257c0 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -28,6 +28,11 @@ ion-app.md { background: none; } +.alert-md .alert-title { + color: color($colors, primary); + text-align: center; +} + .item-submit { font-size: 1.2em; color: rgba(255, 255, 255, .8); diff --git a/src/declarations.d.ts b/src/declarations.d.ts deleted file mode 100644 index 423e2f1..0000000 --- a/src/declarations.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - Declaration files are how the Typescript compiler knows about the type information(or shape) of an object. - They're what make intellisense work and make Typescript know all about your code. - - A wildcard module is declared below to allow third party libraries to be used in an app even if they don't - provide their own type declarations. - - To learn more about using third party libraries in an Ionic app, check out the docs here: - http://ionicframework.com/docs/v2/resources/third-party-libs/ - - For more info on type definition files, check out the Typescript docs here: - https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html -*/ -declare module '*'; \ No newline at end of file diff --git a/src/pages/feedback/feedback.ts b/src/pages/feedback/feedback.ts index fe8b755..95384dc 100644 --- a/src/pages/feedback/feedback.ts +++ b/src/pages/feedback/feedback.ts @@ -54,6 +54,9 @@ export class FeedbackPage { result => { console.log('Form submitted!'); this.presentToast('Feedback succesfully submitted.'); + this.feedbackForm.patchValue({ + feedbacktext: '', + }); }, error => { console.log(JSON.parse(error._body).message); diff --git a/src/pages/receipt/receipt.html b/src/pages/receipt/receipt.html index 1001130..71ff907 100644 --- a/src/pages/receipt/receipt.html +++ b/src/pages/receipt/receipt.html @@ -69,7 +69,7 @@ Click to Edit Time of Purchase - + diff --git a/src/pages/receipt/receipt.ts b/src/pages/receipt/receipt.ts index ecca4f7..e8387e3 100644 --- a/src/pages/receipt/receipt.ts +++ b/src/pages/receipt/receipt.ts @@ -4,6 +4,7 @@ import { LoadingController, Loading, ToastController } from 'ionic-angular'; import { AlertController, ActionSheetController } from 'ionic-angular'; +import { convertDataToISO } from 'ionic-angular/util/datetime-util'; import { Camera, CameraOptions } from '@ionic-native/camera'; import { FilePath } from '@ionic-native/file-path'; import { Transfer } from '@ionic-native/transfer'; @@ -54,6 +55,7 @@ export class ReceiptPage { currentStep: number = 1; myDate: string; + minDate: any; constructor( public actionSheetCtrl: ActionSheetController, @@ -72,32 +74,27 @@ export class ReceiptPage { public alertCtrl: AlertController // alert screen for confirmation of receipt entries ) { this.myDate = moment().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); - } - // calculateTime(offset: any) { - // // create Date object for current location - // let d = new Date(); - // - // // create new Date object using supplied offset - // let nd = new Date(d.getTime() + (3600000 * offset)); - // - // return nd.toISOString(); - // } - // - // stdTimezoneOffset(today: any) { - // let jan = new Date(today.getFullYear(), 0, 1); - // let jul = new Date(today.getFullYear(), 6, 1); - // return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); - // } - // - // dst(today: any) { - // return today.getTimezoneOffset() < this.stdTimezoneOffset(today); - // } + } ionViewDidEnter(){ this.platform.ready().then(() => { this.keyboard.disableScroll(true); }); + this.getMinDate(); + } + + getMinDate(){ + // gets the April 1st date of the current year + let aprilDate = moment().month(3).date(1); + let now = moment(); + // Checks if current time is before April 1st, if so returns true + let beforeApril = now.isBefore(aprilDate); + if ( beforeApril == true ) { + this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); + } else { + this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); + } } previousStep(){ @@ -271,12 +268,18 @@ export class ReceiptPage { // // File name only var filename = this.lastImage; var myParams: any; + let purchaseTime: string; + if ( typeof( this.myDate ) === 'string' ) { + purchaseTime = this.myDate; + } else { + purchaseTime = convertDataToISO( this.myDate ); + } switch(this.transactionAdditionType){ case 1: myParams = { transaction_type : this.transactionAdditionType, transaction_value : this.amount, - purchase_time : this.myDate, + purchase_time : purchaseTime, organisation_id : this.organisationId, }; break; @@ -284,7 +287,7 @@ export class ReceiptPage { myParams = { transaction_type : this.transactionAdditionType, transaction_value : this.amount, - purchase_time : this.myDate, + purchase_time : purchaseTime, organisation_id : this.organisationId, }; break; @@ -292,7 +295,7 @@ export class ReceiptPage { myParams = { transaction_type : this.transactionAdditionType, transaction_value : this.amount, - purchase_time : this.myDate, + purchase_time : purchaseTime, organisation_name : this.submitOrg.name, street_name : this.submitOrg.street_name, town : this.submitOrg.town, @@ -309,16 +312,30 @@ export class ReceiptPage { this.peopleService.upload(myParams, targetPath).subscribe( response => { - console.log('Successful Upload'); - console.log(response); - this.loading.dismiss(); - this.readSubmitPrompt(); + if( response.success == true ) { + console.log('Successful Upload'); + console.log(response); + this.loading.dismiss(); + this.readSubmitPrompt(); + this.resetForm(); + } else { + console.log('Upload Error'); + this.loading.dismiss(); + this.presentToast(JSON.stringify(response.status) + 'Error, ' + JSON.stringify(response.message)); + } }, err => { console.log('Upload Error'); console.log(err); this.loading.dismiss(); - this.presentToast('Error while uploading:' + JSON.stringify(err)); + let errorString; + try { + let jsonError = JSON.parse(err.body); + errorString = JSON.stringify(jsonError.status) + 'Error, ' + JSON.stringify(jsonError.message); + } catch(e) { + errorString = 'There was a server error, please try again later.'; + } + this.presentToast(errorString); } ); } @@ -330,9 +347,13 @@ export class ReceiptPage { town: '', postcode: '', }; + this.storeList = null; this.amount = null; this.lastImage = null; + this.step1Invalid = true; + this.step2Invalid = true; this.currentStep = 1; + this.myDate = moment().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); } // Create a new name for the image @@ -360,7 +381,6 @@ export class ReceiptPage { buttons: [ { text: 'No Thanks', - role: 'Yes I do!', handler: () => { console.log('Cancel clicked'); this.navCtrl.setRoot(UserPage); @@ -370,7 +390,6 @@ export class ReceiptPage { text: 'Yes!', handler: () => { console.log('Form reset clicked'); - this.resetForm(); } } ] diff --git a/src/theme/variables.scss b/src/theme/variables.scss index e91b3e6..7365dd7 100644 --- a/src/theme/variables.scss +++ b/src/theme/variables.scss @@ -35,6 +35,7 @@ $colors: ( whitish: #fefefe, button-blue: #248ed0, light-grey: #9f9f9f, + background-blue: #34688d, ); @@ -64,14 +65,31 @@ $tabs-md-tab-color-active: rgba(255, 255, 255, 1); $grid-padding-width: 2px; -$alert-md-button-text-color: color($colors, secondary); +// $alert-md-button-text-color: color($colors, primary); +$alert-md-background-color: color($colors, background-blue); +$alert-md-message-text-color: color($colors, primary); +$alert-md-input-text-color: color($colors, primary); +$alert-md-radio-label-text-color: darken(color($colors, primary), 25%); +$alert-md-radio-label-text-color-checked: color($colors, primary); +$alert-md-button-text-align: center; +$alert-md-button-group-justify-content: center; +// These two below should work but are not in 3.4.2 +// $alert-md-button-padding-start: 20px; +// $alert-md-button-padding-end: 20px; +$alert-md-button-group-padding: 8px; +$alert-md-button-padding: 14px; +$alert-button-font-size: 18px; +$alert-md-border-radius: 10px; + + $label-md-text-color: color($colors, primary); $select-md-icon-color: color($colors, whitish); -$picker-md-button-text-color: color($colors, secondary); -$picker-md-option-selected-color: color($colors, button-blue); +// $picker-md-button-text-color: color($colors, secondary); +// $picker-md-option-selected-color: color($colors, button-blue); +$picker-md-background-color: color($colors, background-blue); /*$segment-button-md-border-bottom-color-activated: #ff0000;*/ // App Windows Variables