Upon redirection when clicking the new sample type or group link, you're automatically in adding mode. [Fixes SCI-701]

This commit is contained in:
Matej Zrimšek 2016-12-09 17:22:09 +01:00
parent 0b12c87b09
commit 54de13de82
3 changed files with 18 additions and 4 deletions

View file

@ -759,7 +759,7 @@ function createSampleTypeSelect(data, selected) {
.attr('value', val.id).text(val.name); .attr('value', val.id).text(val.name);
$selectType.append($option); $selectType.append($option);
}); });
$selectType.makeDropdownOptionsLinks(selected); $selectType.makeDropdownOptionsLinks(selected, 'add-mode');
return $selectType; return $selectType;
} }
@ -791,7 +791,7 @@ function createSampleGroupSelect(data, selected) {
$selectGroup.append($option); $selectGroup.append($option);
}); });
$selectGroup.makeDropdownOptionsLinks(selected); $selectGroup.makeDropdownOptionsLinks(selected, 'add-mode');
return $selectGroup; return $selectGroup;
} }

View file

@ -4,6 +4,7 @@
function showNewSampleTypeGroupForm() { function showNewSampleTypeGroupForm() {
$('#create-resource').on('click', function() { $('#create-resource').on('click', function() {
$('.new-resource-form').slideDown(); $('.new-resource-form').slideDown();
$('#name-input').focus();
}); });
} }
@ -211,6 +212,16 @@
}); });
} }
/**
* Opens adding mode when redirected from samples page, when clicking link for
* adding sample type or group link
*/
function sampleTypeGroupEditMode() {
if (getParam('add-mode')) {
$('#create-resource').click();
}
}
function initSampleTypesGroups() { function initSampleTypesGroups() {
showNewSampleTypeGroupForm(); showNewSampleTypeGroupForm();
newSampleTypeFormCancel(); newSampleTypeFormCancel();
@ -223,6 +234,7 @@
initSampleGroupColor(); initSampleGroupColor();
bindNewSampleGroupAction(); bindNewSampleGroupAction();
appendCarretToColorPickerDropdown(); appendCarretToColorPickerDropdown();
sampleTypeGroupEditMode();
} }
// initialize sample types/groups actions // initialize sample types/groups actions

View file

@ -221,13 +221,15 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath,
* attribute yourself, and the dropdown elments which don't have them, will get * attribute yourself, and the dropdown elments which don't have them, will get
* '#' by default. * '#' by default.
* @param {number} selectedIdx Index of element to be selected * @param {number} selectedIdx Index of element to be selected
* @param {string} urlParam URL parameter to pass to the link URLs
* @return {Object} This * @return {Object} This
*/ */
$.fn.makeDropdownOptionsLinks = function(selectedIdx) { $.fn.makeDropdownOptionsLinks = function(selectedIdx, urlParam) {
selectedIdx = _.isUndefined(selectedIdx) ? 1 : selectedIdx; selectedIdx = _.isUndefined(selectedIdx) ? 1 : selectedIdx;
$(this).change(function() { $(this).change(function() {
location = $(this).find('option:selected').attr('href'); window.location.href = addParam($(this).find('option:selected')
.attr('href'), urlParam);
}); });
$(this).find('option') $(this).find('option')