Enhance viewing key saving
This commit is contained in:
parent
92865a6ee3
commit
c9bf50170d
5 changed files with 80 additions and 41 deletions
|
@ -89,14 +89,14 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div style="height: 15px;"></div>
|
<div style="height: 15px;"></div>
|
||||||
<div width="100%"
|
<div *ngIf="!order.paid" width="100%"
|
||||||
style="font-size: 14px;
|
style="font-size: 14px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
text-align: center;">
|
text-align: center;">
|
||||||
{{ vE.invoiceScanQrcode }}
|
{{ vE.invoiceScanQrcode }}
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center;
|
<div *ngIf="!order.paid" style="text-align: center;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
line-height: 30px;">
|
line-height: 30px;">
|
||||||
<div style="font-family: 'Spartan';
|
<div style="font-family: 'Spartan';
|
||||||
|
|
|
@ -214,7 +214,8 @@ export class OrderComponent implements OnInit{
|
||||||
dialogConfig.disableClose = true;
|
dialogConfig.disableClose = true;
|
||||||
dialogConfig.autoFocus = true;
|
dialogConfig.autoFocus = true;
|
||||||
dialogConfig.data = {
|
dialogConfig.data = {
|
||||||
orderId: this.order._id
|
orderId: this.order._id,
|
||||||
|
orderToken: this.order.token
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log ('order_id : ' + this.order._id);
|
//console.log ('order_id : ' + this.order._id);
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<mat-form-field class="full-width"
|
<mat-form-field class="full-width"
|
||||||
appearance="fill">
|
appearance="fill">
|
||||||
<mat-label>{{ vE.settingsVkeyLbl }}</mat-label>
|
<mat-label>{{ vE.settingsVkeyLbl }}</mat-label>
|
||||||
<textarea matInput placeholder="{{ vE.settingsVkeyPlaceholder }}"
|
<textarea matInput [readonly]="vKaccess" placeholder="{{ vE.settingsVkeyPlaceholder }}"
|
||||||
formControlName="vKey">
|
formControlName="vKey">
|
||||||
</textarea>
|
</textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
|
@ -29,7 +29,6 @@ export class SettingsComponent implements OnInit {
|
||||||
owner: Owner;
|
owner: Owner;
|
||||||
useZats: boolean;
|
useZats: boolean;
|
||||||
proVersion: boolean = false;
|
proVersion: boolean = false;
|
||||||
useVKey: boolean = false;
|
|
||||||
linkMsg: string = '';
|
linkMsg: string = '';
|
||||||
xeroAccCod: string = '';
|
xeroAccCod: string = '';
|
||||||
saveAccOk: boolean = false;
|
saveAccOk: boolean = false;
|
||||||
|
@ -117,6 +116,7 @@ export class SettingsComponent implements OnInit {
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
languageRdy = new Subject<boolean>();
|
languageRdy = new Subject<boolean>();
|
||||||
|
vKaccess = true;
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -128,13 +128,11 @@ export class SettingsComponent implements OnInit {
|
||||||
private dialogRef: MatDialogRef<SettingsComponent>,
|
private dialogRef: MatDialogRef<SettingsComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: {o: Owner}) {
|
@Inject(MAT_DIALOG_DATA) public data: {o: Owner}) {
|
||||||
this.useZats = data.o.zats;
|
this.useZats = data.o.zats;
|
||||||
this.useVKey = data.o.payconf;
|
|
||||||
this.settingsForm = fb.group({
|
this.settingsForm = fb.group({
|
||||||
name: [data.o.name, Validators.required],
|
name: [data.o.name, Validators.required],
|
||||||
currency: [data.o.currency, Validators.required],
|
currency: [data.o.currency, Validators.required],
|
||||||
useZats: [data.o.zats, Validators.required],
|
useZats: [data.o.zats, Validators.required],
|
||||||
useVKey: [data.o.payconf, Validators.required],
|
useVKey: [data.o.payconf, Validators.required],
|
||||||
// proVersion: [data.invoices, Validators.required],
|
|
||||||
vKey: [data.o.viewkey]
|
vKey: [data.o.viewkey]
|
||||||
});
|
});
|
||||||
this.accCodForm = fb.group ({
|
this.accCodForm = fb.group ({
|
||||||
|
@ -142,7 +140,8 @@ export class SettingsComponent implements OnInit {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.o.payconf) {
|
if (data.o.payconf) {
|
||||||
this.settingsForm.get('vKey')!.enable();
|
this.vKaccess = false;
|
||||||
|
//this.settingsForm.get('vKey')!.enable();
|
||||||
}
|
}
|
||||||
this.owner = data.o;
|
this.owner = data.o;
|
||||||
this.viewkey = data.o.viewkey;
|
this.viewkey = data.o.viewkey;
|
||||||
|
@ -181,8 +180,9 @@ export class SettingsComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.settingsForm.get('vKey')!.disable();
|
//this.settingsForm.get('vKey')!.disable();
|
||||||
//
|
//
|
||||||
|
this.vKaccess = true;
|
||||||
this.chgUILanguage();
|
this.chgUILanguage();
|
||||||
//console.log('SETTINGS: Return from chgUILanguage()');
|
//console.log('SETTINGS: Return from chgUILanguage()');
|
||||||
//
|
//
|
||||||
|
@ -206,7 +206,7 @@ export class SettingsComponent implements OnInit {
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
|
||||||
this.dialogRef.close();
|
this.dialogRef.close(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeIntegration() {
|
closeIntegration() {
|
||||||
|
@ -223,8 +223,8 @@ export class SettingsComponent implements OnInit {
|
||||||
this.owner.currency = this.settingsForm.value.currency;
|
this.owner.currency = this.settingsForm.value.currency;
|
||||||
this.owner.zats = this.settingsForm.value.useZats;
|
this.owner.zats = this.settingsForm.value.useZats;
|
||||||
this.owner.payconf = this.settingsForm.value.useVKey;
|
this.owner.payconf = this.settingsForm.value.useVKey;
|
||||||
this.viewkey = this.settingsForm.value.vKey;
|
this.owner.viewkey = this.settingsForm.value.vKey;
|
||||||
//this.owner.invoices = this.settingsForm.value.proVersion
|
console.log('Settings component key: ' + this.owner.viewkey);
|
||||||
this.dialogRef.close(this.owner);
|
this.dialogRef.close(this.owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,12 +240,13 @@ export class SettingsComponent implements OnInit {
|
||||||
// console.log("Viewing key switch is " +
|
// console.log("Viewing key switch is " +
|
||||||
// ( ob.checked ? "[ON]." : "[OFF]." ) );
|
// ( ob.checked ? "[ON]." : "[OFF]." ) );
|
||||||
|
|
||||||
this.useVKey = ob.checked;
|
if ( ob.checked ) {
|
||||||
|
//this.settingsForm.get('vKey')!.enable();
|
||||||
if ( ob.checked )
|
this.vKaccess = false;
|
||||||
this.settingsForm.get('vKey')!.enable();
|
} else {
|
||||||
else
|
//this.settingsForm.get('vKey')!.disable();
|
||||||
this.settingsForm.get('vKey')!.disable();
|
this.vKaccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,10 @@ export class UserService{
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOwnerSettings(o: Owner) {
|
saveOwnerSettings(o: Owner) {
|
||||||
|
console.log('saveOwnerSettings: ' + o.viewkey);
|
||||||
|
if(o.viewkey.length > 20) {
|
||||||
|
this.saveOwnerViewingKey(o.viewkey).subscribe({
|
||||||
|
next: () => {
|
||||||
let obs = this.http.post(this.beUrl + 'api/ownersettings', {payload: o}, {headers: this.reqHeaders, params: this.reqParams});
|
let obs = this.http.post(this.beUrl + 'api/ownersettings', {payload: o}, {headers: this.reqHeaders, params: this.reqParams});
|
||||||
obs.subscribe({
|
obs.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
|
@ -172,7 +176,40 @@ export class UserService{
|
||||||
this.notifierService.showNotification("Saving settings failed", "Close", "error")
|
this.notifierService.showNotification("Saving settings failed", "Close", "error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let obs = this.http.post(this.beUrl + 'api/ownersettings', {payload: o}, {headers: this.reqHeaders, params: this.reqParams});
|
||||||
|
obs.subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.getOwner();
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
if ( error.status == 500 ){
|
||||||
|
this.notifierService.showNotification("Saving settings failed", "Close", "error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveOwnerViewingKey(vk: string){
|
||||||
|
let obs = this.http.post(this.beUrl + 'api/ownervk', {payload: vk}, {headers: this.reqHeaders, params: this.reqParams});
|
||||||
|
obs.subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.getOwner();
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
if (error.status == 400) {
|
||||||
|
this.notifierService.showNotification('Invalid viewing key, changes not saved', 'Close', 'error');
|
||||||
|
} else if (error.status == 403) {
|
||||||
|
this.notifierService.showNotification('Viewing key does not match shop, changes not saved', 'Close', 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return obs;
|
||||||
}
|
}
|
||||||
|
|
||||||
getOwner() {
|
getOwner() {
|
||||||
|
|
Loading…
Reference in a new issue