Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Angular mixins for fractional-width columns and groupable columns #1587

Merged
merged 6 commits into from
Oct 5, 2023

Conversation

mollykreis
Copy link
Contributor

Pull Request

🤨 Rationale

Resolves #1211

In Angular, we didn't have a solution for the code duplication that came with multiple columns being fractional width and groupable. This PR creates mixins for fractional width columns and groupable columns to reduce the amount of duplication. There is still the potential for future code reduction within the tests, but I decided that coming up to a solution single-sourcing more of our test code was out of scope for this PR.

👩‍💻 Implementation

  • Create mixinFractionalWidthColumnAPI function that allows a NimbleTableColumnBaseDirective to claim support for being fractional width (i.e. inputs for fractionalWidth and minPixelWidth). This function is exported from the existing @ni/nimble-angular/table-column entry point.
  • Create mixinGroupableColumnAPI function that allows a NimbleTableColumnBaseDirective to claim support for being groupable (i.e. inputs for groupIndex and groupingDisabled). This function is exported from the existing @ni/nimble-angular/table-column entry point.
  • Update existing table columns to use these new mixins
  • These changes required making renderer and elementRef public (though marked as internal) in NimbleTableColumnBaseDirective because otherwise TS error 4094 is triggered. This is related to the mixinFractionalWidthColumnAPI and mixinGroupableColumnAPI functions having an implicit return type and that inferred type including NimbleTableColumnBaseDirective. The scenario I was hitting is described in this TypeScript issue.

🧪 Testing

  • Verified existing unit tests are passing
  • Verified Angular example app still works as expected

✅ Checklist

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

@mollykreis mollykreis marked this pull request as ready for review October 5, 2023 20:19
@rajsite rajsite enabled auto-merge (squash) October 5, 2023 23:02
@rajsite rajsite merged commit c074575 into main Oct 5, 2023
9 checks passed
@rajsite rajsite deleted the angular-mixins branch October 5, 2023 23:28
rajsite added a commit that referenced this pull request Oct 6, 2023
rajsite added a commit that referenced this pull request Oct 6, 2023
…ble columns (#1591)

# Pull Request

## 🤨 Rationale
Turns out the pattern introduced in #1587 for [using TypeScript mixins
does not work for Angular
directives](angular/angular#42594 (comment))
and resulted in [build failures for a built library used outside the
workspace](https://dev.azure.com/ni/DevCentral/_build/results?buildId=6361598&view=logs&j=5cb0c4d9-f36d-5fb3-bf2e-85320ef8bd68&t=51824763-f056-5c1e-0120-b664705fb575&l=71).

Reading the linked comment it sounds like we are seeing the exact
behavior described. `@Input` bindings used in the base class (column-id)
are failing to resolve. Even the extra sinister part where it works in
the workspace (our tests do [test bindings to base class props like
column-id](https://github.com/ni/nimble/blob/main/angular-workspace/projects/ni/nimble-angular/table-column/anchor/tests/nimble-table-column-anchor.directive.spec.ts#L169))
but not in apps using the published library 😵.

## 👩‍💻 Implementation

Revert the refactor

## 🧪 Testing

Rely on CI

## ✅ Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed. Nada
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create mixins for Angular table column directives
3 participants