Skip to content

Commit

Permalink
Added a warning to inform the user of potentially long save times and…
Browse files Browse the repository at this point in the history
… disabled the button until complete. Added the title and a scrollbar to UUID dropdown
  • Loading branch information
Matt Szczerba committed Jun 10, 2024
1 parent 35b4caf commit aa4b657
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/components/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
:class="{ 'input-error': error || !reqFields.uuid }"
/>
<div
class="absolute z-10 w-full bg-white border border-gray-200 mt-1"
class="absolute z-10 w-full bg-white border border-gray-200 mt-1 max-h-96 overflow-y-auto"
v-show="showDropdown"
>
<ul>
Expand All @@ -71,7 +71,7 @@
storyline.isUserStoryline ? 'bg-gray-200' : ''
]"
>
{{ storyline.uuid }}
{{ storyline.uuid + ' - ' + storyline.title }}
</li>
</ul>
</div>
Expand Down Expand Up @@ -944,6 +944,7 @@ export default class MetadataEditorV extends Vue {
const formData = new FormData();
formData.append('data', content, `${this.uuid}.zip`);
const headers = { 'Content-Type': 'multipart/form-data' };
Message.warning('Please wait. This may take several minutes.');
axios
.post(this.apiUrl + '/upload', formData, { headers })
Expand All @@ -953,13 +954,13 @@ export default class MetadataEditorV extends Vue {
responseData.status; // HTTP status
this.unsavedChanges = false;
this.loadExisting = true; // if editExisting was false, we can now set it to true
Message.success('Successfully saved changes!');
if (process.env.VUE_APP_CURR_ENV !== '#{CURR_ENV}#') {
if (responseData.new) {
axios
.post(process.env.VUE_APP_NET_API_URL + '/api/user/register', {
uuid: this.uuid
uuid: this.uuid,
title: this.metadata.title ?? ''
})
.then((response: any) => {
const userStore = useUserStore();
Expand All @@ -970,19 +971,31 @@ export default class MetadataEditorV extends Vue {
axios
.post(process.env.VUE_APP_NET_API_URL + '/api/version/commit', formData)
.then((response: any) => {
console.log('Version saved successfully.');
Message.success('Successfully saved changes!');
})
.catch((error: any) => console.log(error.response || error));
.catch((error: any) => console.log(error.response || error))
.finally(() => {
// padding to prevent save button from being clicked rapidly
setTimeout(() => {
this.saving = false;
}, 500);
});
})
.catch((error: any) => console.log(error.response || error));
} else {
formData.append('uuid', this.uuid);
axios
.post(process.env.VUE_APP_NET_API_URL + '/api/version/commit', formData)
.then((response: any) => {
console.log('Version saved successfully.');
Message.success('Successfully saved changes!');
})
.catch((error: any) => console.log(error.response || error));
.catch((error: any) => console.log(error.response || error))
.finally(() => {
// padding to prevent save button from being clicked rapidly
setTimeout(() => {
this.saving = false;
}, 500);
});
}
fetch(this.apiUrl + `/retrieveMessages`)
Expand All @@ -1001,12 +1014,6 @@ export default class MetadataEditorV extends Vue {
})
.catch(() => {
Message.error('Failed to save changes.');
})
.finally(() => {
// padding to prevent save button from being clicked rapidly
setTimeout(() => {
this.saving = false;
}, 500);
});
});
Expand Down Expand Up @@ -1276,8 +1283,13 @@ export default class MetadataEditorV extends Vue {
let combined = [...userStorylines, ...allStorylines];
if (this.uuid)
combined = combined.filter((storyline) => storyline.uuid.toLowerCase().includes(this.uuid.toLowerCase()));
if (this.uuid) {
combined = combined.filter(
(storyline) =>
storyline.uuid.toLowerCase().includes(this.uuid.toLowerCase()) ||
(storyline.title && storyline.title.toLowerCase().includes(this.uuid.toLowerCase()))
);
}
return combined;
}
Expand Down
1 change: 1 addition & 0 deletions src/stores/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineStore } from 'pinia';

interface Storyline {
uuid: string;
title: string;
isUserStoryline?: boolean;
}

Expand Down

0 comments on commit aa4b657

Please sign in to comment.