Skip to content

Commit

Permalink
add loading state - closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Dillingham committed Feb 20, 2019
1 parent 4d04ff1 commit f175130
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
</div>
</div>
<div class="border border-40 relative overflow-auto" :style="{ height: field.height }">
<div v-for="resource in resources" :key="resource.value" @click="toggle($event, resource.value)" class="flex py-3 cursor-pointer select-none hover:bg-30">
<div v-if="loading" class="flex items-center h-full">
<h3 class="text-center w-full text-80">{{ __('Loading..') }}</h3>
</div>
<div v-else v-for="resource in resources" :key="resource.value" @click="toggle($event, resource.value)" class="flex py-3 cursor-pointer select-none hover:bg-30">
<div class="w-16 flex justify-center">
<fake-checkbox :checked="selected.includes(resource.value)" />
</div>
Expand All @@ -28,7 +31,7 @@
{{ firstError }}
</help-text>

<div class="help-text mt-3">
<div class="help-text mt-3" :class="{ 'invisible': loading }">
<span v-if="field.showCounts" class="pr-2">
{{ selected.length }} / {{ available.length }}
</span>
Expand Down Expand Up @@ -59,7 +62,8 @@ export default {
selected: [],
selectingAll: false,
available: [],
preview: false
preview: false,
loading: true,
}
},
methods: {
Expand All @@ -72,14 +76,17 @@ export default {
.then((data) => {
this.selected = data.data.selected || [];
this.available = data.data.available || [];
this.loading = false;
});
}
else {
Nova.request(baseUrl + this.resourceName + '/attachable/' + this.field.attribute)
.then((data) => {
this.available = data.data.available || [];
this.loading = false;
});
}
},
fill(formData) {
Expand Down

0 comments on commit f175130

Please sign in to comment.