From 53c7f3381a8bca773b60b3274b521789d46b05b3 Mon Sep 17 00:00:00 2001 From: Lloyd Dakin Date: Fri, 2 Feb 2024 11:31:46 -0800 Subject: [PATCH 1/4] Revert "Revert "warning for no target name, error handling, ra and dec warnings"" This reverts commit 1c345e4339379062d6a52e4bcff338c82a67cfa6. --- src/components/projects/CreateProjectForm.vue | 85 +++++++++++-------- src/mixins/target_names.js | 2 +- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/src/components/projects/CreateProjectForm.vue b/src/components/projects/CreateProjectForm.vue index c4c2d909..3522dba4 100644 --- a/src/components/projects/CreateProjectForm.vue +++ b/src/components/projects/CreateProjectForm.vue @@ -174,39 +174,52 @@ - - -

- - - -

-
+ + +

+ + + +

- + + @@ -848,6 +861,7 @@ export default { max_airmass: false, lunar_dist_min: false, lunar_phase_max: false, + target_name: false, targetRA: false, targetDec: false }, @@ -989,10 +1003,9 @@ export default { this.updateTargetsValue(target_index, 'dec', '') this.$buefy.notification.open({ duration: 10000, - message: 'Could not resolve object with name ' + this.targets[target_index].name, + message: 'Could not find target ' + this.targets[target_index].name, position: 'is-top', - type: 'is-danger', - hasIcon: true + type: 'is-info' }) } }, @@ -1008,6 +1021,7 @@ export default { verifyForm () { if (this.project_name === '') { this.warn.project_name = true } + if (this.targets[0].name === '') { this.warn.target_name = true } if (this.project_name.includes('#')) { this.warn.project_name = true this.$buefy.toast.open({ @@ -1027,10 +1041,8 @@ export default { this.project_sites = [this.sitecode] } - if (this.targets[0].ra === '' || this.targets[0].dec === '') { - this.warn.targetRA = this.targets[0].ra === '' - this.warn.targetDec = this.targets[0].dec === '' - } + this.warn.targetRA = this.targets[0].ra === '' + this.warn.targetDec = this.targets[0].dec === '' }, resetInputWarnings () { Object.keys(this.warn).forEach(k => { this.warn[k] = false }) @@ -1065,13 +1077,6 @@ export default { const project = this.projectToSend - if (!Object.values(this.warn).every(x => !x)) { - this.$buefy.toast.open({ - message: 'Please fix the highlighted fields and try again', - type: 'is-warning' - }) - } - // Make sure all warnings are false, otherwise don't create the project. if (Object.values(this.warn).every(x => !x)) { this.createProjectButtonIsLoading = true @@ -1100,11 +1105,18 @@ export default { }).finally(() => { this.createProjectButtonIsLoading = false }) + } else { + this.$buefy.toast.open({ + message: 'Please fix the highlighted fields', + type: 'is-warning' + }) } console.log(this.warn) }, modifyProject () { + this.resetInputWarnings() + this.verifyForm() const url = this.projects_api_url + '/modify-project' const project = this.projectToSend @@ -1138,6 +1150,11 @@ export default { }).finally(() => { this.createProjectButtonIsLoading = false }) + } else { + this.$buefy.toast.open({ + message: 'Please fix the highlighted fields', + type: 'is-warning' + }) } }, refreshUserEvents () { diff --git a/src/mixins/target_names.js b/src/mixins/target_names.js index 00d39bd1..00e99722 100644 --- a/src/mixins/target_names.js +++ b/src/mixins/target_names.js @@ -15,7 +15,7 @@ export const target_names = { return new Promise(resolve => { axios.get(url).then(response => { const result = JSON.parse(response.data.slice(10, -3)) - if (!result.Target.Resolver || !result.Target.Resolver.jradeg || !result.Target.Resolver.jdedeg) { + if (!result.Target || !result.Target.Resolver || !result.Target.Resolver.jradeg || !result.Target.Resolver.jdedeg) { console.error('failed to fetch coordinates for ', common_name) error = true } else { From 73ea9610c46d585ae68be5d5014c734e09b57423 Mon Sep 17 00:00:00 2001 From: Lloyd Dakin Date: Fri, 2 Feb 2024 13:58:59 -0800 Subject: [PATCH 2/4] added trim method to name checks --- src/components/projects/CreateProjectForm.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/projects/CreateProjectForm.vue b/src/components/projects/CreateProjectForm.vue index 3522dba4..aaed6c11 100644 --- a/src/components/projects/CreateProjectForm.vue +++ b/src/components/projects/CreateProjectForm.vue @@ -1020,8 +1020,8 @@ export default { }, verifyForm () { - if (this.project_name === '') { this.warn.project_name = true } - if (this.targets[0].name === '') { this.warn.target_name = true } + if (this.project_name.trim() === '') { this.warn.project_name = true } + if (this.targets[0].name.trim() === '') { this.warn.target_name = true } if (this.project_name.includes('#')) { this.warn.project_name = true this.$buefy.toast.open({ From d92d0fc4ddb9439be04d0a3f0a202628c1f4d89b Mon Sep 17 00:00:00 2001 From: Lloyd Dakin Date: Tue, 6 Feb 2024 12:04:02 -0800 Subject: [PATCH 3/4] added field name --- src/components/projects/CreateProjectForm.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/projects/CreateProjectForm.vue b/src/components/projects/CreateProjectForm.vue index aaed6c11..45aaaadc 100644 --- a/src/components/projects/CreateProjectForm.vue +++ b/src/components/projects/CreateProjectForm.vue @@ -183,6 +183,14 @@ + + + !x)) { From 3dc7bcfe1623a1eb7e5b7602bf29e975676f76ca Mon Sep 17 00:00:00 2001 From: Lloyd Dakin Date: Tue, 6 Feb 2024 12:06:38 -0800 Subject: [PATCH 4/4] removed console log --- src/components/projects/CreateProjectForm.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/projects/CreateProjectForm.vue b/src/components/projects/CreateProjectForm.vue index 45aaaadc..f43c102d 100644 --- a/src/components/projects/CreateProjectForm.vue +++ b/src/components/projects/CreateProjectForm.vue @@ -1085,8 +1085,6 @@ export default { } const project = this.projectToSend - console.log('saving new project: ') - console.log(project) // Make sure all warnings are false, otherwise don't create the project. if (Object.values(this.warn).every(x => !x)) {