Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.8 kB
1
Indexable
Never
    public onPaginationParametersChanged(event: PaginationParametersChangedArgs): void {

        const pageSizeChanged = this.pageSize != event.pageSize;
        const pageNumberChanged = this.pageNumber != event.page;

        if (pageSizeChanged && !pageNumberChanged) {

            if (this.dictionaryItemsHasChanges()) {

                const settings = new ConfirmDialogSettings(
                    "Данные не сохранены",
                    DictionariesGlossary.CAN_CHANGE_GRID_PAGE_SIZE_QUESTION,
                    new ConfirmDialogButtonSettings("Да", "fa-check"),
                    new ConfirmDialogButtonSettings("Отмена", "fa-reply")
                );

                this.confirmDialogService.showDialog(settings)
                    .then(result => {
                        if (result === DialogResultType.Ok) {
                            this.pageSize = event.pageSize;
                            this.needUpdateDataSourceChange.emit({ pageNumber: this.pageNumber, pageSize: this.pageSize });
                            return;
                        }
                        this.gridView.onPerPageChanged(this.pageSize);
                        return;
                    });
            }
            else {
                this.pageSize = event.pageSize;
                this.needUpdateDataSourceChange.emit({ pageNumber: this.pageNumber, pageSize: this.pageSize });
                return;
            }
        }

        if (pageNumberChanged && !pageSizeChanged) {

            if (this.dictionaryItemsHasChanges()) {

                const settings = new ConfirmDialogSettings(
                    "Данные не сохранены",
                    DictionariesGlossary.CAN_CHANGE_GRID_PAGE_QUESTION,
                    new ConfirmDialogButtonSettings("Да", "fa-check"),
                    new ConfirmDialogButtonSettings("Отмена", "fa-reply")
                );

                this.confirmDialogService.showDialog(settings)
                    .then(result => {
                        if (result === DialogResultType.Ok) {
                            this.pageNumber = event.page;
                            this.needUpdateDataSourceChange.emit({ pageNumber: this.pageNumber, pageSize: this.pageSize });
                        }
                        else {
                            this.gridView.goToPage(this.pageNumber);
                        }
                    });
            }
            else {
                this.pageNumber = event.page;
                this.needUpdateDataSourceChange.emit({ pageNumber: this.pageNumber, pageSize: this.pageSize });
            }
        }
    }