Skip to content

Commit

Permalink
confirm: support prop: showCancelButton showConfirmButton airyland#2795
Browse files Browse the repository at this point in the history
  • Loading branch information
unclay committed Jun 2, 2018
1 parent 8547e74 commit faad1aa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/components/confirm/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</div>
</template>
<div class="weui-dialog__ft">
<a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default" @click="_onCancel">{{cancelText || $t('cancel_text')}}</a>
<a href="javascript:;" class="weui-dialog__btn" :class="`weui-dialog__btn_${confirmType}`" @click="_onConfirm">{{confirmText || $t('confirm_text')}}</a>
<a v-if="showCancelButton" href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default" @click="_onCancel">{{cancelText || $t('cancel_text')}}</a>
<a v-if="showConfirmButton" href="javascript:;" class="weui-dialog__btn" :class="`weui-dialog__btn_${confirmType}`" @click="_onConfirm">{{confirmText || $t('confirm_text')}}</a>
</div>
</x-dialog>
</div>
Expand Down Expand Up @@ -95,6 +95,14 @@ export default {
confirmType: {
type: String,
default: 'primary'
},
showCancelButton: {
type: Boolean,
default: true
},
showConfirmButton: {
type: Boolean,
default: true
}
},
created () {
Expand Down
17 changes: 17 additions & 0 deletions src/components/confirm/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ props:
default: 1000
en: zIndex of mask
zh-CN: 遮罩层 z-index 值
show-cancel-button:
version: next
type: Boolean
default: true
en: if show cancel button
zh-CN: 是否显示取消按钮
show-confirm-button:
version: next
type: Boolean
default: true
en: if show confirm button
zh-CN: 是否显示确定按钮
slots:
default:
en: body content of the dialog
Expand All @@ -152,6 +164,11 @@ methods:
en: set input value when show-input is true
zh-CN: 设置输入值,当 show-input 为 true 时有效
changes:
next:
en:
- '[feature] Support prop: showCancelButton showConfirmButton #2795'
zh-CN:
- '[feature] 支持 prop: showCancelButton showConfirmButton #2795'
v2.9.1:
en:
- '[feature] add isVisible function for ConfirmPlugin #2704'
Expand Down
18 changes: 17 additions & 1 deletion src/demos/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<group>
<x-switch :title="$t('closeOnConfirm=false')" v-model="show4"></x-switch>
</group>
<group>
<x-switch :title="$t('showCancelButton=false')" v-model="show6"></x-switch>
</group>
<div v-transfer-dom>
<confirm v-model="show"
:title="$t('Confirm deleting the item')"
Expand Down Expand Up @@ -72,6 +75,16 @@
</confirm>
</div>
<br>
<div v-transfer-dom>
<confirm
v-model="show6"
:show-cancel-button="false"
:title="$t('Confirm deleting the item')"
@on-confirm="onConfirm">
<p style="text-align:center;">{{ $t('Are you sure?') }}</p>
</confirm>
</div>
<br>
<div style="padding:15px;">
<x-button @click.native="showPlugin" type="primary">{{ $t('Show') }}</x-button>
</div>
Expand Down Expand Up @@ -107,6 +120,8 @@ Set default input value:
zh-CN: 设置默认输入文字
Call prompt by using plugin:
zh-CN: 插件形式调用prompt
showCancelButton=false:
zh-CN: 隐藏取消按钮
</i18n>

<script>
Expand All @@ -127,7 +142,8 @@ export default {
show2: false,
show3: false,
show4: false,
show5: false
show5: false,
show6: false
}
},
methods: {
Expand Down

0 comments on commit faad1aa

Please sign in to comment.