Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Jul 4, 2020
1 parent 0dd2872 commit 1b153f2
Show file tree
Hide file tree
Showing 27 changed files with 528 additions and 112 deletions.
2 changes: 1 addition & 1 deletion docs/directives/L10nDateDirective.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ <h3 id="accessors">
}

protected getValue(text: string): string {
return this.intl.formatDate(text, this.options);
return this.intl.formatDate(text, this.options, this.language);
}

}
Expand Down
2 changes: 1 addition & 1 deletion docs/directives/L10nNumberDirective.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ <h3 id="accessors">
}

protected getValue(text: string): string {
return this.intl.formatNumber(text, this.options);
return this.intl.formatNumber(text, this.options, this.language);
}

}
Expand Down
2 changes: 1 addition & 1 deletion docs/directives/L10nTimeAgoDirective.html
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ <h3 id="accessors">
}

protected getValue(text: string): string {
return this.intl.formatRelativeTime(text, this.unit, this.options);
return this.intl.formatRelativeTime(text, this.unit, this.options, this.language);
}

}
Expand Down
2 changes: 1 addition & 1 deletion docs/directives/L10nTranslateDirective.html
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ <h3 id="accessors">
}

protected getValue(text: string): string {
return this.translation.translate(text, this.params);
return this.translation.translate(text, this.params, this.language);
}

}
Expand Down
128 changes: 108 additions & 20 deletions docs/directives/L10nValidateDateDirective.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ <h3>Implements</h3>
<p class="comment">
<code><a href="https://angular.io/api/forms/Validator" target="_blank" >Validator</a></code>
<code><a href="https://angular.io/api/core/OnInit" target="_blank" >OnInit</a></code>
<code><a href="https://angular.io/api/core/OnChanges" target="_blank" >OnChanges</a></code>
</p>


Expand Down Expand Up @@ -118,6 +119,10 @@ <h6><b>Methods</b></h6>
<tr>
<td class="col-md-4">
<ul class="index-list">
<li>
<span class="modifier">Public</span>
<a href="#ngOnChanges">ngOnChanges</a>
</li>
<li>
<span class="modifier">Public</span>
<a href="#ngOnInit">ngOnInit</a>
Expand All @@ -141,6 +146,9 @@ <h6><b>Inputs</b></h6>
<li>
<a href="#l10nValidateDate">l10nValidateDate</a>
</li>
<li>
<a href="#language">language</a>
</li>
<li>
<a href="#maxDate">maxDate</a>
</li>
Expand Down Expand Up @@ -186,7 +194,7 @@ <h3 id="constructor">Constructor</h3>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="56" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:56</a></div>
<div class="io-line">Defined in <a href="" data-line="60" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:60</a></div>
</td>
</tr>

Expand Down Expand Up @@ -233,10 +241,37 @@ <h3 id="inputs">Inputs</h3>
<a name="l10nValidateDate"></a>
<b>l10nValidateDate</b>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>

</td>
</tr>
<tr>
<td class="col-md-2" colspan="2">
<div class="io-line">Defined in <a href="" data-line="47" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:47</a></div>
<div class="io-line">Defined in <a href="" data-line="49" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:49</a></div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="language"></a>
<b>language</b>
</td>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>

</td>
</tr>
<tr>
<td class="col-md-2" colspan="2">
<div class="io-line">Defined in <a href="" data-line="58" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:58</a></div>
</td>
</tr>
</tbody>
Expand All @@ -257,7 +292,7 @@ <h3 id="inputs">Inputs</h3>
</tr>
<tr>
<td class="col-md-2" colspan="2">
<div class="io-line">Defined in <a href="" data-line="54" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:54</a></div>
<div class="io-line">Defined in <a href="" data-line="56" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:56</a></div>
</td>
</tr>
</tbody>
Expand All @@ -278,7 +313,7 @@ <h3 id="inputs">Inputs</h3>
</tr>
<tr>
<td class="col-md-2" colspan="2">
<div class="io-line">Defined in <a href="" data-line="53" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:53</a></div>
<div class="io-line">Defined in <a href="" data-line="55" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:55</a></div>
</td>
</tr>
</tbody>
Expand All @@ -293,13 +328,13 @@ <h3 id="inputs">Inputs</h3>
</tr>
<tr>
<td class="col-md-4">
<i>Type : </i> <code><a href="../interfaces/L10nDateTimeFormatOptions.html" target="_self" >L10nDateTimeFormatOptions</a></code>
<i>Type : </i> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>

</td>
</tr>
<tr>
<td class="col-md-2" colspan="2">
<div class="io-line">Defined in <a href="" data-line="51" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:51</a></div>
<div class="io-line">Defined in <a href="" data-line="53" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:53</a></div>
</td>
</tr>
</tbody>
Expand All @@ -313,6 +348,47 @@ <h3 id="inputs">Inputs</h3>
<h3 id="methods">
Methods
</h3>
<table class="table table-sm table-bordered">
<tbody>
<tr>
<td class="col-md-4">
<a name="ngOnChanges"></a>
<span class="name">
<b>
<span class="modifier">Public</span>
ngOnChanges
</b>
<a href="#ngOnChanges"><span class="icon ion-ios-link"></span></a>
</span>
</td>
</tr>
<tr>
<td class="col-md-4">
<span class="modifier-icon icon ion-ios-reset"></span>
<code>ngOnChanges()</code>
</td>
</tr>


