Project

General

Profile

« Previous | Next » 

Revision 27715

free text editing of relations (client side)

View differences:

modules/dnet-modular-vocabularies-ui/trunk/src/main/resources/eu/dnetlib/functionality/modular/ui/views/ui/vocabularies.st
65 65
				    	</div>
66 66
				    	<div id="accordionTerm{{\$index}}" class="panel-collapse collapse">
67 67
				      		<div class="panel-body">
68
			      		
69
								<p class="text-muted" ng-hide="term.synonyms">No synonyms</p>
70
								
71
								<table class="table table-bordered" ng-show="term.synonyms">
72
									<th>Synonym</th>
73
									<th>Encoding</th>
74
									<th>Operation</th>
75
									<tr ng-repeat="synonym in term.synonyms">
76
										<td class="col-md-8">{{synonym.term}}</td>
77
										<td class="col-md-4">{{synonym.encoding}}</td>
78
										<td class="col-md-1">
79
											<button type="button" class="btn btn-xs btn-primary" ng-click="showSynonymModal(term, synonym)">
80
												<span class="glyphicon glyphicon-pencil"></span>
81
											</button>
82
											<button type="button" class="btn btn-xs btn-danger" ng-click="deleteSynonym(term, synonym)">
83
												<span class="glyphicon glyphicon-trash"></span>
84
											</button>
85
										</td>
86
									</tr>
87
								</table>
88
								<button class="btn btn-xs btn-primary" type="button" ng-click="showSynonymModal(term, null)">
89
									<span class="glyphicon glyphicon-plus"></span>
90
								</button>
68
				      			<ul class="nav nav-tabs">
69
  									<li class="active"><a href="#accordionTerm{{\$index}}_synonyms" data-toggle="tab">Synonyms</a></li>
70
  									<li><a href="#accordionTerm{{\$index}}_rels" data-toggle="tab">Relations</a></li>
71
  								</ul>
72
				      		
73
			      				<div class="tab-content" style="margin-top:10px;">
74
  									<div class="tab-pane active" id="accordionTerm{{\$index}}_synonyms">
75
										<p class="text-muted" ng-hide="term.synonyms">No synonyms</p>
76
										
77
										<table class="table table-bordered table-striped" ng-show="term.synonyms">
78
											<th>Synonym</th>
79
											<th>Encoding</th>
80
											<th>Operation</th>
81
											<tr ng-repeat="synonym in term.synonyms">
82
												<td class="col-md-8">{{synonym.term}}</td>
83
												<td class="col-md-4">{{synonym.encoding}}</td>
84
												<td class="col-md-1">
85
													<button type="button" class="btn btn-xs btn-primary" ng-click="showSynonymModal(term, synonym)">
86
														<span class="glyphicon glyphicon-pencil"></span>
87
													</button>
88
													<button type="button" class="btn btn-xs btn-danger" ng-click="deleteSynonym(term, synonym)">
89
														<span class="glyphicon glyphicon-trash"></span>
90
													</button>
91
												</td>
92
											</tr>
93
										</table>
94
										<button class="btn btn-xs btn-primary" type="button" ng-click="showSynonymModal(term, null)">
95
											<span class="glyphicon glyphicon-plus"></span>
96
										</button>
97
									</div>
98
									<div class="tab-pane" id="accordionTerm{{\$index}}_rels">
99
										<p class="text-muted" ng-hide="term.relations">No relations</p>
100
										<table class="table table-bordered table-striped" ng-show="term.relations">
101
											<th>Related Term</th>
102
											<th>Relation Type</th>
103
											<th>Operation</th>
104
											<tr ng-repeat="rel in term.relations">
105
												<td class="col-md-8">{{rel.value}}</td>
106
												<td class="col-md-4">{{rel.type}}</td>
107
												<td class="col-md-1">
108
													<button type="button" class="btn btn-xs btn-primary" ng-click="showRelModal(term, rel)">
109
														<span class="glyphicon glyphicon-pencil"></span>
110
													</button>
111
													<button type="button" class="btn btn-xs btn-danger" ng-click="deleteRel(term, rel)">
112
														<span class="glyphicon glyphicon-trash"></span>
113
													</button>
114
												</td>
115
											</tr>
116
										</table>
117
										<button class="btn btn-xs btn-primary" type="button" ng-click="showRelModal(term, null)">
118
											<span class="glyphicon glyphicon-plus"></span>
119
										</button>
120
									
121
									</div>
122
								</div>
91 123
				      		</div>
92 124
				    	</div>
93 125
				  	</div>
......
217 249
				</div>
218 250
			</div>
219 251
		</div>
252

  
253
		<!-- relModal -->
254
		<div class="modal fade" id="relModal" tabindex="-1" role="dialog" aria-labelledby="relModalLabel" aria-hidden="true">
255
			<div class="modal-dialog">
256
				<div class="modal-content">
257
					<div class="modal-header">
