Skip to content

Commit

Permalink
Remove hard-coded sample name on frontend #1516
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jan 17, 2024
1 parent 053e332 commit 4fe4143
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ define([
this.areaNameFromTileData = (tileData) => {
const nameValue = tileData[self.partIdentifierAssignmentLabelNodeId];
const baseName = self.getStrValue(nameValue) || "";
return `${baseName} [${arches.translations.analysisArea} ${arches.translations.of} ${self.physicalThingName()}]`;
return arches.translations.analysisAreaOf.replace('{}', baseName).replace('{}', self.physicalThingName());
};
this.areaName = ko.computed(function(){
if (self.selectedAnalysisAreaInstance()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@ define([
}
});

this.sampleNameFromTileData = (data) => {
const partIdentifierAssignmentLabelNodeId = '3e541cc6-859b-11ea-97eb-acde48001122';
const baseName = ko.unwrap(ko.unwrap(data[partIdentifierAssignmentLabelNodeId])?.[arches.activeLanguage]?.["value"]) || "";
return arches.translations.sampleOf.replace('{}', baseName).replace('{}', params.physicalThingName);
};

this.sampleName = ko.computed(function() {
var partIdentifierAssignmentLabelNodeId = '3e541cc6-859b-11ea-97eb-acde48001122';
if (self.selectedSampleLocationInstance()){
const baseName = ko.unwrap(ko.unwrap(self.selectedSampleLocationInstance().data[partIdentifierAssignmentLabelNodeId])?.[arches.activeLanguage]?.["value"]) || "";
return `${baseName} [Sample of ${params.physicalThingName}]`;
return self.sampleNameFromTileData(self.selectedSampleLocationInstance().data);
}
});

Expand Down
2 changes: 2 additions & 0 deletions arches_for_science/templates/javascript.htm
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
analysis-area='{% trans "Analysis Area" as analysisArea %} "{{ analysisArea|escapejs }}"'
analysis-areas='{% trans "Analysis Areas" as analysisAreas %} "{{ analysisAreas|escapejs }}"'
no-modifying-areas='{% trans "Analysis Areas may not be modified in the sample taking workflow" as noModifyingAreas %} "{{ noModifyingAreas|escapejs }}"'
analysis-area-of='{% trans "{} [Analysis Area of {}]" as analysisAreaOf %} "{{ analysisAreaOf|escapejs }}"'
sample-of='{% trans "{} [Sample of {}]" as sampleOf %} "{{ sampleOf|escapejs }}"'
sample-location='{% trans "Sample Location" as sampleLocation %} "{{ sampleLocation|escapejs }}"'
no-modifying-samples='{% trans "Sample locations may not be modified in the analysis area workflow" as noModifyingSamples %} "{{ noModifyingSamples|escapejs }}"'
physical-thing-placeholder='{% trans "find a physical thing: enter an artist, object name, artwork title or object number" as physicalThingPlaceholder %} "{{ physicalThingPlaceholder|escapejs }}"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ <h5>{% trans 'Sample locations' %}</h5>
</a>
</td>
<!-- /ko -->
<!-- TODO(i18n) samples -->
<td class="afs-workflow-table-contents" data-bind="text: (function(){
var partIdentifierAssignmentLabelNodeId = '3e541cc6-859b-11ea-97eb-acde48001122';
return ko.unwrap($data.data[partIdentifierAssignmentLabelNodeId][$parent.activeLanguage()]['value']) + ' [Sample of ' + $parent.physicalThingName + ']';
})()" style="width: 100%; padding: 0px 5px;"></td>
<td class="afs-workflow-table-contents" data-bind="text: $parent.sampleNameFromTileData($data.data)" style="width: 100%; padding: 0px 5px;"></td>
</tr>
<!-- /ko -->
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def get_type(self, resourceid):
try:
object_type_tile = TileModel.objects.filter(resourceinstance_id=resourceid).get(nodegroup_id=type_nodegroup_id)
object_types = object_type_tile.data[type_nodegroup_id]
# TODO(i18n) samples
if sample_area_value_id in object_types:
return "sample area"
elif sample_value_id in object_types:
Expand Down

0 comments on commit 4fe4143

Please sign in to comment.