Skip to content

Commit

Permalink
Refactor: Move Document to models/document (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
denysvitali committed Mar 20, 2019
1 parent e746f7f commit e7ae729
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 35 deletions.
19 changes: 12 additions & 7 deletions config/webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = {

resolve: {
extensions: [".ts", ".js"],
alias: {
Models: helpers.root("src/app/models")
}
},

module: {
Expand All @@ -23,17 +26,19 @@ module.exports = {
},
{
test: /\.(scss|sass|css)$/,
loaders: ['to-string-loader', 'css-loader', 'sass-loader'],
loaders: ["to-string-loader", "css-loader", "sass-loader"]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "fonts/"
}
}
}]
]
}
]
},
Expand Down
31 changes: 31 additions & 0 deletions src/app/models/document/document.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
interface Header {
textfile: string;
lang: string;
}

interface Segment {
features: string[];
id: number;
state: string;
}

interface Body {
segments: Segment[];
}

interface Document {
header: Header;
body: Body;
}

class File {
private version: number;
private data: Document;

constructor(version: number, data: Document){
this.version = version;
this.data = data;
}
};

export {File, Document, Body, Segment, Header};
30 changes: 2 additions & 28 deletions src/app/shared/components/xmlupload/xmlupload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,7 @@ import { Component } from "@angular/core";
import { HtmlParser } from "@angular/compiler";
import { parse } from "url";

interface Header {
textfile: string;
lang: string;
}

interface Segment {
features: string[];
id: number;
state: string;
}

interface Body {
segments: Segment[];
}

interface Document {
header: Header;
body: Body;
}

interface File {
version : number;
data: Document;
}
import {Body, Document, Segment, Header, File} from 'Models/document/document';

function createSegment(features: string[], id: number, state: string) {
let newSegment = { features : [""] , id: -1, state : "active"};
Expand Down Expand Up @@ -119,10 +96,7 @@ export class XmlUploadComponent {
body : bod
}

let file : File = {
version : 1,
data : doc
}
let file : File = new File(1, doc);
};

}
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"es6",
"dom"
],
"paths": {
"Models*": ["src/app/models/*"]
},
"baseUrl": "./",
"typeRoots": [
"node_modules/@types"
],
Expand Down

0 comments on commit e7ae729

Please sign in to comment.