diff --git a/afrc/media/js/views/components/plugins/afrc-search.js b/afrc/media/js/views/components/plugins/afrc-search.js new file mode 100644 index 0000000..e453741 --- /dev/null +++ b/afrc/media/js/views/components/plugins/afrc-search.js @@ -0,0 +1,31 @@ +import ko from 'knockout'; +import createVueApplication from 'arches/arches/app/media/js/utils/create-vue-application'; + +import { definePreset } from '@primevue/themes'; +import Aura from '@primevue/themes/aura'; + +import Search from '@/afrc/Search/SearchPage.vue'; +import AFRCSEarchTemplate from 'templates/views/components/plugins/afrc-search.htm'; + +ko.components.register('afrc-search', { + viewModel: function() { + const EditableReportPreset = definePreset(Aura, { + components: { + toast: { + summary: { fontSize: '1.5rem' }, + detail: { fontSize: '1.25rem' }, + }, + }, + }); + + const EditableReportTheme = { + theme: { + preset: EditableReportPreset, + }, + }; + createVueApplication(Search, EditableReportTheme).then(vueApp => { + vueApp.mount('#search-mounting-point'); + }); + }, + template: AFRCSEarchTemplate, +}); \ No newline at end of file diff --git a/afrc/media/js/views/search.js b/afrc/media/js/views/search.js deleted file mode 100644 index 5af9874..0000000 --- a/afrc/media/js/views/search.js +++ /dev/null @@ -1,25 +0,0 @@ -import createVueApplication from 'arches/arches/app/media/js/utils/create-vue-application'; - -import { definePreset } from '@primevue/themes'; -import Aura from '@primevue/themes/aura'; - -import Search from '@/afrc/Search/SearchPage.vue'; - -const EditableReportPreset = definePreset(Aura, { - components: { - toast: { - summary: { fontSize: '1.5rem' }, - detail: { fontSize: '1.25rem' }, - }, - }, -}); - -const EditableReportTheme = { - theme: { - preset: EditableReportPreset, - }, -}; - -createVueApplication(Search, EditableReportTheme).then(vueApp => { - vueApp.mount('#search-mounting-point'); -}); diff --git a/afrc/migrations/0002_plugin.py b/afrc/migrations/0002_plugin.py new file mode 100644 index 0000000..6e8e64e --- /dev/null +++ b/afrc/migrations/0002_plugin.py @@ -0,0 +1,30 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("afrc", "0001_initial"), + ] + + forward_sql = """ + INSERT INTO public.plugins( + pluginid, name, icon, component, componentname, config, slug, sortorder, helptemplate) + VALUES ('929e1b9b-a9dc-4603-ae0a-f129d89d8b66', + '{"en": "Search Reference Collections"}', + 'fa fa-search', + 'views/components/plugins/afrc-search', + 'afrc-search', + '{"show": true, "description": {"en": null}, "i18n_properties": ["description"]}', + 'afrc-search', + 1, + '' + ); + """ + reverse_sql = """ + DELETE FROM public.plugins WHERE pluginid = '929e1b9b-a9dc-4603-ae0a-f129d89d8b66'; + """ + + operations = [ + migrations.RunSQL(forward_sql, reverse_sql), + ] diff --git a/afrc/src/afrc/Search/SearchPage.vue b/afrc/src/afrc/Search/SearchPage.vue index 0a57e34..d7e367a 100644 --- a/afrc/src/afrc/Search/SearchPage.vue +++ b/afrc/src/afrc/Search/SearchPage.vue @@ -6,21 +6,16 @@ import { useGettext } from "vue3-gettext"; import Toast from "primevue/toast"; import { useToast } from "primevue/usetoast"; import Button from "primevue/button"; -import { - DEFAULT_ERROR_TOAST_LIFE, - ERROR, -} from "@/afrc/Search/constants.ts"; +import { DEFAULT_ERROR_TOAST_LIFE, ERROR } from "@/afrc/Search/constants.ts"; + +import arches from "arches"; import SimpleSearchFilter from "@/afrc/Search/components/SimpleSearchFilter.vue"; import SearchResultItem from "@/afrc/Search/components/SearchResultItem.vue"; import InteractiveMap from "@/afrc/Search/components/InteractiveMap/InteractiveMap.vue"; import { fetchMapData } from "@/afrc/Search/api.ts"; import type { GenericObject } from "@/afrc/Search/types"; -import type { - Basemap, - MapLayer, - MapSource, -} from "@/afrc/Search/types.ts"; +import type { Basemap, MapLayer, MapSource } from "@/afrc/Search/types.ts"; let query = getQueryObject(null); let queryString = ref(JSON.stringify(query)); @@ -94,7 +89,7 @@ const doQuery = function () { const qs = new URLSearchParams(queryObj); - fetch("search/resources" + "?" + qs.toString()) + fetch(arches.urls.search_results + "?" + qs.toString()) .then((response) => response.json()) .then((data) => { console.log(data); @@ -153,18 +148,19 @@ async function fetchSystemMapData() { layer.maplayerid !== "6b9d3c6a-60a4-4630-b4f8-4c5159b68cec", ); - layers.filter((layer: MapLayer) => !layer.isoverlay).forEach((layer: MapLayer) => { - basemaps.value.push({ - name: layer.name, - active: layer.addtomap, - value: layer.name, - id: layer.name, - url: "https://tiles.openfreemap.org/styles/positron" + layers + .filter((layer: MapLayer) => !layer.isoverlay) + .forEach((layer: MapLayer) => { + basemaps.value.push({ + name: layer.name, + active: layer.addtomap, + value: layer.name, + id: layer.name, + url: "https://tiles.openfreemap.org/styles/positron", + }); }); - }); sources.value = mapData.map_sources; - } catch (error) { toast.add({ severity: ERROR, @@ -175,7 +171,7 @@ async function fetchSystemMapData() { } } -onMounted(async () =>{ +onMounted(async () => { doQuery(); await fetchSystemMapData(); dataLoaded.value = true; @@ -183,7 +179,7 @@ onMounted(async () =>{