Implemented readonly support

pull/132/head
cagataycivici 2019-12-06 17:09:29 +03:00
parent 956698fa37
commit 978dce8c3d
3 changed files with 65 additions and 35 deletions

View File

@ -2,10 +2,14 @@
<div :class="containerClass"> <div :class="containerClass">
<ul role="tablist"> <ul role="tablist">
<li v-for="(item,index) of model" :key="item.to" :class="getItemClass(item)" :style="item.style"> <li v-for="(item,index) of model" :key="item.to" :class="getItemClass(item)" :style="item.style">
<router-link :to="item.to" class="p-menuitem-link" @click.native="onItemClick($event, item)"> <router-link :to="item.to" class="p-menuitem-link" @click.native="onItemClick($event, item)" v-if="!isItemDisabled(item)">
<span class="p-steps-number">{{index + 1}}</span> <span class="p-steps-number">{{index + 1}}</span>
<span class="p-steps-title">{{item.label}}</span> <span class="p-steps-title">{{item.label}}</span>
</router-link> </router-link>
<span v-else class="p-menuitem-link">
<span class="p-steps-number">{{index + 1}}</span>
<span class="p-steps-title">{{item.label}}</span>
</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -40,8 +44,11 @@ export default {
getItemClass(item) { getItemClass(item) {
return ['p-steps-item', item.class, { return ['p-steps-item', item.class, {
'p-highlight p-steps-current': (this.activeRoute === item.to), '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: { computed: {

View File

@ -3,7 +3,7 @@
<div class="content-section introduction"> <div class="content-section introduction">
<div class="feature-intro"> <div class="feature-intro">
<h1>Steps</h1> <h1>Steps</h1>
<p>Steps components is an indicator for the steps in a wizard workflow.</p> <p>Steps components is an indicator for the steps in a wizard workflow. Example below uses nested routes with Steps.</p>
</div> </div>
</div> </div>

View File

@ -8,12 +8,12 @@ import Steps from 'primevue/steps';
</CodeHighlight> </CodeHighlight>
<h3>MenuModel</h3> <h3>MenuModel</h3>
<p>TabMenu uses the common MenuModel API to define the items, visit <router-link to="/menumodel">MenuModel API</router-link> for details.</p> <p>Steps uses the common MenuModel API to define the items, visit <router-link to="/menumodel">MenuModel API</router-link> for details.</p>
<h3>Getting Started</h3> <h3>Getting Started</h3>
<p>TabMenu is integrated with Vue Router and requires a collection of menuitems as its model.</p> <p>Steps is integrated with Vue Router and requires a collection of menuitems as its model.</p>
<CodeHighlight> <CodeHighlight>
&lt;Menu :model="items" /&gt; &lt;Steps :model="items" /&gt;
&lt;router-view /&gt; &lt;router-view /&gt;
</CodeHighlight> </CodeHighlight>
@ -21,16 +21,32 @@ import Steps from 'primevue/steps';
export default { export default {
data() { data() {
return { return {
items: [ items: [{
{label: 'Home', icon: 'pi pi-fw pi-home', to: '/tabmenu'}, label: 'Personal',
{label: 'Calendar', icon: 'pi pi-fw pi-calendar', to: '/tabmenu/calendar'}, to: '/steps'
{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'} label: 'Seat',
] to: '/steps/seat'
},
{
label: 'Payment',
to: '/steps/payment'
},
{
label: 'Confirmation',
to: '/steps/confirmation'
}]
} }
} }
} }
</CodeHighlight>
<h3>Interactive</h3>
<p>Items are readonly by default, if you'd like to make them interactive then disable <i>readonly</i> property.</p>
<CodeHighlight>
&lt;Steps :model="items" :readonly="false" /&gt;
&lt;router-view /&gt;
</CodeHighlight> </CodeHighlight>
<h3>Properties</h3> <h3>Properties</h3>
@ -51,6 +67,12 @@ export default {
<td>array</td> <td>array</td>
<td>null</td> <td>null</td>
<td>An array of menuitems.</td> <td>An array of menuitems.</td>
</tr>
<tr>
<td>readonly</td>
<td>boolean</td>
<td>true</td>
<td>Whether the items are clickable or not.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -68,28 +90,20 @@ export default {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>p-tabmenu</td> <td>p-steps</td>
<td>Container element.</td> <td>Container element.</td>
</tr> </tr>
<tr> <tr>
<td>p-tabmenu-nav</td> <td>p-steps-item</td>
<td>List element.</td>
</tr>
<tr>
<td>p-tabmenuitem</td>
<td>Menuitem element.</td> <td>Menuitem element.</td>
</tr> </tr>
<tr> <tr>
<td>p-highlight</td> <td>p-steps-number</td>
<td>Active menuitem element.</td> <td>Number of menuitem.</td>
</tr> </tr>
<tr> <tr>
<td>p-menuitem-icon</td> <td>p-steps-title</td>
<td>Icon of a menuitem.</td> <td>Label of menuitem.</td>
</tr>
<tr>
<td>p-menuitem-text</td>
<td>Text of a menuitem.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -105,7 +119,7 @@ export default {
</a> </a>
<CodeHighlight> <CodeHighlight>
<template v-pre> <template v-pre>
&lt;Menu :model="items" /&gt; &lt;Steps :model="items" :readonly="false" /&gt;
&lt;router-view /&gt; &lt;router-view /&gt;
</template> </template>
</CodeHighlight> </CodeHighlight>
@ -114,13 +128,22 @@ export default {
export default { export default {
data() { data() {
return { return {
items: [ items: [{
{label: 'Home', icon: 'pi pi-fw pi-home', to: '/tabmenu'}, label: 'Personal',
{label: 'Calendar', icon: 'pi pi-fw pi-calendar', to: '/tabmenu/calendar'}, to: '/steps'
{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'} label: 'Seat',
] to: '/steps/seat'
},
{
label: 'Payment',
to: '/steps/payment'
},
{
label: 'Confirmation',
to: '/steps/confirmation'
}]
} }
} }
} }