Skip to content

Commit 4395e09

Browse files
authored
Develop update (#920)
* DHFPROD-496 fix QuickStart naming in app “QuickStart”, not “Quick Start” * DHFPROD-497 fix property index selection Add flags to property to keep track of what indexes are set (instead of using name). Set flags based on entity state when editor opens. Set entity state based on flags on save. * Fixes #582 - should be reviewed for UX before merging. (#906) * Fix tab bar layout issue #798 (#909) * Rework of fix for issue #557 where URI in request to /doc API (#915) Now matches other implementations throughout codebase which leverage encodeURIComponent() * Fixing Issue #578: Adding deletion dialog (#889) (#917) Adding an additional dialog message to the 2.0 development branch that will require the user to press yes twice before the entity and all associated flows and code are deleted * DHFPROD-664 adjust offset, size of new entities in UI (#918)
1 parent b013c20 commit 4395e09

File tree

11 files changed

+84
-73
lines changed

11 files changed

+84
-73
lines changed

quick-start/src/main/ui/app/entities/entity.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export class Entity {
138138
},
139139
'filename': null,
140140
'hubUi': {
141-
x: 100,
142-
y: 100,
141+
x: 10,
142+
y: 115,
143143
width: 350,
144144
height: 100
145145
},

quick-start/src/main/ui/app/entities/property.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export class PropertyType {
1313

1414
// ui only
1515
showCollation: boolean = false;
16+
isPrimaryKey: boolean = false;
17+
hasElementRangeIndex: boolean = false;
18+
hasRangeIndex: boolean = false;
19+
hasWordLexicon: boolean = false;
20+
required: boolean = false;
1621

1722
UNICODE_COLLATION: string = 'http://marklogic.com/collation/codepoint';
1823

quick-start/src/main/ui/app/entity-modeler/entity-editor.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ <h4>Properties</h4>
4444
<tbody>
4545
<tr *ngFor="let property of entity.definition.properties; let i = index">
4646
<td><input type="checkbox" [(ngModel)]="property.selected"></td>
47-
<td class="col-toggler" (click)="togglePrimaryKey(property)"><i [ngClass]="{'active': isPrimaryKey(property.name)}" class="fa fa-key"></i></td>
48-
<td class="col-toggler" (click)="toggleRangeIndex(property)"><i [ngClass]="{'active': isRangeIndex(property.name)}" class="fa fa-bolt"></i></td>
49-
<td class="col-toggler" (click)="togglePathRangeIndex(property)"><i [ngClass]="{'active': isPathRangeIndex(property.name)}" class="fa fa-code"></i></td>
50-
<td class="col-toggler" (click)="toggleWordLexicon(property)"><i [ngClass]="{'active': isWordLexicon(property.name)}" class="fa fa-won"></i></td>
51-
<td class="col-toggler" (click)="toggleRequired(property)"><i [ngClass]="{'active': isRequired(property.name)}" class="fa fa-exclamation"></i></td>
47+
<td class="col-toggler" (click)="togglePrimaryKey(property)"><i [ngClass]="{'active': property.isPrimaryKey}" class="fa fa-key"></i></td>
48+
<td class="col-toggler" (click)="property.hasElementRangeIndex = !property.hasElementRangeIndex"><i [ngClass]="{'active': property.hasElementRangeIndex}" class="fa fa-bolt"></i></td>
49+
<td class="col-toggler" (click)="property.hasRangeIndex = !property.hasRangeIndex"><i [ngClass]="{'active': property.hasRangeIndex}" class="fa fa-code"></i></td>
50+
<td class="col-toggler" (click)="property.hasWordLexicon = !property.hasWordLexicon"><i [ngClass]="{'active': property.hasWordLexicon}" class="fa fa-won"></i></td>
51+
<td class="col-toggler" (click)="property.required = !property.required"><i [ngClass]="{'active': property.required}" class="fa fa-exclamation"></i></td>
5252

5353
<td><input type="text" [(ngModel)]="property.name"></td>
5454
<td>

quick-start/src/main/ui/app/entity-modeler/entity-editor.component.ts

Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ export class EntityEditorComponent {
5151
this.actions = actions;
5252
this.dataTypes = dataTypes;
5353
this.entityBackup = JSON.stringify(this.entity);
54+
// Set property ui flags based on entity state
55+
this.entity.definition.properties.forEach(function(property) {
56+
property.isPrimaryKey = this.entity.definition.primaryKey === property.name;
57+
property.hasElementRangeIndex = this.entity.definition.elementRangeIndex.indexOf(property.name) >= 0;
58+
property.hasRangeIndex = this.entity.definition.rangeIndex.indexOf(property.name) >= 0;
59+
property.hasWordLexicon = this.entity.definition.wordLexicon.indexOf(property.name) >= 0;
60+
property.required = this.entity.definition.required.indexOf(property.name) >= 0;
61+
}, this);
5462
}
5563

5664
getType(property: PropertyType) {
@@ -147,26 +155,6 @@ export class EntityEditorComponent {
147155
});
148156
}
149157

150-
isPrimaryKey(key: string) {
151-
return this.entity.definition.primaryKey === key;
152-
}
153-
154-
isRangeIndex(key: string) {
155-
return this.entity.definition.elementRangeIndex.indexOf(key) >= 0;
156-
}
157-
158-
isPathRangeIndex(key: string) {
159-
return this.entity.definition.rangeIndex.indexOf(key) >= 0;
160-
}
161-
162-
isWordLexicon(key: string) {
163-
return this.entity.definition.wordLexicon.indexOf(key) >= 0;
164-
}
165-
166-
isRequired(key: string) {
167-
return this.entity.definition.required.indexOf(key) >= 0;
168-
}
169-
170158
addProperty() {
171159
this.entity.definition.properties.push(new PropertyType());
172160
}
@@ -212,6 +200,29 @@ export class EntityEditorComponent {
212200

213201
saveEntity() {
214202
if (this.actions.save) {
203+
// Set entity state based on property ui flags
204+
this.entity.definition.primaryKey = null;
205+
this.entity.definition.elementRangeIndex = [];
206+
this.entity.definition.rangeIndex = [];
207+
this.entity.definition.wordLexicon = [];
208+
this.entity.definition.required = [];
209+
this.entity.definition.properties.forEach(function(property) {
210+
if (property.isPrimaryKey) {
211+
this.entity.definition.primaryKey = property.name;
212+
}
213+
if (property.hasElementRangeIndex) {
214+
this.entity.definition.elementRangeIndex.push(property.name);
215+
}
216+
if (property.hasRangeIndex) {
217+
this.entity.definition.rangeIndex.push(property.name);
218+
}
219+
if (property.hasWordLexicon) {
220+
this.entity.definition.wordLexicon.push(property.name);
221+
}
222+
if (property.required) {
223+
this.entity.definition.required.push(property.name);
224+
}
225+
}, this);
215226
this.actions.save();
216227
}
217228
this.dialog.hide();
@@ -243,28 +254,14 @@ export class EntityEditorComponent {
243254
}
244255

245256
togglePrimaryKey(property: PropertyType) {
246-
if (this.entity.definition.primaryKey === property.name) {
247-
this.entity.definition.primaryKey = null;
257+
if (property.isPrimaryKey) {
258+
property.isPrimaryKey = false;
248259
} else {
249-
this.entity.definition.primaryKey = property.name;
250-
}
251-
}
252-
253-
toggleRangeIndex(property: PropertyType) {
254-
let idx = this.entity.definition.elementRangeIndex.indexOf(property.name);
255-
if (idx >= 0) {
256-
this.entity.definition.elementRangeIndex.splice(idx, 1);
257-
} else {
258-
this.entity.definition.elementRangeIndex.push(property.name);
259-
}
260-
}
261-
262-
togglePathRangeIndex(property: PropertyType) {
263-
let idx = this.entity.definition.rangeIndex.indexOf(property.name);
264-
if (idx >= 0) {
265-
this.entity.definition.rangeIndex.splice(idx, 1);
266-
} else {
267-
this.entity.definition.rangeIndex.push(property.name);
260+
// Unset any existing primary key
261+
this.entity.definition.properties.map(function(prop) {
262+
prop.isPrimaryKey = false;
263+
});
264+
property.isPrimaryKey = true;
268265
}
269266
}
270267

@@ -314,24 +311,6 @@ export class EntityEditorComponent {
314311
}
315312
}
316313

317-
toggleWordLexicon(property: PropertyType) {
318-
let idx = this.entity.definition.wordLexicon.indexOf(property.name);
319-
if (idx >= 0) {
320-
this.entity.definition.wordLexicon.splice(idx, 1);
321-
} else {
322-
this.entity.definition.wordLexicon.push(property.name);
323-
}
324-
}
325-
326-
toggleRequired(property: PropertyType) {
327-
let idx = this.entity.definition.required.indexOf(property.name);
328-
if (idx >= 0) {
329-
this.entity.definition.required.splice(idx, 1);
330-
} else {
331-
this.entity.definition.required.push(property.name);
332-
}
333-
}
334-
335314
onDescKey($event: KeyboardEvent, propertyIndex: number) {
336315
if (
337316
(propertyIndex === (this.entity.definition.properties.length - 1)) &&

quick-start/src/main/ui/app/entity-modeler/entity-modeler.component.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ export class EntityModelerComponent implements AfterViewChecked {
299299
deleteEntity(entity: Entity) {
300300
let result = this.dialogService.confirm(`Really delete ${entity.name}?`, 'No', 'Yes');
301301
result.subscribe(() => {
302-
this.entitiesService.deleteEntity(entity);
302+
let confirmResult = this.dialogService.confirm(`Are you sure really want to delete the ${entity.name} entity as it will delete the entity and all associated flows and code?`, 'No', 'Yes');
303+
confirmResult.subscribe(() => {
304+
this.entitiesService.deleteEntity(entity);
305+
}, () => {});
303306
}, () => {});
304307
}
305308

@@ -353,9 +356,28 @@ export class EntityModelerComponent implements AfterViewChecked {
353356
this.saveUiState();
354357
}
355358

359+
/**
360+
* Adjust entity container coordinates based on number of entities already in UI
361+
* @param {Entity} entity
362+
*/
363+
adjustCoords(entity: Entity) {
364+
entity.hubUi.x += 20*this.entities.length;
365+
entity.hubUi.y += 30*this.entities.length;
366+
}
367+
368+
/**
369+
* Adjust entity container size based on its number of properties
370+
* @param {Entity} entity
371+
*/
372+
adjustSize(entity: Entity) {
373+
entity.hubUi.height += 22*entity.definition.properties.length;
374+
}
375+
356376
addEntity() {
357377
let entity = new Entity().defaultValues();
358378
this.entitiesService.editEntity(entity).subscribe(() => {
379+
this.adjustCoords(entity);
380+
this.adjustSize(entity);
359381
this.entitiesService.saveEntity(entity);
360382
},
361383
// cancel... do nothing

quick-start/src/main/ui/app/flows/flows.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@ li.flow.mdl-list__item div ul li {
363363
height: 100%;
364364
}
365365

366+
/deep/ .mdl-tabs__tab {
367+
padding: 0 12px;
368+
white-space: nowrap;
369+
}
370+
366371
/deep/ mdl-tab-panel-title {
367372
.fa {
368373
margin-right: 5px;

quick-start/src/main/ui/app/header/header.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<header class="mdl-layout__header">
22
<div class="mdl-layout__header-row">
33
<img src="assets/img/odh.svg">
4-
<span class="mdl-layout-title">Data Hub Quick Start</span>
4+
<span class="mdl-layout-title">Data Hub QuickStart</span>
55
<!-- Add spacer, to align navigation to the right -->
66
<div class="mdl-layout-spacer"></div>
77
<div *ngIf="getRunningJobCount() !== 0" layout="row" layout-align="center center" class="job-progress" (click)="gotoJobs()">

quick-start/src/main/ui/app/jobs/job-output.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
pre {
88
overflow: auto;
9+
white-space: pre-wrap;
910
}

quick-start/src/main/ui/app/login/login.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</div>
55
<div class="login-wrapper" layout="row" layout-align="center start">
66
<section layout="column" layout-align="center center" class="left-pane">
7-
<h1 id="mla-loginPage-Text">Data Hub Quick Start</h1>
7+
<h1 id="mla-loginPage-Text">Data Hub QuickStart</h1>
88
<img class="odh-icon" src="assets/img/odh.svg">
99
<section flex layout-padding class="install-status" *ngIf="installationStatus">
1010
<pre>{{installationStatus}}</pre>
@@ -165,7 +165,7 @@ <h3>Choose Your Project Environment</h3>
165165

166166
<p class="help-text">Each Hub Project can be deployed to multiple environments. Environments are
167167
determined by the presence of a gradle-env.properties file in your hub project
168-
directory. By default the Quick Start only creates a local environment file.
168+
directory. By default QuickStart only creates a local environment file.
169169
Read more <a target="_blank" href="https://github.com/marklogic/marklogic-data-hub/wiki/Data-Hub-QuickStart-Project-Environments">on the Data Hub Framework Wiki</a>.
170170
</p>
171171
<app-select-list

quick-start/src/main/ui/app/search/search.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export class SearchService {
3131
}
3232

3333
getDoc(database: string, docUri: string) {
34-
let encodedURI = encodeURI(docUri);
35-
return this.get(`/api/search/doc?database=${database}&docUri=${encodedURI}`);
34+
return this.get(`/api/search/doc?database=${database}&docUri=${encodeURIComponent(docUri)}`);
3635
}
3736

3837
private extractData = (res: Response) => {

0 commit comments

Comments
 (0)