Skip to content

Commit

Permalink
Fix portfolio summary editable cells (#4557)
Browse files Browse the repository at this point in the history
* refactor editable cell permissions

* precommit

* 2nd filter also contains goal note details
  • Loading branch information
perryr16 authored Mar 6, 2024
1 parent a551a09 commit aef8c6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
21 changes: 10 additions & 11 deletions seed/static/seed/js/controllers/portfolio_summary_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ angular.module('BE.seed.controller.portfolio_summary', [])
spinner_utility
) {
$scope.organization = organization_payload.organization;
$scope.write_permission = $scope.menu.user.is_ali_root || !$scope.menu.user.is_ali_leaf;
const viewer = $scope.menu.user.organization.user_role === 'viewer';
$scope.write_permission = ($scope.menu.user.is_ali_root || !$scope.menu.user.is_ali_leaf) && !viewer;
// Ii there a better way to convert string units to displayUnits?
const area_units = $scope.organization.display_units_area.replace('**2', '²');
const eui_units = $scope.organization.display_units_eui.replace('**2', '²');
Expand Down Expand Up @@ -209,7 +210,7 @@ angular.module('BE.seed.controller.portfolio_summary', [])
combined_result[cycle_priority[0].id] = properties;
const property_ids = properties.map((p) => p.id);

get_paginated_properties(page, per_page, cycle_priority[1], access_level_instance_id, false, property_ids).then((result1) => {
get_paginated_properties(page, per_page, cycle_priority[1], access_level_instance_id, false, property_ids, $scope.goal.id).then((result1) => {
properties = result1.results;
// if result0 returns fewer properties than result1, use result1 for ui-grid config
if (result1.pagination.num_pages > $scope.inventory_pagination.num_pages) {
Expand Down Expand Up @@ -530,7 +531,7 @@ angular.module('BE.seed.controller.portfolio_summary', [])
editDropdownOptionsArray: $scope.question_options,
editDropdownIdLabel: 'value',
enableCellEdit: $scope.write_permission,
cellClass: () => $scope.write_permission && 'cell-dropdown',
cellClass: () => $scope.write_permission && 'cell-edit',
// if user has write permission show a dropdown indicator
width: 350,
cellTemplate: `
Expand All @@ -547,19 +548,17 @@ angular.module('BE.seed.controller.portfolio_summary', [])
displayName: 'Resolution',
enableFiltering: false,
enableSorting: false,
enableCellEdit: true,
editableCellTemplate: 'ui-grid/cellTitleValidator',
cellClass: 'cell-edit',
enableCellEdit: !viewer,
cellClass: !viewer && 'cell-edit',
width: 300
},
{
field: 'historical_note.text',
displayName: 'Historical Notes',
enableFiltering: false,
enableSorting: false,
enableCellEdit: true,
editableCellTemplate: 'ui-grid/cellTitleValidator',
cellClass: 'cell-edit',
enableCellEdit: !viewer,
cellClass: !viewer && 'cell-edit',
width: 300
},
{
Expand All @@ -571,7 +570,7 @@ angular.module('BE.seed.controller.portfolio_summary', [])
editDropdownOptionsArray: [{ id: 1, value: true }, { id: 2, value: false }],
editDropdownIdLabel: 'value',
enableCellEdit: $scope.write_permission,
cellClass: () => $scope.write_permission && 'cell-dropdown',
cellClass: () => $scope.write_permission && 'cell-edit',
// if user has write permission show a dropdown indicator
cellTemplate: `
<div class='ui-grid-cell-contents' ng-class="row.entity.goal_note.passed_checks ? 'cell-pass' : 'cell-fail'">
Expand All @@ -590,7 +589,7 @@ angular.module('BE.seed.controller.portfolio_summary', [])
editDropdownOptionsArray: [{ id: 1, value: true }, { id: 2, value: false }],
editDropdownIdLabel: 'value',
enableCellEdit: $scope.write_permission,
cellClass: () => $scope.write_permission && 'cell-dropdown',
cellClass: () => $scope.write_permission && 'cell-edit',
// if user has write permission show a dropdown indicator
cellTemplate: `
<div class='ui-grid-cell-contents' ng-class="row.entity.goal_note.new_or_acquired && 'cell-pass'">
Expand Down
5 changes: 1 addition & 4 deletions seed/static/seed/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5428,11 +5428,8 @@ tags-input .tags .tag-item {
word-wrap: break-word;
}

.cell-dropdown {
cursor: copy;
}
.cell-edit {
cursor: cell;
cursor: copy;
}
.cell-dropdown-indicator {
display: flex;
Expand Down

0 comments on commit aef8c6c

Please sign in to comment.