Skip to content

Commit

Permalink
fix selected column from CSV not taken into account by import urls
Browse files Browse the repository at this point in the history
  • Loading branch information
boogheta committed Dec 9, 2022
1 parent 50d97e8 commit 85decf2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
16 changes: 8 additions & 8 deletions hyphe_frontend/app/views/definewebentities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hyphe_frontend/app/views/importurls.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h1>

<md-input-container>
<label>Column containing the URLs</label>
<md-select ng-model="selectedColumn" ng-click="settingsTouched = true">
<md-select ng-model="$parent.selectedColumn" ng-click="$parent.settingsTouched = true">
<md-option ng-repeat="col in columns" ng-value="col">{{col.name}}</md-option>
</md-select>
</md-input-container>
Expand Down
6 changes: 5 additions & 1 deletion hyphe_frontend/app/views/importurls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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)
}
})

Expand Down

0 comments on commit 85decf2

Please sign in to comment.