mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Fix sample type groups edit color script so it works properly now
Closes SCI-1078.
This commit is contained in:
parent
634336e1a4
commit
3599537e42
1 changed files with 30 additions and 20 deletions
|
@ -45,7 +45,6 @@
|
||||||
destroySampleTypeGroup();
|
destroySampleTypeGroup();
|
||||||
initSampleColorPicker(newLi);
|
initSampleColorPicker(newLi);
|
||||||
appendCarretToColorPickerDropdown();
|
appendCarretToColorPickerDropdown();
|
||||||
editSampleGroupColor();
|
|
||||||
editSampleGroupForm();
|
editSampleGroupForm();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -111,17 +110,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function editSampleGroupColor() {
|
|
||||||
$('.edit_sample_group a.color-btn').off();
|
|
||||||
$('.edit_sample_group a.color-btn').on('click', function() {
|
|
||||||
var color = $(this).attr('data-value');
|
|
||||||
var form = $(this).closest('form');
|
|
||||||
$('select[name="sample_group[color]"]')
|
|
||||||
.val(color);
|
|
||||||
form.submit();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function bindNewSampleGroupAction() {
|
function bindNewSampleGroupAction() {
|
||||||
$('#new_sample_group').off();
|
$('#new_sample_group').off();
|
||||||
$('#new_sample_group').bind('ajax:success', function(ev, data) {
|
$('#new_sample_group').bind('ajax:success', function(ev, data) {
|
||||||
|
@ -131,7 +119,6 @@
|
||||||
$(li).insertAfter('.new-resource-form');
|
$(li).insertAfter('.new-resource-form');
|
||||||
initSampleColorPicker(li);
|
initSampleColorPicker(li);
|
||||||
appendCarretToColorPickerDropdown();
|
appendCarretToColorPickerDropdown();
|
||||||
editSampleGroupColor();
|
|
||||||
editSampleGroupForm();
|
editSampleGroupForm();
|
||||||
destroySampleTypeGroup();
|
destroySampleTypeGroup();
|
||||||
$('#new_sample_group').clearFormErrors();
|
$('#new_sample_group').clearFormErrors();
|
||||||
|
@ -194,7 +181,6 @@
|
||||||
destroySampleTypeGroup();
|
destroySampleTypeGroup();
|
||||||
initSampleColorPicker(newLi);
|
initSampleColorPicker(newLi);
|
||||||
appendCarretToColorPickerDropdown();
|
appendCarretToColorPickerDropdown();
|
||||||
editSampleGroupColor();
|
|
||||||
|
|
||||||
$('#edit_sample_group_' + data.id)
|
$('#edit_sample_group_' + data.id)
|
||||||
.find('[name="sample_group[name]"]')
|
.find('[name="sample_group[name]"]')
|
||||||
|
@ -209,7 +195,6 @@
|
||||||
destroySampleTypeGroup();
|
destroySampleTypeGroup();
|
||||||
initSampleColorPicker(newLi);
|
initSampleColorPicker(newLi);
|
||||||
appendCarretToColorPickerDropdown();
|
appendCarretToColorPickerDropdown();
|
||||||
editSampleGroupColor();
|
|
||||||
}).bind('ajax:error', function(ev, error){
|
}).bind('ajax:error', function(ev, error){
|
||||||
$(this).clearFormErrors();
|
$(this).clearFormErrors();
|
||||||
var msg = $.parseJSON(error.responseText);
|
var msg = $.parseJSON(error.responseText);
|
||||||
|
@ -225,16 +210,42 @@
|
||||||
function initSampleGroupColor() {
|
function initSampleGroupColor() {
|
||||||
var elements = $('.edit-sample-group-color');
|
var elements = $('.edit-sample-group-color');
|
||||||
_.each(elements, function(el) {
|
_.each(elements, function(el) {
|
||||||
var color = $(el).closest('[data-color]')
|
initSampleColorPicker(el);
|
||||||
.attr('data-color');
|
|
||||||
$(el).colorselector('setColor', color);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSampleColorPicker(el) {
|
function initSampleColorPicker(el) {
|
||||||
var element = $(el).find('.edit-sample-group-color');
|
var element;
|
||||||
|
if ($(el).is('.edit-sample-group-color')) {
|
||||||
|
element = $(el);
|
||||||
|
} else {
|
||||||
|
element = $(el).find('.edit-sample-group-color');
|
||||||
|
}
|
||||||
var color = $(element).closest('[data-color]').attr('data-color');
|
var color = $(element).closest('[data-color]').attr('data-color');
|
||||||
$(element).colorselector('setColor', color);
|
$(element).colorselector('setColor', color);
|
||||||
|
|
||||||
|
// Bind on buttons
|
||||||
|
var btns = $(element).closest('.edit_sample_group').find('a.color-btn');
|
||||||
|
btns.off();
|
||||||
|
btns.on('click', function() {
|
||||||
|
var color = $(this).attr('data-value');
|
||||||
|
$('select[name="sample_group[color]"]').val(color);
|
||||||
|
|
||||||
|
var form = $(this).closest('form');
|
||||||
|
form
|
||||||
|
.off('ajax:success ajax:error')
|
||||||
|
.on('ajax:success', function() {
|
||||||
|
})
|
||||||
|
.on('ajax:error', function() {
|
||||||
|
form
|
||||||
|
.find('select')
|
||||||
|
.colorselector(
|
||||||
|
'setColor',
|
||||||
|
form.closest('[data-color]').attr('data-color')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
form.submit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,7 +265,6 @@
|
||||||
editSampleTypeForm();
|
editSampleTypeForm();
|
||||||
destroySampleTypeGroup();
|
destroySampleTypeGroup();
|
||||||
editSampleGroupForm();
|
editSampleGroupForm();
|
||||||
editSampleGroupColor();
|
|
||||||
initSampleGroupColor();
|
initSampleGroupColor();
|
||||||
bindNewSampleGroupAction();
|
bindNewSampleGroupAction();
|
||||||
appendCarretToColorPickerDropdown();
|
appendCarretToColorPickerDropdown();
|
||||||
|
|
Loading…
Reference in a new issue