in modules/frontend/app/configuration/components/page-configure-advanced/components/page-configure-advanced-models/controller.ts [62:161]
$onInit() {
this.visibleRows$ = new Subject();
this.selectedRows$ = new Subject();
this.columnDefs = [
{
name: 'hasIndex',
displayName: 'Indexed',
field: 'hasIndex',
type: 'boolean',
enableFiltering: true,
visible: true,
multiselectFilterOptions: [{value: true, label: 'Yes'}, {value: false, label: 'No'}],
width: 100,
cellTemplate: hasIndexTemplate
},
{
name: 'keyType',
displayName: 'Key type',
field: 'keyType',
enableHiding: false,
filter: {
placeholder: 'Filter by key type…'
},
cellTemplate: keyCellTemplate,
minWidth: 165
},
{
name: 'valueType',
displayName: 'Value type',
field: 'valueType',
enableHiding: false,
filter: {
placeholder: 'Filter by value type…'
},
sort: {direction: 'asc', priority: 0},
cellTemplate: valueCellTemplate,
minWidth: 165
}
];
this.itemID$ = this.$uiRouter.globals.params$.pipe(pluck('modelID'));
this.shortItems$ = this.ConfigureState.state$.pipe(
this.ConfigSelectors.selectCurrentShortModels,
tap((shortModels = []) => {
const value = shortModels.every((m) => m.hasIndex);
this.columnDefs[0].visible = !value;
}),
publishReplay(1),
refCount()
);
this.shortCaches$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortCaches);
this.originalItem$ = this.itemID$.pipe(
distinctUntilChanged(),
switchMap((id) => {
return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectModelToEdit(id));
}),
distinctUntilChanged(),
publishReplay(1),
refCount()
);
this.isNew$ = this.itemID$.pipe(map((id) => id === 'new'));
this.itemEditTitle$ = combineLatest(this.isNew$, this.originalItem$, (isNew, item) => {
return `${isNew ? 'Create' : 'Edit'} model ${!isNew && get(item, 'valueType') ? `‘${get(item, 'valueType')}’` : ''}`;
});
this.selectionManager = this.configSelectionManager({
itemID$: this.itemID$,
selectedItemRows$: this.selectedRows$,
visibleRows$: this.visibleRows$,
loadedItems$: this.shortItems$
});
this.tableActions$ = this.selectionManager.selectedItemIDs$.pipe(map((selectedItems) => [
{
action: 'Clone',
click: () => this.clone(selectedItems),
available: false
},
{
action: 'Delete',
click: () => {
this.remove(selectedItems);
},
available: true
}
]));
this.subscription = merge(
this.originalItem$,
this.selectionManager.editGoes$.pipe(tap((id) => this.edit(id))),
this.selectionManager.editLeaves$.pipe(tap((options) => this.$state.go('base.configuration.edit.advanced.models', null, options)))
).subscribe();
}