Allow adding a user from UI
continuous-integration/drone Build is passing
Details
continuous-integration/drone Build is passing
Details
parent
06c49558c4
commit
8fd40c8dc6
|
|
@ -14,6 +14,7 @@
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-autocomplete>
|
</mat-autocomplete>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<button mat-button class="m-5" type="button" (click)="addUser()">Add</button>
|
||||||
<br>
|
<br>
|
||||||
<mat-form-field class="w-50">
|
<mat-form-field class="w-50">
|
||||||
<mat-select formControlName="typeId">
|
<mat-select formControlName="typeId">
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import { Component, OnInit, Inject } from '@angular/core';
|
import { Component, OnInit, Inject } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators, FormArray } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators, FormArray } from '@angular/forms';
|
||||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material';
|
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef, MatDialog } from '@angular/material';
|
||||||
import { contributorValidator } from '../contributor-validator';
|
import { contributorValidator } from '../contributor-validator';
|
||||||
import { Transaction } from '../transaction';
|
import { Transaction } from '../transaction';
|
||||||
|
import { AddUserPopupComponent } from '../../popups/add-user-popup/add-user-popup.component';
|
||||||
|
|
||||||
export interface ValDisplay {
|
export interface ValDisplay {
|
||||||
value: number;
|
value: number;
|
||||||
|
|
@ -41,7 +42,7 @@ export class AddTransactionPopupComponent implements OnInit {
|
||||||
funds: ValDisplay[];
|
funds: ValDisplay[];
|
||||||
types: ValDisplay[];
|
types: ValDisplay[];
|
||||||
|
|
||||||
constructor(private formBuilder: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: DialogData, private dialogRef:MatDialogRef<AddTransactionPopupComponent>) {
|
constructor(private dialogService: MatDialog, private formBuilder: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: DialogData, private dialogRef:MatDialogRef<AddTransactionPopupComponent>) {
|
||||||
this.contributors = this.data.contributors || [];
|
this.contributors = this.data.contributors || [];
|
||||||
this.funds = this.data.funds || [];
|
this.funds = this.data.funds || [];
|
||||||
this.types = this.data.types || [];
|
this.types = this.data.types || [];
|
||||||
|
|
@ -101,4 +102,19 @@ export class AddTransactionPopupComponent implements OnInit {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addUser() {
|
||||||
|
const ref = this.dialogService.open(AddUserPopupComponent);
|
||||||
|
|
||||||
|
ref.afterClosed().subscribe((res: any) => {
|
||||||
|
if (res && res.id > 0) {
|
||||||
|
|
||||||
|
this.contributors.push({ value: res.id, display: res.lastName + ' ' + res.firstName });
|
||||||
|
|
||||||
|
let contrib = this.contributors.find(c => c.value === res.id);
|
||||||
|
|
||||||
|
this.form.get("contributor").setValue(contrib);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
.full-width {
|
.full-width {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-5 {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
{{error}}
|
{{error}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<button mat-raised-button class="first" (click)="cancel($event)" >Cancel</button><!--
|
<button mat-raised-button class="first m-5" (click)="cancel($event)" >Cancel</button><!--
|
||||||
--><button mat-raised-button type="submit" [disabled]="!addUserForm.form.valid || addUserButtonDisabled">{{ addUserButtonText }}</button>
|
--><button mat-raised-button class="m-5" type="submit" [disabled]="!addUserForm.form.valid || addUserButtonDisabled">{{ addUserButtonText }}</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -98,7 +98,8 @@ exports.createUser = async function(firstName, lastName, street, city, state, zi
|
||||||
Country: country,
|
Country: country,
|
||||||
EmailVerified: false,
|
EmailVerified: false,
|
||||||
Federated: false,
|
Federated: false,
|
||||||
FederationCode: hash.createVerificationCode()
|
FederationCode: hash.createVerificationCode(),
|
||||||
|
Password: ''
|
||||||
};
|
};
|
||||||
const newUserResult = await connectionAsync.nonQuery('INSERT INTO Users Set ?', newUser);
|
const newUserResult = await connectionAsync.nonQuery('INSERT INTO Users Set ?', newUser);
|
||||||
return await this.getUser2(tempUserName);
|
return await this.getUser2(tempUserName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue