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

new feature: add disabled for pagination #10006

Merged
merged 1 commit into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/docs/en-US/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Add more modules based on your scenario.
| popper-class | custom class name for the page size Select's dropdown | string | — | — |
| prev-text | text for the prev button | string | — | — |
| next-text | text for the next button | string | — | — |
| disabled | whether Pagination is disabled | boolean | — | false |

### Events
| Event Name | Description | Parameters |
Expand Down
1 change: 1 addition & 0 deletions examples/docs/es/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Agrega más modulos basados en su escenario.
| popper-class | clase propia para el `dropdown` del `select` del número de páginas | string | — | — |
| prev-text | texto para el botón `prev` | string | — | — |
| next-text | texto para el botón `next` | string | — | — |
| disabled | whether Pagination is disabled | boolean | — | false |

### Eventos
| Nombre del evento | Descripción | Parámetros |
Expand Down
1 change: 1 addition & 0 deletions examples/docs/zh-CN/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
| popper-class | 每页显示个数选择器的下拉框类名 | string | — | — |
| prev-text | 替代图标显示的上一页文字 | string | — | — |
| next-text | 替代图标显示的下一页文字 | string | — | — |
| disabled | 是否禁用 | boolean | — | false |

### Events
| 事件名称 | 说明 | 回调参数 |
Expand Down
29 changes: 20 additions & 9 deletions packages/pagination/src/pager.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<template>
<ul @click="onPagerClick" class="el-pager">
<li
:class="{ active: currentPage === 1 }"
:class="{ active: currentPage === 1, disabled }"
v-if="pageCount > 0"
class="number">1</li>
<li
class="el-icon more btn-quickprev"
:class="[quickprevIconClass]"
:class="[quickprevIconClass, { disabled }]"
v-if="showPrevMore"
@mouseenter="quickprevIconClass = 'el-icon-d-arrow-left'"
@mouseenter="onMouseenter('left')"
@mouseleave="quickprevIconClass = 'el-icon-more'">
</li>
<li
v-for="pager in pagers"
:key="pager"
:class="{ active: currentPage === pager }"
:class="{ active: currentPage === pager, disabled }"
class="number">{{ pager }}</li>
<li
class="el-icon more btn-quicknext"
:class="[quicknextIconClass]"
:class="[quicknextIconClass, { disabled }]"
v-if="showNextMore"
@mouseenter="quicknextIconClass = 'el-icon-d-arrow-right'"
@mouseenter="onMouseenter('right')"
@mouseleave="quicknextIconClass = 'el-icon-more'">
</li>
<li
:class="{ active: currentPage === pageCount }"
:class="{ active: currentPage === pageCount, disabled }"
class="number"
v-if="pageCount > 1">{{ pageCount }}</li>
</ul>
Expand All @@ -37,7 +37,9 @@
props: {
currentPage: Number,

pageCount: Number
pageCount: Number,

disabled: Boolean
},

