You've already forked openaccounting-web
forked from cybercinch/openaccounting-web
update org timezone
This commit is contained in:
@@ -1,6 +1,41 @@
|
||||
<h1>Organization</h1>
|
||||
|
||||
<div class="section">
|
||||
<h2>Current Organization</h2>
|
||||
|
||||
<form [formGroup]="updateOrgForm" (ngSubmit)="updateOrgSubmit()">
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-sm-3 col-form-label">Name</label>
|
||||
<div class="col-sm-9">
|
||||
<input formControlName="name" type="text" class="form-control" id="name" placeholder="Organization name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="currency" class="col-sm-3 col-form-label">Currency</label>
|
||||
<div class="col-sm-9">
|
||||
<input formControlName="currency" type="text" class="form-control" id="currency" placeholder="Currency">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="precision" class="col-sm-3 col-form-label">Decimal Places</label>
|
||||
<div class="col-sm-9">
|
||||
<input formControlName="precision" type="text" class="form-control" id="precision" placeholder="Decimal Places">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="timezone" class="col-sm-3 col-form-label">Timezone</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-control" id="timezone" formControlName="timezone">
|
||||
<option *ngFor="let tz of timezones" [value]="tz">
|
||||
{{tz}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p *ngIf="updateOrgError" class="error">{{updateOrgError.message}}</p>
|
||||
<button class="btn btn-primary" type="submit" [disabled]="!updateOrgForm.valid">Save Changes</button>
|
||||
</form>
|
||||
|
||||
<h2>Choose Organization</h2>
|
||||
|
||||
<form [formGroup]="chooseOrgForm" (ngSubmit)="chooseOrgSubmit()">
|
||||
@@ -103,6 +138,16 @@
|
||||
<input formControlName="precision" type="text" class="form-control" id="precision" placeholder="Decimal Places">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="timezone" class="col-sm-3 col-form-label">Timezone</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-control" id="timezone" formControlName="timezone">
|
||||
<option *ngFor="let tz of timezones" [value]="tz">
|
||||
{{tz}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="createDefaultAccounts" class="col-sm-3 col-form-label">Create default accounts<br>(can be customized later)</label>
|
||||
<div class="col-sm-9">
|
||||
|
||||
@@ -30,7 +30,11 @@ export class OrgPage {
|
||||
public inviteFormError: AppError;
|
||||
public newOrgForm: FormGroup;
|
||||
public newOrgError: AppError;
|
||||
public updateOrgForm: FormGroup;
|
||||
public updateOrgError: AppError;
|
||||
public invites: Invite[];
|
||||
public timezones: string[];
|
||||
public defaultTz: string;
|
||||
|
||||
constructor(
|
||||
private log: Logger,
|
||||
@@ -38,8 +42,19 @@ export class OrgPage {
|
||||
private fb: FormBuilder
|
||||
) {
|
||||
|
||||
this.timezones = Util.getTimezones();
|
||||
this.defaultTz = Util.getDefaultTimezone();
|
||||
|
||||
console.log('defaultTz', this.defaultTz);
|
||||
this.invites = null;
|
||||
|
||||
this.updateOrgForm = fb.group({
|
||||
'name': ['', Validators.required],
|
||||
'currency': [{value: '', disabled: true}, Validators.required],
|
||||
'precision': [{value: null, disabled: true}, Validators.required],
|
||||
'timezone': ['', Validators.required]
|
||||
});
|
||||
|
||||
this.chooseOrgForm = fb.group({
|
||||
'id': [null, Validators.required]
|
||||
});
|
||||
@@ -56,6 +71,7 @@ export class OrgPage {
|
||||
'name': ['', Validators.required],
|
||||
'currency': ['', Validators.required],
|
||||
'precision': [null, Validators.required],
|
||||
'timezone': [this.defaultTz, Validators.required],
|
||||
'createDefaultAccounts': [true, Validators.required]
|
||||
});
|
||||
}
|
||||
@@ -63,12 +79,22 @@ export class OrgPage {
|
||||
ngOnInit() {
|
||||
this.currentOrg = this.orgService.getCurrentOrg();
|
||||
|
||||
this.updateOrgForm.setValue(
|
||||
{
|
||||
name: this.currentOrg.name,
|
||||
currency: this.currentOrg.currency,
|
||||
precision: this.currentOrg.precision,
|
||||
timezone: this.currentOrg.timezone
|
||||
}
|
||||
);
|
||||
|
||||
this.chooseOrgForm.setValue({id: this.currentOrg.id});
|
||||
this.newOrgForm.setValue(
|
||||
{
|
||||
name: '',
|
||||
currency: this.currentOrg.currency,
|
||||
precision: this.currentOrg.precision,
|
||||
timezone: this.defaultTz,
|
||||
createDefaultAccounts: true
|
||||
}
|
||||
);
|
||||
@@ -139,6 +165,22 @@ export class OrgPage {
|
||||
);
|
||||
}
|
||||
|
||||
updateOrgSubmit() {
|
||||
let org = this.currentOrg;
|
||||
org.name = this.updateOrgForm.get('name').value;
|
||||
org.timezone = this.updateOrgForm.get('timezone').value;
|
||||
|
||||
this.orgService.updateOrg(org)
|
||||
.subscribe(
|
||||
org => {
|
||||
this.log.debug(org);
|
||||
},
|
||||
error => {
|
||||
this.updateOrgError = error;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
deleteInvite(invite: Invite) {
|
||||
this.orgService.deleteInvite(invite.id).subscribe(() => {
|
||||
this.invites = this.invites.filter(inv => {
|
||||
|
||||
Reference in New Issue
Block a user