Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit c2cae6f

Browse files
committed
Merge branch 'master' into observable_card_container
# Conflicts: # source/ui.module.ts
2 parents 6057a8f + b1e7b5a commit c2cae6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+539
-304
lines changed

bootstrapper/bootstrapper.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.rl-tab-item.error {
2+
color: red;
3+
}
4+
5+
.rl-tab-item.current {
6+
color: blue;
7+
}

bootstrapper/forms/formsNg2.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ <h5>Form with validation</h5>
44
<rlForm [save]="waitCallback">
55
<rlTextbox rlRequired="This is a required field" label="Required textbox" maxlength="10"></rlTextbox>
66
<rlValidationGroup [model]="rating" [validator]="validator">
7-
<rlUserRating [(value)]="rating" [range]="3"></rlUserRating>
7+
<rlUserRating [value]="rating" (valueChange)="setRating($event)" [range]="3"></rlUserRating>
88
</rlValidationGroup>
99
<rlButtonSubmit>Submit</rlButtonSubmit>
1010
</rlForm>
@@ -27,7 +27,7 @@ <h5>Form with names</h5>
2727
<rlButtonSubmit rightAligned="true">Submit right</rlButtonSubmit>
2828
</rlForm>
2929
<h5>Autosave form</h5>
30-
<rlBusy [loading]="autosaveAction.saving || autosaveAction.complete"></rlBusy>
30+
<rlBusy [loading]="(autosaveAction.saving$ | async) || (autosaveAction.complete$ | async)"></rlBusy>
3131
<rlForm #autosaveForm [save]="waitCallback" rlAutosave [saveWhenInvalid]="true">
3232
<rlTextbox name="textbox1" label="Autosave textbox" rlRequired="Required textbox"></rlTextbox>
3333
</rlForm>

bootstrapper/forms/formsNg2Bootstrapper.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, ViewChild } from '@angular/core';
2+
import { Observable, BehaviorSubject } from 'rxjs';
23

