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

Added row iterator properties #10

Merged
merged 12 commits into from
Dec 20, 2018
Merged

Conversation

Blackbaud-AlexKingman
Copy link
Contributor

@Blackbaud-AlexKingman Blackbaud-AlexKingman commented Dec 18, 2018

@codecov-io
Copy link

codecov-io commented Dec 18, 2018

Codecov Report

Merging #10 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #10      +/-   ##
==========================================
+ Coverage   99.64%   99.71%   +0.07%     
==========================================
  Files           9       10       +1     
  Lines         280      350      +70     
  Branches       42       53      +11     
==========================================
+ Hits          279      349      +70     
  Misses          1        1
Impacted Files Coverage Δ
src/app/public/modules/flyout/flyout.module.ts 100% <100%> (ø) ⬆️
...public/modules/flyout/types/flyout-message-type.ts 100% <100%> (ø) ⬆️
src/app/public/modules/flyout/flyout.component.ts 100% <100%> (ø) ⬆️
src/app/public/modules/flyout/flyout-instance.ts 100% <100%> (ø) ⬆️
...public/modules/flyout/flyout-iterator.component.ts 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f85ff15...f2ef418. Read the comment docs.

}
});

this.flyout.onRowIteratorPreviousClick.subscribe(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix "on" should be used for the listener, not the event itself. In this case, consumers are subscribing to an observable event, so the name shouldn't be prefixed with "on".

(Also, I know this feature is going to be used by grid rows, but we probably shouldn't include the "row" keyword to the event name. To me, it communicates an enforced pattern that isn't always applicable. What if the buttons iterated through a list or a group of action buttons?)

Something like the following?

this.flyout.previousIteratorButtonClick.subscribe(...)
// or...
this.flyout.iteratorPreviousButtonClick.subscribe(...)
// or...
this.flyout.iterator.previousButtonClick.subscribe(...)

(That last example matches the config pattern, if you wanted to go that route.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visual test (and the future demo) should also demonstrate that these subscriptions need to be completed in ngOnDestroy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call about the "row" keyword. I've removed all references to "row" in the codebase. I've also gone with the this.flyout.iterator.previousButtonClick pattern.

useValue: record
}],
rowIterator: {
previousIsDisabled: previousIsDisabled,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previousButtonDisabled

It might be easier for people to remember the property name if we use the pattern set by the HTML standard for the disabled attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done

@@ -3,7 +3,7 @@ import {
} from '@angular/core';

import {
SkyFlyoutService
SkyFlyoutService, SkyFlyoutInstance

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiline import.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/app/public/modules/flyout/flyout-instance.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
export interface SkyFlyoutIterator {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should rename this to SkyFlyoutIteratorConfig so that we can use the SkyFlyoutIterator type for the public SkyFlyoutInstance.iterator property?

<div class="sky-flyout-header-content">

<div *ngIf="config?.iterator"
id="row-iterators"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why you need an id on this element? If so, it will need an auto-increment applied to keep it unique.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant as a unique identifier to easily locate the buttons in the unit test. Isn't there only ever one flyout open at a time?

</div>

</div>
<div class="sky-flyout-header-buttons">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a few extra tabs in the template, here.

@@ -251,6 +251,18 @@ export class SkyFlyoutComponent implements OnDestroy, OnInit {
this.adapter.toggleIframePointerEvents(true);
}

public onIteratorPreviousClick() {
if (this.config.iterator && !this.config.iterator.previousButtonDisabled) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these methods are isolated to the buttons' click events, do we need the conditions? For these events to be executed, the iterator configuration must already exist, and the event won't be triggered if the button is natively disabled. You might be safe to simply call the emit methods without any condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah true, but these are public methods. I think I was just adding extra safeguards here in case they were used for something else in the future. Could I persuade you on this one in the interest of being extra cautious?

} from '@angular/core';

import {
Subject
} from 'rxjs';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 'rxjs/Subject' until we can update to the latest version of RxJS (they've improved their imports in later versions, and don't pull in more than they ought to).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@Blackbaud-TimHammond
Copy link

The next row/previous row buttons look good from a UX perspective.

@@ -60,7 +65,8 @@ import {
SkyFlyoutResourcesModule
],
exports: [
SkyFlyoutComponent
SkyFlyoutComponent,
SkyFlyoutIteratorComponent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't want to export the iterator component to the consumers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. That was an oversight. Fixed.

public closed = new EventEmitter<void>();
public componentInstance: T;
public isOpen = true;

public iteratorPreviousButtonClick = new EventEmitter<void>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EventEmitter instance variables should be getters, so that the consumer cannot reassign them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

}

public onIteratorNextButtonClick() {
if (this.config.showIterator && !this.config.iteratorNextButtonDisabled) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These events should never be emitted if the underlying button is disabled, so isn't the this.config.iteratorNextButtonDisabled check redundant? (Same for the previous button.)

@@ -1,4 +1,8 @@
export enum SkyFlyoutMessageType {
Open = 0,
Close = 1
Close = 1,
IteratorNextButtonEnabled = 10,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message types should be verbs, EnableIteratorNextButton. Also, you can let the enum auto-increment the IDs by writing it this way:

export enum SkyFlyoutMessageType {
  Open = 0,
  Close,
  EnableIteratorNextButton,
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good tip. Done.

Copy link
Member

@Blackbaud-SteveBrush Blackbaud-SteveBrush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants