edit relations

This commit is contained in:
Michele Artini 2021-10-21 11:54:57 +02:00
parent b736851035
commit 51bfb5866b
3 changed files with 27 additions and 24 deletions

View File

@ -33,10 +33,9 @@ public class VocabulariesController extends AbstractDnetController {
vocs.put("languages", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.languages));
vocs.put("relTypes", Arrays.stream(RelationType.values())
.filter(t -> t != RelationType.Merged_In)
.filter(t -> t != RelationType.Merges)
.map(t -> new VocabularyTerm(t.toString(), t.toString()))
.map(t -> new VocabularyTerm(t.name(), t.name()))
.collect(Collectors.toList()));
vocs.put("similaritiesType", Arrays.stream(SimilarityType.values())
.map(t -> new VocabularyTerm(t.toString(), t.toString()))
.collect(Collectors.toList()));

View File

@ -248,20 +248,22 @@
<div class="card">
<div class="card-header text-white text-center py-1 bg-primary" ng-class="{'bg-light text-dark' : mode == 'readonly' || mode == 'not_authorized', 'bg-warning' : mode == 'approve'}">Relations</div>
<table class="table table-sm">
<thead class="thead-light">
<tr>
<th class="pl-3" style="border-top: none;">Related organization</th>
<th style="border-top: none; width: 156px">Type</th>
<th style="border-top: none; width: 44px"></th>
</tr>
</thead>
<tbody>
<tr ng-if="org.relations.length == 0">
<td class="text-center text-muted" colspan="3">No relations</td>
<td class="text-center text-muted" colspan="4">No relations</td>
</tr>
<tr ng-repeat="r in org.relations">
<td class="pl-3"><a href="#!/edit/0/{{r.relatedOrgId}}" title="{{r.relatedOrgId}}">{{r.relatedOrgName}}</a></td>
<td>{{r.type}}</td>
<tr ng-repeat="r in org.relations | orderBy:['type','relatedOrgName']">
<td class="pl-3" colspan="3">This organizazion
<!-- NB: The showed value MUST be the inverse -->
<span ng-switch="r.type">
<b ng-switch-when="Child">is parent of</b>
<b ng-switch-when="Parent">is child of</b>
<b ng-switch-when="Merges">is merged in</b>
<b ng-switch-when="Merged_In">merges</b>
<b ng-switch-default>is related to</b>
</span>
<a href="#!/edit/0/{{r.relatedOrgId}}" title="{{r.relatedOrgId}}">{{r.relatedOrgName}}</a>
</td>
<td class="text-right">
<button type="button" class="btn btn-sm btn-outline-danger" ng-click="org.relations.splice($index, 1)"><i class="fa fa-trash"></i></button>
</td>
@ -269,20 +271,23 @@
</tbody>
<tfoot>
<tr>
<td class="text-right" style="width: 120px; vertical-align: middle;">This organization</td>
<td style="width: 140px;">
<select class="custom-select custom-select-sm" ng-model="newRelType">
<option disabled="disabled" value=''>rel type...</option>
<!-- NB: The showed value MUST be the inverse -->
<option value="Parent">is child of</option>
<option value="Child">is parent of</option>
</select>
</td>
<td>
<input type="text" placeholder="add a related organization..." readonly="readonly"
<input type="text" placeholder="related organization..." readonly="readonly"
class="form-control form-control-sm" style="background-color: white; color: #007bff;"
ng-model="newRelation.name" ng-click="resetSelectedRelation()"
data-toggle="modal" data-target="#selectRelatedOrgModal" ng-hide="mode == 'readonly'"/>
<input type="text" placeholder="add a related organization..." disabled="disabled"
<input type="text" placeholder="related organization..." disabled="disabled"
class="form-control form-control-sm" ng-model="newRelation.name" ng-show="mode == 'readonly'"/>
</td>
<td>
<select class="custom-select custom-select-sm" ng-model="newRelType">
<option disabled="disabled" value=''>rel type...</option>
<option ng-repeat="t in vocabularies.relTypes" value="{{t.value}}">{{t.name}}</option>
</select>
</td>
<td class="text-right">
<button type="button" class="btn btn-sm btn-outline-success" ng-disabled="!newRelType || !newRelation.id" ng-click="addNewRelation()"><i class="fa fa-plus"></i></button>
</td>
@ -294,7 +299,6 @@
</div>
</fieldset>
<fieldset ng-if="mode == 'update_full'">
<button type="submit" class="btn btn-primary" ng-click="save()" ng-disabled="organizationForm.$invalid">Save</button>
</fieldset>

View File

@ -167,7 +167,7 @@ orgsModule.directive('orgFormMetadata', function($http, $location, $route, $rout
scope.newRelation = {};
}
scope.addNewRelation = function(r) {
scope.addNewRelation = function() {
scope.org.relations.push({
'relatedOrgId' : scope.newRelation.id,
'relatedOrgName' : scope.newRelation.name,