From 0328bb81e4dc77707768ffb8c389308edf2ab6f8 Mon Sep 17 00:00:00 2001
From: Frederic Bonifas <fredericbonifas@gmail.com>
Date: Tue, 21 Jul 2015 17:46:05 +0200
Subject: [PATCH] =?UTF-8?q?#91:=20champs=20=C3=A9ditables=20et=20checkboxe?=
 =?UTF-8?q?s?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/scripts/app.js                   |  3 ++-
 app/scripts/controllers/commonmap.js | 17 +++++++++++++----
 app/views/commonmap.html             |  2 +-
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/app/scripts/app.js b/app/scripts/app.js
index b03d9e9a..38773984 100644
--- a/app/scripts/app.js
+++ b/app/scripts/app.js
@@ -20,7 +20,8 @@ angular
     'ui.select',
     'ui.bootstrap-slider',
     'ui.keypress',
-    'ui.grid'
+    'ui.grid',
+    'ui.grid.edit'
   ])
   .config(function($routeProvider) {
     $routeProvider
diff --git a/app/scripts/controllers/commonmap.js b/app/scripts/controllers/commonmap.js
index 80f862ff..ebbb1bca 100644
--- a/app/scripts/controllers/commonmap.js
+++ b/app/scripts/controllers/commonmap.js
@@ -79,19 +79,28 @@ angular.module('accessimapEditeurDerApp')
         'f0': 'Aucune interaction',
         'f1': 'Valeur OSM'
       }, {
-        'id': 'expandable',
+        'id': 'Guidage',
         'f0': false,
-        'f1': false
+        'f1': true,
+        'type': 'boolean'
       }, {
         'id': 'title',
         'f0': 'Titre par défaut',
       }];
 
+      var checkboxTemplate = '<input ng-if="row.entity.type === \'boolean\'" type="checkbox" value="{{row.entity[col.field]}}" ng-model="row.entity[col.field]"><div ng-if="row.entity.type !== \'boolean\'">{{row.entity[col.field]}}</div>';
+
       $scope.interactiveFilters = {
-        data: $scope.interactiveFiltersInit
+        data: $scope.interactiveFiltersInit,
+        showSelectionCheckbox: true,
+        enableSorting: false,
+        columnDefs: [
+          { name: 'id', enableCellEdit: false },
+          { name: 'f0', cellTemplate: checkboxTemplate },
+          { name: 'f1', cellTemplate: checkboxTemplate }
+        ],
       };
 
-
       d3.select('svg').append('defs')
           .append('marker')
           .attr('id', 'midmarker')
diff --git a/app/views/commonmap.html b/app/views/commonmap.html
index f4a065aa..dc945988 100644
--- a/app/views/commonmap.html
+++ b/app/views/commonmap.html
@@ -102,6 +102,6 @@
     <i class="fa fa-times"></i>
   </span>
     Ajouter des interactions
-    <div ui-grid="interactiveFilters" class="myGrid"></div>
+    <div ui-grid="interactiveFilters" ui-grid-edit class="myGrid"></div>
 </div>