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

[FEATURE] @prizm-ui/components - pass context as $implicit to templates #291

Closed
1 of 9 tasks
AleksandrSibiakov opened this issue May 19, 2023 · 0 comments
Closed
1 of 9 tasks
Assignees
Labels
estimate:sp2 priority:middle Tag: priority:middle — Denotes tasks or issues with a moderate level of importance. These items shou source:idp issue from IDP state:ready ready for release (pass tested) term:2024 type:feature
Milestone

Comments

@AleksandrSibiakov
Copy link
Contributor

Библиотека

  • @prizm-ui/core
  • @prizm-ui/components
  • @prizm-ui/install
  • @prizm-ui/icons
  • @prizm-ui/flag-icons
  • @prizm-ui/theme
  • @prizm-ui/charts
  • @prizm-ui/ast
  • @prizm-ui/nx-plugin

Компонент

PrizmHint, PrzimTooltip

Описание проблемы

При передаче контекста в [prizmHint]="someTemplate" через [prizmHintContext] шаблон создается с контекстом, отличным от того, который указал пользователь.

Делаю задачу

Примерный реальный кейс - необходимо реализовать тултип для ячеек таблицы, содержимое зависит от значения в строке.

предположим, имеется Array<Item>, interface Item { name: string, description: string }

Создаем лист:

<div *ngFor="let item in collection">
  {{ item.name }}
  
   <i class="prizm-icons-settings-tools_ellipsis-v" [prizmHint]="hint" [prizmHintContext]="{ $implicit: item }"></i>
</div>

<ng-template #hint let-ctx>
   <span>{{ ctx.description }}</span>
</ng-template>

Ожидаю, что пример выше работает (контекст, переданный в шаблон - соответствует контексту, с которым шаблон инстанциирован)

Есть проблема следующего характера:

  • контекст вычисляется один раз при иницииализации prizmHint, а не при каждом открытии (не кейс для простого примера, представленного выше)
  • Не присваивается $implicit значение из контекста в переменную ctx шаблона. Шаблон создается со значением контекста специфичным для директивы (prizmHint, prizmTooltip) - эти данные, возможно, нужны для позиционирования overlay, но не для целевого шаблона (возможно, имеет смысл их присваивать в служебное поле контекста, но не наоборот) . Непосредственно переданный контекст содержится в поле "context", т.е. рабочий сетап мог бы быть <ng-template #hint let-ctx="context.$implicit">, что выглядит неуклюже. Также, разработчик может не иметь доступа к шаблону чтобы модифицировать его, или же шаблон может использовать в разных контекстах (не внутри хинта) - что приводит к тому, что шаблон инстанциируется с различным значением контекста, в зависимости от директивы с которой он используется => приводит к ограничениям переиспользования пользовательских шаблонов\компонентов

Ожидание\предложение:

  1. Пользовательские элементы переданные как PolymorphContent (PolymorphComponent, TemplateRef) должны создаваться точно с тем контекстом, переданным в поле контекст ([prizmHintContext] в случае prizmHint).
  2. Тип поля [prizmHintContext] должен соответсвовать тому что в него передают (any\unknown). Сейчас используется Record<string, unknown> что ограничивает пользователей.
  3. Для [prizmTooltip] поле prizmHintContext переименовано в prizmTooltipContext (но доступно т.к. используется наследование)
@irustm irustm added the source:idp issue from IDP label May 22, 2023
@ZurabDev ZurabDev self-assigned this May 22, 2023
@ZurabDev ZurabDev added the state:in_progress We work on this issue label May 24, 2023
@ZurabDev ZurabDev added this to the next milestone May 24, 2023
@alexhawkins94 alexhawkins94 added the type:bug Something isn't working label May 31, 2023
@ZurabDev ZurabDev modified the milestones: next, 2.1.0 Jun 19, 2023
@ZurabDev ZurabDev removed the state:in_progress We work on this issue label Jul 11, 2023
@ZurabDev ZurabDev modified the milestones: 2.1.0, current1, 2.1.0-next.4, next, 2.1.2 Jul 17, 2023
@ZurabDev ZurabDev modified the milestones: 2.1.2, 2.1.3 Jul 24, 2023
@ZurabDev ZurabDev modified the milestones: next, 3.0.1 Aug 29, 2023
@ZurabDev ZurabDev added the state:in_progress We work on this issue label Aug 29, 2023
@ZurabDev ZurabDev modified the milestones: 3.0.1, 4.0.0 Oct 6, 2023
@ZurabDev ZurabDev added the priority:low "Tag: priority:low — Indicates tasks or issues that have a low urgency. These items are not critical label Oct 6, 2023
@ZurabDev ZurabDev added type:bc breacking_changes term:2024 and removed state:in_progress We work on this issue labels Oct 6, 2023
@alexhawkins94 alexhawkins94 added priority:middle Tag: priority:middle — Denotes tasks or issues with a moderate level of importance. These items shou and removed priority:low "Tag: priority:low — Indicates tasks or issues that have a low urgency. These items are not critical labels Feb 5, 2024
@ZurabDev ZurabDev added the state:ready ready for release (pass tested) label Mar 6, 2024
@ZurabDev ZurabDev removed the type:bc breacking_changes label Mar 6, 2024
@ZurabDev ZurabDev changed the title [BUG] @prizm-ui/components - prizmHint модифицирует переданный контекст при создании представления из шаблона [FEATURE] @prizm-ui/components - pass context as $implicit to templates Mar 6, 2024
@ZurabDev ZurabDev added type:feature and removed type:bug Something isn't working labels Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
estimate:sp2 priority:middle Tag: priority:middle — Denotes tasks or issues with a moderate level of importance. These items shou source:idp issue from IDP state:ready ready for release (pass tested) term:2024 type:feature
Projects
Status: Done
Development

No branches or pull requests

6 participants