258
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
259
						<h4 id="relModalLabel">Relation editor</h4>
260
					</div>
261
					<div class="modal-body">
262
						<form name="relForm" class="form-horizontal" role="form">
263
							<div class="form-group">
264
								<label class="col-sm-4 control-label" for="refterm">Ref. Term</label>
265
							    <div class="col-sm-8">
266
									<span id="refterm" class="form-control" type="text" disabled>{{modalRel.refTerm}}</span>
267
							    </div>
268
							</div>
269
							<div class="form-group" ng-class="{'has-error': !modalRel.value}">
270
								<label class="col-sm-4 control-label" for="term">Related term</label>
271
								<div class="col-sm-8">
272
									<input class="form-control" name="value" type="text" placeholder="new relation" ng-model="modalRel.value">
273
								</div>
274
							</div>
275
							<div class="form-group" ng-class="{'has-error': !modalRel.type}">
276
								<label class="col-sm-4 control-label" for="encoding">Relation type</label>
277
								<div class="col-sm-8">
278
									<input class="form-control" name="type" type="text" placeholder="type" ng-model="modalRel.type">
279
								</div>
280
							</div>
281
						</form>				
282
					</div>
283
					<div class="modal-footer">
284
						<button type="button" class="btn btn-primary" ng-disabled="!(modalRel.type && modalRel.value) " ng-click="editRel()">Save</button>
285
					</div>
286
				</div>
287
			</div>
288
		</div>
289

  
290

  
220 291
		
221 292
	</div>
222 293
} )$
modules/dnet-modular-vocabularies-ui/trunk/src/main/resources/eu/dnetlib/web/resources/js/vocabularies.js
100 100
module.controller('vocabulariesCtrl', function ($scope, $http) {
101 101
	$scope.entries = [];
102 102
	$scope.modalSynonym = {};
103
	$scope.modalRel = {};
103 104
	$scope.modalTerm = {};
104 105
	$scope.modalInfo = {};
105 106
	
......
170 171
		$scope.entries[termIndex].synonyms.splice(synonymIndex, 1);
171 172
		showPermanotice("Uncommitted changes!");
172 173
	}
174
	
175
	$scope.deleteRel = function(term, rel) {
176
		var termIndex = $scope.entries.indexOf(term);
177
		var relIndex = $scope.entries[termIndex].relations.indexOf(rel);
178
		$scope.entries[termIndex].relations.splice(relIndex, 1);
179
		showPermanotice("Uncommitted changes!");
180
	}
173 181

  
174 182
	$scope.dropVocabulary = function() {
175 183
		showSpinner();
......
240 248
			$scope.modalSynonym.encoding = '';
241 249
		}
242 250
		$('#synonymModal').modal();
251
	}	
252
	
253
	$scope.showRelModal = function(term, rel) {
254
		$scope.selectedTermIndex = $scope.entries.indexOf(term);
255
		$scope.selectedRelIndex = $scope.entries[$scope.selectedTermIndex].relations.indexOf(rel);
256
		if (rel != null) {
257
			// edit existing synonym
258
			$scope.modalRel.refTerm = $scope.entries[$scope.selectedTermIndex].englishName;
259
			$scope.modalRel.value = $scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].value;
260
			$scope.modalRel.type = $scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].type;
261
		} else {
262
			// new synonym
263
			$scope.modalRel.refTerm = $scope.entries[$scope.selectedTermIndex].englishName;
264
			$scope.modalRel.value = '';
265
			$scope.modalRel.type = '';
266
		}
267
		$('#relModal').modal();
243 268
	}
244 269

  
245 270
	$scope.editInfo = function() {
......
323 348
				"encoding" : $scope.modalSynonym.encoding
324 349
			});
325 350
		} else {
326
			$scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].term = $scope.modalSynonym.term
351
			$scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].term = $scope.modalSynonym.term;
327 352
			$scope.entries[$scope.selectedTermIndex].synonyms[$scope.selectedSynonymIndex].encoding = $scope.modalSynonym.encoding;
328 353
		}
329 354
		// dismiss modal
330 355
		$('.modal').modal('hide');
331 356
		showPermanotice("Uncommitted changes!");
332 357
	}
358
	
359
	$scope.editRel = function() {
360
		if ($scope.selectedRelIndex == -1) {
361
			$scope.entries[$scope.selectedTermIndex].relations.push({
362
				"value" : $scope.modalRel.value,
363
				"type" : $scope.modalRel.type
364
			});
365
		} else {
366
			$scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].value = $scope.modalRel.value;
367
			$scope.entries[$scope.selectedTermIndex].relations[$scope.selectedRelIndex].type = $scope.modalRel.type;
368
		}
369
		// dismiss modal
370
		$('.modal').modal('hide');
371
		showPermanotice("Uncommitted changes!");
372
	}
333 373

  
334 374
	/*---------COMMIT---------*/
335 375
	$scope.commit = function() {

Also available in: Unified diff