From e98e8a223e7fcdf88ee8483cbfc7789d2504e8d3 Mon Sep 17 00:00:00 2001 From: Oak McIlwain Date: Tue, 26 Nov 2024 17:05:00 +0800 Subject: [PATCH 001/138] Change all species and communities urls to use hyphen instead of underscore in url so that correct primary menu item is always selected when it should be. --- boranga/components/history/api.py | 2 +- boranga/components/species_and_communities/models.py | 4 ++-- boranga/frontend/boranga/src/api.js | 10 +++++----- .../src/components/common/communities_dashboard.vue | 8 ++++---- .../common/species_communities/community_profile.vue | 2 +- .../src/components/common/species_fauna_dashboard.vue | 8 ++++---- .../src/components/common/species_flora_dashboard.vue | 8 ++++---- .../boranga/src/components/external/routes/index.js | 2 +- .../internal/occurrence/occurrence_report.vue | 4 ++-- .../boranga/src/components/internal/routes/index.js | 2 +- boranga/urls.py | 6 +++--- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/boranga/components/history/api.py b/boranga/components/history/api.py index 1bf06bd6..5f567e73 100644 --- a/boranga/components/history/api.py +++ b/boranga/components/history/api.py @@ -286,7 +286,7 @@ def get(self, request, app_label, component_name, model_name, pk): Example: - api/history/boranga/species_communities/SpeciesDocument/729 + api/history/boranga/species-communities/SpeciesDocument/729 """ super().get(request, model_name) diff --git a/boranga/components/species_and_communities/models.py b/boranga/components/species_and_communities/models.py index f260009b..633a0f06 100644 --- a/boranga/components/species_and_communities/models.py +++ b/boranga/components/species_and_communities/models.py @@ -767,7 +767,7 @@ def as_related_item(self): descriptor=self.related_item_descriptor, status=self.related_item_status, action_url=( - f'View ' '' ), @@ -1546,7 +1546,7 @@ def as_related_item(self): descriptor=self.related_item_descriptor, status=self.related_item_status, action_url=( - f'View ' '' ), diff --git a/boranga/frontend/boranga/src/api.js b/boranga/frontend/boranga/src/api.js index d491426b..ead72597 100644 --- a/boranga/frontend/boranga/src/api.js +++ b/boranga/frontend/boranga/src/api.js @@ -210,16 +210,16 @@ module.exports = { return `/api/observer_detail/${id}.json`; }, lookup_history_species_document: function (id) { - return `/api/history/boranga/species_communities/SpeciesDocument/${id}/`; + return `/api/history/boranga/species-communities/SpeciesDocument/${id}/`; }, lookup_history_species: function (id) { - return `/api/history/boranga/species_communities/Species/${id}/`; + return `/api/history/boranga/species-communities/Species/${id}/`; }, lookup_history_community_document: function (id) { - return `/api/history/boranga/species_communities/CommunityDocument/${id}/`; + return `/api/history/boranga/species-communities/CommunityDocument/${id}/`; }, lookup_history_community: function (id) { - return `/api/history/boranga/species_communities/Community/${id}/`; + return `/api/history/boranga/species-communities/Community/${id}/`; }, lookup_history_conservation_status_document: function (id) { @@ -248,7 +248,7 @@ module.exports = { }, lookup_history_conservation_threat: function (id) { - return `/api/history/boranga/species_communities/ConservationThreat/${id}/`; + return `/api/history/boranga/species-communities/ConservationThreat/${id}/`; }, lookup_history_ocr_conservation_threat: function (id) { diff --git a/boranga/frontend/boranga/src/components/common/communities_dashboard.vue b/boranga/frontend/boranga/src/components/common/communities_dashboard.vue index 84caacff..1695c802 100644 --- a/boranga/frontend/boranga/src/components/common/communities_dashboard.vue +++ b/boranga/frontend/boranga/src/components/common/communities_dashboard.vue @@ -562,7 +562,7 @@ export default { if (full.processing_status == 'Discarded') { links += `Reinstate
`; } else { - links += `Continue
`; + links += `Continue
`; links += `Discard
`; links += `History
`; } @@ -570,13 +570,13 @@ export default { else { if (full.user_process) { - links += `Edit
`; + links += `Edit
`; } - links += `View
`; + links += `View
`; links += `History
`; } } else { - links += `View
`; + links += `View
`; } return links; } diff --git a/boranga/frontend/boranga/src/components/common/species_communities/community_profile.vue b/boranga/frontend/boranga/src/components/common/species_communities/community_profile.vue index cee308b8..6cb9a201 100644 --- a/boranga/frontend/boranga/src/components/common/species_communities/community_profile.vue +++ b/boranga/frontend/boranga/src/components/common/species_communities/community_profile.vue @@ -18,7 +18,7 @@
+ :href="`/internal/species-communities/${species_community.renamed_from.id}?group_type_name=${species_community.group_type}`"> {{ species_community.renamed_from.community_number }}
diff --git a/boranga/frontend/boranga/src/components/common/species_fauna_dashboard.vue b/boranga/frontend/boranga/src/components/common/species_fauna_dashboard.vue index 94049ebd..2802dbc8 100644 --- a/boranga/frontend/boranga/src/components/common/species_fauna_dashboard.vue +++ b/boranga/frontend/boranga/src/components/common/species_fauna_dashboard.vue @@ -677,20 +677,20 @@ export default { if (full.processing_status == 'Discarded') { links += `Reinstate
`; } else { - links += `Continue
`; + links += `Continue
`; links += `Discard
`; links += `History
`; } } else { if (full.user_process) { - links += `Edit
`; + links += `Edit
`; } - links += `View
`; + links += `View
`; links += `History
`; } } else { - links += `View
`; + links += `View
`; } return links; } diff --git a/boranga/frontend/boranga/src/components/common/species_flora_dashboard.vue b/boranga/frontend/boranga/src/components/common/species_flora_dashboard.vue index 717583a2..96ab54ea 100755 --- a/boranga/frontend/boranga/src/components/common/species_flora_dashboard.vue +++ b/boranga/frontend/boranga/src/components/common/species_flora_dashboard.vue @@ -689,20 +689,20 @@ export default { if (full.processing_status == 'Discarded') { links += `Reinstate
`; } else { - links += `Continue
`; + links += `Continue
`; links += `Discard
`; links += `History
`; } } else { if (full.user_process) { - links += `Edit
`; + links += `Edit
`; } - links += `View
`; + links += `View
`; links += `History
`; } } else { - links += `View
`; + links += `View
`; } return links; } diff --git a/boranga/frontend/boranga/src/components/external/routes/index.js b/boranga/frontend/boranga/src/components/external/routes/index.js index 11b91a40..0a5b592f 100755 --- a/boranga/frontend/boranga/src/components/external/routes/index.js +++ b/boranga/frontend/boranga/src/components/external/routes/index.js @@ -29,7 +29,7 @@ export default name: "external-species-communities-dash" }, { - path: 'species_communities', + path: 'species-communities', component: { render(c) { return c('router-view') diff --git a/boranga/frontend/boranga/src/components/internal/occurrence/occurrence_report.vue b/boranga/frontend/boranga/src/components/internal/occurrence/occurrence_report.vue index 98a12927..e20d18d3 100644 --- a/boranga/frontend/boranga/src/components/internal/occurrence/occurrence_report.vue +++ b/boranga/frontend/boranga/src/components/internal/occurrence/occurrence_report.vue @@ -19,7 +19,7 @@ @@ -309,11 +314,15 @@ export default { updateObservationDetails: function () { let vm = this; vm.updatingObservationDetails = true; - vm.$http.post(helpers.add_endpoint_json(api_endpoints.occurrence, (vm.occurrence_obj.id + '/update_observation_details')), JSON.stringify(vm.occurrence_obj.observation_detail), { - emulateJSON: true - }).then((response) => { + fetch(helpers.add_endpoint_json(api_endpoints.occurrence, (vm.occurrence_obj.id + '/update_observation_details')), { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(vm.occurrence_obj.observation_detail) + }).then(async (response) => { vm.updatingObservationDetails = false; - vm.occurrence_obj.observation_detail = response.body; + vm.occurrence_obj.observation_detail = await response.json(); swal.fire({ title: 'Saved', text: 'Observation details have been saved', @@ -342,11 +351,15 @@ export default { updateIdentificationDetails: function () { let vm = this; vm.updatingIdentificationDetails = true; - vm.$http.post(helpers.add_endpoint_json(api_endpoints.occurrence, (vm.occurrence_obj.id + '/update_identification_details')), JSON.stringify(vm.occurrence_obj.identification), { - emulateJSON: true - }).then((response) => { + fetch(helpers.add_endpoint_json(api_endpoints.occurrence, (vm.occurrence_obj.id + '/update_identification_details')), { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(vm.occurrence_obj.identification) + }).then(async (response) => { vm.updatingIdentificationDetails = false; - vm.occurrence_obj.identification = response.body; + vm.occurrence_obj.identification = await response.json(); swal.fire({ title: 'Saved', text: 'Identification details have been saved', @@ -433,8 +446,8 @@ export default { created: async function () { let vm = this; //------fetch list of values - const res = await Vue.http.get(`/api/occurrence/observation_list_of_values.json?group_type=${vm.occurrence_obj.group_type}`); - vm.listOfValuesDict = res.body; + const repsonse = await fetch(`/api/occurrence/observation_list_of_values.json?group_type=${vm.occurrence_obj.group_type}`); + vm.listOfValuesDict = await repsonse.json(); vm.observation_method_list = vm.listOfValuesDict.observation_method_list; vm.observation_method_list.splice(0, 0, { diff --git a/boranga/frontend/boranga/src/components/common/occurrence/occ_ocr_existing_threats.vue b/boranga/frontend/boranga/src/components/common/occurrence/occ_ocr_existing_threats.vue index 6c111c6a..a3820137 100644 --- a/boranga/frontend/boranga/src/components/common/occurrence/occ_ocr_existing_threats.vue +++ b/boranga/frontend/boranga/src/components/common/occurrence/occ_ocr_existing_threats.vue @@ -1,30 +1,19 @@ diff --git a/boranga/frontend/boranga/src/components/forms/text_info.vue b/boranga/frontend/boranga/src/components/forms/text_info.vue index b4934d83..8c2b1dac 100755 --- a/boranga/frontend/boranga/src/components/forms/text_info.vue +++ b/boranga/frontend/boranga/src/components/forms/text_info.vue @@ -1,15 +1,20 @@ - + diff --git a/boranga/frontend/boranga/src/components/internal/Home.vue b/boranga/frontend/boranga/src/components/internal/Home.vue index b53298cb..75f3d9ce 100644 --- a/boranga/frontend/boranga/src/components/internal/Home.vue +++ b/boranga/frontend/boranga/src/components/internal/Home.vue @@ -1,5 +1,5 @@ diff --git a/boranga/frontend/boranga/src/components/internal/conservation_status/amendment_request.vue b/boranga/frontend/boranga/src/components/internal/conservation_status/amendment_request.vue index f3bfcdf2..eacabf35 100644 --- a/boranga/frontend/boranga/src/components/internal/conservation_status/amendment_request.vue +++ b/boranga/frontend/boranga/src/components/internal/conservation_status/amendment_request.vue @@ -1,18 +1,40 @@ diff --git a/boranga/frontend/boranga/src/components/internal/conservation_status/back_to_assessor.vue b/boranga/frontend/boranga/src/components/internal/conservation_status/back_to_assessor.vue index d1dc79f9..d10166f8 100644 --- a/boranga/frontend/boranga/src/components/internal/conservation_status/back_to_assessor.vue +++ b/boranga/frontend/boranga/src/components/internal/conservation_status/back_to_assessor.vue @@ -1,20 +1,45 @@ diff --git a/boranga/frontend/boranga/src/components/internal/conservation_status/community_conservation_status_history.vue b/boranga/frontend/boranga/src/components/internal/conservation_status/community_conservation_status_history.vue index d14cc27c..a288ead7 100644 --- a/boranga/frontend/boranga/src/components/internal/conservation_status/community_conservation_status_history.vue +++ b/boranga/frontend/boranga/src/components/internal/conservation_status/community_conservation_status_history.vue @@ -2,23 +2,33 @@
{{ errorString }} + >{{ errorString }}
-
+
- +
@@ -53,7 +65,7 @@ import DisplayHistory from '../../common/display_history.vue'; import { v4 as uuid } from 'uuid'; export default { - name: 'communityConservationStatusHistory', + name: 'CommunityConservationStatusHistory', components: { modal, alert, @@ -79,8 +91,7 @@ export default { historyId: null, historySequence: null, datatable_id: 'history-datatable-' + uuid(), - documentDetails: { - }, + documentDetails: {}, isModalOpen: false, errorString: '', successString: '', @@ -118,16 +129,28 @@ export default { }, column_sequence: function () { return { - data: 'revision_sequence', orderable: true, searchable: false, visible: true, render: function (row, type, full) { - if (full.data.conservationstatus.fields.conservation_status_number) { - return full.data.conservationstatus.fields.conservation_status_number+'-'+full.revision_sequence; + if ( + full.data.conservationstatus.fields + .conservation_status_number + ) { + return ( + full.data.conservationstatus.fields + .conservation_status_number + + '-' + + full.revision_sequence + ); } else { - return "CS"+full.data.conservationstatus.pk+'-'+full.revision_sequence; + return ( + 'CS' + + full.data.conservationstatus.pk + + '-' + + full.revision_sequence + ); } }, name: 'revision_sequence', @@ -154,14 +177,14 @@ export default { searchable: false, visible: true, render: function (row, type, full) { - return full.data.conservationstatus.fields.conservation_status_number; + return full.data.conservationstatus.fields + .conservation_status_number; }, name: 'conservation_status_number', }; }, column_revision_id: function () { return { - data: 'revision_id', orderable: true, searchable: true, @@ -174,7 +197,6 @@ export default { }, column_revision_date: function () { return { - data: 'date_created', orderable: true, searchable: true, @@ -187,7 +209,6 @@ export default { }, column_revision_user: function () { return { - data: 'revision_user', orderable: false, searchable: false, @@ -237,7 +258,6 @@ export default { }, column_list: function () { return { - data: 'data.data.conservationlist.fields.code', defaultContent: '', orderable: false, @@ -255,21 +275,20 @@ export default { }, column_processing_status: function () { return { - data: 'data.data.conservationstatus.fields.processing_status', defaultContent: '', orderable: true, searchable: false, visible: true, render: function (row, type, full) { - return full.data.conservationstatus.fields.processing_status; + return full.data.conservationstatus.fields + .processing_status; }, name: 'processing_status', }; }, column_comment: function () { return { - data: 'data.data.conservationstatus.fields.comment', defaultContent: '', orderable: false, @@ -279,7 +298,7 @@ export default { //return full.data.conservationstatus.fields.comment; let value = full.data.conservationstatus.fields.comment; let result = helpers.dtPopover(value, 30, 'hover'); - return type=='export' ? value : result; + return type == 'export' ? value : result; }, name: 'comment', }; @@ -290,11 +309,11 @@ export default { orderable: false, searchable: false, visible: true, - mRender: function(data, type, full){ - let links = ""; + mRender: function (data, type, full) { + let links = ''; links += `View
`; return links; - } + }, }; }, datatable_options: function () { @@ -322,7 +341,10 @@ export default { order: [[0, 'desc']], serverSide: true, ajax: { - url: api_endpoints.lookup_history_conservation_status(this.conservationStatusId)+"?format=datatables", + url: + api_endpoints.lookup_history_conservation_status( + this.conservationStatusId + ) + '?format=datatables', dataSrc: 'data', }, buttons: [ @@ -332,8 +354,8 @@ export default { text: ' Excel', className: 'btn btn-primary me-2 rounded', exportOptions: { - orthogonal: 'export' - } + orthogonal: 'export', + }, }, { extend: 'csv', @@ -341,65 +363,73 @@ export default { text: ' CSV', className: 'btn btn-primary rounded', exportOptions: { - orthogonal: 'export' - } + orthogonal: 'export', + }, }, ], - dom: "<'d-flex align-items-center'<'me-auto'l>fB>" + - "<'row'<'col-sm-12'tr>>" + - "<'d-flex align-items-center'<'me-auto'i>p>", + dom: + "<'d-flex align-items-center'<'me-auto'l>fB>" + + "<'row'<'col-sm-12'tr>>" + + "<'d-flex align-items-center'<'me-auto'i>p>", columns: columns, processing: true, - drawCallback: function() { + drawCallback: function () { helpers.enablePopovers(); }, - initComplete: function() { + initComplete: function () { helpers.enablePopovers(); }, }; }, }, - methods: { - close: function () { - this.errorString = ''; - this.isModalOpen = false; - $('.has-error').removeClass('has-error'); + watch: { + isModalOpen() { + let vm = this; + if (this.isModalOpen) { + vm.$refs.history_datatable.vmDataTable.ajax.reload(); + } }, - viewHistory: function(id,seq){ - console.log("viewHistory"); - this.historyId = parseInt(id); - this.historySequence = parseInt(seq); - this.uuid++; - this.$nextTick(() => { - this.$refs.display_history.isModalOpen = true; - }); - }, - addEventListeners:function (){ - let vm=this; - vm.$refs.history_datatable.vmDataTable.on('click', 'a[data-view-history]', function(e) { - e.preventDefault(); - var id = $(this).attr('data-view-history'); - var seq = $(this).attr('data-view-history-seq'); - vm.viewHistory(id,seq); - }); - vm.$refs.history_datatable.vmDataTable.on('childRow.dt', function (e, settings) { - helpers.enablePopovers(); - }); - } }, - mounted: function(){ + mounted: function () { let vm = this; this.$nextTick(() => { vm.addEventListeners(); }); }, - watch: { - isModalOpen() { + methods: { + close: function () { + this.errorString = ''; + this.isModalOpen = false; + $('.has-error').removeClass('has-error'); + }, + viewHistory: function (id, seq) { + console.log('viewHistory'); + this.historyId = parseInt(id); + this.historySequence = parseInt(seq); + this.uuid++; + this.$nextTick(() => { + this.$refs.display_history.isModalOpen = true; + }); + }, + addEventListeners: function () { let vm = this; - if (this.isModalOpen) { - vm.$refs.history_datatable.vmDataTable.ajax.reload(); - } - } + vm.$refs.history_datatable.vmDataTable.on( + 'click', + 'a[data-view-history]', + function (e) { + e.preventDefault(); + var id = $(this).attr('data-view-history'); + var seq = $(this).attr('data-view-history-seq'); + vm.viewHistory(id, seq); + } + ); + vm.$refs.history_datatable.vmDataTable.on( + 'childRow.dt', + function (e, settings) { + helpers.enablePopovers(); + } + ); + }, }, }; diff --git a/boranga/frontend/boranga/src/components/internal/conservation_status/conservation_status.vue b/boranga/frontend/boranga/src/components/internal/conservation_status/conservation_status.vue index 094ee62c..b88f6652 100644 --- a/boranga/frontend/boranga/src/components/internal/conservation_status/conservation_status.vue +++ b/boranga/frontend/boranga/src/components/internal/conservation_status/conservation_status.vue @@ -1,71 +1,173 @@