Skip to content

Commit

Permalink
RavenDB-20246 Identities View: Explain better the meaning of the Docu…
Browse files Browse the repository at this point in the history
…ment ID Prefix
  • Loading branch information
Danielle9897 committed May 1, 2024
1 parent 0635a94 commit 3bc6c6e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class identity {
currentValue = ko.observable<number>();
warnAboutSmallerValue: KnockoutComputed<boolean>;

nextDocumentText: KnockoutComputed<string>;
textForEditIdentity: KnockoutComputed<string>;
textForNewIdentity: KnockoutComputed<string>;

identitySeparator = ko.observable<string>();
static readonly defaultIdentitySeparator = "/";
Expand Down Expand Up @@ -59,11 +60,27 @@ class identity {
return prefix;
});

this.nextDocumentText = ko.pureComputed(() => {
return `<span>The effective identity separator defined in configuration is: <strong>${genUtils.escapeHtml(this.identitySeparator())}</strong></span><br/>
<span>The next document that will be created with Prefix: "<strong>${genUtils.escapeHtml(this.prefixWithPipe())}</strong>"
will have ID: "<strong>${genUtils.escapeHtml(this.prefixWithoutPipe())}${this.identitySeparator()}${this.value() + 1}</strong>"</span>`;
this.textForEditIdentity = ko.pureComputed(() => {
return `<ul class="margin-top">
<li>The next document that will be created using a <strong>pipe symbol</strong>, e.g.: <code>${genUtils.escapeHtml(this.prefixWithPipe())}</code>,
will have ID: <code>${genUtils.escapeHtml(this.prefixWithoutPipe())}${this.identitySeparator()}${this.value() + 1}</code>
</li>
<li class="margin-top-sm">${separatorText}</li>
</ul>`;
});

this.textForNewIdentity = ko.pureComputed(() => {
return `<ul class="margin-top">
<li>When setting "Prefix" & "Value", the next document created using a <strong>pipe symbol</strong>, i.e.: <code>&lt;Prefix&gt;|</code><br/>
will be assigned an ID structured as <code>&lt;Prefix&gt;${genUtils.escapeHtml(this.identitySeparator())}&lt;Value + 1&gt;</code>
</li>
<li class="margin-top-sm">${separatorText}</li>
</ul>`;
});

const separatorText =
`In the resulting ID, the Prefix and Value parts are separated by the effective separator character defined in your configuration,
which is: <code>${genUtils.escapeHtml(this.identitySeparator())}</code>`;

this.warnAboutSmallerValue = ko.pureComputed(() => {
return this.value() < this.currentValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div class="flex-separator"></div>
<small title="Go to the RavenDB identities documentation">
<a target="_blank" data-bind="attr: { href: 'https://ravendb.net/l/CN81C4/' + clientVersion() }"><i class="icon-link"></i>Identities tutorial</a>
<a target="_blank" data-bind="attr: { href: 'https://ravendb.net/l/KOVX2N/' + clientVersion() }"><i class="icon-link"></i>Identities tutorial</a>
</small>
</div>
<div class="flex-horizontal flex-stretch-items content-margin identities-grid">
Expand All @@ -33,30 +33,41 @@ <h3 data-bind="text: $root.isNewIdentity() ? `Add New Identity` : `Edit Identity
<label for="prefix" class="control-label">Prefix</label>
<div class="flex-grow">
<input type="text" class="form-control" data-bind="textInput: prefix, disable: !$root.isNewIdentity()"
id="prefix" placeholder="Enter the Document ID Prefix">
id="prefix" placeholder="Enter the collection for which to set an identity value, e.g. 'orders'">
</div>
</div>
<div class="form-group margin-top margin-top-lg" data-bind="validationElement: value">
<label for="value" class="control-label">Value</label>
<div class="flex-grow">
<input type="number" min="0" class="form-control" data-bind="numericInput: value"
id="value" placeholder="Enter identity value">
id="value" placeholder="Enter a number that will be the latest identity value for this collection">
</div>
</div>
</div>
<div class="form-group margin-top margin-top-lg" data-bind="if: validationGroup.isValid()">
<label class="control-label">&nbsp;</label>
<div class="flex-vertical flex-grow">
<div class="text-info bg-info padding padding-sm flex-horizontal">
<div class="flex-start"><i class="icon-info"></i></div>
<div data-bind="html: nextDocumentText"></div>
<div data-bind="if: validationGroup.isValid()">
<div class="form-group margin-top-lg" >
<label class="control-label">&nbsp;</label>
<div class="flex-vertical flex-grow">
<div class="text-info bg-info padding padding-sm">
<div data-bind="html: textForEditIdentity"></div>
</div>
<div class="margin-top" data-bind="if: warnAboutSmallerValue">
<div class="text-warning bg-warning padding padding-xs">
<small>
<i class="icon-warning"></i>
<span>New value is smaller than current. Please verify documents with higher identity value do not exist.</span>
</small>
</div>
</div>
</div>
<div class="margin-top" data-bind="if: warnAboutSmallerValue">
<div class="text-warning bg-warning padding padding-xs">
<small>
<i class="icon-warning"></i>
<span>New value is smaller than current. Please verify documents with higher identity value do not exist.</span>
</small>
</div>
</div>
<div data-bind="if: $root.isNewIdentity() && !validationGroup.isValid()">
<div class="form-group margin-top-lg" >
<label class="control-label">&nbsp;</label>
<div class="flex-vertical flex-grow">
<div class="text-info bg-info padding padding-sm">
<div data-bind="html: textForNewIdentity"></div>
</div>
</div>
</div>
Expand Down

0 comments on commit 3bc6c6e

Please sign in to comment.