Commit dee8e918 authored by Romain Loth's avatar Romain Loth

reconnect the side panel input text 'add ngram' in annotations view

parent a4977857
......@@ -5,13 +5,6 @@
* To display another list name, add a new class under this
*/
.MapList {
color: black;
/* green */
background-color: rgba(60, 118, 61, .7);
cursor: pointer;
}
.MAPLIST {
color: black;
/* green */
......@@ -22,8 +15,9 @@
.MAINLIST {
color: black;
/* background-color: rgba(60, 118, 61, 0.5); */
/* orange */
background-color: orange;
/* background-color: rgba(60, 118, 61, 0.5); */
cursor: pointer;
}
......@@ -42,6 +36,47 @@
cursor: pointer;
}
.inlay {
border-radius: .8em;
padding: 0 .5em;
margin: 0 .2em;
}
.words-panel > .tab-content {
font-size: 80%;
border-left: 1px solid #aaa;
border-right: 1px solid #aaa;
border-bottom: 1px solid #aaa;
padding: 1em ;
margin-right: 1px;
min-height: 22em ; /* needs to be bigger than .words-list */
}
#addfreengram {
padding: 3em .5em .2em .5em ;
}
.nav-pills.activelists >li>a {
padding:10px 1px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-top: 1px solid #ddd;
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
border-bottom: 1px solid #aaa;
}
.nav-pills.activelists > li.active > a,
.nav-pills.activelists > li.active > a:focus,
.nav-pills.activelists > li.active > a:hover {
background-color: #337ab7;
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-right: 1px solid #aaa;
border-bottom: none ;
}
.delete-keyword, .occurrences {
vertical-align: super;
......@@ -89,6 +124,7 @@
.words-list {
margin-bottom: 5px;
min-height: 17em ;
}
.keyword-text {
......
......@@ -103,8 +103,8 @@
/*
* Add a new NGram from the user input in the extra-text list
*/
$scope.onListSubmit = function ($event, listId) {
var inputEltId = "#"+ listId +"-input";
$scope.onListSubmit = function ($event, tgtListId) {
var inputEltId = "#"+ tgtListId +"-input";
if ($event.keyCode !== undefined && $event.keyCode != 13) return;
var value = angular.element(inputEltId).val().trim();
......@@ -118,11 +118,11 @@
// TODO £NEW : lookup obj[list_id][term_text] = {terminfo}
// // $rootScope.lookup =
console.log('looking for "' + value + '" in list:' + listId)
console.log('looking for "' + value + '" in list:' + tgtListId)
var already_in_list = false ;
angular.forEach($rootScope.annotations, function(annot,i) {
// console.log(i + ' => ' + annot.text + ',' + annot.list_id) ;
if (value == annot.text && listId == annot.list_id) {
if (value == annot.text && tgtListId == annot.list_id) {
console.log('the term "' + value + '" was already present in list')
// no creation
already_in_list = true ;
......@@ -132,74 +132,46 @@
if (already_in_list) { return ; }
// ---------------------------------------------------------------
var tgtListName = $rootScope.lists[tgtListId]
// alert("ADDING TO listId: " + tgtListId +"\n listName: "+ tgtListName)
var crudCallsToMake = []
switch (tgtListName) {
case "STOPLIST":
crudCallsToMake = [
{'service': MainApiAddNgramHttpService, 'action': 'put',
'params' : {'ngramStr':value, corpusId: $rootScope.corpusId},
'dataPropertiesToCache': ['id'] },
{'service': MainApiChangeNgramHttpService, 'action': 'put',
'params' : {'listId':tgtListId, 'ngramIdList': {'fromCache': 'id'} } }
];
break;
case "MAINLIST":
crudCallsToMake = [
{'service': MainApiAddNgramHttpService, 'action': 'put',
'params' : {'ngramStr':value, corpusId: $rootScope.corpusId},
'dataPropertiesToCache': ['id'] },
{'service': MainApiChangeNgramHttpService, 'action': 'put',
'params' : {'listId':tgtListId, 'ngramIdList': {'fromCache': 'id'} } }
];
break;
case "MAPLIST":
crudCallsToMake = [
{'service': MainApiAddNgramHttpService, 'action': 'put',
'params' : {'ngramStr':value, corpusId: $rootScope.corpusId},
'dataPropertiesToCache': ['id'] },
{'service': MainApiChangeNgramHttpService, 'action': 'put',
'params' : {'listId':$rootScope.listIds.MAINLIST, 'ngramIdList': {'fromCache': 'id'} } },
{'service': MainApiChangeNgramHttpService, 'action': 'put',
'params' : {'listId':tgtListId, 'ngramIdList': {'fromCache': 'id'} } }
];
break;
}
// run the ajax calls in a recursive loop by calling the step n° 0
$rootScope.makeChainedCalls(0, crudCallsToMake, $rootScope.refresh)
var listName = $rootScope.lists[listId]
alert("listId: " + listId +"\n listName: "+ listName)
console.log("dir $rootScope :")
console.dir($rootScope)
// run the loop by calling the initial recursion step
// $rootScope.makeChainedCalls(0, crudCalls, lastCallback)
// AddNgram
// --------
// creation will return an ngramId
// (checks if there's a preexisting ngramId for this value
// otherwise creates a new one and indexes the ngram in corpus)
// MainApiAddNgramHttpService.put(
// {
// // text <=> str to create the new ngram
// 'text': value,
// 'corpusId': $rootScope.corpusId
// },
// // on AddNgram success
// function(data) {
// var newNgramId = data.id
// console.log("OK created new ngram for '"+value+"' with id: "+newNgramId)
//
// // ChangeNgram
// // -----------
// // add to listId after creation
// // TODO: if maplist => also add to miam
// MainApiChangeNgramHttpService["put"](
// {
// 'listId': listId,
// 'ngramIdList': newNgramId
// },
// // on ChangeNgram success
// function(data) {
// // Refresh the annotations (was broken: TODO FIX)
// console.warn("refresh attempt");
// angular.element(inputEltId).val(""); // what for ???
// NgramListHttpService.get(
// {
// 'corpusId': $rootScope.corpusId,
// 'docId': $rootScope.docId
// },
// // on refresh success
// function(data) {
// $rootScope.annotations = data[$rootScope.corpusId.toString()][$rootScope.docId.toString()];
// $rootScope.refreshDisplay();
// },
// // on refresh error
// function(data) {
// console.error("unable to get the list of ngrams");
// }
// );
// },
// // on ChangeNgram error
// function(data) {
// console.error("unable to edit the Ngram"+ngramId+") on list "+listId+")");
// }
// );
// },
// // on AddNgram error
// function(data) {
// angular.element(inputEltId).parent().addClass("has-error");
// console.error("error adding Ngram "+ value);
// }
// );
}; // onListSubmit
}]);
......
......@@ -36,9 +36,11 @@
</select>
</h5>
<div class="row spacer"></div>
<ul class="nav nav-pills nav-justified">
<ul class="nav nav-pills nav-justified activelists">
<li ng-repeat="(listId, listName) in activeLists" ng-class="{active: $first == true}">
<a href="#tab-{[{listId}]}" data-toggle="tab">{[{listName}]}</a>
<a href="#tab-{[{listId}]}" data-toggle="tab">
<span class="{[{listName}]} inlay">{[{listName}]}</span>
</a>
</li>
</ul>
</div>
......@@ -60,12 +62,11 @@
<li ng-class="{'disabled': currentListPage >= totalListPages(listId) - 1}"><a ng-click="nextListPage()" class="glyphicon glyphicon-forward"></a></li>
</ul>
</nav>
<!--
<div class="form-group" ng-controller="NgramInputController">
<input autosave="search" maxlength="240" placeholder="Add any text" type="text" class="form-control" id="{[{listId}]}-input" ng-keypress="onListSubmit($event, listId)">
<button type="submit" class="form-control btn btn-default btn-primary" ng-click="onListSubmit($event, listId)">Add to {[{listName}]}</button>
<div id="addfreengram" class="form-group" ng-controller="NgramInputController">
<label for="{[{listId}]}-input">Add a free term to <span class="{[{listName}]} inlay">{[{listName}]}</span>:</label>
<input autosave="search" maxlength="240" placeholder="Any text" type="text" class="form-control" id="{[{listId}]}-input" ng-keypress="onListSubmit($event, listId)">
<button type="submit" class="form-control btn btn-default" ng-click="onListSubmit($event, listId)">Create &amp; add</button>
</div>
-->
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment