Skip to content

Commit 3eab0b3

Browse files
bsrikanMarkLogic Builder
authored andcommitted
Changes to QuickStart to make the baseUri property required
1 parent bbde99f commit 3eab0b3

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

quick-start/e2e/page-objects/entities/entities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export class EntityPage extends AppPage {
5353
return element(by.css('mdl-textfield[label=Version] input'));
5454
}
5555

56+
get entityBaseUri() {
57+
return element(by.css('mdl-textfield[label="Base URI"] input'));
58+
}
59+
5660
getEntityBox(entityName: string) {
5761
return element(by.cssContainingText('app-entity-box div.title span', entityName));
5862
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class Entity {
160160
height: 100
161161
},
162162
'info': {
163-
'baseUri': null,
163+
'baseUri': 'http://example.org',
164164
'description': null,
165165
'title': null,
166166
'version': '0.0.1'

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
<mdl-textfield type="text" label="Description" [(ngModel)]="entity.info.description" floating-label></mdl-textfield>
1919
</div>
2020
<div>
21-
<mdl-textfield type="text" label="Base URI" [(ngModel)]="entity.info.baseUri" floating-label></mdl-textfield>
21+
<mdl-textfield type="text" label="Base URI" required [(ngModel)]="entity.info.baseUri" floating-label></mdl-textfield>
22+
<span *ngIf="!validBaseUri" class="alert-text">A valid base uri is required, eg http://example.org</span>
2223
</div>
2324
<div class="properties-heading">
2425
<div class="properties-title">Properties</div>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ export class EntityEditorComponent implements AfterViewChecked {
4949

5050
propAdded: boolean = false;
5151
validTitle: boolean = true;
52+
validBaseUri: boolean = true;
5253

5354
// property name pattern: name cannot have space characters in it
5455
readonly PROPERTY_NAME_PATTERN = /^[^\s]+$/;
5556
// Entity title: no space or invalid characters
5657
readonly ENTITY_TITLE_REGEX = /^.*?(?=[\^\s!@#%&$\*:;<>\?/\{\|\}]).*$/;
5758

59+
// Base URI: http://example.org/
60+
readonly BASE_URI_REGEX = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]/;
61+
5862
constructor(
5963
private dialog: MdlDialogReference,
6064
private dialogService: MdlDialogService,
@@ -232,6 +236,9 @@ export class EntityEditorComponent implements AfterViewChecked {
232236
// invalid characters in title
233237
this.validTitle = false;
234238
return;
239+
} if (!this.BASE_URI_REGEX.test(this.entity.info.baseUri) || this.entity.info.baseUri === '' || this.entity.info.baseUri === null) {
240+
this.validBaseUri = false;
241+
return;
235242
} else {
236243
this.validTitle = true;
237244
// Set entity state based on property ui flags

0 commit comments

Comments
 (0)