mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-28 07:54:28 +08:00
Fix permission check and due date clear
This commit is contained in:
parent
33a4cb93c7
commit
e76b4ca26f
3 changed files with 45 additions and 15 deletions
|
@ -3,18 +3,26 @@
|
||||||
|
|
||||||
// Bind ajax for editing due dates
|
// Bind ajax for editing due dates
|
||||||
function initDueDatePicker() {
|
function initDueDatePicker() {
|
||||||
$('#calendar-due-date').on('dp.change', function() {
|
function updateDueDate(val) {
|
||||||
var updateUrl = $('.due-date-container').data('update-url');
|
var updateUrl = $('.due-date-container').data('update-url');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: updateUrl,
|
url: updateUrl,
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: { my_module: { due_date: $('#calendar-due-date').val() } },
|
data: { my_module: { due_date: val } },
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
$('.due-date-container').html($(result.module_header_due_date_label));
|
$('.due-date-container').html($(result.module_header_due_date_label));
|
||||||
initDueDatePicker();
|
initDueDatePicker();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#calendar-due-date').on('dp.change', function() {
|
||||||
|
updateDueDate($('#calendar-due-date').val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.flex-block.date-block .clear-date').off('click').on('click', function() {
|
||||||
|
updateDueDate(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
line-height: 34px;
|
line-height: 34px;
|
||||||
|
margin-right: 25px;
|
||||||
padding: 0 3px;
|
padding: 0 3px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
@ -73,6 +74,18 @@
|
||||||
&.alert-red {
|
&.alert-red {
|
||||||
color: $brand-danger;
|
color: $brand-danger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clear-date {
|
||||||
|
color: $color-silver;
|
||||||
|
cursor: pointer;
|
||||||
|
display: none;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 34px;
|
||||||
|
left: 100%;
|
||||||
|
margin-left: 5px;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.datetime-picker-container {
|
.datetime-picker-container {
|
||||||
|
@ -86,12 +99,16 @@
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.date-text {
|
.date-text[data-editable=true] {
|
||||||
border-color: $color-silver;
|
border-color: $color-silver;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
|
.clear-date {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,21 @@ elsif my_module.is_overdue?
|
||||||
label = "(#{t('my_modules.states.overdue')})"
|
label = "(#{t('my_modules.states.overdue')})"
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<span class="date-text <%= date_class %>">
|
<span class="date-text <%= date_class if my_module.due_date %>" data-editable="<%= can_manage_module?(my_module) %>">
|
||||||
<span class="view-block">
|
<span class="view-block">
|
||||||
<%= my_module.due_date ? l(my_module.due_date.utc, format: :full) : t("experiments.canvas.full_zoom.no_due_date") %>
|
<%= my_module.due_date ? l(my_module.due_date.utc, format: :full) : t("experiments.canvas.full_zoom.no_due_date") %>
|
||||||
</span>
|
</span>
|
||||||
<%= render partial: "global_activities/date_picker.html.erb", locals: {
|
<% if can_manage_module?(my_module) %>
|
||||||
id: 'due-date',
|
<%= render partial: "global_activities/date_picker.html.erb", locals: {
|
||||||
use_current: 'false',
|
id: 'due-date',
|
||||||
setDate: my_module.due_date ? l(my_module.due_date.utc, format: :full) : '',
|
use_current: 'false',
|
||||||
placeholder: t("experiments.canvas.full_zoom.no_due_date"),
|
setDate: my_module.due_date ? l(my_module.due_date.utc, format: :full) : '',
|
||||||
label: nil
|
placeholder: t("experiments.canvas.full_zoom.no_due_date"),
|
||||||
} %>
|
label: nil
|
||||||
|
} %>
|
||||||
|
<% end %>
|
||||||
<%= label %>
|
<%= label %>
|
||||||
|
<% if my_module.due_date && can_manage_module?(my_module) %>
|
||||||
|
<span class="fas fa-times clear-date"></span>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Add table
Reference in a new issue