Skip to content

Commit e1d8187

Browse files
seeker25bferguso
andauthored
Fix initial step validation not working + Add in Organization to Internal/External Cards and filing summary (#1687)
* Fix initial validation, devmode = false, devmode was enabled to bypass validation * Add in organization to internal/external dashboard cards also on the filing summary page * Move datatype factory into initialize, so we don't need a unit test wide mock that depends on import order * remove comma replacement * new descriptor types * remove devmode and some clean up * use new format, don't stub ProjectCard * clean up * use bcgov/arches-component-lab#v0.0.1a13-bcgov use github:bcgov/bcgov-arches-common#ts/bugfix/general_fixes * descriptors for contributor * function manager give ability to reindex * Point back at release/2.1.x of bcgov-arches-common --------- Co-authored-by: brett <brett@qedsystems.ca>
1 parent 872e804 commit e1d8187

32 files changed

Lines changed: 1622 additions & 910 deletions

bcap/functions/bcap_site_descriptors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444

4545
class BCAPSiteDescriptors(AbstractPrimaryDescriptorsFunction):
46-
_datatype_factory = DataTypeFactory()
46+
_datatype_factory = None
4747
# For Name part of descriptor
4848
graph_slug = "archaeological_site"
4949

@@ -68,6 +68,7 @@ class BCAPSiteDescriptors(AbstractPrimaryDescriptorsFunction):
6868

6969
# Initializes the static nodes and datatypes data
7070
def initialize(self):
71+
BCAPSiteDescriptors._datatype_factory = DataTypeFactory()
7172
for alias in (
7273
BCAPSiteDescriptors._name_nodes
7374
+ BCAPSiteDescriptors._sig_event_nodes
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from bcap.util.bcap_aliases import GraphSlugs
2+
from bcap.util.descriptors import DescriptorTypes
3+
from bcap.util.aliases.contributor import ContributorAliases as aliases
4+
from bcgov_arches_common.util.bc_primary_descriptors_function import (
5+
BCPrimaryDescriptorsFunction,
6+
)
7+
from bcgov_arches_common.util.graph_lookup import GraphLookup
8+
9+
details = {
10+
"functionid": "60000000-0000-0000-0000-000000001007",
11+
"name": "Contributor Descriptors",
12+
"type": "primarydescriptors",
13+
"modulename": "contributor_descriptors.py",
14+
"description": "Function that provides the primary descriptors for BCAP Contributors",
15+
"defaultconfig": {
16+
"module": "bcap.functions.contributor_descriptors",
17+
"class_name": "ContributorDescriptors",
18+
"descriptor_types": {
19+
DescriptorTypes.NAME: {},
20+
DescriptorTypes.DESCRIPTION: {},
21+
DescriptorTypes.MAP_POPUP: {},
22+
},
23+
"triggering_nodegroups": [],
24+
},
25+
"classname": "ContributorDescriptors",
26+
"component": "views/components/functions/contributor-descriptors",
27+
}
28+
29+
30+
class ContributorDescriptorNodes:
31+
NAME = [aliases.CONTRIBUTOR_NAME, aliases.FIRST_NAME]
32+
CARD = [aliases.CONTRIBUTOR_TYPE, aliases.CONTRIBUTOR_ROLE]
33+
34+
# A descriptor with no nodes renders as "".
35+
BY_DESCRIPTOR = {
36+
DescriptorTypes.NAME: NAME,
37+
DescriptorTypes.DESCRIPTION: CARD,
38+
DescriptorTypes.MAP_POPUP: [],
39+
}
40+
41+
42+
class ContributorDescriptors(BCPrimaryDescriptorsFunction):
43+
# Arches builds a fresh instance per descriptor per resource, and a lookup
44+
# re-reads its nodes on first use, so share one for the whole process.
45+
_graph_lookup = GraphLookup(
46+
GraphSlugs.CONTRIBUTOR,
47+
ContributorDescriptorNodes.NAME + ContributorDescriptorNodes.CARD,
48+
)
49+
50+
def get_primary_descriptor_from_nodes(
51+
self, resource, config, context=None, descriptor=None
52+
):
53+
node_aliases = ContributorDescriptorNodes.BY_DESCRIPTOR.get(descriptor, [])
54+
values = [
55+
self.format_value(
56+
None,
57+
self.get_value_from_node(
58+
self._graph_lookup.get_node(alias),
59+
self._graph_lookup.get_datatype(alias),
60+
resource,
61+
context=context,
62+
),
63+
show_name=False,
64+
)
65+
for alias in node_aliases
66+
]
67+
68+
return ", ".join(filter(None, values))

bcap/functions/process_requirement_descriptors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848

4949
class ProcessRequirementDescriptors(AbstractPrimaryDescriptorsFunction):
50-
_datatype_factory = DataTypeFactory()
50+
_datatype_factory = None
5151
# For Name part of descriptor
5252
graph_slug = "process_requirement"
5353

@@ -69,6 +69,7 @@ class ProcessRequirementDescriptors(AbstractPrimaryDescriptorsFunction):
6969

7070
# Initializes the static nodes and datatypes data
7171
def initialize(self):
72+
ProcessRequirementDescriptors._datatype_factory = DataTypeFactory()
7273
for alias in (
7374
ProcessRequirementDescriptors._name_nodes
7475
+ ProcessRequirementDescriptors._popup_nodes
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import $ from 'jquery';
2+
import arches from 'arches';
3+
import ko from 'knockout';
4+
import FunctionViewModel from 'viewmodels/function-view-model';
5+
import contributorDescriptorsTemplate from 'templates/views/components/functions/contributor-descriptors.htm';
6+
7+
// The descriptor nodes are hardcoded in ContributorDescriptorNodes, so the only
8+
// thing this panel offers is re-indexing.
9+
export default ko.components.register(
10+
'views/components/functions/contributor-descriptors',
11+
{
12+
viewModel: function () {
13+
FunctionViewModel.apply(this, arguments);
14+
this.loading = ko.observable(false);
15+
16+
this.reindexdb = function () {
17+
this.loading(true);
18+
$.ajax({
19+
type: 'POST',
20+
url: arches.urls.reindex,
21+
context: this,
22+
data: JSON.stringify({ graphids: [this.graph.graphid] }),
23+
error: function () {
24+
console.error('Re-index request failed');
25+
},
26+
complete: function () {
27+
this.loading(false);
28+
},
29+
});
30+
};
31+
},
32+
template: contributorDescriptorsTemplate,
33+
},
34+
);

bcap/pkg/graphs/resource_models/Contributor.json

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -472,23 +472,16 @@
472472
"functions_x_graphs": [
473473
{
474474
"config": {
475+
"class_name": "ContributorDescriptors",
475476
"descriptor_types": {
476-
"description": {
477-
"nodegroup_id": "c4ec91a4-9dea-11ed-9a7b-5254004d77d3",
478-
"string_template": "<Contributor Type>, <Contributor Role>"
479-
},
480-
"map_popup": {
481-
"nodegroup_id": "",
482-
"string_template": ""
483-
},
484-
"name": {
485-
"nodegroup_id": "c4ec91a4-9dea-11ed-9a7b-5254004d77d3",
486-
"string_template": "<Contributor Name>, <First Name>"
487-
}
477+
"description": {},
478+
"map_popup": {},
479+
"name": {}
488480
},
481+
"module": "bcap.functions.contributor_descriptors",
489482
"triggering_nodegroups": []
490483
},
491-
"function_id": "60000000-0000-0000-0000-000000000001",
484+
"function_id": "60000000-0000-0000-0000-000000001007",
492485
"graph_id": "605b0bbc-8661-4cf2-b340-df743a8c5f89",
493486
"id": "a62973b8-f0d8-4e1c-a47b-323dd4ad4bb2"
494487
}

bcap/services/dashboard/base_dashboard_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class BaseDashboardService(BaseGraphService):
2828
PA.FILING_TYPE,
2929
PA.INDUSTRIAL_SECTOR,
3030
PA.APPLICATION_PRIORITY_LEVEL,
31+
PA.OWNING_ORGANIZATION,
3132
PA.RELATED_PERMIT,
3233
PA.MODULE_ID,
3334
PA.MODULE_NAME,
@@ -83,6 +84,7 @@ def display(alias):
8384
submission_type=display(self.PA.FILING_TYPE),
8485
industrial_sector=display(self.PA.INDUSTRIAL_SECTOR),
8586
priority_level=display(self.PA.APPLICATION_PRIORITY_LEVEL),
87+
organization=display(self.PA.OWNING_ORGANIZATION),
8688
related_permit_id=self._resource_id(
8789
self._node_value(aliased, self.PA.RELATED_PERMIT)
8890
),

bcap/services/dashboard/dashboard_types.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class InternalDashboardCard:
104104
industrial_sector: str = described(
105105
"Permit application's industrial sector (reference label).", ""
106106
)
107+
organization: str = described(
108+
"Name of the organization the application is filed under (its stamped "
109+
"owning_organization); empty when it was filed under none.",
110+
"",
111+
)
107112
permit_id: str | None = described(
108113
"Resourceinstanceid of the related HCA Permit; its drill-in GUID.", None
109114
)
@@ -210,6 +215,11 @@ class ExternalDashboardCard:
210215
industrial_sector: str = described(
211216
"Permit application's industrial sector (reference label).", ""
212217
)
218+
organization: str = described(
219+
"Name of the organization the application is filed under (its stamped "
220+
"owning_organization); empty when it was filed under none.",
221+
"",
222+
)
213223
permit_id: str | None = described(
214224
"Resourceinstanceid of the related HCA Permit; its drill-in GUID.", None
215225
)
@@ -269,6 +279,7 @@ class ApplicationCore:
269279
submission_type: str = ""
270280
industrial_sector: str = ""
271281
priority_level: str = ""
282+
organization: str = ""
272283
related_permit_id: str | None = None
273284

274285

bcap/services/dashboard/external_dashboard_service.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ def _application_queryset(self):
6868
GraphSlugs.PERMIT_APPLICATION,
6969
nodes=self.nodes(
7070
GraphSlugs.PERMIT_APPLICATION,
71-
self.CARD_NODES
72-
+ [
73-
self.PA.APPLICATION_SUBMISSION_DATE,
74-
self.PA.OWNING_ORGANIZATION,
75-
],
71+
self.CARD_NODES + [self.PA.APPLICATION_SUBMISSION_DATE],
7672
),
7773
as_representation=True,
7874
)
@@ -114,6 +110,7 @@ def _application_card(self, permit, hca_permits, unread_messages=0):
114110
application_number=core.application_number,
115111
submission_type=core.submission_type,
116112
industrial_sector=core.industrial_sector,
113+
organization=core.organization,
117114
permit_id=core.related_permit_id,
118115
permit_number=hca.number,
119116
urgency=0,
@@ -160,7 +157,12 @@ def _draft_parents(self, drafts):
160157
permits = self._tiles(
161158
GraphSlugs.PERMIT_APPLICATION,
162159
ids,
163-
[self.PA.PROJECT_NAME, self.PA.APPLICATION_ID, self.PA.FILING_TYPE],
160+
[
161+
self.PA.PROJECT_NAME,
162+
self.PA.APPLICATION_ID,
163+
self.PA.FILING_TYPE,
164+
self.PA.OWNING_ORGANIZATION,
165+
],
164166
)
165167
return {
166168
str(permit.pk): self._application_core(permit.aliased_data)
@@ -195,5 +197,6 @@ def field(alias):
195197
self.PA.APPLICATION_ID, parent.application_number
196198
),
197199
submission_type=identification(self.PA.FILING_TYPE, parent.submission_type),
200+
organization=parent.organization,
198201
unread_messages=unread_messages,
199202
)

bcap/services/dashboard/internal_dashboard_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ def _card_to_json(self, permit, data: InternalDashboardData):
375375
application_number=core.application_number,
376376
submission_type=core.submission_type,
377377
industrial_sector=core.industrial_sector,
378+
organization=core.organization,
378379
permit_id=core.related_permit_id,
379380
permit_number=hca.number,
380381
permit_holder=holder_names,

bcap/src/bcap/apps/Permit/Modules/WorkflowStepper.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ const state = reactive({
8181
submitting: false,
8282
savingDraft: false,
8383
confirmingExit: false,
84-
devMode: true,
8584
isDataLoaded: false,
8685
finalizedResourceData: null as PermitApplication | null,
8786
});
@@ -132,7 +131,6 @@ const currentStepIsValid = computed(
132131
);
133132
134133
const stepIsValid = (step: number): boolean => {
135-
if (state.devMode) return true;
136134
const el = stepEls.value[step - 1];
137135
let valid = true;
138136
if (typeof el?.isValid === 'function') valid = el.isValid();

0 commit comments

Comments
 (0)