Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

now checking if we have defined a mapper or not #965

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions app/assets/javascripts/controllers/wizardModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,25 @@ angular.module('QuepidApp')
/*jshint evil:false */

/* jshint undef: false */
settingsForValidation.docsMapper = docsMapper;
settingsForValidation.numberOfResultsMapper = numberOfResultsMapper;
if (typeof numberOfResultsMapper === 'undefined') {
$scope.mapperInvalid = true;
$scope.mapperErrorMessage = 'You need to define a "numberOfResultsMapper"';
}
else {
settingsForValidation.numberOfResultsMapper = numberOfResultsMapper;
}

if (typeof docsMapper === 'undefined') {
$scope.mapperInvalid = true;
$scope.mapperErrorMessage = 'You need to define a "docsMapper"';
}
else {
settingsForValidation.docsMapper = docsMapper;
}
/* jshint undef: true */

// This is an example of what the above mapper code looks like.
// This is an example of what the above mapper code might look like.

//eval(kode);
// settingsForValidation.docsMapper = function(data){
// let docs = [];
Expand All @@ -330,11 +344,15 @@ angular.module('QuepidApp')
validator.validateUrl()
.then(function () {
$scope.validatorLastResponse = JSON.stringify(validator.searcher.lastResponse,null,2);
setupDefaults(validator);
$scope.urlValid = true;

if (!justValidate) {
$scope.pendingWizardSettings.searchUrl = settingsForValidation.searchUrl;
WizardHandler.wizard().next();
if ( !$scope.mapperInvalid ){
setupDefaults(validator);

if (!justValidate) {
$scope.pendingWizardSettings.searchUrl = settingsForValidation.searchUrl;
WizardHandler.wizard().next();
}
}
}, function (error) {

Expand Down
9 changes: 7 additions & 2 deletions app/assets/templates/views/wizardModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ <h2>CSV</h2>
<div class="col-sm-12 clearfix">
<label class="control-label">Mapping To Quepid Format</label>
<p class="help-block">Enter JavaScript that maps from YOUR API to the JSON structure expected by Quepid.
The JSON from your API is nested under the <code>data</code> object.
The JSON response is nested under the <code>data</code> object.
</p>
</div>
<div class="btn-group btn-group-justified" role="group">
Expand All @@ -312,9 +312,14 @@ <h2>CSV</h2>
<button type="button" class="btn" ng-click="showSearchApiJavaScriptEditor=false" ng-class="showSearchApiJavaScriptEditor ? 'btn-default' : 'btn-primary'">Search API Response</button>
</div>
</div>

<p/>
<div class="form-group clearfix" ng-show="showSearchApiJavaScriptEditor">
<div class="col-sm-12">
<div ng-show="pendingWizardSettings.mapperCode.trim().length == 0" class="alert alert-warning">
<span>
You need to specify your mapper code here.
</span>
</div>
<div ui-ace="{
require: ['ace/ext/language_tools'],
advanced: {
Expand Down