Skip to content

Commit

Permalink
added "item.disabled" logic, supporting both boolean values and a fun…
Browse files Browse the repository at this point in the history
…ction that is passed a reference to the model to determine disabled logic based on the model.
  • Loading branch information
zoul0813 committed Dec 10, 2018
1 parent a484031 commit b227eb4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/fields/core/fieldRadios.vue
@@ -1,13 +1,13 @@
<template lang="pug">
.radio-list(:disabled="disabled", v-attributes="'wrapper'")
label(v-for="item in items", :class="{'is-checked': isItemChecked(item)}", v-attributes="'label'")
input(:id="getFieldID(schema)", type="radio", :disabled="disabled", :name="id", @click="onSelection(item)", :value="getItemValue(item)", :checked="isItemChecked(item)", :class="schema.fieldClasses", :required="schema.required", v-attributes="'input'")
input(:id="getFieldID(schema)", type="radio", :disabled="isItemDisabled(item)", :name="id", @click="onSelection(item)", :value="getItemValue(item)", :checked="isItemChecked(item)", :class="schema.fieldClasses", :required="schema.required", v-attributes="'input'")
| {{ getItemName(item) }}

</template>

<script>
import { isObject } from "lodash";
import { isObject, isFunction, get as objGet } from "lodash";
import abstractField from "../abstractField";
export default {
Expand Down Expand Up @@ -64,6 +64,12 @@ export default {
isItemChecked(item) {
let currentValue = this.getItemValue(item);
return currentValue === this.value;
},
isItemDisabled(item) {
if(this.disabled) return true;
let disabled = objGet(item, "disabled", false);
if(isFunction(disabled)) return disabled(this.model);
return disabled;
}
}
};
Expand Down

0 comments on commit b227eb4

Please sign in to comment.