Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #165 from mdrillin/sp10b
Browse files Browse the repository at this point in the history
TTTOOLS-427 Minor UI improvements
  • Loading branch information
mdrillin committed Aug 9, 2018
2 parents f233954 + a5dc5db commit b83474f
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class Composition {
* Determine whether the composition is in a complete state
* @returns {boolean} true if complete
*/
public get valid(): boolean {
public get complete(): boolean {
if ( this.name !== null &&
this.type && this.type !== null &&
this.operator && this.operator !== null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe("ViewDefinition", () => {
[
{
"name": "compositionName",
"leftSourcePath": "leftSourcePath",
"rightSourcePath": "rightSourcePath",
"leftSourcePath": "sourcePath1",
"rightSourcePath": "sourcePath2",
"leftCriteriaColumn": "leftCriteriaCol",
"rightCriteriaColumn": "rightCriteriaCol",
"type": "INNER_JOIN",
Expand All @@ -44,8 +44,8 @@ describe("ViewDefinition", () => {
expect(viewDefn.getSourcePaths()[1]).toEqual("sourcePath2");
expect(viewDefn.getCompositions().length).toEqual(1);
expect(viewDefn.getCompositions()[0].getName()).toEqual("compositionName");
expect(viewDefn.getCompositions()[0].getLeftSourcePath()).toEqual("leftSourcePath");
expect(viewDefn.getCompositions()[0].getRightSourcePath()).toEqual("rightSourcePath");
expect(viewDefn.getCompositions()[0].getLeftSourcePath()).toEqual("sourcePath1");
expect(viewDefn.getCompositions()[0].getRightSourcePath()).toEqual("sourcePath2");
expect(viewDefn.getCompositions()[0].getLeftCriteriaColumn()).toEqual("leftCriteriaCol");
expect(viewDefn.getCompositions()[0].getRightCriteriaColumn()).toEqual("rightCriteriaCol");
expect(viewDefn.getCompositions()[0].getType()).toEqual(CompositionType.INNER_JOIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { VdbsConstants } from "@dataservices/shared/vdbs-constants";
export class ViewDefinition {
private viewName: string;
private keng__description: string;
private isComplete = false;
private isEditable = false;
private sourcePaths: string[] = [];
private compositions: Composition[] = [];
Expand Down Expand Up @@ -216,7 +215,48 @@ export class ViewDefinition {
* @returns {boolean} true if complete
*/
public get complete(): boolean {
return this.viewName != null && this.sourcePaths.length > 0;
// Checks to determine whether the viewDefinition is complete.

// View name must be set
if (!this.viewName || this.viewName.length === 0) {
return false;
}

// Must be at least one source Path
if (!this.sourcePaths || this.sourcePaths.length === 0) {
return false;
}

// If single source path, then any compositions will be ignored - and it's complete
if (this.sourcePaths.length === 1) {
return true;
} else {
// Has more than one source path. Make sure the composition is complete,
// and the sides of the composition are contained in the sourcePaths
const comps: Composition[] = this.getCompositions();
if (!comps || comps.length !== 1) {
return false;
} else if (!comps[0].complete) {
return false;
}
// Make sure the left and right composition source paths are present in the view definition sourcePaths
const leftSrcPath = comps[0].getLeftSourcePath();
const rightSrcPath = comps[0].getRightSourcePath();
let hasLeft = false;
let hasRight = false;
for (const srcPath of this.sourcePaths) {
if (srcPath === leftSrcPath) {
hasLeft = true;
} else if (srcPath === rightSrcPath) {
hasRight = true;
}
}
if (!hasLeft || !hasRight) {
return false;
}
}

return true;
}

/**
Expand All @@ -240,7 +280,8 @@ export class ViewDefinition {
* @returns {string} the view SQL
*/
public getSql(): string {
// The view currently supports single source only
// TODO: The view currently supports single source only.
// Probably need to get SQL from a rest service call. to support joins
let sourceNodeName = "unknownSource";
let connectionName = "unknownConnection";
const sourcePath = this.getSourcePaths()[ 0 ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ describe("ViewEditorState", () => {
[
{
"name": "compositionName",
"leftSourcePath": "leftSourcePath",
"rightSourcePath": "rightSourcePath",
"leftSourcePath": "sourcePath1",
"rightSourcePath": "sourcePath2",
"leftCriteriaColumn": "leftCriteriaCol",
"rightCriteriaColumn": "rightCriteriaCol",
"type": "INNER_JOIN",
Expand Down Expand Up @@ -154,8 +154,8 @@ describe("ViewEditorState", () => {
expect(viewDefn.getSourcePaths()[1]).toEqual("sourcePath2");
expect(viewDefn.getCompositions().length).toEqual(1);
expect(viewDefn.getCompositions()[0].getName()).toEqual("compositionName");
expect(viewDefn.getCompositions()[0].getLeftSourcePath()).toEqual("leftSourcePath");
expect(viewDefn.getCompositions()[0].getRightSourcePath()).toEqual("rightSourcePath");
expect(viewDefn.getCompositions()[0].getLeftSourcePath()).toEqual("sourcePath1");
expect(viewDefn.getCompositions()[0].getRightSourcePath()).toEqual("sourcePath2");
expect(viewDefn.getCompositions()[0].getLeftCriteriaColumn()).toEqual("leftCriteriaCol");
expect(viewDefn.getCompositions()[0].getRightCriteriaColumn()).toEqual("rightCriteriaCol");
expect(viewDefn.getCompositions()[0].getType()).toEqual(CompositionType.INNER_JOIN);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.sources-indent {
margin-top: 7px;
margin-left: 10px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,16 @@
</div>
<div class="row">
<div class="object-card-description">
<!-- View Description -->
{{ view.getDescription() }}
<!-- <div><span class="fa fa-database"></span>&nbsp;&nbsp;<strong>{{ sourceTableText }}</strong></div> -->
</div>
</div>
</ng-template>
<!--
<div class="object-card-body">
<div *ngIf="showDetails">
<div [class]="isSelected() ? 'object-card-body-title-selected' : 'object-card-body-title'">Properties</div>
<div [class]="isSelected() ? 'col-sm-12 properties-group-selected' : 'col-sm-12 properties-group'">
<div class="form-group">
<pfng-list
[config]="listConfig"
[itemTemplate]="itemTemplate"
[items]="properties">
<ng-template #itemTemplate let-item="item">
<div class="object-card-body-item">
<div class="col-sm-6 property-name">{{ item[ 0 ] }}</div>
<div class="col-sm-6 property-value">{{ item[ 1 ] }}</div>
</div>
</ng-template>
</pfng-list>
<!-- View Sources -->
<div class="sources-indent" *ngIf="view.getSourcePaths().length > 0">
<div *ngFor="let sourceStr of sourceTablesText"><span class="fa fa-database"></span>&nbsp;&nbsp;<strong>{{sourceStr}}</strong></div>
</div>
<div class="sources-indent" *ngIf="view.getSourcePaths().length === 0">
<div><strong>[No sources defined]</strong></div>
</div>
</div>
</div>
</div>
-->
</ng-template>
</pfng-card>
Original file line number Diff line number Diff line change
Expand Up @@ -126,43 +126,19 @@ export class ViewCardComponent implements DoCheck, OnInit {
}

/**
* Returns display text for the selected view source
* Returns display text array for the selected view sources
* @returns {string}
*/
public get sourceTableText(): string {
let sourceText = "[No Source Selected]";
public get sourceTablesText(): string[] {
const sourceTextArray: string[] = [];
const sourcePaths = this.view.getSourcePaths();
if (sourcePaths && sourcePaths.length > 0) {
sourceText = "[" + PathUtils.getConnectionName(sourcePaths[0]) + "] " + PathUtils.getSourceName(sourcePaths[0]);
for (const path of sourcePaths) {
const sourceText = "[" + PathUtils.getConnectionName(path) + "]: " + PathUtils.getSourceName(path);
sourceTextArray.push(sourceText);
}
}
return sourceText;
return sourceTextArray;
}

/**
* An event handler for footer action link.
* @param {CardAction} $event the event being processed
*/
// public onShowDetails( $event: CardAction ): void {
// this.showDetails = !this.showDetails;
// $event.hypertext = this.showDetailsTitle;
// }

/**
* @returns {string[][]} the properties of a connection
*/
// public get properties(): string[][] {
// const props = [
// [ "testLabel", "value" ],
// ];
//
// return props;
// }

/**
* @returns {string} the footer details action text
*/
// public get showDetailsTitle(): string {
// return this.showDetails ? "Less" : "More";
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ export class AddCompositionWizardComponent implements OnInit {
* Updates the page 2 status
*/
private updatePage2ValidStatus( ): void {
this.step2Config.nextEnabled = this.composition.valid;
this.step2Config.nextEnabled = this.composition.complete;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class CanvasConstants {
// Node Types
//
public static readonly SOURCE_TYPE = 'SOURCE';
public static readonly COMPONENT_TYPE = 'COMPONENT';
public static readonly COMPOSITION_TYPE = 'COMPOSITION';

//
// Model constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class CanvasService {
if (source.type === CanvasConstants.SOURCE_TYPE) {
eventType = ViewCanvasEventType.CREATE_COMPOSITION;
args.push(source.decodedId);
} else if (source.type === CanvasConstants.COMPONENT_TYPE)
} else if (source.type === CanvasConstants.COMPOSITION_TYPE)
eventType = ViewCanvasEventType.CREATE_SOURCE;

const event = ViewCanvasEvent.create(eventType, args);
Expand All @@ -121,7 +121,7 @@ export class CanvasService {
//
// let type = null;
// if (source.type === CanvasConstants.SOURCE_TYPE)
// type = CanvasConstants.COMPONENT_TYPE;
// type = CanvasConstants.COMPOSITION_TYPE;
// else
// type = CanvasConstants.SOURCE_TYPE;
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export class ViewCanvasComponent implements OnInit, AfterViewInit, OnDestroy {
// CanvasConstants.SOURCE_TYPE,
// CanvasConstants.SOURCE_TYPE,
// CanvasConstants.SOURCE_TYPE,
// CanvasConstants.COMPONENT_TYPE,
// CanvasConstants.COMPONENT_TYPE
// CanvasConstants.COMPOSITION_TYPE,
// CanvasConstants.COMPOSITION_TYPE
// ];
//
// /** constructing the nodes array */
Expand Down Expand Up @@ -303,7 +303,7 @@ export class ViewCanvasComponent implements OnInit, AfterViewInit, OnDestroy {
*/
private createComposition(command: AddCompositionCommand): void {
const composition = command.getComposition();
const compNodeId = this.canvasService.createNode(command.getId(composition.getName()), CanvasConstants.COMPONENT_TYPE, composition.getName(), true);
const compNodeId = this.canvasService.createNode(command.getId(composition.getName()), CanvasConstants.COMPOSITION_TYPE, composition.getName(), true);
// Create links to source nodes if not found
this.createLink(compNodeId, composition.getLeftSourcePath());
this.createLink(compNodeId, composition.getRightSourcePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export class NodeVisualComponent {
public get icon(): string {
if (this.node.type === CanvasConstants.SOURCE_TYPE)
return "/assets/graphicsfuel/database-64.png";
else if (this.node.type === CanvasConstants.COMPONENT_TYPE)
return "/assets/component.png";
else if (this.node.type === CanvasConstants.COMPOSITION_TYPE)
return "/assets/composition.png";

return "/assets/iconfinder/Natalya-Skidan/question-mark.png";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ViewEditorComponent implements DoCheck, OnDestroy, OnInit, AfterVie
private canSave(): boolean {
return !this.fatalErrorOccurred
&& !this.editorService.isReadOnly()
&& this.editorService.getErrorMessageCount() === 0
&& this.editorService.canSaveView()
&& this.editorService.hasChanges()
&& !this.saveInProgress;
}
Expand Down Expand Up @@ -484,7 +484,11 @@ export class ViewEditorComponent implements DoCheck, OnDestroy, OnInit, AfterVie
}
}
else if (event.typeIsCreateSource()) {
this.doAddSource();
if (event.sourceIsCanvas()) {
alert("Multiple compositions not yet supported");
} else {
this.doAddSource();
}
}
else if (event.typeIsCreateComposition()) {
this.doAddComposition(event.args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ export class ViewEditorService {
return true;
}

/**
* @returns {boolean} `true` if the editor view can be saved
*/
public canSaveView(): boolean {
return this._editorView && this._editorView.getName() && this._editorView.getName().length > 0;
}

/**
* @returns {boolean} `true` if editor is readonly or has not been set
*/
Expand Down

0 comments on commit b83474f

Please sign in to comment.