Skip to content

Commit

Permalink
fixed infite loading and dropdown errors in new case generation for l…
Browse files Browse the repository at this point in the history
…egal cases dashboard
  • Loading branch information
Shruti Hindocha committed Jan 22, 2024
1 parent 18f8c9b commit 4fd261a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion wildlifecompliance/components/legal_case/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ def workflow_action(self, request, instance=None, create_legal_case=None, *args,
instance.district_id = None if not request.data.get('district_id') else request.data.get('district_id')
instance.assigned_to_id = None if not request.data.get('assigned_to_id') else request.data.get('assigned_to_id')
instance.legal_case_priority_id = None if not request.data.get('legal_case_priority_id') else request.data.get('legal_case_priority_id')
instance.allocated_group_id = None if not request.data.get('allocated_group_id') else request.data.get('allocated_group_id')
# instance.allocated_group_id = None if not request.data.get('allocated_group_id') else request.data.get('allocated_group_id')
instance.call_email_id = None if not request.data.get('call_email_id') else request.data.get('call_email_id')
instance.details = None if not request.data.get('details') else request.data.get('details')

Expand Down
10 changes: 5 additions & 5 deletions wildlifecompliance/components/legal_case/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,11 +1359,11 @@ def get_user_action(self, obj):
returned_url = view_url
elif user_id == obj.assigned_to_id:
returned_url = process_url
elif (obj.allocated_group
and not obj.assigned_to_id):
for member in obj.allocated_group.members:
if user_id == member.id:
returned_url = process_url
# elif (obj.allocated_group
# and not obj.assigned_to_id):
# for member in obj.allocated_group.members:
# if user_id == member.id:
# returned_url = process_url

if not returned_url:
returned_url = view_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ export default {
let returned_regions = await cache_helper.getSetCacheList('Regions', '/api/regions/');
Object.assign(this.regions, returned_regions);
// blank entry allows user to clear selection
this.regions.splice(0, 0,
{
id: "",
display_name: "",
district: "",
districts: [],
region: null,
});
// inspection_types
let returned_inspection_types = await cache_helper.getSetCacheList(
'InspectionTypes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="col-sm-9">
<select class="form-control col-sm-9" @change.prevent="updateDistricts()" v-model="region_id">
<option v-for="option in regions" :value="option.id" v-bind:key="option.id">
{{ option.display_name }}
{{ option.name }}
</option>
</select>
</div>
Expand All @@ -25,8 +25,8 @@
</div>
<div class="col-sm-9">
<select class="form-control" @change.prevent="updateAllocatedGroup()" v-model="district_id">
<option v-for="option in availableDistricts" :value="option.id" v-bind:key="option.id">
{{ option.display_name }}
<option v-for="option in availableDistricts" :value="option.district_id" v-bind:key="option.district_id">
{{ option.district_name }}
</option>
</select>
</div>
Expand Down Expand Up @@ -147,7 +147,7 @@ export default {
assigned_to_id: null,
advice_details: "",
allocatedGroup: [],
allocated_group_id: null,
// allocated_group_id: null,
documentActionUrl: '',
temporary_document_collection_id: null,
legal_case_priority_id: null,
Expand Down Expand Up @@ -211,18 +211,11 @@ export default {
updateDistricts: function() {
// this.district_id = null;
this.availableDistricts = [];
for (let record of this.regionDistricts) {
if (this.region_id === record.id) {
for (let district of record.districts) {
for (let district_record of this.regionDistricts) {
if (district_record.id === district) {
this.availableDistricts.push(district_record)
}
}
}
for (let region of this.regions) {
if (this.region_id === region.id) {
this.availableDistricts=region.districts
}
}
console.log(this.availableDistricts);
this.availableDistricts.splice(0, 0,
{
id: "",
Expand All @@ -235,18 +228,16 @@ export default {
this.updateAllocatedGroup();
},
updateAllocatedGroup: async function() {
console.log("updateAllocatedGroup");
this.errorResponse = "";
if (this.regionDistrictId) {
if (this.region_id && this.district_id) {
let allocatedGroupResponse = await this.loadAllocatedGroup({
region_district_id: this.regionDistrictId,
group_permission: 'officer',
workflow_type: 'forward_to_regions',
region_id: this.region_id,
district_id: this.district_id ? this.district_id : null,
});
if (allocatedGroupResponse.ok) {
console.log(allocatedGroupResponse.body.allocated_group);
//this.allocatedGroup = Object.assign({}, allocatedGroupResponse.body.allocated_group);
Vue.set(this, 'allocatedGroup', allocatedGroupResponse.body.allocated_group);
this.allocated_group_id = allocatedGroupResponse.body.group_id;
Vue.set(this, 'allocatedGroup', allocatedGroupResponse.body);
// this.allocated_group_id = allocatedGroupResponse.body.group_id;
} else {
// Display http error response on modal
this.errorResponse = allocatedGroupResponse.statusText;
Expand All @@ -266,7 +257,6 @@ export default {
let is_valid_form = this.isValidForm();
if (is_valid_form) {
const response = await this.sendData();
console.log(response);
if (response.ok) {
// For LegalCase Dashboard
if (this.$parent.$refs.legal_case_table) {
Expand All @@ -287,7 +277,6 @@ export default {
}
},
isValidForm: function() {
console.log("performValidation");
this.$v.$touch();
if (this.$v.$invalid) {
this.errorResponse = 'Invalid form:\n';
Expand Down Expand Up @@ -330,7 +319,7 @@ export default {
this.assigned_to_id ? payload.append('assigned_to_id', this.assigned_to_id) : null;
this.inspection_type_id ? payload.append('legal_case_priority_id', this.legal_case_priority_id) : null;
this.region_id ? payload.append('region_id', this.region_id) : null;
this.allocated_group_id ? payload.append('allocated_group_id', this.allocated_group_id) : null;
// this.allocated_group_id ? payload.append('allocated_group_id', this.allocated_group_id) : null;
this.temporary_document_collection_id ? payload.append('temporary_document_collection_id', this.temporary_document_collection_id.temp_doc_id) : null;
//this.workflow_type ? payload.append('workflow_type', this.workflow_type) : null;
Expand Down Expand Up @@ -361,7 +350,7 @@ export default {
},
created: async function() {
// regions
let returned_regions = await cache_helper.getSetCacheList('Regions', '/api/region_district/get_regions/');
let returned_regions = await cache_helper.getSetCacheList('Regions', '/api/regions/');
Object.assign(this.regions, returned_regions);
// blank entry allows user to clear selection
this.regions.splice(0, 0,
Expand All @@ -372,7 +361,6 @@ export default {
districts: [],
region: null,
});
// regionDistricts
let returned_region_districts = await cache_helper.getSetCacheList(
'RegionDistricts',
api_endpoints.region_district
Expand Down

0 comments on commit 4fd261a

Please sign in to comment.