add multiple parent/child relations

This commit is contained in:
Michele Artini 2024-11-29 14:14:20 +01:00
parent d40d9adc9c
commit b5f9fed5da
2 changed files with 31 additions and 28 deletions

View File

@ -271,25 +271,22 @@
</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="IsChildOf">is child of</option>
<option value="IsParentOf">is parent of</option>
</select>
</td>
<td>
<input type="text" placeholder="related organization..." readonly="readonly"
class="form-control form-control-sm text-primary"
ng-model="newRelation.name" ng-click="resetSelectedRelation()"
data-toggle="modal" data-target="#selectRelatedOrgModal" ng-hide="mode == 'readonly'"/>
<input type="text" placeholder="related organization..." disabled="disabled"
class="form-control form-control-sm" ng-model="newRelation.name" ng-show="mode == 'readonly'"/>
</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 colspan="4" class="text-right">
<button type="button" class="btn btn-sm btn-outline-success"
ng-click="setRelationType('IsChildOf')"
data-toggle="modal"
data-target="#selectRelatedOrgModal"
ng-hide="mode == 'readonly'">
<i class="fa fa-plus"></i> add parents
</button>
<button type="button" class="btn btn-sm btn-outline-success"
ng-click="setRelationType('IsParentOf')"
data-toggle="modal"
data-target="#selectRelatedOrgModal"
ng-hide="mode == 'readonly'">
<i class="fa fa-plus"></i> add children
</button>
</td>
</tr>
</tfoot>
@ -340,5 +337,5 @@
</div>
</div>
<select-org-modal modal-id="selectRelatedOrgModal" selected-org="newRelation" filter-status="approved" on-select="addRelation()" multiple="true"></select-org-modal>
<select-org-modal modal-id="selectRelatedOrgModal" selected-org="newRelation" filter-status="approved"></select-org-modal>

View File

@ -172,21 +172,27 @@ orgsModule.directive('orgFormMetadata', function($http, $location, $route, $rout
},
templateUrl: 'resources/html/parts/org_metadata.form.html',
link: function(scope, element, attrs, ctrl) {
scope.newRelation = {};
scope.newRelType = '';
scope.resetSelectedRelation = function() {
scope.newRelation = {};
}
scope.newRelation = {};
scope.addNewRelation = function() {
scope.addRelation = function() {
for (var i = 0; i < scope.org.relations.length; i++) {
if (scope.org.relations[i].relatedOrgId == scope.newRelation.id) {
alert("The selected organization has been already added !!!");
return;
}
}
scope.org.relations.push({
'relatedOrgId' : scope.newRelation.id,
'relatedOrgName' : scope.newRelation.name,
'type' : scope.newRelType
});
scope.newRelation = {};
scope.newRelType = '';
}
scope.setRelationType = function(relType) {
scope.newRelType = relType;
}
scope.save = function() {