Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Code Editor Not Clearing After Import Submission #3727

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions CSETWebNg/src/app/import/import.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h6>{{set.name}}</h6>
<h4>Drop code file here</h4>
</div>
<h4 class="d-flex" style="align-items:center">Module Code
<div class="btn-group ml-3 flex-11a" role="group" aria-label="...">
<div class="btn-group ml-3 mr-3 flex-11a" role="group" aria-label="...">
<button (click)="switchToJson()" type="button" class="btn btn-secondary"
[ngClass]="{'active': this.lang=='json'}">JSON</button>
<button (click)="switchToXml()" type="button" class="btn btn-secondary"
Expand Down Expand Up @@ -239,12 +239,17 @@ <h4>Supporting Documents</h4>
<span *ngIf="state=='Processing'">Processing</span>
<span *ngIf="state=='Ready'">Import</span>
</button>
<button *ngIf="state!='Processing'&&state!='Ready'" class="btn btn-primary"
(click)="clearForm()">Import
another module</button>
<div class="d-flex align-items-center" *ngIf="state!='Processing' && state!='Ready'">
<button class="btn btn-primary"
(click)="clearForm()">Import another module
</button>
<div style="margin-bottom: 0" class="alert alert-warning ml-3">
Warning: This will clear the code editor
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
8 changes: 3 additions & 5 deletions CSETWebNg/src/app/import/import.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//
////////////////////////////////
import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { CodeEditorComponent, CodeEditorService, CodeModel } from '@ngstack/code-editor';
import { saveAs } from 'file-saver';
import { editor } from 'monaco-editor/esm/vs/editor/editor.api';
Expand Down Expand Up @@ -214,7 +213,7 @@ export class ImportComponent implements OnInit, OnDestroy {
}
},
e => {
console.log(e)
console.error(e)
for (let key in e.error.errors) {
this.errors.push(`${e.error.errors[key]}`);
}
Expand All @@ -226,7 +225,7 @@ export class ImportComponent implements OnInit, OnDestroy {
public clearForm() {
this.uploader.clearQueue();
this.moduleCode = '';
this.codeModel.value = '';
this.codeModel = { ...this.jsonCodeModel };
this.state = 'Ready';
this.errors = [];
this.subscriptions.forEach(s => s.unsubscribe());
Expand All @@ -249,7 +248,6 @@ export class ImportComponent implements OnInit, OnDestroy {
constructor(
private configSvc: ConfigService,
private fileClient: FileUploadClientService,
private sanitizer: DomSanitizer,
private editorService: CodeEditorService
) {
// hardcoding the polyfill here, as ugly as that is TODO: Remove
Expand Down Expand Up @@ -303,7 +301,7 @@ export class ImportComponent implements OnInit, OnDestroy {
return promise;
};
this.initializeUploader();
this.codeModel = this.jsonCodeModel;
this.codeModel = { ...this.jsonCodeModel };

}

Expand Down
Loading