Skip to content

Commit

Permalink
Hotfix for the modal stuff in self service
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-marquardt committed Jun 14, 2017
1 parent 1f3c3fc commit 561e9eb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/app/components/self-service-point.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from "@angular/core";
import { FlashMessagesService } from "angular2-flash-messages/module";

declare var jQuery:any;

import { Cart, User, Identifiable, Product } from "app/models";
import { BackendService, ConfigService } from "app/services";
import { GlobalInput, KeyCode } from "app/utils";


@Component({
selector: 'self-service-point',
templateUrl: '../templates/self-service-point.html',
Expand All @@ -26,7 +28,8 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On

constructor(
private backend_service: BackendService,
private config_service: ConfigService
private config_service: ConfigService,
private flash_messages_service: FlashMessagesService
) {
super();
this.cart = new Cart();
Expand Down Expand Up @@ -76,7 +79,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
error => {
this.wait_identifier = false;
console.error(error);
this.modalDisplay('Not found!', 'No product or user with this barcode exists.');
this.flash_messages_service.show('Not found! No product or user with this barcode exists.', { cssClass: 'alert-danger' });
}
);
this.identifier_input = '';
Expand All @@ -85,15 +88,15 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
processItem(item: Identifiable): void {
if(item instanceof Product){
if(!this.user){
this.modalDisplay('Please scan your ID card first!', 'You have scanned a product, but you need to scan your ID card.');
this.flash_messages_service.show('Please scan your ID card first! You have scanned a product, but you need to scan your ID card.', { cssClass: 'alert-danger' });
return;
}
this.cart.addToCart(item.name, item.pricings[0]); // hackedyhack ... select proper pricing instead
this.updateCart();
}
else if(item instanceof User){
if(this.user){
this.modalDisplay('Already logged in!', 'You have already scanned an ID card. If you want to change the user, please abort this transaction.');
this.flash_messages_service.show('Already logged in! You have already scanned an ID card. If you want to change the user, please abort this transaction.', { cssClass: 'alert-danger' });
return;
}
this.user = item;
Expand All @@ -108,7 +111,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
cart => this.cart = cart,
error => {
console.error(error);
this.modalDisplay('Cart update failed!', 'The cart could not be updated, probably because the product is no longer available.');
this.flash_messages_service.show('Cart update failed! The cart could not be updated, probably because the product is no longer available.', { cssClass: 'alert-danger' });
}
);
}
Expand All @@ -122,7 +125,7 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
},
error => {
console.error(error);
this.modalDisplay('Cart payment failed!', 'The server did not accept the transaction, probably because your account balance is insufficient.');
this.flash_messages_service.show('Cart payment failed! The server did not accept the transaction, probably because your account balance is insufficient.', { cssClass: 'alert-danger' });
}
);
}
Expand All @@ -139,12 +142,13 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
}

abort(): void {
this.modalDisplay('Aborted', 'The checkout process has been aborted.');
this.flash_messages_service.show('The checkout process has been aborted.', { cssClass: 'alert-warning' });
this.cart = new Cart();
this.user = null;
this.mode = 0;
}

/*
modalDisplay(heading: string, text: string): void {
this.modal_heading = heading;
this.modal_text = text;
Expand All @@ -164,4 +168,5 @@ export class SelfServicePointComponent extends GlobalInput implements OnInit, On
jQuery(this.feedback_modal.nativeElement).modal('hide');
}, 4000);
}
*/
}

0 comments on commit 561e9eb

Please sign in to comment.