Skip to content

Commit

Permalink
Fix vscode input field
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed May 23, 2024
1 parent 5f7e60b commit 9e7eefa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h4 mat-title>{{'CREATE_VIEW_TITLE' | translate}}</h4>
</mat-form-field>
<mat-form-field>
<mat-label>{{'FIELD_VIEW_VSCODE_SETTINGS' | translate}}</mat-label>
<input matInput placeholder="{{'FIELD_VIEW_VSCODE_PLACEHOLDER' | translate}}" [(ngModel)]="view.general.vscodeSettings" name="vscodeSettings">
<input [disabled]="true" matInput placeholder="{{'FIELD_VIEW_VSCODE_PLACEHOLDER' | translate}}" [(ngModel)]="view.general.vscodeSettings" name="vscodeSettings">
</mat-form-field>
</p>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { BehaviorSubject, Subject, catchError, combineLatest, debounceTime, from, map, switchMap, takeUntil } from 'rxjs';
import { Extension, ViewCreate } from 'src/app/models/view';
import { RestClientService } from 'src/app/services/rest-client.service';
import { ErrorDialogComponent } from '../../dialogs/error-dialog/error-dialog.component';

@Component({
selector: 'app-view-create-form',
Expand Down Expand Up @@ -84,6 +86,7 @@ export class ViewCreateFormComponent implements OnInit, OnDestroy {

constructor(
private restClient: RestClientService,
public dialog: MatDialog,
) {
}

Expand Down Expand Up @@ -149,9 +152,18 @@ export class ViewCreateFormComponent implements OnInit, OnDestroy {
}

public save() {
// TODO fix model
(this.view as any)['vscode-settings'] = JSON.parse(this.view.general.vscodeSettings || '{}');
this.view.general.vscodeSettings = undefined;
try {
// TODO fix model
(this.view as any)['vscode-settings'] = JSON.parse(this.view.general.vscodeSettings || '{}');
this.view.general.vscodeSettings = undefined;
} catch (error) {
this.dialog.open(ErrorDialogComponent, {
width: '300px',
height: '150px',
data: { err: 'VSCode Settings, invalid json file' },
});
return;
}

if (this.repositoryInfo) {
if (this.view.repo) {
Expand Down

0 comments on commit 9e7eefa

Please sign in to comment.