This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TTOOLS-465 Addition of projected columns editor
- Loading branch information
Showing
26 changed files
with
1,126 additions
and
64 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
ngapp/src/app/dataservices/create-views-dialog/create-views-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
ngapp/src/app/dataservices/shared/projected-column.model.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ProjectedColumn } from "@dataservices/shared/projected-column.model"; | ||
|
||
describe("ProjectedColumn", () => { | ||
let projCol1: ProjectedColumn; | ||
let projCol2: ProjectedColumn; | ||
|
||
beforeEach(() => { | ||
projCol1 = null; | ||
projCol2 = null; | ||
}); | ||
|
||
it("should create", () => { | ||
console.log("========== [ProjectedColumn] should create"); | ||
projCol1 = ProjectedColumn.create( | ||
{ | ||
"name": "colName1", | ||
"type": "string", | ||
"selected": true | ||
} | ||
); | ||
projCol2 = ProjectedColumn.create( | ||
{ | ||
"name": "colName2", | ||
"type": "integer", | ||
"selected": false | ||
} | ||
); | ||
|
||
expect(projCol1.getName()).toEqual("colName1"); | ||
expect(projCol1.getType()).toEqual("string"); | ||
expect(projCol1.selected).toEqual(true); | ||
|
||
expect(projCol2.getName()).toEqual("colName2"); | ||
expect(projCol2.getType()).toEqual("integer"); | ||
expect(projCol2.selected).toEqual(false); | ||
}); | ||
|
||
}); |
91 changes: 91 additions & 0 deletions
91
ngapp/src/app/dataservices/shared/projected-column.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* ProjectedColumn model - to hold the column info for projected view columns | ||
*/ | ||
export class ProjectedColumn { | ||
|
||
private name: string; | ||
private type: string; | ||
public selected = false; | ||
|
||
/** | ||
* @param {Object} json the JSON representation of ProjectedColumn | ||
* @returns {ProjectedColumn} the new ProjectedColumn (never null) | ||
*/ | ||
public static create( json: object = {} ): ProjectedColumn { | ||
const projCol = new ProjectedColumn(); | ||
for (const field of Object.keys(json)) { | ||
if (field === "name") { | ||
projCol.setName(json[field]); | ||
} else if (field === "type") { | ||
projCol.setType(json[field]); | ||
} else if (field === "selected") { | ||
projCol.selected = json[field]; | ||
} | ||
} | ||
return projCol; | ||
} | ||
|
||
constructor() { | ||
// nothing to do | ||
} | ||
|
||
/** | ||
* @returns {string} the column name | ||
*/ | ||
public getName(): string { | ||
return this.name; | ||
} | ||
|
||
/** | ||
* @param {string} name the column name | ||
*/ | ||
public setName( name?: string ): void { | ||
this.name = name ? name : null; | ||
} | ||
|
||
/** | ||
* @returns {string} the column type | ||
*/ | ||
public getType(): string { | ||
return this.type; | ||
} | ||
|
||
/** | ||
* @param {string} type the column type | ||
*/ | ||
public setType( type?: string ): void { | ||
this.type = type ? type : ""; | ||
} | ||
|
||
/** | ||
* Determine if the supplied ProjectedColumn is equal to this | ||
* @param {ProjectedColumn} otherCol the other column | ||
*/ | ||
public isEqual( otherCol: ProjectedColumn ): boolean { | ||
let equal = false; | ||
if (this.getName() === otherCol.getName() && | ||
this.getType() === otherCol.getType() && | ||
this.selected === otherCol.selected ) { | ||
equal = true; | ||
} | ||
return equal; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.