Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Commit

Permalink
Fix checkList label and removed unnecessary message form radio list
Browse files Browse the repository at this point in the history
ref #24
  • Loading branch information
Sneki committed Jun 28, 2018
1 parent bba9e97 commit e1e4b92
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/components/CCheckList/CCheckList.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ export default {
};

const children = [
createElement('v-label', this.config.label),
map(this.config.dataSource.items,
item => createElement('v-checkbox',
{
attrs: getItemAttrs(this),
staticlass: 'mt-0',
props: getItemProps(this, item),
on: getItemListeners(this, item),
},
Expand Down
14 changes: 10 additions & 4 deletions src/components/CCheckList/index.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,35 @@ export default {
value: null,
priority: 1,
},
label: {
type: 'input',
name: 'Radio Label',
value: 'Radio',
priority: 2,
},
prependIcon: {
type: 'input',
name: 'Prepend Icon',
value: null,
priority: 2,
priority: 3,
},
appendIcon: {
type: 'input',
name: 'Append Icon',
value: null,
priority: 3,
priority: 4,
},
hint: {
type: 'input',
name: 'Hint Text',
value: null,
priority: 4,
priority: 5,
},
hideDetails: {
type: 'check',
name: 'Hide Details',
value: false,
priority: 5,
priority: 6,
},
disabled: {
type: 'check',
Expand Down
27 changes: 12 additions & 15 deletions src/components/CRadioList/CRadioList.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { map, isNil, filter } from 'lodash';
import { fieldable, validatable } from '@mixins';
import { validator } from '@validators';
import Element from '../Element';

const createErrorMessage = (createElement, context) => {
const el = createElement(
'div',
{
staticClass: 'input-group__details error--text',
},
context.errorBucket[0],
);

return el;
};

const getListeners = (context) => {
const self = context;

Expand All @@ -30,16 +19,27 @@ const getListeners = (context) => {
return listeners;
};

const getPropRequired = (config) => {
if (config.validation) {
return !!config.validation.required;
}

return false;
};

const getProps = (context) => {
const config = context.config;

const props = {
appendIcon: config.appendIcon,
dark: context.isThemeDark,
light: context.isThemeLight,
label: config.label,
hint: config.hint,
persistentHint: config.persistentHint,
prependIcon: config.prependIcon,
required: getPropRequired(config),
rules: validator.getRules(config, context.validators),
value: config.value,
};

Expand Down Expand Up @@ -87,8 +87,6 @@ export default {
this.loadData();
},
render(createElement) {
const message = createErrorMessage(createElement, this);

if (isNil(this.config.dataSource)) {
this.config.dataSource = {
items: [],
Expand All @@ -110,7 +108,6 @@ export default {
props: getItemProps(this, item),
},
)),
message,
];

return this.renderElement('v-radio-group', data, children);
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/specs/__snapshots__/elements.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ exports[`AllComponents c-check renders correctly 1`] = `
exports[`AllComponents c-check-list renders correctly 1`] = `
<div data-type="check-list" data-group="inputs" data-uid="6" class="c-element c-check-list v-card v-card--flat transparent" style="height:undefined;">
<label aria-hidden="true" class="v-label" style="left:0px;right:auto;position:relative;"></label>
<div class="input-group__details error--text"></div>
</div>
`;
Expand Down Expand Up @@ -1110,9 +1111,7 @@ exports[`AllComponents c-radio-list renders correctly 1`] = `
<div data-type="radio-list" data-group="inputs" data-uid="22" class="v-input c-element c-radio-list v-input--selection-controls v-input--radio-group v-input--radio-group--column">
<div class="v-input__control">
<div class="v-input__slot" style="height:auto;">
<div role="radiogroup" class="v-input--radio-group__input">
<div class="input-group__details error--text"></div>
</div>
<div role="radiogroup" class="v-input--radio-group__input"></div>
</div>
<div class="v-messages">
<div class="v-messages__wrapper"></div>
Expand Down

0 comments on commit e1e4b92

Please sign in to comment.