Skip to content

Commit

Permalink
Add altid search functionality (#84)
Browse files Browse the repository at this point in the history
* Add altid search functionality

Fixes #80

Add search functionality for alternative IDs in the search form and quick search.

* **Search Form (`src/views/Search.vue`):**
  - Add a dropdown to toggle between `sdss_id` and `altid` input fields.
  - Add a new input field for `altid` with validation rules.
  - Update the form submission logic to handle `altid`.

* Adds a note to quick id input on Home page

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/sdss/zora/issues/80?shareId=XXXX-XXXX-XXXX-XXXX).

* fixing the altid
  • Loading branch information
havok2063 authored Dec 4, 2024
1 parent 0425717 commit 4b6932f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
</template>
</v-text-field>
</v-card-text>
<v-card-actions class="justify-center">
<p class="text-subtitle1">To input an alternate id, use the <a href="/search">full search form</a>.</p>
</v-card-actions>
</v-card>
</v-col>
</v-row>
Expand All @@ -71,9 +74,7 @@ const router = useRouter();
const targetId = ref('');
const navigateToTarget = () => {
if (targetId.value) {
router.push(`/target/${targetId.value}`);
}
router.push(`/target/${targetId.value}`);
};
</script>
32 changes: 28 additions & 4 deletions src/views/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@
</v-col>
</v-row>
<v-row>
<v-col cols="4" md="4">
<v-col cols="2" md="2">
<!-- search id field -->
<v-select
v-model="searchType"
label="ID Type"
v-tippy="{content:'Select the type of identifier to search on', placement: 'left', maxWidth: 200}"
:items="['sdssid', 'altid']"
></v-select>
</v-col>
<v-col cols="3" md="3">
<text-input
v-if="searchType === 'sdssid'"
v-model="formData.id"
label="ID Search"
placeholder="23326"
Expand All @@ -51,16 +60,26 @@
id="id"
:disabled="idDisabled"
/>
<text-input
v-if="searchType === 'altid'"
v-model="formData.altid"
label="Alternative ID Search"
placeholder="2M23595980+1528407"
hint="Enter an alternative identifier, e.g. an APOGEE_ID or catalogid"
:rules="altidRules"
id="altid"
:disabled="idDisabled"
/>
</v-col>
<!-- cartons and programs dropdown menus -->
<v-col cols="4" md="4">
<v-col cols="auto" md="3">
<dropdown-select label="Programs" id="programs" :items="store.programs" v-model="formData.program"/>
<v-row no-gutters class="d-flex align-center">
<p class="text-body-2 font-weight-medium mt-1 text-primary d-flex align-center" v-tippy="'Searches on programs may take a long time and/or time out. There is a time out limit of 30 minutes. For faster searches, we suggest combining it with a cone search, or searching by carton instead.'">
<v-icon class='align-center' size="x-small">mdi-help-circle-outline</v-icon>Program Caveat</p>
</v-row>
</v-col>
<v-col cols="4" md="4">
<v-col cols="auto" md="3">
<dropdown-select label="Cartons" id="cartons" :items="store.cartons" v-model="formData.carton"/>
</v-col>
</v-row>
Expand Down Expand Up @@ -145,11 +164,15 @@ let radiusRules = [
(value: number) => !isNaN(value) || 'Value must be a number.',
]
let altidRules = [
(value: string) => (!!value ? /^[a-zA-Z0-9-+]+$/.test(value) : true) || 'Only alphanumeric characters and hyphens are allowed.',
]
// parameters
let loading = ref(false)
let coordsDisabled = ref(false)
let idDisabled = ref(false)
let searchType = ref('sdssid')
// create initial state of formData
let initFormData = {
Expand All @@ -158,6 +181,7 @@ let initFormData = {
dec: '',
radius: '0.1',
id: '',
altid: '',
units: 'degree',
release: store.release,
carton: '',
Expand All @@ -178,7 +202,7 @@ watch(formData, async () => {
// update id/coords disabled states
idDisabled.value = !!formData.value.coords.trim()
coordsDisabled.value = !!formData.value.id.trim()
coordsDisabled.value = !!formData.value.id.trim() || !!formData.value.altid.trim()
const formValid = await form.value.validate(); // validate the form
valid.value = formValid.valid; // update the valid state
Expand Down
44 changes: 44 additions & 0 deletions vite.config.ts.timestamp-1729616849795-71a83969c8603.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// vite.config.ts
import vue from "file:///workspaces/zora/node_modules/@vitejs/plugin-vue/dist/index.mjs";
import vuetify, { transformAssetUrls } from "file:///workspaces/zora/node_modules/vite-plugin-vuetify/dist/index.mjs";
import { defineConfig } from "file:///workspaces/zora/node_modules/vite/dist/node/index.js";
import { fileURLToPath, URL } from "node:url";
var __vite_injected_original_import_meta_url = "file:///workspaces/zora/vite.config.ts";
var vite_config_default = defineConfig({
plugins: [
vue({
template: { transformAssetUrls }
}),
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
vuetify({
autoImport: true,
styles: {
configFile: "src/styles/settings.scss"
}
})
],
define: { "process.env": {} },
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", __vite_injected_original_import_meta_url))
},
extensions: [
".js",
".json",
".jsx",
".mjs",
".ts",
".tsx",
".vue"
]
},
base: process.env.BASE_URL || "/",
server: {
port: 3e3,
host: "0.0.0.0"
}
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvd29ya3NwYWNlcy96b3JhXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvd29ya3NwYWNlcy96b3JhL3ZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy93b3Jrc3BhY2VzL3pvcmEvdml0ZS5jb25maWcudHNcIjsvLyBQbHVnaW5zXG5pbXBvcnQgdnVlIGZyb20gJ0B2aXRlanMvcGx1Z2luLXZ1ZSdcbmltcG9ydCB2dWV0aWZ5LCB7IHRyYW5zZm9ybUFzc2V0VXJscyB9IGZyb20gJ3ZpdGUtcGx1Z2luLXZ1ZXRpZnknXG5cbi8vIFV0aWxpdGllc1xuaW1wb3J0IHsgZGVmaW5lQ29uZmlnIH0gZnJvbSAndml0ZSdcbmltcG9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