<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="68"
class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:68</a></div>
</td>
</tr>


<tr>
<td class="col-md-4">

<div class="io-description">
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>

</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-bordered">
<tbody>
<tr>
Expand All @@ -337,8 +413,8 @@ <h3 id="methods">

<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="60"
class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:60</a></div>
<div class="io-line">Defined in <a href="" data-line="64"
class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:64</a></div>
</td>
</tr>

Expand Down Expand Up @@ -378,8 +454,8 @@ <h3 id="methods">

<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="64"
class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:64</a></div>
<div class="io-line">Defined in <a href="" data-line="72"
class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:72</a></div>
</td>
</tr>

Expand Down Expand Up @@ -453,7 +529,7 @@ <h3 id="inputs">
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="56" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:56</a></div>
<div class="io-line">Defined in <a href="" data-line="60" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:60</a></div>
</td>
</tr>

Expand All @@ -478,12 +554,12 @@ <h3 id="accessors">

<tr>
<td class="col-md-4">
<span class="accessor"><b>set</b><code>l10nValidateDate(options)</code></span>
<span class="accessor"><b>set</b><code>l10nValidateDate(options: <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank">any</a>)</code></span>
</td>
</tr>
<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="47" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:47</a></div>
<div class="io-line">Defined in <a href="" data-line="49" class="link-to-prism">projects/angular-l10n/src/lib/directives/l10n-validate-date.directive.ts:49</a></div>
</td>
</tr>
<tr>
Expand All @@ -495,13 +571,17 @@ <h3 id="accessors">
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td>Optional</td>
</tr>
</thead>
<tbody>
<tr>
<td>options</td>

<td>
<code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>
</td>

<td>
No
Expand All @@ -527,7 +607,7 @@ <h3 id="accessors">


<div class="tab-pane fade tab-source-code" id="c-source">
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Directive, forwardRef, OnInit, Input } from &#x27;@angular/core&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Directive, forwardRef, OnInit, Input, OnChanges } from &#x27;@angular/core&#x27;;
import { NG_VALIDATORS, Validator, ValidatorFn, ValidationErrors, AbstractControl } from &#x27;@angular/forms&#x27;;

import { L10nDateTimeFormatOptions } from &#x27;../models/types&#x27;;
Expand All @@ -539,18 +619,20 @@ <h3 id="accessors">
* @param options A L10n or Intl DateTimeFormatOptions object
* @param minDate The minimum date
* @param maxDate The maximum date
* @param language The current language
* @return An error object: &#x27;format&#x27;, &#x27;minDate&#x27; or &#x27;maxDate&#x27;; null in case the date is valid
*/
export function l10nValidateDate(
validation: L10nValidation,
options?: L10nDateTimeFormatOptions,
minDate?: Date,
maxDate?: Date
maxDate?: Date,
language?: string
): ValidatorFn {
const validator &#x3D; (c: AbstractControl): ValidationErrors | null &#x3D;&gt; {
if (c.value &#x3D;&#x3D;&#x3D; &#x27;&#x27; || c.value &#x3D;&#x3D; null) return null;

const date &#x3D; validation.parseDate(c.value, options);
const date &#x3D; validation.parseDate(c.value, options, language);
if (date !&#x3D; null) {
if (minDate &amp;&amp; date &lt; minDate) {
return { mindate: true };
Expand All @@ -571,23 +653,29 @@ <h3 id="accessors">
{ provide: NG_VALIDATORS, useExisting: forwardRef(() &#x3D;&gt; L10nValidateDateDirective), multi: true }
]
})
export class L10nValidateDateDirective implements Validator, OnInit {
export class L10nValidateDateDirective implements Validator, OnInit, OnChanges {

@Input() set l10nValidateDate(options: L10nDateTimeFormatOptions) {
@Input() set l10nValidateDate(options: any) {
this.options &#x3D; options;
}

@Input() public options: L10nDateTimeFormatOptions;
@Input() public options: any;

@Input() public minDate: Date;
@Input() public maxDate: Date;

@Input() public language: string;

protected validator: ValidatorFn;

constructor(protected validation: L10nValidation) { }

public ngOnInit() {
this.validator &#x3D; l10nValidateDate(this.validation, this.options, this.minDate, this.maxDate);
this.validator &#x3D; l10nValidateDate(this.validation, this.options, this.minDate, this.maxDate, this.language);
}

public ngOnChanges() {
this.validator &#x3D; l10nValidateDate(this.validation, this.options, this.minDate, this.maxDate, this.language);
}

public validate(c: AbstractControl): ValidationErrors | null {
Expand Down
Loading

0 comments on commit 1b153f2

Please sign in to comment.