watch: {
Expand All @@ -53,7 +55,7 @@
methods: {
onPagerClick(event) {
const target = event.target;
if (target.tagName === 'UL') {
if (target.tagName === 'UL' || this.disabled) {
return;
}

Expand Down Expand Up @@ -83,6 +85,15 @@
if (newPage !== currentPage) {
this.$emit('change', newPage);
}
},

onMouseenter(direction) {
if (this.disabled) return;
if (direction === 'left') {
this.quickprevIconClass = 'el-icon-d-arrow-left';
} else {
this.quicknextIconClass = 'el-icon-d-arrow-right';
}
}
},

Expand Down
16 changes: 11 additions & 5 deletions packages/pagination/src/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export default {

nextText: String,

background: Boolean
background: Boolean,

disabled: Boolean
},

data() {
Expand All @@ -62,7 +64,7 @@ export default {
const TEMPLATE_MAP = {
prev: <prev></prev>,
jumper: <jumper></jumper>,
pager: <pager currentPage={ this.internalCurrentPage } pageCount={ this.internalPageCount } on-change={ this.handleCurrentChange }></pager>,
pager: <pager currentPage={ this.internalCurrentPage } pageCount={ this.internalPageCount } on-change={ this.handleCurrentChange } disabled={ this.disabled }></pager>,
next: <next></next>,
sizes: <sizes pageSizes={ this.pageSizes }></sizes>,
slot: <my-slot></my-slot>,
Expand Down Expand Up @@ -107,7 +109,7 @@ export default {
return (
<button
type="button"
class={['btn-prev', { disabled: this.$parent.internalCurrentPage <= 1 }]}
class={['btn-prev', { disabled: this.$parent.disabled || this.$parent.internalCurrentPage <= 1 }]}
on-click={ this.$parent.prev }>
{
this.$parent.prevText
Expand All @@ -126,7 +128,7 @@ export default {
type="button"
class={[
'btn-next',
{ disabled: this.$parent.internalCurrentPage === this.$parent.internalPageCount || this.$parent.internalPageCount === 0 }
{ disabled: this.$parent.disabled || this.$parent.internalCurrentPage === this.$parent.internalPageCount || this.$parent.internalPageCount === 0 }
]}
on-click={ this.$parent.next }>
{
Expand Down Expand Up @@ -166,7 +168,8 @@ export default {
<el-select
value={ this.$parent.internalPageSize }
popperClass={ this.$parent.popperClass || '' }
on-input={ this.handleChange }>
on-input={ this.handleChange }
disabled={ this.$parent.disabled }>
{
this.pageSizes.map(item =>
<el-option
Expand Down Expand Up @@ -253,6 +256,7 @@ export default {
domPropsValue={ this.$parent.internalCurrentPage }
type="number"
ref="input"
disabled={ this.$parent.disabled }
nativeOnKeyup={ this.handleKeyup }
onChange={ this.handleChange }
onFocus={ this.handleFocus }
Expand Down Expand Up @@ -284,11 +288,13 @@ export default {
},

prev() {
if (this.disabled) return;
const newVal = this.internalCurrentPage - 1;
this.internalCurrentPage = this.getValidCurrentPage(newVal);
},

next() {
if (this.disabled) return;
const newVal = this.internalCurrentPage + 1;
this.internalCurrentPage = this.getValidCurrentPage(newVal);
},
Expand Down
15 changes: 14 additions & 1 deletion packages/theme-chalk/src/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
padding-left: 12px;
}

.el-pager li.disabled {
color: $--color-text-placeholder;
cursor: not-allowed;
}

@include m(small) {
.btn-prev,
.btn-next,
Expand Down Expand Up @@ -173,6 +178,10 @@
color: $--color-text-regular;
min-width: 30px;
border-radius: 2px;

&.disabled {
color: $--color-text-placeholder;
}
}

.btn-prev, .btn-next {
Expand All @@ -183,7 +192,7 @@
}
}

.el-pager li {
.el-pager li:not(.disabled) {
&:hover {
color: $--pagination-hover-fill;
}
Expand Down Expand Up @@ -236,6 +245,10 @@
&.btn-quickprev {
line-height: 28px;
color: $--pagination-button-color;

&.disabled {
color: $--color-text-placeholder;
}
}

&.btn-quickprev:hover {
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2434,6 +2434,10 @@ eslint-config-defaults@*:
version "9.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-defaults/-/eslint-config-defaults-9.0.0.tgz#a090adc13b2935e3f43b3cd048a92701654e5ad5"

eslint-config-elemefe@*:
version "0.3.0"
resolved "https://registry.yarnpkg.com/eslint-config-elemefe/-/eslint-config-elemefe-0.3.0.tgz#6f06cd6a8c6949bf58fa7fe2d4b4a4fde89bf008"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert 一下这个文件吧

[email protected]:
version "0.1.1"
resolved "https://registry.yarnpkg.com/eslint-config-elemefe/-/eslint-config-elemefe-0.1.1.tgz#5a1664ce3f7d91f68528b508d040044ae6c10aa3"
Expand Down