Skip to content

Commit

Permalink
Added TKBL to the inventory detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
axelstudios committed Jul 2, 2024
1 parent ac478d3 commit 39d6d17
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 4 deletions.
10 changes: 7 additions & 3 deletions seed/static/seed/js/controllers/inventory_detail_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ angular.module('BE.seed.controller.inventory_detail', []).controller('inventory_
'scenario_service',
'uniformat_payload',
'elements_payload',
'tkbl_payload',
// eslint-disable-next-line func-names
function (
$http,
Expand Down Expand Up @@ -80,7 +81,8 @@ angular.module('BE.seed.controller.inventory_detail', []).controller('inventory_
property_measure_service,
scenario_service,
uniformat_payload,
elements_payload
elements_payload,
tkbl_payload
) {
$scope.inventory_type = $stateParams.inventory_type;
$scope.organization = organization_payload.organization;
Expand All @@ -103,6 +105,7 @@ angular.module('BE.seed.controller.inventory_detail', []).controller('inventory_

$scope.uniformat = uniformat_payload;
$scope.elements = elements_payload;
$scope.tkbl = tkbl_payload;

$scope.element_extra_data_columns = [...elements_payload.reduce((set, element) => {
for (const key of Object.keys(element.extra_data)) {
Expand Down Expand Up @@ -1061,11 +1064,12 @@ angular.module('BE.seed.controller.inventory_detail', []).controller('inventory_
* @param {string} code - Code representing the Uniformat category.
* @return {string} Formatted category hierarchy or the original code if the category is not found.
*/
$scope.uniformat_category = (code) => {
$scope.uniformat_hierarchy = (code) => {
const element = uniformat_payload[code];
if (element) {
const { category, parent } = element;
return parent ? `${$scope.uniformat_category(parent)}${category}` : category;
const formattedCategory = $filter('startCase')(category);
return parent ? `${$scope.uniformat_hierarchy(parent)}${formattedCategory}` : formattedCategory;
}
return code;
};
Expand Down
16 changes: 16 additions & 0 deletions seed/static/seed/js/filters/startCase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
* See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md
*
* StartCase
* For when you want to capitalize the first letter of each word
* https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage
*/
angular.module('startCase', []).filter(
'startCase',
() => (input) => {
if (typeof input !== 'string') return input;

return _.startCase(input.toLowerCase());
}
);
7 changes: 7 additions & 0 deletions seed/static/seed/js/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ angular.module('BE.seed.filters', [
'getAnalysisRunAuthor',
'htmlToPlainText',
'ignoremap',
'startCase',
'startFrom',
'stripImportPrefix',
'titleCase',
Expand Down Expand Up @@ -2342,6 +2343,12 @@ SEED_app.config([
'user_service',
'inventory_payload',
(element_service, user_service, inventory_payload) => element_service.get_elements(user_service.get_organization().id, inventory_payload.property.id)
],
tkbl_payload: [
'element_service',
'user_service',
'inventory_payload',
(element_service, user_service, inventory_payload) => element_service.get_tkbl(user_service.get_organization().id, inventory_payload.property.id)
]
}
})
Expand Down
6 changes: 6 additions & 0 deletions seed/static/seed/js/services/element_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ angular.module('BE.seed.service.element', []).factory('element_service', [
delete_element: (organization_id, property_id, element_id) => $http
.delete(`/api/v3/properties/${property_id}/elements/${element_id}/`, {
organization_id
}).then(({ data }) => data),

// Return Technology Knowledge Base Library guidance for a given property
get_tkbl: (organization_id, property_id) => $http
.get(`/api/v3/properties/${property_id}/elements/tkbl`, {
params: { organization_id }
}).then(({ data }) => data)
})
]);
54 changes: 53 additions & 1 deletion seed/static/seed/partials/inventory_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ <h2><i class="fa-solid fa-atom"></i>{$:: 'Property Elements' | translate $}<span
</thead>
<tbody>
<tr ng-repeat="element in ::elements">
<td><span ng-attr-title="{$:: uniformat_category(element.code) $}">{$:: element.code $}</span></td>
<td><span ng-attr-title="{$:: uniformat_hierarchy(element.code) $} ({$:: element.code $})">{$:: uniformat[element.code].category | startCase $}</span></td>
<td>{$:: element.description $}</td>
<td>{$:: element.installation_date $}</td>
<td>{$:: element.manufacturing_date $}</td>
Expand All @@ -400,6 +400,58 @@ <h2><i class="fa-solid fa-atom"></i>{$:: 'Property Elements' | translate $}<span
</div>
</div>

<div class="section" ng-if="::tkbl.length > 0">
<div class="section_header_container" style="margin-top: 20px; border-bottom: 0">
<div class="section_header fixed_height_short has_no_padding">
<div class="section_action_container left" style="width: 50%">
<h2><i class="fa-solid fa-atom"></i>{$:: 'Building Performance Standard (BPS) Compliance Pathway Support' | translate $}</h2>
</div>
</div>
</div>
<div class="section_content">
<div class="table_list_container table_item_detail" style="overflow: auto hidden">
<table class="table table-striped tkbl-table" style="margin-bottom: -1px">
<thead>
<tr>
<th translate>Remaining Service Life</th>
<th translate>Uniformat</th>
<th translate>Description</th>
<th translate>GSA SFTool Guidance</th>
<th translate>ESTCP Report</th>
<th translate>BuildingSync Recommended Measures</th>
<th translate>Federal BPS Recommended Measures</th>
<th translate>Auditor Recommended Measures</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="element in tkbl">
<td>{$:: element.remaining_service_life | number $}</td>
<td ng-attr-title="{$:: uniformat_hierarchy(element.code) $} ({$:: element.code $})">{$:: uniformat[element.code].category | startCase $}</td>
<td>{$:: element.description $}</td>
<td>
<ul ng-if="element.tkbl.sftool.length > 0">
<li ng-repeat="entry in ::element.tkbl.sftool">
<a ng-href="{$:: entry.url $}" target="_blank" rel="noopener noreferrer">{$:: entry.name $}</a>
</li>
</ul>
</td>
<td>
<ul ng-if="element.tkbl.estcp.length > 0">
<li ng-repeat="entry in ::element.tkbl.estcp">
<a ng-href="{$:: entry.url $}" target="_blank" rel="noopener noreferrer">{$:: entry.name $}</a>
</li>
</ul>
</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

<!-- Inventory Document Section -->
<div class="section">
<div class="section_header_container" style="margin-top: 20px; border-bottom: 0">
Expand Down
4 changes: 4 additions & 0 deletions seed/static/seed/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5540,3 +5540,7 @@ tags-input .tags .tag-item {
font-weight: normal;
}
}

.tkbl-table ul {
padding-left: 18px;
}
1 change: 1 addition & 0 deletions seed/static/seed/tests/inventory_detail_controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe('controller: inventory_detail_controller', () => {
analyses: []
},
elements_payload: [],
tkbl_payload: [],
uniformat_payload: {},
views_payload: {
status: 'success',
Expand Down
1 change: 1 addition & 0 deletions seed/static/seed/tests/property_detail_controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ describe('controller: inventory_detail_controller', () => {
analyses: []
},
elements_payload: [],
tkbl_payload: [],
uniformat_payload: {},
views_payload: {
status: 'success',
Expand Down
1 change: 1 addition & 0 deletions seed/static/seed/tests/taxlot_detail_controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ describe('controller: inventory_detail_controller', () => {
analyses: []
},
elements_payload: [],
tkbl_payload: [],
uniformat_payload: {},
views_payload: {
status: 'success',
Expand Down
1 change: 1 addition & 0 deletions seed/templates/seed/_scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script src="{{ STATIC_URL }}seed/js/filters/getAnalysisRunAuthor.js"></script>
<script src="{{ STATIC_URL }}seed/js/filters/htmlToPlainText.js"></script>
<script src="{{ STATIC_URL }}seed/js/filters/ignoremap.js"></script>
<script src="{{ STATIC_URL }}seed/js/filters/startCase.js"></script>
<script src="{{ STATIC_URL }}seed/js/filters/startFrom.js"></script>
<script src="{{ STATIC_URL }}seed/js/filters/stripImportPrefix.js"></script>
<script src="{{ STATIC_URL }}seed/js/filters/titleCase.js"></script>
Expand Down

0 comments on commit 39d6d17

Please sign in to comment.