Skip to content

Commit

Permalink
Remove "Resource ID exists?" question and code
Browse files Browse the repository at this point in the history
- Insert vs Update will be determined by whether SNAC ID exists on a record-by-record basis rather than a project or upload basis.
  • Loading branch information
glassjoseph committed Aug 10, 2021
1 parent 9434d90 commit 1a4cfe2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 93 deletions.
83 changes: 1 addition & 82 deletions src/resources/module/scripts/dialogs/schema-alignment-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,6 @@ SNACSchemaAlignmentDialog.setUpTabs = function() {
// init the radio buttons

var uploadingResourceButtonClicked = function() {
// Show SNAC ID Buttons
$('#idRadio').show();

if ($('#idYesButton').is(':checked')) {
idYesButtonClicked();
} else if ($('#idNoButton').is(':checked')) {
idNoButtonClicked();
}

// Show Resources
$('.schema-alignment-dialog-columns-area-resource').show();
Expand All @@ -251,11 +243,6 @@ SNACSchemaAlignmentDialog.setUpTabs = function() {
};

var uploadingConstellationButtonClicked = function() {
// Hide SNAC ID Buttons
$('#idRadio').hide();
$('#idSelectionDiv').css('visibility', 'hidden');
$('.idfield').prop('disabled', false);

// Hide Resources
$('.schema-alignment-dialog-columns-area-resource').hide();
$('.schema-alignment-dialog-columns-area-resource--ref').hide();
Expand All @@ -265,15 +252,6 @@ SNACSchemaAlignmentDialog.setUpTabs = function() {
$('.schema-alignment-dialog-columns-area-constellation--ref').show();
};

var idYesButtonClicked = function() {
$('.idfield').prop('disabled', false);
$('#idSelectionDiv').css('visibility', 'visible');
};

var idNoButtonClicked = function() {
$('.idfield').prop('disabled', true);
$('#idSelectionDiv').css('visibility', 'hidden');
};

$('#uploadingResourceButton').on('click', function() {
uploadingResourceButtonClicked();
Expand All @@ -287,18 +265,6 @@ SNACSchemaAlignmentDialog.setUpTabs = function() {
self._hasChanged();
});

$('#idYesButton').on('click', function() {
idYesButtonClicked();
snacDebug(`idYes calling _hasChanged()`);
self._hasChanged();
});

$('#idNoButton').on('click', function() {
idNoButtonClicked();
snacDebug(`idNo calling _hasChanged()`);
self._hasChanged();
});

// Init the column area
this.updateColumns(theProject.overlayModels.snacSchema);

Expand Down Expand Up @@ -405,12 +371,6 @@ SNACSchemaAlignmentDialog.addResourceTable = function (schema) {
.addClass(column.name + "ResDropDown")
.attr('style', 'width: 180px');

/*
if (column.name == 'id') {
selectList.addClass('idfield');
}
*/

//Create and append the options
var defaultoption = document.createElement('option');
defaultoption.setAttribute('value', 'default');
Expand Down Expand Up @@ -506,12 +466,6 @@ SNACSchemaAlignmentDialog.addConstellationTable = function (schema) {
.addClass(column.name + "ConstDropDown")
.attr('style', 'width: 180px');

/*
if (column.name == 'id') {
selectList.addClass('idfield');
}
*/

//Create and append the options
var defaultoption = document.createElement('option');
defaultoption.setAttribute('value', 'default');
Expand Down Expand Up @@ -635,29 +589,6 @@ SNACSchemaAlignmentDialog.updateColumns = function(schema) {
var myTableDivResource = this.addResourceTable(schema);
this._columnAreaResource.append(myTableDivResource);

this._idDropdownDiv = $('#idSelectionDiv');

var idDropdown = document.getElementById('idDropDown');
if (idDropdown == null) {
idDropdown = document.createElement('select');
idDropdown.setAttribute('id', 'idDropDown');
var defaultOp = new Option();
defaultOp.value = 'idDefault';
defaultOp.text = 'Select ID Column';
idDropdown.options.add(defaultOp);
columns.forEach(function (arrItem){
var op = new Option();
op.value = arrItem.originalName;
op.text = arrItem.originalName;
idDropdown.options.add(op);
});
this._idDropdownDiv.append(idDropdown);
this._idDropdownDiv.on('change', function(){
snacDebug(`idDropdown calling _hasChanged()`);
self._hasChanged();
});
}

for (var i = 0; i < dragItemsResource.length; i++) {
var cell = this._createDraggableColumn(dragItemsResource[i], false);
cell.attr('id', 'dragResource');
Expand Down Expand Up @@ -839,13 +770,7 @@ SNACSchemaAlignmentDialog._reset = function(schema) {
$('#uploadingConstellationButton').trigger('click');
} else {
$('#uploadingResourceButton').trigger('click');
if (this._schema.idColumn == "") {
$('#idNoButton').trigger('click');
$('#idDropDown').val('idDefault').change();
} else {
$('#idYesButton').trigger('click');
$('#idDropDown').val(this._schema.idColumn).change();
}

}

this._ignoreChanges = false;
Expand Down Expand Up @@ -934,12 +859,6 @@ SNACSchemaAlignmentDialog.getJSON = function() {
schemaType = "resource";
dropDownColumn = $('.selectColumnRes');

if ($('#idYesButton').is(':checked')) {
let value = $('#idDropDown').val();
if (value != "idDefault") {
idColumn = value;
}
}
} else if ($('#uploadingConstellationButton').is(':checked')) {
schemaType = "constellation";
dropDownColumn = $('.selectColumnConst');
Expand Down
11 changes: 0 additions & 11 deletions src/resources/module/scripts/schema-alignment-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
<input type="radio" name="uploadingGroup" value="resource" id="uploadingResourceButton" checked="checked"> Resource<br>
<input type="radio" name="uploadingGroup" value="constellation" id="uploadingConstellationButton"> Constellation<br>
</div>

<div id="idRadio" style="padding-left: 20px;">
<p>Does the SNAC ID column already exist in the CSV?: </p>
<input type="radio" name="idGroup" value="Yes" id="idYesButton"> Yes<br>
<input type="radio" name="idGroup" value="No" id="idNoButton" checked="checked"> No<br>
</div>

<div id="idSelectionDiv" style = "padding-left: 20px; visibility: hidden;">
<p>Which CSV column is associated to the SNAC ID: </p>
<!-- dropdown of column names-->
</div>
</div>

<div class="snac-columns-container">
Expand Down

0 comments on commit 1a4cfe2

Please sign in to comment.