Fixed #1263 - Kebap-case is not supported in some components like DataTable
parent
231dfe22c1
commit
fe9413c7b7
|
@ -4,8 +4,8 @@
|
||||||
<component :is="column.children.body" :data="rowData" :column="column" :index="rowIndex" :frozenRow="frozenRow" v-if="column.children && column.children.body && !d_editing" />
|
<component :is="column.children.body" :data="rowData" :column="column" :index="rowIndex" :frozenRow="frozenRow" v-if="column.children && column.children.body && !d_editing" />
|
||||||
<component :is="column.children.editor" :data="rowData" :column="column" :index="rowIndex" :frozenRow="frozenRow" v-else-if="column.children && column.children.editor && d_editing" />
|
<component :is="column.children.editor" :data="rowData" :column="column" :index="rowIndex" :frozenRow="frozenRow" v-else-if="column.children && column.children.editor && d_editing" />
|
||||||
<template v-else-if="columnProp('selectionMode')">
|
<template v-else-if="columnProp('selectionMode')">
|
||||||
<DTRadioButton :value="rowData" :checked="selected" @change="toggleRowWithRadio" v-if="column.props.selectionMode === 'single'" />
|
<DTRadioButton :value="rowData" :checked="selected" @change="toggleRowWithRadio" v-if="columnProp('selectionMode') === 'single'" />
|
||||||
<DTCheckbox :value="rowData" :checked="selected" @change="toggleRowWithCheckbox" v-else-if="column.props.selectionMode ==='multiple'" />
|
<DTCheckbox :value="rowData" :checked="selected" @change="toggleRowWithCheckbox" v-else-if="columnProp('selectionMode') ==='multiple'" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="columnProp('rowReorder')">
|
<template v-else-if="columnProp('rowReorder')">
|
||||||
<i :class="['p-datatable-reorderablerow-handle', (columnProp('rowReorderIcon') || 'pi pi-bars')]"></i>
|
<i :class="['p-datatable-reorderablerow-handle', (columnProp('rowReorderIcon') || 'pi pi-bars')]"></i>
|
||||||
|
@ -115,7 +115,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
return ObjectUtils.getVNodeProp(this.column, prop);
|
||||||
},
|
},
|
||||||
resolveFieldData() {
|
resolveFieldData() {
|
||||||
return ObjectUtils.resolveFieldData(this.rowData, this.columnProp('field'));
|
return ObjectUtils.resolveFieldData(this.rowData, this.columnProp('field'));
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {DomHandler} from 'primevue/utils';
|
import {DomHandler,ObjectUtils} from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FooterCell',
|
name: 'FooterCell',
|
||||||
|
@ -34,7 +34,8 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
let propName = ObjectUtils.camelToKebap(prop);
|
||||||
|
return this.column.props ? ((this.column.type.props[propName].type === Boolean && this.column.props[propName] === '') ? true : this.column.props[propName]) : null;
|
||||||
},
|
},
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {DomHandler} from 'primevue/utils';
|
import {DomHandler,ObjectUtils} from 'primevue/utils';
|
||||||
import HeaderCheckbox from './HeaderCheckbox.vue';
|
import HeaderCheckbox from './HeaderCheckbox.vue';
|
||||||
import ColumnFilter from './ColumnFilter.vue';
|
import ColumnFilter from './ColumnFilter.vue';
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
return ObjectUtils.getVNodeProp(this.column, prop);
|
||||||
},
|
},
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
this.$emit('column-click', {originalEvent: event, column: this.column});
|
this.$emit('column-click', {originalEvent: event, column: this.column});
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {DomHandler} from 'primevue/utils';
|
import {DomHandler,ObjectUtils} from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Splitter',
|
name: 'Splitter',
|
||||||
|
@ -150,11 +150,13 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateResize(newPrevPanelSize, newNextPanelSize) {
|
validateResize(newPrevPanelSize, newNextPanelSize) {
|
||||||
if (this.panels[0].props && this.panels[0].props.minSize && this.panels[0].props.minSize > newPrevPanelSize) {
|
let prevPanelMinSize = ObjectUtils.getVNodeProp(this.panels[0], 'minSize');
|
||||||
|
if (this.panels[0].props && prevPanelMinSize && prevPanelMinSize > newPrevPanelSize) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.panels[1].props && this.panels[1].props.minSize && this.panels[1].props.minSize > newNextPanelSize) {
|
let newPanelMinSize = ObjectUtils.getVNodeProp(this.panels[1], 'minSize');
|
||||||
|
if (this.panels[1].props && newPanelMinSize && newPanelMinSize > newNextPanelSize) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {DomHandler} from 'primevue/utils';
|
import {DomHandler,ObjectUtils} from 'primevue/utils';
|
||||||
import {ObjectUtils} from 'primevue/utils';
|
|
||||||
import Ripple from 'primevue/ripple'
|
import Ripple from 'primevue/ripple'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -83,7 +82,7 @@ export default {
|
||||||
this.$emit('node-toggle', this.node);
|
this.$emit('node-toggle', this.node);
|
||||||
},
|
},
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
return ObjectUtils.getVNodeProp(this.column, prop);
|
||||||
},
|
},
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {DomHandler} from 'primevue/utils';
|
import {DomHandler,ObjectUtils} from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FooterCell',
|
name: 'FooterCell',
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
return ObjectUtils.getVNodeProp(this.column, prop);
|
||||||
},
|
},
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {DomHandler} from 'primevue/utils';
|
import {DomHandler,ObjectUtils} from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HeaderCell',
|
name: 'HeaderCell',
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
columnProp(prop) {
|
columnProp(prop) {
|
||||||
return this.column.props ? ((this.column.type.props[prop].type === Boolean && this.column.props[prop] === '') ? true : this.column.props[prop]) : null;
|
return ObjectUtils.getVNodeProp(this.column, prop);
|
||||||
},
|
},
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
|
|
|
@ -191,4 +191,17 @@ export default class ObjectUtils {
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getVNodeProp(vnode, prop) {
|
||||||
|
let props = vnode.props;
|
||||||
|
if (props) {
|
||||||
|
let kebapProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||||
|
let propName = Object.prototype.hasOwnProperty.call(props, kebapProp) ? kebapProp : prop;
|
||||||
|
|
||||||
|
return ((vnode.type.props[prop].type === Boolean && props[propName] === '') ? true : props[propName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -53,6 +53,17 @@ app.component('Dialog', Dialog);
|
||||||
<pre v-code><code>
|
<pre v-code><code>
|
||||||
<Dialog></Dialog>
|
<Dialog></Dialog>
|
||||||
|
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h5>Prop Cases</h5>
|
||||||
|
<p>Component prop names are described as camel case throughout the documentation however camel-case is also fully supported. Events on the other hand should always be camel-case.</p>
|
||||||
|
<pre v-code><code>
|
||||||
|
<Dialog :showHeader="false"></Dialog>
|
||||||
|
|
||||||
|
<!-- can be written as -->
|
||||||
|
|
||||||
|
<Dialog :show-header="false"></Dialog>
|
||||||
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
<h5>Single File Components</h5>
|
<h5>Single File Components</h5>
|
||||||
|
|
Loading…
Reference in New Issue