Skip to content
Closed
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
26 changes: 21 additions & 5 deletions src/plugins/Imports/JsonImportPlugin.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
<template>
<v-btn color='primary' @click='dialog = true'>Import JSON</v-btn>
<v-btn color='primary' @click='dialog = true'>Import REQIF</v-btn>
<v-dialog v-model='dialog'>
<v-card class='w-50'>
<v-card-title>Select Import Elements</v-card-title>
<v-card-actions>
<v-file-input
accept='.json'
label='JSON Input'
v-model='selectedFiles'
accept='.reqif'
label='REQIF Input'
prepend-icon='mdi-folder-open'
multiple
></v-file-input>
<v-btn color='red' @click='dialog = false'>Close</v-btn>
<v-btn color='blue' @click='submitFiles'>Submit</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>

<script lang="ts">
import { Options, Vue } from 'vue-class-component';
import { reqif2pig } from '../../utils/import/ReqIF/reqif2pig';

@Options({
data() {
return {
dialog: false
dialog: false,
selectedFiles: []
};
},
methods: {
submitFiles() {
const ReqifTranslator = new reqif2pig();
let translatorResponse = ReqifTranslator.toPig(this.selectedFiles);
console.log(translatorResponse.ok);

Check warning on line 36 in src/plugins/Imports/JsonImportPlugin.vue

View workflow job for this annotation

GitHub Actions / build (24.4.0)

Unexpected console statement
console.log(translatorResponse.status);

Check warning on line 37 in src/plugins/Imports/JsonImportPlugin.vue

View workflow job for this annotation

GitHub Actions / build (24.4.0)

Unexpected console statement

// reset variables
this.dialog = false;
this.selectedFiles = [];
}
}
},
})

export default class JsonImportComponent extends Vue {}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/import/ReqIF/reqif2pig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { IXhr } from '../../lib/helper';
import { IEntity, IRelationship, IProperty, IAnEntity, IARelationship } from '../../schemas/pig/pig-metaclasses';

Check warning on line 14 in src/utils/import/ReqIF/reqif2pig.ts

View workflow job for this annotation

GitHub Actions / build (24.4.0)

'IEntity' is defined but never used

export class reqif2pig {
private validate(xml: Document): boolean {
Expand All @@ -19,7 +19,7 @@
return xml.getElementsByTagName("REQ-IF-HEADER").length == 0
&& xml.getElementsByTagName("REQ-IF-CONTENT").length == 0;
}
toPig(xml: string, options?: any): IXhr {
toPig(xml: string[] | Document[], options?: any): IXhr {

const opts = Object.assign(
{
Expand Down Expand Up @@ -63,7 +63,7 @@

// Parse an XML string and returns an XML Document;
// proposed by: https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parsing_an_XML_string (through GitHub Copilot)
function parseXML(input: string | Document): IXhr {
function parseXML(input: string[] | Document[]): IXhr {
if (typeof (input) !== 'string') {
// already a Document / XMLDocument
return { ok: true, status: 297, statusText: '', response: input, responseType: 'document' };
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/pig-metaclasses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* We appreciate any correction, comment or contribution as Github issue (https://github.com/GfSE/CASCaDE-Reference-Implementation/issues)
*
* Design Decisions:
* - Testing and verification of the concrete children in the PIG metaclasses,
* - Testing and verification of the concrete children in the PIG metaclasses,
* will provide test coverage for the abstract classes they inherit from.
*/

Expand Down
Loading