mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
Merge pull request #353 from ZmagoD/zd_SCI_781_796
fixes sample group/type and sample gorups colorpicker
This commit is contained in:
commit
0d6f85e8bd
4 changed files with 30 additions and 21 deletions
|
@ -749,7 +749,9 @@ function createSampleTypeSelect(data, selected) {
|
|||
var $selectType = $('<select></select>')
|
||||
.attr('name', 'sample_type_id').addClass('show-tick');
|
||||
|
||||
var $option = $("<option href='/organizations/1/sample_types'></option>")
|
||||
var sampleTypesLink = $('#samples').attr('data-sample-types-link');
|
||||
|
||||
var $option = $("<option href='" + sampleTypesLink + "'></option>")
|
||||
.attr('value', -2)
|
||||
.text(I18n.t('samples.table.add_sample_type'));
|
||||
$selectType.append($option);
|
||||
|
@ -777,7 +779,9 @@ function createSampleGroupSelect(data, selected) {
|
|||
var $selectGroup = $('<select></select>')
|
||||
.attr('name', 'sample_group_id').addClass('show-tick');
|
||||
|
||||
var $option = $("<option href='/organizations/1/sample_groups'></option>")
|
||||
var sampleGroupsLink = $('#samples').attr('data-sample-groups-link');
|
||||
|
||||
var $option = $("<option href='" + sampleGroupsLink + "'></option>")
|
||||
.text(I18n.t('samples.table.add_sample_group'));
|
||||
$selectGroup.append($option);
|
||||
$option = $('<option></option>')
|
||||
|
|
|
@ -17,14 +17,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
function newSampleTypeGroupFormSubmit() {
|
||||
$('#submit').off();
|
||||
$('#submit').on('click', function() {
|
||||
var form = $(this).closest('form');
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
|
||||
function submitEditSampleTypeGroupForm() {
|
||||
$('.edit-confirm').off();
|
||||
$('.edit-confirm').on('click', function() {
|
||||
|
@ -39,7 +31,7 @@
|
|||
var li = $(this).closest('li');
|
||||
var href = $(this).attr('data-element');
|
||||
var id = $(li).attr('data-id');
|
||||
|
||||
$().clearFormErrors();
|
||||
$.ajax({
|
||||
url: href,
|
||||
data: { id: id },
|
||||
|
@ -47,7 +39,7 @@
|
|||
$(li).replaceWith($.parseHTML(data.html));
|
||||
editSampleTypeForm();
|
||||
destroySampleTypeGroup();
|
||||
initSampleGroupColor();
|
||||
initSampleColorPicker(li)
|
||||
appendCarretToColorPickerDropdown();
|
||||
editSampleGroupColor();
|
||||
editSampleGroupForm();
|
||||
|
@ -95,6 +87,7 @@
|
|||
$(li).insertAfter('.new-resource-form');
|
||||
editSampleTypeForm();
|
||||
destroySampleTypeGroup();
|
||||
$('#new_sample_type').clearFormErrors();
|
||||
}).bind('ajax:error', function(ev, error) {
|
||||
$(this).clearFormErrors();
|
||||
var msg = $.parseJSON(error.responseText);
|
||||
|
@ -128,17 +121,18 @@
|
|||
}
|
||||
|
||||
function bindNewSampleGroupAction() {
|
||||
$('#new_sample_group').off();
|
||||
$('#new_sample_group').off();
|
||||
$('#new_sample_group').bind('ajax:success', function(ev, data) {
|
||||
var li = $.parseHTML(data.html);
|
||||
$('#name-input').val('');
|
||||
$('.new-resource-form').slideUp();
|
||||
$(li).insertAfter('.new-resource-form');
|
||||
initSampleGroupColor();
|
||||
initSampleColorPicker(li);
|
||||
appendCarretToColorPickerDropdown();
|
||||
editSampleGroupColor();
|
||||
editSampleGroupForm();
|
||||
destroySampleTypeGroup();
|
||||
$('#new_sample_group').clearFormErrors();
|
||||
}).bind('ajax:error', function(ev, error) {
|
||||
$(this).clearFormErrors();
|
||||
var msg = $.parseJSON(error.responseText);
|
||||
|
@ -195,7 +189,7 @@
|
|||
submitEditSampleTypeGroupForm();
|
||||
abortEditSampleTypeGroupAction();
|
||||
destroySampleTypeGroup();
|
||||
initSampleGroupColor();
|
||||
initSampleColorPicker(li);
|
||||
appendCarretToColorPickerDropdown();
|
||||
editSampleGroupColor();
|
||||
|
||||
|
@ -209,7 +203,7 @@
|
|||
$(this).closest('li').replaceWith($.parseHTML(data.html));
|
||||
editSampleGroupForm();
|
||||
destroySampleTypeGroup();
|
||||
initSampleGroupColor();
|
||||
initSampleColorPicker($(this).closest('li'));
|
||||
appendCarretToColorPickerDropdown();
|
||||
editSampleGroupColor();
|
||||
}).bind('ajax:error', function(ev, error){
|
||||
|
@ -233,6 +227,12 @@
|
|||
});
|
||||
}
|
||||
|
||||
function initSampleColorPicker(el) {
|
||||
var element = $(el).find('.edit-sample-group-color');
|
||||
var color = $(element).closest('[data-color]').attr('data-color');
|
||||
$(element).colorselector('setColor', color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens adding mode when redirected from samples page, when clicking link for
|
||||
* adding sample type or group link
|
||||
|
@ -246,7 +246,6 @@
|
|||
function initSampleTypesGroups() {
|
||||
showNewSampleTypeGroupForm();
|
||||
newSampleTypeFormCancel();
|
||||
newSampleTypeGroupFormSubmit();
|
||||
bindNewSampleTypeAction();
|
||||
editSampleTypeForm();
|
||||
destroySampleTypeGroup();
|
||||
|
|
|
@ -40,11 +40,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="text-right col-md-4">
|
||||
<button type="button"
|
||||
id="submit"
|
||||
<button id="submit"
|
||||
class="btn btn-primary"><%= t('general.create') %></button>
|
||||
<button type="button"
|
||||
id="remove"
|
||||
<button id="remove"
|
||||
class="btn btn-default"><%= t('general.cancel') %></button>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -129,6 +129,14 @@
|
|||
data-num-columns="<%= num_of_columns %>"
|
||||
data-new-sample="<%= new_organization_sample_path(organization_id: @organization) %>"
|
||||
data-create-sample="<%= organization_samples_path(organization_id: @organization) %>"
|
||||
data-sample-types-link="<%= organization_sample_types_path(@organization,
|
||||
project_id: (@project.id if @project),
|
||||
my_module_id: (@my_module.id if @my_module),
|
||||
experiment_id: (@experiment.id if @experiment)) %>"
|
||||
data-sample-groups-link="<%= organization_sample_groups_path(current_organization,
|
||||
project_id: (@project.id if @project),
|
||||
my_module_id: (@my_module.id if @my_module),
|
||||
experiment_id: (@experiment.id if @experiment)) %>"
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
Loading…
Reference in a new issue