Skip to content

Commit

Permalink
fixed form fields to correspond to the JSON schema (#71)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Rinnetmäki <[email protected]>
  • Loading branch information
samuelmr committed Apr 24, 2024
1 parent 05e5a2d commit 8aeaee3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 19 deletions.
47 changes: 40 additions & 7 deletions viewer/src/app/wallets-add/wallets-add.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ <h1 mat-dialog-title>Add wallet</h1>
</mat-select>
<mat-hint>{{ walletsService.getTooltip('type') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>License</mat-label>
<input matInput placeholder="License" formControlName="license" />
<mat-hint>{{ walletsService.getTooltip('license') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Capability</mat-label>
<mat-select formControlName="capability" multiple>
Expand All @@ -94,11 +89,49 @@ <h1 mat-dialog-title>Add wallet</h1>
</mat-select>
<mat-hint>{{ walletsService.getTooltip('capability') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Web site URL</mat-label>
<input matInput placeholder="https://..." formControlName="urlWebsite" />
<mat-hint>{{ walletsService.getTooltip('urlWebsite') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>AppStore URL</mat-label>
<input matInput placeholder="https://apple.co/..." formControlName="urlAppStore" />
<mat-hint>{{ walletsService.getTooltip('urlAppStore') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Google Play Store URL</mat-label>
<input matInput placeholder="https://play.google.com/store/apps/..." formControlName="urlGooglePlayStore" />
<mat-hint>{{ walletsService.getTooltip('urlGooglePlayStore') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Web app URL</mat-label>
<input matInput placeholder="https://..." formControlName="urlWebApp" />
<mat-hint>{{ walletsService.getTooltip('urlWebApp') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Open source?</mat-label>
<mat-select formControlName="openSource">
<mat-option value="true">Yes</mat-option>
<mat-option value="false">No</mat-option>
</mat-select>
<mat-hint>{{ walletsService.getTooltip('openSource') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>License</mat-label>
<input matInput placeholder="License" formControlName="license" />
<mat-hint>{{ walletsService.getTooltip('license') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Source code</mat-label>
<input matInput placeholder="https://github.com/..." formControlName="downloadSource" />
<mat-hint>{{ walletsService.getTooltip('downloadSource') }}</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Portability</mat-label>
<mat-select formControlName="portability">
<mat-option value="yes">Yes</mat-option>
<mat-option value="no">No</mat-option>
<mat-option value="true">Yes</mat-option>
<mat-option value="false">No</mat-option>
</mat-select>
<mat-hint>{{ walletsService.getTooltip('portability') }}</mat-hint>
</mat-form-field>
Expand Down
25 changes: 14 additions & 11 deletions viewer/src/app/wallets-add/wallets-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ export class WalletsAddComponent implements OnInit {
async ngOnInit(): Promise<void> {
this.values = await this.walletsService.getDefinitions();
this.form = new FormGroup({
capability: new FormControl([], [Validators.required]),
type: new FormControl(''),
name: new FormControl('', [Validators.required]),
logo: new FormControl(''),
company: new FormControl('', [Validators.required]),
companyUrl: new FormControl(''),
type: new FormControl('', [Validators.required]),
openSource: new FormControl(false, [Validators.required]),
license: new FormControl('', [Validators.required]),
capability: new FormControl([]),
portability: new FormControl(),
linkToApp: new FormControl(''),
urlWebsite: new FormControl('', [Validators.required]),
urlAppStore: new FormControl(''),
urlGooglePlayStore: new FormControl(''),
urlWebApp: new FormControl(''),
downloadSource: new FormControl(''),
openSource: new FormControl(false),
license: new FormControl(''),
portability: new FormControl(false),
});

this.walletsService.resources.forEach((resource) => {
Expand All @@ -73,11 +77,10 @@ export class WalletsAddComponent implements OnInit {
}

getJSON() {
return JSON.stringify(
{ ...this.form.value, $schema: '../viewer/src/assets/schema.json' },
null,
2
);
const json = { ...this.form.value, $schema: '../viewer/src/assets/schema.json' }
json.openSource = json.openSource == "true" ? true : false
json.portability = json.portability == "true" ? true : false
return JSON.stringify(json, null, 2);
}
copy() {
this.clipboard.copy(this.getJSON());
Expand Down
2 changes: 1 addition & 1 deletion viewer/src/app/wallets-list/wallets-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
><mat-icon>phone_iphone</mat-icon></a
>
<a
*ngIf="element.url"
*ngIf="element.urlWebApp"
mat-icon-button
[href]="element.urlWebApp"
target="_blank"
Expand Down

0 comments on commit 8aeaee3

Please sign in to comment.