Commit 01e26e50 authored by Tom Quirk's avatar Tom Quirk

Add isLoading prop to design item.vue

For clarity, isLoading is now a prop on an item,
rather than this value being determined within the
component from other state.

Tests updated to reflect this.
parent 370fac6a
...@@ -36,11 +36,13 @@ export default { ...@@ -36,11 +36,13 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
isLoading: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
isLoading() {
return !this.image;
},
icon() { icon() {
const normalizedEvent = this.event.toLowerCase(); const normalizedEvent = this.event.toLowerCase();
const icons = { const icons = {
......
...@@ -189,12 +189,11 @@ export default { ...@@ -189,12 +189,11 @@ export default {
isDesignSelected(filename) { isDesignSelected(filename) {
return this.selectedDesigns.includes(filename); return this.selectedDesigns.includes(filename);
}, },
isDesignToBeSaved(filename) {
return this.filesToBeSaved.some(file => file.name === filename);
},
canSelectDesign(filename) { canSelectDesign(filename) {
return ( return this.isLatestVersion && this.canCreateDesign && !this.isDesignToBeSaved(filename);
this.isLatestVersion &&
this.canCreateDesign &&
!this.filesToBeSaved.some(file => file.name === filename)
);
}, },
onDesignDelete() { onDesignDelete() {
this.selectedDesigns = []; this.selectedDesigns = [];
...@@ -250,7 +249,7 @@ export default { ...@@ -250,7 +249,7 @@ export default {
</div> </div>
<ol v-else-if="hasDesigns" class="list-unstyled row"> <ol v-else-if="hasDesigns" class="list-unstyled row">
<li v-for="design in designs" :key="design.id" class="col-md-6 col-lg-4 mb-3"> <li v-for="design in designs" :key="design.id" class="col-md-6 col-lg-4 mb-3">
<design v-bind="design" /> <design v-bind="design" :is-loading="isDesignToBeSaved(design.filename)" />
<input <input
v-if="canSelectDesign(design.filename)" v-if="canSelectDesign(design.filename)"
:checked="isDesignSelected(design.filename)" :checked="isDesignSelected(design.filename)"
......
...@@ -28,7 +28,8 @@ describe('Design management list item component', () => { ...@@ -28,7 +28,8 @@ describe('Design management list item component', () => {
propsData: { propsData: {
id: 1, id: 1,
filename: 'test', filename: 'test',
image: isLoading ? '' : 'http://via.placeholder.com/300', image: 'http://via.placeholder.com/300',
isLoading,
event, event,
notesCount, notesCount,
updatedAt: '01-01-2019', updatedAt: '01-01-2019',
...@@ -86,7 +87,7 @@ describe('Design management list item component', () => { ...@@ -86,7 +87,7 @@ describe('Design management list item component', () => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
it('renders loading spinner when no image prop present', () => { it('renders loading spinner when isLoading is true', () => {
createComponent({ notesCount: 0, isLoading: true }); createComponent({ notesCount: 0, isLoading: true });
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment