Commit 759f5c12 authored by c24b's avatar c24b

ANNOTATIONS names: changement des values et name du model de ActiveList

parent 6827c1f7
...@@ -6,15 +6,28 @@ ...@@ -6,15 +6,28 @@
annotationsAppActiveLists.controller('ActiveListsController', annotationsAppActiveLists.controller('ActiveListsController',
['$scope', '$rootScope', '$timeout', ['$scope', '$rootScope', '$timeout',
function ($scope, $rootScope, $timeout) { function ($scope, $rootScope, $timeout) {
//Lists change
$scope.activeListsChange = function() { $scope.activeListsChange = function() {
var selected = $('.selectpicker option:selected').val(); var selected = $('.selectpicker option:selected').val();
var newActive = {}; var newActive = {};
$('.selectpicker option:selected').each(function(item, opt) { $('.selectpicker option:selected').each(function(item, opt) {
console.log(opt)
// ex opt: // ex opt:
// <option id="list---748" value="MAINLIST">MAINLIST</option> // <option id="list---748" value="MAINLIST">MAINLIST</option>
var id = opt.id.split("---", 2)[1]; var id = opt.id.split("---", 2)[1];
newActive[id] = opt.value; if(opt.value == 'map list'){
var name = "map list"
var value = "MAPLIST"
}
else if (opt.value == "stop list"){
var name = "stop list"
var value = "STOPLIST"
}
else {
var name = "candidate list"
var value = "MAINLIST"
}
newActive[id] = {"value":value, "name":name};
}); });
// ex: {745: "MAINLIST", 748: "MAPLIST"} // ex: {745: "MAINLIST", 748: "MAPLIST"}
...@@ -32,19 +45,32 @@ ...@@ -32,19 +45,32 @@
// FIXME: est-ce qu'on ne pourrait pas directement utiliser lists // FIXME: est-ce qu'on ne pourrait pas directement utiliser lists
// au lieu de recopier dans allListsSelect ? // au lieu de recopier dans allListsSelect ?
$rootScope.$watchCollection('lists', function (newValue, oldValue) { $rootScope.$watchCollection('lists', function (newValue, oldValue) {
console.log(">>>CHANGE", newValue, oldValue)
if (newValue === undefined) return; if (newValue === undefined) return;
// reformat lists to allListsSelect // reformat lists to allListsSelect
var allListsSelect = []; var allListsSelect = [];
// console.log($rootScope.lists) // console.log($rootScope.lists)
angular.forEach($rootScope.lists, function(value, key) { angular.forEach($rootScope.lists, function(value, key) {
this.push({ //console.log(value, key)
if (value == "MAPLIST"){
var name = "map list"
}
else if (value == "STOPLIST"){
var name = "stop list"
}
else{
var name = "candidate list"
}
allListsSelect.push({
'id': key, 'id': key,
'label': value 'label': value,
'name': name,
}); });
// initialize activeLists with the MAPLIST by default // initialize activeLists with the MAPLIST by default
if (value == 'MAPLIST') { if (value == 'MAPLIST') {
$rootScope.activeLists = {}; $rootScope.activeLists = {};
$rootScope.activeLists[key] = value; $rootScope.activeLists[key] = {"value":value, "name":"map terms"};
} }
}, allListsSelect); }, allListsSelect);
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
<div ng-if="workflow_finished" class="col-md-4 col-xs-4 tabbable words-panel"> <div ng-if="workflow_finished" class="col-md-4 col-xs-4 tabbable words-panel">
<div class="list-selector"> <div class="list-selector">
<h5>Select highlighted list(s) <h5>Select highlighted list(s)
<select class="selectpicker" multiple ng-change="activeListsChange()" ng-model="lists" ng-controller="ActiveListsController"> <select class="selectpicker" multiple ng-change="activeListsChange()" ng-model="lists" ng-controller="ActiveListsController" >
<option ng-repeat="item in allListsSelect" id="list---{[{item.id}]}" ng-disabled="{[{ item.label == 'MAPLIST' }]}" >{[{item.label}]}</option> <option ng-repeat="item in allListsSelect" id="list---{[{item.id}]}">{[{item.name}]}</option>
<!-- to disallow unchecking MapList add this into <option> element: ng-disabled="{[{ item.label == 'MAPLIST' }]}" --> <!-- to disallow unchecking MapList add this into <option> element: ng-disabled="{[{ item.label == 'MAPLIST' }]}" -->
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
</h5> </h5>
<div class="row spacer"></div> <div class="row spacer"></div>
<ul class="nav nav-pills nav-justified activelists"> <ul class="nav nav-pills nav-justified activelists">
<li ng-repeat="(listId, listName) in activeLists" ng-class="{active: $first == true}"> <li ng-repeat="(listId, listV) in activeLists" >
<a href="#tab-{[{listId}]}" data-toggle="tab"> <a href="#tab-{[{listId}]}" data-toggle="tab">
<span class="{[{listName}]} inlay">{[{listName}]}</span> <span class="{[{listV.value}]} inlay">{[{listV.name}]}</span>
</a> </a>
</li> </li>
</ul> </ul>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</ul> </ul>
</nav> </nav>
<div id="addfreengram" class="form-group" ng-controller="NgramInputController"> <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> <label for="{[{listId}]}-input">Add a free term to <span class="{[{listName.value}]} inlay">{[{listName.name}]}</span>:</label>
<input autosave="search" maxlength="240" placeholder="Any text" type="text" class="form-control" id="{[{listId}]}-input" ng-keypress="onListSubmit($event, listId)"> <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> <button type="submit" class="form-control btn btn-default" ng-click="onListSubmit($event, listId)">Create &amp; add</button>
</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