-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: match matrix params when resolving views for activation or closing
fixes #120
- Loading branch information
1 parent
34cd8de
commit 65ba4f0
Showing
17 changed files
with
461 additions
and
10 deletions.
There are no files selected for viewing
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
19 changes: 19 additions & 0 deletions
19
projects/app/workbench/workbench-app/src/app/view-navigation/view-navigation.component.html
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,19 @@ | ||
<input placeholder="Path" [formControl]="form.get(PATH)" class="e2e-path"> | ||
<sci-params-enter [title]="'Query parameters'" [paramsFormArray]="form.get(QUERY_PARAMS)" [addable]="true" [removable]="true" class="e2e-query-params-panel"></sci-params-enter> | ||
<sci-params-enter [title]="'Matrix parameters'" [paramsFormArray]="form.get(MATRIX_PARAMS)" [addable]="true" [removable]="true" class="e2e-matrix-params-panel"></sci-params-enter> | ||
|
||
<form autocomplete="off"> | ||
<label for="activateIfPresent">ActivateIfPresent</label> | ||
<input id="activateIfPresent" type="checkbox" [formControl]="form.get(ACTIVATE_IF_PRESENT)"> | ||
|
||
<label for="closeIfPresent">CloseIfPresent</label> | ||
<input id="closeIfPresent" type="checkbox" [formControl]="form.get(CLOSE_IF_PRESENT)"> | ||
|
||
<label for="target">Target</label> | ||
<select id="target" [formControl]="form.get(TARGET)"> | ||
<option value="self">self</option> | ||
<option value="blank">blank</option> | ||
</select> | ||
</form> | ||
|
||
<button (click)="onNavigate()" class="e2e-navigate">Navigate</button> |
26 changes: 26 additions & 0 deletions
26
projects/app/workbench/workbench-app/src/app/view-navigation/view-navigation.component.scss
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,26 @@ | ||
@import 'common'; | ||
|
||
:host { | ||
padding: app-padding(); | ||
display: grid; | ||
grid-auto-rows: min-content; | ||
grid-row-gap: .5em; | ||
font-size: .9em; | ||
|
||
> sci-params-enter { | ||
background-color: #FFFFFF; | ||
} | ||
|
||
> form { | ||
display: grid; | ||
grid-template-columns: 100px minmax(75px, 300px); | ||
grid-column-gap: 1em; | ||
grid-row-gap: .5em; | ||
@include grid-container-align-items(center); | ||
background-color: #FFFFFF; | ||
|
||
border: 1px solid accentColor(.25); | ||
border-radius: 5px; | ||
padding: 1em; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
projects/app/workbench/workbench-app/src/app/view-navigation/view-navigation.component.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,71 @@ | ||
/* | ||
* Copyright (c) 2018 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import { Component } from '@angular/core'; | ||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms'; | ||
import { SciParamsEnterComponent } from '@scion/app/common'; | ||
import { WbNavigationExtras, WorkbenchRouter, WorkbenchView } from '@scion/workbench'; | ||
import { Params } from '@angular/router'; | ||
|
||
const PATH = 'path'; | ||
const QUERY_PARAMS = 'queryParams'; | ||
const MATRIX_PARAMS = 'matrixParams'; | ||
const ACTIVATE_IF_PRESENT = 'activateIfPresent'; | ||
const CLOSE_IF_PRESENT = 'closeIfPresent'; | ||
const TARGET = 'target'; | ||
|
||
@Component({ | ||
selector: 'app-view-navigation', | ||
templateUrl: './view-navigation.component.html', | ||
styleUrls: ['./view-navigation.component.scss'], | ||
}) | ||
export class ViewNavigationComponent { | ||
|
||
public readonly PATH = PATH; | ||
public readonly MATRIX_PARAMS = MATRIX_PARAMS; | ||
public readonly QUERY_PARAMS = QUERY_PARAMS; | ||
public readonly ACTIVATE_IF_PRESENT = ACTIVATE_IF_PRESENT; | ||
public readonly CLOSE_IF_PRESENT = CLOSE_IF_PRESENT; | ||
public readonly TARGET = TARGET; | ||
|
||
public form: FormGroup; | ||
|
||
constructor(formBuilder: FormBuilder, private _router: WorkbenchRouter, private _view: WorkbenchView) { | ||
this._view.title = 'View Navigation'; | ||
this._view.heading = 'Interact with Workbench Router'; | ||
this._view.cssClass = 'e2e-view-navigation'; | ||
this.form = formBuilder.group({ | ||
[PATH]: formBuilder.control(''), | ||
[MATRIX_PARAMS]: formBuilder.array([]), | ||
[QUERY_PARAMS]: formBuilder.array([]), | ||
[ACTIVATE_IF_PRESENT]: formBuilder.control(true), | ||
[CLOSE_IF_PRESENT]: formBuilder.control(false), | ||
[TARGET]: formBuilder.control('blank'), | ||
}); | ||
} | ||
|
||
public onNavigate(): void { | ||
const matrixParams: Params = SciParamsEnterComponent.toParams(this.form.get(MATRIX_PARAMS) as FormArray); | ||
const extras: WbNavigationExtras = { | ||
queryParams: SciParamsEnterComponent.toParams(this.form.get(QUERY_PARAMS) as FormArray), | ||
activateIfPresent: this.form.get(ACTIVATE_IF_PRESENT).value, | ||
closeIfPresent: this.form.get(CLOSE_IF_PRESENT).value, | ||
target: this.form.get(TARGET).value, | ||
selfViewRef: this._view.viewRef, | ||
}; | ||
|
||
const commands: any[] = String(this.form.get(PATH).value).split('/'); | ||
if (matrixParams && Object.keys(matrixParams).length) { | ||
commands.push(matrixParams); | ||
} | ||
|
||
this._router.navigate(commands, extras); | ||
} | ||
} |
10 changes: 9 additions & 1 deletion
10
projects/app/workbench/workbench-app/src/app/view/view.component.html
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
<h2>{{view.title}}</h2> | ||
<section class="params"> | ||
<h2>URL Parameters</h2> | ||
<sci-property class="params" [properties]="params$ | async"></sci-property> | ||
</section> | ||
|
||
<section class="query-params"> | ||
<h2>URL Query Parameters</h2> | ||
<sci-property class="query-params" [properties]="queryParams$ | async"></sci-property> | ||
</section> |
22 changes: 21 additions & 1 deletion
22
projects/app/workbench/workbench-app/src/app/view/view.component.scss
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 |
---|---|---|
@@ -1,3 +1,23 @@ | ||
@import 'common'; | ||
|
||
:host { | ||
margin: 1em; | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
grid-auto-rows: min-content; | ||
grid-column-gap: 1em; | ||
grid-row-gap: 1em; | ||
padding: app-padding(); | ||
|
||
> section { | ||
border: 1px solid accentColor(.25); | ||
border-radius: 5px; | ||
padding: 1em; | ||
font-size: .9em; | ||
|
||
> h2 { | ||
font-size: 1em; | ||
font-weight: bold; | ||
margin-top: 0; | ||
} | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
projects/e2e/workbench/src/page-object/sci-params-enter.po.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,39 @@ | ||
/* | ||
* Copyright (c) 2018 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms from the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import { ElementFinder } from 'protractor'; | ||
|
||
export class SciParamsEnterPanelPO { | ||
|
||
constructor(private _sciParamsEnterPanel: ElementFinder) { | ||
} | ||
|
||
/** | ||
* Clears all params. | ||
*/ | ||
public async clear(): Promise<void> { | ||
await this._sciParamsEnterPanel.$$('.e2e-remove').each(removeParamButton => removeParamButton.click()); | ||
} | ||
|
||
/** | ||
* Allows to enter parameters into '<sci-params-enter>' panel. | ||
*/ | ||
public async enterParams(params: Object): Promise<void> { | ||
const addButton = this._sciParamsEnterPanel.$('button.e2e-add'); | ||
const lastKeyInput = this._sciParamsEnterPanel.$$('input.e2e-key').last(); | ||
const lastValueInput = this._sciParamsEnterPanel.$$('input.e2e-value').last(); | ||
|
||
for (const key of Object.keys(params)) { | ||
await addButton.click(); | ||
await lastKeyInput.sendKeys(key); | ||
await lastValueInput.sendKeys(`${params[key]}`); | ||
} | ||
} | ||
} |
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,36 @@ | ||
/* | ||
* Copyright (c) 2018 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms from the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import { ElementFinder } from 'protractor'; | ||
|
||
export class SciPropertyPanelPO { | ||
|
||
/** | ||
* Allows to read properties from '<sci-property>' panel. | ||
*/ | ||
public async readProperties(sciPropertyPanel: ElementFinder): Promise<{ [key: string]: string }> { | ||
const keysFinder = sciPropertyPanel.$$('.e2e-key'); | ||
const valuesFinder = sciPropertyPanel.$$('.e2e-value'); | ||
|
||
const propertyCount = await keysFinder.count(); | ||
if (propertyCount === 0) { | ||
return null; | ||
} | ||
|
||
const properties: { [key: string]: string } = {}; | ||
for (let i = 0; i < propertyCount; i++) { | ||
const key = await keysFinder.get(i).getText(); | ||
const value = await valuesFinder.get(i).getText(); | ||
properties[key] = value; | ||
} | ||
|
||
return properties; | ||
} | ||
} |
Oops, something went wrong.