Skip to content

Commit f175130

Browse files
author
Brian Dillingham
committed
add loading state - closes #7
1 parent 4d04ff1 commit f175130

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/FormField.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
</div>
1616
</div>
1717
<div class="border border-40 relative overflow-auto" :style="{ height: field.height }">
18-
<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">
18+
<div v-if="loading" class="flex items-center h-full">
19+
<h3 class="text-center w-full text-80">{{ __('Loading..') }}</h3>
20+
</div>
21+
<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">
1922
<div class="w-16 flex justify-center">
2023
<fake-checkbox :checked="selected.includes(resource.value)" />
2124
</div>
@@ -28,7 +31,7 @@
2831
{{ firstError }}
2932
</help-text>
3033

31-
<div class="help-text mt-3">
34+
<div class="help-text mt-3" :class="{ 'invisible': loading }">
3235
<span v-if="field.showCounts" class="pr-2">
3336
{{ selected.length }} / {{ available.length }}
3437
</span>
@@ -59,7 +62,8 @@ export default {
5962
selected: [],
6063
selectingAll: false,
6164
available: [],
62-
preview: false
65+
preview: false,
66+
loading: true,
6367
}
6468
},
6569
methods: {
@@ -72,14 +76,17 @@ export default {
7276
.then((data) => {
7377
this.selected = data.data.selected || [];
7478
this.available = data.data.available || [];
79+
this.loading = false;
7580
});
7681
}
7782
else {
7883
Nova.request(baseUrl + this.resourceName + '/attachable/' + this.field.attribute)
7984
.then((data) => {
8085
this.available = data.data.available || [];
86+
this.loading = false;
8187
});
8288
}
89+
8390
},
8491
8592
fill(formData) {

0 commit comments

Comments
 (0)