34
import { FormComponent } from '../../source/components/form/form';
45
import { AutosaveActionService } from '../../source/services/autosaveAction/autosaveAction.service';
@@ -12,6 +13,7 @@ export class FormsBootstrapper {
1213
rating: number;
1314
validator: any;
1415
brokenValidator: any;
16+
rating$: BehaviorSubject<any>;
1517

1618
@ViewChild('testForm') testForm: FormComponent;
1719

@@ -20,16 +22,21 @@ export class FormsBootstrapper {
2022
constructor(autosaveAction: AutosaveActionService) {
2123
this.autosaveAction = autosaveAction;
2224

25+
this.rating$ = new BehaviorSubject(null);
26+
2327
this.validator = {
24-
validate: () => this.rating >= 3,
25-
errorMessage: 'You must give at least 3 stars',
28+
validate: () => this.rating$.map(rating => rating >= 3 ? null : 'You must give at least 3 stars'),
2629
};
2730
this.brokenValidator = {
28-
validate: () => false,
29-
errorMessage: null,
31+
validate: () => Observable.of('error'),
3032
};
3133
}
3234

35+
setRating(rating): void {
36+
this.rating = rating;
37+
this.rating$.next(rating);
38+
}
39+
3340
waitCallback: { (data: any): Promise<void> } = (data: any) => {
3441
return new Promise<void>((resolve: Function, reject: Function): void => {
3542
setTimeout(() => {
@@ -45,4 +52,4 @@ export class FormsBootstrapper {
4552
}
4653
return false;
4754
}
48-
}
55+
}

bootstrapper/inputs/inputsNg1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ <h3><a href="https://github.com/SamGraber/TypeScript-Angular-Components/blob/mas
8888

8989
<div>
9090
<label><a href="https://github.com/SamGraber/TypeScript-Angular-Components/tree/master/source/behaviors/required/required.md">Required input</a>:</label>
91-
<rl-textbox ng-model="input.requiredText" rl-required="Input required"></rl-textbox>
91+
<rl-textbox ng-model="input.requiredText" warning="true"></rl-textbox>
9292
</div>
9393
<div>
9494
<label>One validator:</label>

bootstrapper/inputs/inputsNg2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h3><a href="https://github.com/SamGraber/TypeScript-Angular-Components/blob/mas
3434
<rlSelect [(value)]="selection" label="Select" [options]="options" transform="value">
3535
<template let-option>#{{option.value}}</template>
3636
</rlSelect>
37-
<rlSelect name="select1" label="Select" [options]="optionsAsync" transform="value" rlRequired="Required select" nullOption="None"></rlSelect>
37+
<rlSelect name="select1" label="Select" [options]="optionsAsync | async" transform="value" rlRequired="Required select" nullOption="None"></rlSelect>
3838
<rlSelect [value]="selection" (change)="log($event)" label="Output event" [options]="options" transform="value"></rlSelect>
3939
</div>
4040
<div>

bootstrapper/msi/msi.ng2.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<h3>Multi Step Indicator Angular 2</h3>
22
<rlMultiStepIndicator
3-
[numbered]="numbered"
4-
[checked]="checked"
5-
[steps]="steps">
3+
[numbered]="numbered"
4+
[checked]="checked"
5+
[steps]="steps">
66
</rlMultiStepIndicator>
7+
<h3>rlStep</h3>
8+
<rlStep title="Inputs"
9+
link="/inputs/ng2"
10+
[valid]="false"></rlStep>
11+
<rlStep title="MSI"
12+
link="../ng2"></rlStep>

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
1212
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
1313
<link rel="stylesheet" href="/dist/components.css">
14+
<link rel="stylesheet" href="/bootstrapper/bootstrapper.css">
1415

1516
<div>
1617
<ts-app></ts-app>

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-angular-components",
3-
"version": "3.3.0",
3+
"version": "3.7.2",
44
"description": "Reusable responsive angular components",
55
"author": "Renovo Development Team",
66
"keywords": [
@@ -47,7 +47,7 @@
4747
"bundle-deps": "gulp bundle-bootstrapper-vendor && gulp bundle-bootstrapper-renovo && gulp bundle-tests-vendor && gulp bundle-tests-renovo"
4848
},
4949
"devDependencies": {
50-
"@renovolive/gulp-utilities": "~2.3.0",
50+
"@renovolive/gulp-utilities": "~2.4.0",
5151
"chai": "~3.5.0",
5252
"concurrently": "~2.0.0",
5353
"del": "^2.2.0",
@@ -93,7 +93,7 @@
9393
"@types/jquery": "^2.0.32",
9494
"@types/jquery.jsignature": "^2.0.28",
9595
"@types/lodash": "^4.14.36",
96-
"@types/moment-timezone": "^0.2.31",
96+
"@types/moment-timezone": "0.2.31",
9797
"@types/sinon": "^1.16.31",
9898
"angular": "~1.5.3",
9999
"angular-animate": "~1.5.3",
@@ -112,8 +112,7 @@
112112
"rl-http": "~1.2.0",
113113
"rxjs": "5.0.0-beta.12",
114114
"systemjs": "^0.19.28",
115-
"typescript": "^2.0.3",
116-
"typescript-angular-utilities": "~3.8.0",
115+
"typescript-angular-utilities": "~3.9.0",
117116
"ui-select": "~0.14.7",
118117
"zone.js": "~0.6.25"
119118
},

source/animations/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as slide from './slide/slide.animate';
2+
3+
export {
4+
slide,
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { AnimationEntryMetadata, trigger, state, style, transition, animate } from '@angular/core';
2+
3+
export const show: string = 'show';
4+
export const hide: string = 'hide';
5+
6+
export const animation = trigger('slide', [
7+
state(hide, style({
8+
zIndex: 1,
9+
opacity: 0,
10+
transform: 'translateY(100%)',
11+
})),
12+
state(show, style({
13+
opacity: 1,
14+
transform: 'translateY(0)',
15+
})),
16+
transition(`${hide} <=> ${show}`, animate('250ms ease')),
17+
]);

source/behaviors/autosave/autosave.tests.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { services } from 'typescript-angular-utilities';
66
import { AutosaveDirective, DEFAULT_AUTOSAVE_DEBOUNCE } from './autosave';
77

88
interface IFormMock {
9-
form: { statusChanges: Subject<void> };
9+
dirty: boolean;
10+
form: { statusChanges: Subject<void> };
1011
validate: Sinon.SinonSpy;
1112
submitAndWait: Sinon.SinonSpy;
1213
saveForm: Sinon.SinonSpy;
@@ -23,7 +24,10 @@ describe('AutosaveDirective', () => {
2324

2425
beforeEach(() => {
2526
form = {
26-
form: { statusChanges: new Subject<void>() },
27+
dirty: true,
28+
form: {
29+
statusChanges: new Subject<void>(),
30+
},
2731
validate: sinon.spy(() => true),
2832
submitAndWait: sinon.spy(),
2933
saveForm: sinon.spy(),
@@ -89,6 +93,19 @@ describe('AutosaveDirective', () => {
8993
sinon.assert.notCalled(autosaveSpy);
9094
}));
9195

96+
it('should not trigger an autosave if the form is pristine', rlFakeAsync(() => {
97+
const autosaveSpy = sinon.spy();
98+
autosave.autosave = autosaveSpy;
99+
form.dirty = false;
100+
101+
autosave.setDebounce();
102+
103+
rlTick(DEFAULT_AUTOSAVE_DEBOUNCE);
104+
flushMicrotasks();
105+
106+
sinon.assert.notCalled(autosaveSpy);
107+
}));
108+
92109
it('should still trigger an autosave if the form is invalid but saveWhenInvalid is enabled', rlFakeAsync(() => {
93110
const autosaveSpy = sinon.spy();
94111
autosave.autosave = autosaveSpy;

source/behaviors/autosave/autosave.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AutosaveDirective implements AfterViewInit {
3434
}
3535

3636
setDebounce = (): void => {
37-
if (!this.timer && (this.saveWhenInvalid || this.form.validate())) {
37+
if (!this.timer && this.form.dirty && (this.saveWhenInvalid || this.form.validate())) {
3838
this.timer = this.timeoutService.setTimeout(this.autosave, DEFAULT_AUTOSAVE_DEBOUNCE)
3939
.catch(() => null);
4040
}

source/components/cardContainer/cardContainer.ng1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</template>
4040
</rl-generic-container>
4141

42-
<div class="alert alert-info" ng-show="!cardContainer.hasItems">
42+
<div class="alert alert-info" ng-show="cardContainer.dataSource.needsRefinedSearch">
4343
Please refine your search results
4444
</div>
4545
<div class="alert alert-info" ng-show="cardContainer.dataSource.isEmpty">

source/components/cardContainer/cardContainer.ng1.tests.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -592,27 +592,6 @@ describe('CardContainerController', () => {
592592
});
593593
});
594594

595-
describe('hasItems', (): void => {
596-
it('should return true if the data set is not empty', (): void => {
597-
let dataSource: IDataSourceMock;
598-
dataSource = buildMockedDataSource();
599-
dataSource.rawDataSet = [
600-
{ id: 0 },
601-
{ id: 1 },
602-
];
603-
dataSource.dataSet = dataSource.rawDataSet;
604-
buildController();
605-
606-
cardContainer.dataSource.dataSet = [];
607-
608-
expect(cardContainer.hasItems).to.be.false;
609-
610-
cardContainer.dataSource.dataSet = [1];
611-
612-
expect(cardContainer.hasItems).to.be.true;
613-
});
614-
});
615-
616595
function buildController(): void {
617596
if (cardContainer.dataSource == null && builder._dataSource == null) {
618597
mockedDataSource = buildMockedDataSource();

source/components/cardContainer/cardContainer.ng1.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,6 @@ export class CardContainerController {
240240
this.selectionChangedEvent();
241241
}
242242

243-
get hasItems(): boolean {
244-
return this.dataSource.dataSet && !!this.dataSource.dataSet.length;
245-
}
246-
247243
private syncFilters(): void {
248244
if (!this.object.isNullOrEmpty(this.filters)) {
249245
this.dataSource.filters = this.filters;

source/components/cardContainer/dataSources/simpleDataSource/simpleDataSource.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class SimpleDataSource<TDataType> extends DataSourceBaseOld<TDataType> {
1414
super(dataSourceProcessor, array);
1515
this.countFilterGroups = false;
1616
this.rawDataSet = data;
17+
this.isEmpty = !(data && data.length);
1718
this.processData();
1819
}
1920
}

source/components/inputs/absoluteTime/absoluteTime.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<div class="field input-group"
2-
[class.error]="!control.valid"
2+
[class.warning]="warning"
3+
[class.error]="componentValidator.error$ | async"
34
(offClick)="closeTimes()">
4-
<label class="label-slide angular-animate" [hidden]="!(value && label)">{{label}}</label>
5+
<label [@slide]="labelState">{{label}}</label>
56
<input type="text"
6-
class="form-control angular-animate"
7+
class="form-control"
8+
[class.hide-placeholder]="hidePlaceholder"
79
[value]="displayTime"
10+
(focus)="showLabel()"
11+
(blur)="hideLabelIfEmpty()"
812
(click)="toggleTimes()"
913
[placeholder]="label"
1014
[disabled]="disabled" />
@@ -42,7 +46,7 @@
4246
</div>
4347
</div>
4448
</div>
45-
<div [hidden]="control.valid" class="error-string">
46-
{{componentValidator.error}}
49+
<div *ngIf="componentValidator.error$ | async" class="error-string">
50+
{{componentValidator.error$ | async}}
4751
</div>
48-
</div>
52+
</div>

source/components/inputs/absoluteTime/absoluteTime.tests.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Observable } from 'rxjs';
12
import { services } from 'typescript-angular-utilities';
23
import __time = services.time;
34
import __object = services.object;
@@ -14,8 +15,8 @@ describe('AbsoluteTimeComponent', () => {
1415

1516
beforeEach(() => {
1617
const validator: any = {
17-
validate: sinon.spy(),
18-
setValidators: sinon.spy(),
18+
validate: sinon.spy(() => Observable.empty()),
19+
initValidator: sinon.spy(),
1920
};
2021
setValue = sinon.spy();
2122

source/components/inputs/absoluteTime/absoluteTime.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ import { ValidatedInputComponent, validationInputs, baseOutputs } from '../valid
1212
import { ComponentValidator } from '../../../services/componentValidator/componentValidator.service';
1313
import { FormComponent } from '../../form/form';
1414

15+
import { baseAnimations } from '../input';
16+
1517
@Component({
1618
selector: 'rlAbsoluteTime',
1719
template: require('./absoluteTime.html'),
1820
inputs: validationInputs,
1921
outputs: baseOutputs,
2022
providers: [ComponentValidator],
23+
animations: baseAnimations,
2124
})
2225
export class AbsoluteTimeComponent extends ValidatedInputComponent<string> implements OnInit {
2326
@Input() minuteInterval: number = 15;

source/components/inputs/dateTime/dateTime.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<div class="field date-time"
2+
[class.warning]="warning"
23
[class.has-warning]="!validFormat"
3-
[class.error]="!control.valid"
4+
[class.error]="componentValidator.error$ | async"
45
[class.datepicker-with-clear]="showClear">
56
<span #datepicker class="datepicker-input-group">
6-
<label class="label-slide angular-animate" [hidden]="!(value && label)">{{label}}</label>
7+
<label [@slide]="labelState">{{label}}</label>
78
<input type="text"
89
#dateinput
910
class="form-control"
11+
[class.hide-placeholder]="hidePlaceholder"
12+
(focus)="showLabel()"
13+
(blur)="hideLabelIfEmpty()"
1014
[value]="valueAsString"
1115
[placeholder]="label"
1216
[disabled]="disabled" />
@@ -21,7 +25,7 @@
2125
<i class="fa fa-times"></i>
2226
</rlButton>
2327
</span>
24-
<div [hidden]="control.valid" class="error-string">
25-
{{componentValidator.error}}
28+
<div *ngIf="componentValidator.error$ | async" class="error-string">
29+
{{componentValidator.error$ | async}}
2630
</div>
27-
</div>
31+
</div>

source/components/inputs/dateTime/dateTime.ng1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="field date-time" ng-class="{ 'has-warning': !dateTime.validFormat, 'error': dateTime.ngModel.$invalid, 'datepicker-with-clear': dateTime.clearButton }">
1+
<div class="field date-time" ng-class="{ 'has-warning': !dateTime.validFormat, 'warning': input.warning, 'error': dateTime.ngModel.$invalid, 'datepicker-with-clear': dateTime.clearButton }">
22
<span class="show-date-picker datepicker-input-group">
33
<label class="label-slide angular-animate" ng-show="dateTime.ngModel.$viewValue | isEmpty:false && dateTime.label">{{dateTime.label}}</label>
44
<input type="text" class="form-control" ng-model="dateTime.ngModel.$viewValue" placeholder="{{dateTime.label}}"/>

0 commit comments

Comments
 (0)