Skip to content

Commit

Permalink
Correct issue when model settings object was empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaschmi committed Oct 21, 2020
1 parent 58f6b85 commit 0fc7bae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `nova-model-settings-field` will be documented in this file

## 1.0.2 - 2020-10-21

- Correct issue when model settings object was empty

## 1.0.1 - 2020-10-21

- Add doc
Expand Down
2 changes: 1 addition & 1 deletion dist/js/nova-model-settings-field.js

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions resources/js/components/Nova/FormField.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<default-field :field="field">
<template slot="field">
<ul ref="novaitemslist" class="nova-items-field-input-items list-reset border border-40 py-2">
<ul ref="novaitemslist" v-show="Object.keys(items).length !== 0" class="nova-items-field-input-items list-reset border border-40 py-2">
<li
v-for="(item, index) in items"
:key="field.attribute + '.' + index"
Expand Down Expand Up @@ -69,7 +69,7 @@ export default {
data: function() {
return {
value: '',
items: [],
items: Object,
newItem: '',
newSetting: '',
newValue: '',
Expand All @@ -78,11 +78,17 @@ export default {
},
methods: {
setInitialValue() {
this.value = this.field.value || [];
this.items = this.field.value || [];
if (typeof this.field.value === 'object' && Object.keys(this.field.value).length !== 0){
this.value = this.field.value
this.items = this.field.value
}else{
this.value = {}
this.items = {}
}
},
fill(formData) {
formData.append(this.field.attribute, this.value || []);
formData.append(this.field.attribute, this.value || Object)
},
addItem() {
const setting = this.newSetting.trim();
Expand Down

0 comments on commit 0fc7bae

Please sign in to comment.