@coolon/angular-ui-powerups 13.7.12 → 13.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/exports.mjs +2 -1
- package/esm2020/lib/components/tables/abstract-table-model.mjs +61 -16
- package/esm2020/lib/components/tables/column/column-list-model.mjs +5 -1
- package/esm2020/lib/components/tables/filter-strategy.mjs +31 -0
- package/fesm2015/coolon-angular-ui-powerups.mjs +95 -15
- package/fesm2015/coolon-angular-ui-powerups.mjs.map +1 -1
- package/fesm2020/coolon-angular-ui-powerups.mjs +94 -15
- package/fesm2020/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/components/exports.d.ts +1 -0
- package/lib/components/tables/abstract-table-model.d.ts +4 -3
- package/lib/components/tables/column/column-list-model.d.ts +1 -0
- package/lib/components/tables/filter-strategy.d.ts +19 -0
- package/package.json +2 -2
|
@@ -2974,6 +2974,10 @@ class ColumnListModel extends AbstractComputedListModel {
|
|
|
2974
2974
|
hasColumn(id) {
|
|
2975
2975
|
return !!this.columnsById$.get(id);
|
|
2976
2976
|
}
|
|
2977
|
+
hasMatchingColumn(row, regex) {
|
|
2978
|
+
// only search the visible columns
|
|
2979
|
+
return !!this.value.find(c => regex.test(c.getSearchTextFor(row)));
|
|
2980
|
+
}
|
|
2977
2981
|
addColumn(column, index) {
|
|
2978
2982
|
if (this.hasColumn(column.columnId)) {
|
|
2979
2983
|
lang.illegalState(`Column with id=${column.columnId} already exists`);
|
|
@@ -3242,6 +3246,58 @@ class RowClass {
|
|
|
3242
3246
|
this.matches = matches;
|
|
3243
3247
|
}
|
|
3244
3248
|
}
|
|
3249
|
+
class FilterManager extends GarbageCollector {
|
|
3250
|
+
constructor(columns) {
|
|
3251
|
+
super();
|
|
3252
|
+
this.columns = columns;
|
|
3253
|
+
this._userRowPredicate$ = this.registerDisposable(new DelegatingValueModel().withDefault(() => true));
|
|
3254
|
+
this._searchText$ = this.registerDisposable(new DelegatingValueModel());
|
|
3255
|
+
this.updateInProgress = new Guard();
|
|
3256
|
+
const { chain } = Dsl.disposeWith(this);
|
|
3257
|
+
// TODO: should this logic be in the strategy itself? That way users could
|
|
3258
|
+
// customise...
|
|
3259
|
+
const textSearchPredicate$ = chain(this._searchText$).map(text => {
|
|
3260
|
+
if (isEmpty$1(text)) {
|
|
3261
|
+
return () => true;
|
|
3262
|
+
}
|
|
3263
|
+
else {
|
|
3264
|
+
const regex = new RegExp(escapeStringRegexp(text), "i");
|
|
3265
|
+
return (row) => this.hasMatchingColumn(row, regex);
|
|
3266
|
+
}
|
|
3267
|
+
}, {
|
|
3268
|
+
allowNil: true,
|
|
3269
|
+
dependsOn: this.columns
|
|
3270
|
+
});
|
|
3271
|
+
this.rowPredicate$ = chain(this._userRowPredicate$)
|
|
3272
|
+
.map(p => {
|
|
3273
|
+
return ((row) => p(row) && textSearchPredicate$.value(row));
|
|
3274
|
+
}, {
|
|
3275
|
+
dependsOn: textSearchPredicate$,
|
|
3276
|
+
postponeWhile: this.updateInProgress
|
|
3277
|
+
});
|
|
3278
|
+
}
|
|
3279
|
+
setStrategy(filterStrategy) {
|
|
3280
|
+
if (this._searchText$.hasUserDelegate()) {
|
|
3281
|
+
lang.illegalState("Filter strategy has already been set, it must be disposed first.");
|
|
3282
|
+
}
|
|
3283
|
+
this.updateInProgress.whileTrue(() => {
|
|
3284
|
+
this._searchText$.setDelegate(filterStrategy.searchText$);
|
|
3285
|
+
this._userRowPredicate$.setDelegate(filterStrategy.rowPredicate$);
|
|
3286
|
+
});
|
|
3287
|
+
const self = this;
|
|
3288
|
+
return {
|
|
3289
|
+
dispose() {
|
|
3290
|
+
self.updateInProgress.whileTrue(() => {
|
|
3291
|
+
this._searchText$.setDelegate(undefined);
|
|
3292
|
+
this._userRowPredicate$.setDelegate(undefined);
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
hasMatchingColumn(row, regex) {
|
|
3298
|
+
return !!this.columns.value.find(c => regex.test(c.getSearchTextFor(row)));
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3245
3301
|
class AbstractTableModel extends GarbageCollector {
|
|
3246
3302
|
constructor() {
|
|
3247
3303
|
super();
|
|
@@ -3262,18 +3318,12 @@ class AbstractTableModel extends GarbageCollector {
|
|
|
3262
3318
|
});
|
|
3263
3319
|
this._editorSessionByRowId = chain(this._editorSessions).indexBy("rowId");
|
|
3264
3320
|
this.editing$ = chain(this._editorSessions).count().isGreaterThan(0);
|
|
3265
|
-
this.
|
|
3266
|
-
return isEmpty$1(text) ? Functions.identity : (rows) => {
|
|
3267
|
-
const regex = new RegExp(escapeStringRegexp(text), "i");
|
|
3268
|
-
return rows.filter(row => this.hasMatchingColumn(row, regex));
|
|
3269
|
-
};
|
|
3270
|
-
}, {
|
|
3271
|
-
allowNil: true,
|
|
3272
|
-
dependsOn: this.columns
|
|
3273
|
-
});
|
|
3321
|
+
this.filterManager = this.registerDisposable(new FilterManager(this._columnList));
|
|
3274
3322
|
this._filteredRows$ = chain(this._rawDataSource)
|
|
3275
|
-
.reduceToList(items =>
|
|
3276
|
-
|
|
3323
|
+
.reduceToList(items => {
|
|
3324
|
+
return items.filter(item => this.filterManager.rowPredicate$.value(item));
|
|
3325
|
+
}, {
|
|
3326
|
+
dependsOn: this.filterManager.rowPredicate$
|
|
3277
3327
|
})
|
|
3278
3328
|
.replaceAll(this.rowsBeingEdited$);
|
|
3279
3329
|
this._visibleRows$.setDelegate(this._filteredRows$);
|
|
@@ -3306,9 +3356,8 @@ class AbstractTableModel extends GarbageCollector {
|
|
|
3306
3356
|
setDataSource(sourceOfTruth) {
|
|
3307
3357
|
this._rawDataSource.setDelegate(sourceOfTruth);
|
|
3308
3358
|
}
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
this._searchText$.setDelegate(chain(searchText$).throttle(throttleDelayMilliseconds));
|
|
3359
|
+
registerFilterStrategy(filterStrategy) {
|
|
3360
|
+
return this.filterManager.setStrategy(filterStrategy);
|
|
3312
3361
|
}
|
|
3313
3362
|
identityOf(row) {
|
|
3314
3363
|
return this._rawDataSource.identityOf(row);
|
|
@@ -8280,6 +8329,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.4", ngImpor
|
|
|
8280
8329
|
}]
|
|
8281
8330
|
}] });
|
|
8282
8331
|
|
|
8332
|
+
// TODO: This is all kinda ugly and limited, would probably be better to make it an interface
|
|
8333
|
+
// that has a single model with a row matching interface.
|
|
8334
|
+
// rowPredicate$: ValueModel<row => matches(row, visibleColumns)>
|
|
8335
|
+
// that way you can implement it how every you want.... But for now this was quicker.
|
|
8336
|
+
class FilterStrategy extends GarbageCollector {
|
|
8337
|
+
constructor(rowPredicate$, searchText$) {
|
|
8338
|
+
super();
|
|
8339
|
+
this.rowPredicate$ = rowPredicate$;
|
|
8340
|
+
this.searchText$ = searchText$;
|
|
8341
|
+
}
|
|
8342
|
+
static create(build) {
|
|
8343
|
+
const builder = new FilterStrategy.BuilderImp();
|
|
8344
|
+
build(builder);
|
|
8345
|
+
return new FilterStrategy(builder.rowPredicate ?? ValueModel.constant(() => true), builder.searchText$ ?? ValueModel.constant(""));
|
|
8346
|
+
}
|
|
8347
|
+
}
|
|
8348
|
+
(function (FilterStrategy) {
|
|
8349
|
+
class BuilderImp {
|
|
8350
|
+
usePredicate(predicate$) {
|
|
8351
|
+
this.rowPredicate = predicate$;
|
|
8352
|
+
return this;
|
|
8353
|
+
}
|
|
8354
|
+
useSearchText(searchText$) {
|
|
8355
|
+
this.searchText$ = searchText$;
|
|
8356
|
+
return this;
|
|
8357
|
+
}
|
|
8358
|
+
}
|
|
8359
|
+
FilterStrategy.BuilderImp = BuilderImp;
|
|
8360
|
+
})(FilterStrategy || (FilterStrategy = {}));
|
|
8361
|
+
|
|
8283
8362
|
/**
|
|
8284
8363
|
* @file Automatically generated by barrelsby.
|
|
8285
8364
|
*/
|
|
@@ -10219,5 +10298,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.4", ngImpor
|
|
|
10219
10298
|
* Generated bundle index. Do not edit.
|
|
10220
10299
|
*/
|
|
10221
10300
|
|
|
10222
|
-
export { ACTIVITY_DATA, ALERT_CONFIG, AUP_PLACE_CONFIG, AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT, AbstractActivityTriggerComponent, AbstractCardContainerComponent, AbstractConfirmDialogComponent, AbstractDialogComponent, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractPopupMenuComponent, AbstractTableComponent, AbstractTableModel, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityBodyComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, ActivityTitleComponent, AddCardActivityComponent, AddItemInteractionContextComponent, Alert, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CardStackComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnListModel, ColumnModel, ColumnTemplateDirective, ColumnTextSearchFormatter, CommandComponent, CommandContainer, CommandDirective, CommandFace, CommandFaceComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmThenExecuteDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DecoratedTreeNode, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EnableCellTextSearch, EventCleanUpSession, FlattenedTreeListModel, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, HighlightPipe, HighlightTextModelDirective, HorizontalAlignment, IconComponent, InPlaceInteractionContextComponent, InlineActivityTriggerComponent, InlineEditorModel, InlineStringEditorComponent, InputActivity, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, Keys, LEFT_RIGHT_PLACE_ANIMATION, LabelledValueComponent, ListPlaceNavComponent, ListPropertyColumnModel, LoadingContainerComponent, MarkdownComponent, MarkdownService, ModalActivityTriggerComponent, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NotAuthorisedNoticeComponent, NumberInputComponent, POPUP_CONTAINER, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, PaginatorComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceAccessGuard, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupActivityTriggerComponent, PopupAwareComponent, PopupInteractionContextComponent, PopupMenuComponent, PopupMenuRendererComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectInputActivity, SelectInputComponent, SelectionCellComponent, SelectionColumnModel, SelectionHeaderCellComponent, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableBodyComponent, TableCellComponent, TableComponent, TableHeaderCellComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, TreeExpansionModel, TreeInheritanceIconComponent, TreeLabelCellRendererComponent, TreeLabelColumnModel, TreeTableComponent, TreeTableModel, UrlService, UrlSnapshot, VerticalFocusContainerComponent, VisibilityService, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, markdownPillExtension, slideDownOnEnterAnimation, slideRightOnEnterAnimation, treeNodeDecorator };
|
|
10301
|
+
export { ACTIVITY_DATA, ALERT_CONFIG, AUP_PLACE_CONFIG, AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT, AbstractActivityTriggerComponent, AbstractCardContainerComponent, AbstractConfirmDialogComponent, AbstractDialogComponent, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractPopupMenuComponent, AbstractTableComponent, AbstractTableModel, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityBodyComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, ActivityTitleComponent, AddCardActivityComponent, AddItemInteractionContextComponent, Alert, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CardStackComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnListModel, ColumnModel, ColumnTemplateDirective, ColumnTextSearchFormatter, CommandComponent, CommandContainer, CommandDirective, CommandFace, CommandFaceComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmThenExecuteDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DecoratedTreeNode, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EnableCellTextSearch, EventCleanUpSession, FilterStrategy, FlattenedTreeListModel, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, HighlightPipe, HighlightTextModelDirective, HorizontalAlignment, IconComponent, InPlaceInteractionContextComponent, InlineActivityTriggerComponent, InlineEditorModel, InlineStringEditorComponent, InputActivity, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, Keys, LEFT_RIGHT_PLACE_ANIMATION, LabelledValueComponent, ListPlaceNavComponent, ListPropertyColumnModel, LoadingContainerComponent, MarkdownComponent, MarkdownService, ModalActivityTriggerComponent, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NotAuthorisedNoticeComponent, NumberInputComponent, POPUP_CONTAINER, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, PaginatorComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceAccessGuard, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupActivityTriggerComponent, PopupAwareComponent, PopupInteractionContextComponent, PopupMenuComponent, PopupMenuRendererComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectInputActivity, SelectInputComponent, SelectionCellComponent, SelectionColumnModel, SelectionHeaderCellComponent, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableBodyComponent, TableCellComponent, TableComponent, TableHeaderCellComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, TreeExpansionModel, TreeInheritanceIconComponent, TreeLabelCellRendererComponent, TreeLabelColumnModel, TreeTableComponent, TreeTableModel, UrlService, UrlSnapshot, VerticalFocusContainerComponent, VisibilityService, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, markdownPillExtension, slideDownOnEnterAnimation, slideRightOnEnterAnimation, treeNodeDecorator };
|
|
10223
10302
|
//# sourceMappingURL=coolon-angular-ui-powerups.mjs.map
|