From 978dce8c3d6322592d6b58c15d1614fc9e972760 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Fri, 6 Dec 2019 17:09:29 +0300 Subject: [PATCH] Implemented readonly support --- src/components/steps/Steps.vue | 11 ++++- src/views/steps/StepsDemo.vue | 2 +- src/views/steps/StepsDoc.vue | 87 +++++++++++++++++++++------------- 3 files changed, 65 insertions(+), 35 deletions(-) diff --git a/src/components/steps/Steps.vue b/src/components/steps/Steps.vue index 0fa274520..389a7534d 100644 --- a/src/components/steps/Steps.vue +++ b/src/components/steps/Steps.vue @@ -2,10 +2,14 @@
@@ -40,8 +44,11 @@ export default { getItemClass(item) { return ['p-steps-item', item.class, { 'p-highlight p-steps-current': (this.activeRoute === item.to), - 'p-disabled': (item.disabled || (this.activeRoute !== item.to && this.readonly)) + 'p-disabled': this.isItemDisabled(item) }]; + }, + isItemDisabled(item) { + return (item.disabled || (this.readonly && this.activeRoute !== item.to)); } }, computed: { diff --git a/src/views/steps/StepsDemo.vue b/src/views/steps/StepsDemo.vue index 0ebc16c35..d189d58e3 100644 --- a/src/views/steps/StepsDemo.vue +++ b/src/views/steps/StepsDemo.vue @@ -3,7 +3,7 @@

Steps

-

Steps components is an indicator for the steps in a wizard workflow.

+

Steps components is an indicator for the steps in a wizard workflow. Example below uses nested routes with Steps.

diff --git a/src/views/steps/StepsDoc.vue b/src/views/steps/StepsDoc.vue index 06b689ddd..cbfb607bb 100644 --- a/src/views/steps/StepsDoc.vue +++ b/src/views/steps/StepsDoc.vue @@ -8,12 +8,12 @@ import Steps from 'primevue/steps';

MenuModel

-

TabMenu uses the common MenuModel API to define the items, visit MenuModel API for details.

+

Steps uses the common MenuModel API to define the items, visit MenuModel API for details.

Getting Started

-

TabMenu is integrated with Vue Router and requires a collection of menuitems as its model.

+

Steps is integrated with Vue Router and requires a collection of menuitems as its model.

-<Menu :model="items" /> +<Steps :model="items" /> <router-view /> @@ -21,16 +21,32 @@ import Steps from 'primevue/steps'; export default { data() { return { - items: [ - {label: 'Home', icon: 'pi pi-fw pi-home', to: '/tabmenu'}, - {label: 'Calendar', icon: 'pi pi-fw pi-calendar', to: '/tabmenu/calendar'}, - {label: 'Edit', icon: 'pi pi-fw pi-pencil', to: '/tabmenu/edit'}, - {label: 'Documentation', icon: 'pi pi-fw pi-file', to: '/tabmenu/documentation'}, - {label: 'Settings', icon: 'pi pi-fw pi-cog', to: '/tabmenu/settings'} - ] + items: [{ + label: 'Personal', + to: '/steps' + }, + { + label: 'Seat', + to: '/steps/seat' + }, + { + label: 'Payment', + to: '/steps/payment' + }, + { + label: 'Confirmation', + to: '/steps/confirmation' + }] } } } + + +

Interactive

+

Items are readonly by default, if you'd like to make them interactive then disable readonly property.

+ +<Steps :model="items" :readonly="false" /> +<router-view />

Properties

@@ -51,6 +67,12 @@ export default { array null An array of menuitems. + + + readonly + boolean + true + Whether the items are clickable or not. @@ -68,28 +90,20 @@ export default { - p-tabmenu + p-steps Container element. - p-tabmenu-nav - List element. - - - p-tabmenuitem + p-steps-item Menuitem element. - p-highlight - Active menuitem element. + p-steps-number + Number of menuitem. - p-menuitem-icon - Icon of a menuitem. - - - p-menuitem-text - Text of a menuitem. + p-steps-title + Label of menuitem. @@ -105,7 +119,7 @@ export default { @@ -114,13 +128,22 @@ export default { export default { data() { return { - items: [ - {label: 'Home', icon: 'pi pi-fw pi-home', to: '/tabmenu'}, - {label: 'Calendar', icon: 'pi pi-fw pi-calendar', to: '/tabmenu/calendar'}, - {label: 'Edit', icon: 'pi pi-fw pi-pencil', to: '/tabmenu/edit'}, - {label: 'Documentation', icon: 'pi pi-fw pi-file', to: '/tabmenu/documentation'}, - {label: 'Settings', icon: 'pi pi-fw pi-cog', to: '/tabmenu/settings'} - ] + items: [{ + label: 'Personal', + to: '/steps' + }, + { + label: 'Seat', + to: '/steps/seat' + }, + { + label: 'Payment', + to: '/steps/payment' + }, + { + label: 'Confirmation', + to: '/steps/confirmation' + }] } } }