From 85decf2787cb2924928a82dca89be1438778dd14 Mon Sep 17 00:00:00 2001 From: Benjamin Ooghe-Tabanou Date: Fri, 9 Dec 2022 19:58:15 +0100 Subject: [PATCH] fix selected column from CSV not taken into account by import urls --- hyphe_frontend/app/views/definewebentities.js | 16 ++++++++-------- hyphe_frontend/app/views/importurls.html | 2 +- hyphe_frontend/app/views/importurls.js | 6 +++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hyphe_frontend/app/views/definewebentities.js b/hyphe_frontend/app/views/definewebentities.js index 06ea7232..a5e70895 100644 --- a/hyphe_frontend/app/views/definewebentities.js +++ b/hyphe_frontend/app/views/definewebentities.js @@ -43,22 +43,22 @@ angular.module('hyphe.definewebentitiesController', []) } }) } else if(store.get('parsedUrls_type') == 'table') { - var settings = store.get('parsedUrls_settings') + var colId = store.get('parsedUrls_colId') ,table = store.get('parsedUrls') // Table headline - $scope.headline = table.shift().filter(function(d,i){return i != settings.urlColId}) + $scope.headline = table.shift().filter(function(d,i){return i != colId}) list = table.map(function(row, i){ var meta = {} - table[0].forEach(function(colName,j){ - if(j != settings.urlColId) + table[0].forEach(function(colName, j){ + if(j != colId) meta[colName] = row[j] }) return { - id:i - ,url:row[settings.urlColId] - ,row:row.filter(function(d,i){return i != settings.urlColId}) + id: i + ,url: row[colId] + ,row: row.filter(function(d,i){return i != colId}) ,meta:meta } }) @@ -71,7 +71,7 @@ angular.module('hyphe.definewebentitiesController', []) // Clean store store.remove('parsedUrls') store.remove('parsedUrls_type') - store.remove('parsedUrls_settings') + store.remove('parsedUrls_colId') // Build the list bootstrapUrlList(list) diff --git a/hyphe_frontend/app/views/importurls.html b/hyphe_frontend/app/views/importurls.html index 764d7009..69c123c4 100644 --- a/hyphe_frontend/app/views/importurls.html +++ b/hyphe_frontend/app/views/importurls.html @@ -91,7 +91,7 @@

- + {{col.name}} diff --git a/hyphe_frontend/app/views/importurls.js b/hyphe_frontend/app/views/importurls.js index faf6f17c..e5b2cf44 100644 --- a/hyphe_frontend/app/views/importurls.js +++ b/hyphe_frontend/app/views/importurls.js @@ -31,6 +31,10 @@ angular.module('hyphe.importurlsController', []) $scope.$watch('dataText', updatePreview) $scope.$watch('parsingOption', updatePreview) $scope.$watch('headline', updatePreview) + $scope.$watch('selectedColumn', function() { + if (!$scope.table) return; + store.set('parsedUrls_colId', $scope.table[0].indexOf($scope.selectedColumn.name)) + }) // This trick to turn around a bug about textarea initialization $timeout(function(){ @@ -154,7 +158,7 @@ angular.module('hyphe.importurlsController', []) $scope.selectedColumn = $scope.columns[selectedColumnId] // Store these settings - store.set('parsedUrls_settings', {urlColId: selectedColumnId}) + store.set('parsedUrls_colId', selectedColumnId) } })