Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show default display name on analyses #4924

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions seed/models/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,13 @@ def merge_relationships(cls, merged_state, state1, state2):

return merged_state

def default_display_value(self):
try:
field = self.organization.property_display_field
return self.extra_data.get(field) or getattr(self, field)
except AttributeError:
return None


@receiver(pre_delete, sender=PropertyState)
def pre_delete_state(sender, **kwargs):
Expand Down
6 changes: 6 additions & 0 deletions seed/serializers/analysis_property_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ class AnalysisPropertyViewSerializer(serializers.ModelSerializer):
class Meta:
model = AnalysisPropertyView
fields = "__all__"

def to_representation(self, instance):
ret = super().to_representation(instance)
state = instance.property_state
ret["display_name"] = state.default_display_value() if state else None
return ret
9 changes: 0 additions & 9 deletions seed/static/seed/js/controllers/analysis_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,5 @@ angular.module('SEED.controller.analysis', []).controller('analysis_controller',
$scope.views = views_payload.views;
$scope.view_id = $stateParams.view_id;
$scope.original_views = views_payload.original_views;

$scope.has_children = (value) => typeof value === 'object';

$scope.get_display_name = (inventory_state) => organization_service.get_inventory_display_value(
$scope.org,
// NOTE: hardcoding 'property' b/c you can only run analyses on properties
'property',
inventory_state
);
}
]);
2 changes: 0 additions & 2 deletions seed/static/seed/js/controllers/analysis_run_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@ angular.module('SEED.controller.analysis_run', []).controller('analysis_run_cont
$scope.original_view = view_payload.original_view;
$scope.original_views = {};
$scope.original_views[view_payload.view.id] = view_payload.original_view;

$scope.has_children = (value) => typeof value === 'object';
}
]);
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,5 @@ angular.module('SEED.controller.inventory_detail_analyses', []).controller('inve
}
});
};
$scope.has_children = (value) => typeof value === 'object';
}
]);
4 changes: 2 additions & 2 deletions seed/static/seed/partials/analysis_runs.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<td><a ui-sref="analysis_run(::{run_id: view.id, analysis_id: analysis.id, organization_id: org.id})" ui-sref-active="active">{$:: view.id $}</a></td>
<td>
<a ng-if="original_views[view.id]" ui-sref="inventory_detail({inventory_type: 'properties', view_id: original_views[view.id]})">
{$:: view.display_name || 'Property ' + original_views[view.id] $} <i class="glyphicon glyphicon-log-out"></i>
{$:: view.display_name || 'Property: Unknown' $} <i class="glyphicon glyphicon-log-out"></i>
</a>
<span ng-if="!original_views[view.id]" uib-tooltip="Property no longer exists"> <i class="fa-solid fa-triangle-exclamation"></i> {$:: view.display_name || 'Unknown' $} </span>
<span ng-if="!original_views[view.id]" uib-tooltip="Property no longer exists"> <i class="fa-solid fa-triangle-exclamation"></i> {$:: view.display_name || 'Property: Unknown' $} </span>
</td>
<td>
<ul>
Expand Down