Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

List view checklist select mode #873

Merged
merged 35 commits into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e1e6498
Attempt to implement single select mode
Blackbaud-PaulCrowder May 31, 2017
e6afb19
More attempts
Blackbaud-PaulCrowder Jun 6, 2017
a7e37d1
Ng4 upgrade (#799)
Blackbaud-PatrickOFriel Jun 14, 2017
d2caa3a
Updated version of Stache (#805)
Blackbaud-SteveBrush Jun 16, 2017
c1d2d85
update travis scripts (#806)
Blackbaud-PatrickOFriel Jun 16, 2017
10e9cab
Update visual baseline with logging (#807)
Blackbaud-PatrickOFriel Jun 16, 2017
863b2bf
Travis build 1644 pushed to skyux2 [ci skip]
blackbaud-sky-build-user Jun 16, 2017
29a7c7a
Changelog and package updates for rc.0 (#808)
Blackbaud-PatrickOFriel Jun 16, 2017
fc7b73f
Merge 32 (#816)
Blackbaud-PatrickOFriel Jun 20, 2017
a409fba
Updates for rc.1 (#817)
Blackbaud-PatrickOFriel Jun 20, 2017
4d4d26a
Update karma firefox (#818)
Blackbaud-PatrickOFriel Jun 21, 2017
95dba71
Drop down primary (#819)
Blackbaud-SandhyaRajasabeson Jun 21, 2017
963c999
Updated versions of Stache, Builder (#821)
Blackbaud-SteveBrush Jun 23, 2017
25d137f
Merging master branch, Release 2.0.0-beta.2 (#826)
Blackbaud-SteveBrush Jun 23, 2017
ca00005
Merge branch 'rc-ng4-upgrade' into list-view-checklist-select-mode
Blackbaud-PatrickOFriel Jun 28, 2017
cf1b08f
Get select all and clear all buttons hiding correctly for single sele…
Blackbaud-PatrickOFriel Jun 28, 2017
442539e
Add logic around single select functionality in template
Blackbaud-PatrickOFriel Jul 5, 2017
a866dc2
Merge branch 'master' into list-view-checklist-select-mode
Blackbaud-PatrickOFriel Jul 5, 2017
43ddb2e
fix package.json conflict
Blackbaud-PatrickOFriel Jul 5, 2017
6b8acc2
Added appropriate styles for checklist single select
Blackbaud-PatrickOFriel Jul 5, 2017
443ea44
Add cursor pointer styles for single select checklist
Blackbaud-PatrickOFriel Jul 5, 2017
6e38aea
fix sort ordering
Blackbaud-PatrickOFriel Jul 6, 2017
560270a
Add checklist test stubs and accessibility roles for single select
Blackbaud-PatrickOFriel Jul 6, 2017
b18b473
Added initial tests for single select checklist
Blackbaud-PatrickOFriel Jul 6, 2017
d9ca024
Add unit tests for list toolbar
Blackbaud-PatrickOFriel Jul 7, 2017
75130d4
Fix lint errors and unit tests
Blackbaud-PatrickOFriel Jul 7, 2017
28c9d18
Add documentation for checklist select mode
Blackbaud-PatrickOFriel Jul 7, 2017
bdc4988
Add visual tests for single select checklist
Blackbaud-PatrickOFriel Jul 7, 2017
c81acb6
Merge branch 'master' into list-view-checklist-select-mode
Blackbaud-PatrickOFriel Jul 7, 2017
4b46fc4
fix package.json conflict
Blackbaud-PatrickOFriel Jul 7, 2017
24f0feb
Merge branch 'master' into list-view-checklist-select-mode
Blackbaud-PatrickOFriel Jul 13, 2017
96d46e7
Updated demo to use radio buttons
Blackbaud-PatrickOFriel Jul 13, 2017
225d3b9
Updated demo header for select mode choices
Blackbaud-PatrickOFriel Jul 13, 2017
244e27c
Merge branch 'master' into list-view-checklist-select-mode
Blackbaud-PatrickOFriel Jul 13, 2017
615caf6
Merge branch 'master' into list-view-checklist-select-mode
Blackbaud-PatrickOFriel Jul 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<button
type="button"
class="sky-btn sky-btn-primary"
style="margin-bottom: 10px;"
(click)="toggleSelectMode()">
Switch select mode
</button>

<div id="screenshot-list-view-checklist" style="background-color: white">
<sky-list [data]="data">
<sky-list-toolbar></sky-list-toolbar>
<sky-list-view-checklist
label="column1"
description="column2"
name="checklist">
name="checklist"
[selectMode]="selectMode">
</sky-list-view-checklist>
</sky-list>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Observable } from 'rxjs/Observable';
})
export class ListViewChecklistVisualComponent {

public selectMode: string = 'multiple';

public data: Observable<Array<any>> = Observable.of([
{ id: '1', column1: 101, column2: 'Apple', column3: 'Anne eats apples'},
{ id: '2', column1: 202, column2: 'Banana', column3: 'Ben eats bananas' },
Expand All @@ -17,4 +19,12 @@ export class ListViewChecklistVisualComponent {
{ id: '6', column1: 606, column2: 'Lemon', column3: 'Larry eats lemons' },
{ id: '7', column1: 707, column2: 'Strawberry', column3: 'Sally eats strawberries' }
]);

public toggleSelectMode() {
if (this.selectMode === 'multiple') {
this.selectMode = 'single';
} else {
this.selectMode = 'multiple';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ describe('list-view-checklist component', () => {
});

});

it('should display checklist view single select', () => {
return SkyVisualTest.setupTest('list-view-checklist')
.then(() => {
element(by.css('.sky-btn.sky-btn-primary')).click();
return SkyVisualTest.compareScreenshot({
screenshotName: 'list-view-checklist-single',
selector: '#screenshot-list-view-checklist'
});
});

});
});
7 changes: 7 additions & 0 deletions src/app/components/list-view-checklist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
</sky-demo-page-summary>

<sky-demo-page-properties>
<sky-demo-page-property
propertyName="selectMode"
[isOptional]="true"
defaultValue="multiple"
>
When set to single, the checklist will only allow selection of one item in the checklist.
</sky-demo-page-property>
<sky-demo-page-property
propertyName="name"
[isOptional]="false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
<div style="margin-bottom: 10px;">
<h3>Selection mode</h3>
<div>
<sky-radio
name="selectMode"
[(ngModel)]="selectMode"
value="multiple">
<sky-radio-label>
Default select mode
</sky-radio-label>
</sky-radio>
</div>
<div>
<sky-radio
name="selectMode"
[(ngModel)]="selectMode"
value="single">
<sky-radio-label>
Single select mode
</sky-radio-label>
</sky-radio>
</div>
</div>


<sky-list
[data]="items"
(selectedIdsChange)="selectedItemsChange($event)">
<sky-list-toolbar>
</sky-list-toolbar>
<sky-list-view-checklist
label="column2"
description="column3">
description="column3"
[selectMode]="selectMode">
</sky-list-view-checklist>
</sky-list>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class SkyListViewChecklistDemoComponent {

public selectedItems: Array<any> = [];

public selectMode: string = 'multiple';

public selectedItemsChange(selectedMap: Map<string, boolean>) {
this.items.take(1).subscribe((items) => {
this.selectedItems = items.filter((item) => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/list-toolbar/list-toolbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</sky-list-toolbar-item-renderer>
</sky-toolbar-item>
</sky-toolbar-section>
<sky-toolbar-section>
<sky-toolbar-section [hidden]="!(hasAdditionalToolbarSection | async)">
<sky-toolbar-item *ngFor="let item of leftTemplates | async">
<sky-list-toolbar-item-renderer
[template]="item.template"
Expand Down
24 changes: 24 additions & 0 deletions src/modules/list-toolbar/list-toolbar.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
TestBed,
async,
fakeAsync,
tick,
ComponentFixture
} from '@angular/core/testing';
import { DebugElement } from '@angular/core';
Expand Down Expand Up @@ -210,6 +212,28 @@ describe('List Toolbar Component', () => {

}));

it('should remove sort when sort selectors not available', fakeAsync(() => {
initializeToolbar();
tick();
fixture.whenStable().then(() => {
fixture.detectChanges();
tick();
dispatcher.sortSetGlobal([]);
dispatcher.sortSetAvailable([]);
fixture.detectChanges();
tick();
fixture.whenStable().then(() => {
fixture.detectChanges();
tick();
fixture.detectChanges();
state.take(1).subscribe((current) => {
expect(current.toolbar.items
.filter((item) => { return item.id === 'sort-selector'; }).length).toBe(0);
});
});
});
}));

it('should not display when sortSelectorEnabled is false', async(() => {
component.sortEnabled = false;
initializeToolbar();
Expand Down
71 changes: 51 additions & 20 deletions src/modules/list-toolbar/list-toolbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {

public inlineFilterBarExpanded: boolean = false;

public hasAdditionalToolbarSection: Observable<boolean>;

@ContentChildren(SkyListToolbarItemComponent)
private toolbarItems: QueryList<SkyListToolbarItemComponent>;

Expand All @@ -123,6 +125,8 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {
@ViewChild('inlineFilterButton')
private inlineFilterButtonTemplate: TemplateRef<any>;

private hasSortSelectors: boolean = false;

constructor(
private state: ListState,
private dispatcher: ListStateDispatcher,
Expand All @@ -145,6 +149,7 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {

getValue(this.toolbarType, (type: string) => {
this.dispatcher.next(new ListToolbarSetTypeAction(this.toolbarType));

});

getValue(this.sortSelectorEnabled, (sortSelectorEnabled: any) =>
Expand All @@ -155,22 +160,28 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {
)
);

this.dispatcher.toolbarAddItems([
this.toolbarType !== 'search' ?
new ListToolbarItemModel({
id: 'search',
template: this.searchTemplate,
location: 'center'
}) : undefined,
new ListToolbarItemModel({
id: 'sort-selector',
template: this.sortSelectorTemplate,
location: 'right'
})
].filter(item => item !== undefined));

this.sortSelectors = this.getSortSelectors();

// Initialize the sort toolbar item if necessary
this.sortSelectors.distinctUntilChanged().subscribe((currentSort) => {

if (currentSort.length > 0 && !this.hasSortSelectors) {
this.hasSortSelectors = true;
this.dispatcher.toolbarAddItems([
new ListToolbarItemModel({
id: 'sort-selector',
template: this.sortSelectorTemplate,
location: 'right'
})
], 0);
} else if (currentSort.length < 1 && this.hasSortSelectors) {
this.hasSortSelectors = false;
this.dispatcher.toolbarRemoveItems([
'sort-selector'
]);
}
});

this.searchTextInput = this.state.map(s => s.search.searchText).distinctUntilChanged();

this.view = this.state.map(s => s.views.active).distinctUntilChanged();
Expand All @@ -183,6 +194,20 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {

this.type = this.state.map((state) => state.toolbar.type).distinctUntilChanged();

this.type.subscribe((toolbarType) => {
if (toolbarType === 'search') {
this.dispatcher.toolbarRemoveItems(['search']);
} else {
this.dispatcher.toolbarAddItems([
new ListToolbarItemModel({
id: 'search',
template: this.searchTemplate,
location: 'center'
})
]);
}
});

this.isSearchEnabled = this.toolbarState.map(s => s.config)
.distinctUntilChanged().map(c => c.searchEnabled);

Expand All @@ -194,24 +219,27 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {
})
.distinctUntilChanged()
.map((filters) => {
let activeFilters = filters
.filter((f) => {
let activeFilters = filters.filter((f) => {
return f.value !== '' &&
f.value !== undefined &&
f.value !== false &&
f.value !== f.defaultValue;
});
return activeFilters.length > 0;
});

this.hasAdditionalToolbarSection = this.state.map((current) => {
return current.toolbar.items.length > 0;
});
}

public ngAfterContentInit() {
this.toolbarItems.forEach(toolbarItem =>
this.toolbarItems.forEach((toolbarItem) => {
this.dispatcher.toolbarAddItems(
[new ListToolbarItemModel(toolbarItem)],
toolbarItem.index
)
);
);
});

let sortModels = this.toolbarSorts.map(sort =>
new ListSortLabelModel(
Expand Down Expand Up @@ -273,12 +301,13 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {
global: Array<ListSortLabelModel>,
fieldSelectors: Array<ListSortFieldSelectorModel>
) => {

// Get sorts that are in the global that are not in the available
let sorts = global.filter(
g => available.filter(a => a.fieldSelector === g.fieldSelector).length === 0
);

return [...sorts, ...available].map(sortLabels => {
let resultSortSelectors = [...sorts, ...available].map(sortLabels => {
let fs = fieldSelectors.filter(f => {
return f.fieldSelector === sortLabels.fieldSelector
&& f.descending === sortLabels.descending;
Expand All @@ -293,6 +322,8 @@ export class SkyListToolbarComponent implements OnInit, AfterContentInit {
selected: selected
};
});

return resultSortSelectors;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<sky-list-toolbar>
</sky-list-toolbar>
<sky-list-view-checklist
[selectMode]="selectMode"
label="column2"
description="column3">
</sky-list-view-checklist>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
})
export class ListViewChecklistToolbarTestComponent {
public selectedItems: Map<string, boolean>;
public selectMode: string = 'multiple';

constructor(@Inject('items') public items: any) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@
cursor: pointer;
padding-left: $sky-padding;
}

/deep/ .sky-list-view-checklist-single-button {
background-color: transparent;
border: none;
border-bottom: 1px dotted $sky-color-gray-lighter;
display: block;
text-align: left;
margin-bottom: 0;
padding: $sky-padding;
width: 100%;
cursor: pointer;
}
/deep/ .sky-list-view-checklist-single-button.sky-list-view-checklist-row-selected {
background-color: $sky-selected-color;
}
}
Loading