mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Code style fixes [SCI-999]
This commit is contained in:
parent
f97c20e9b5
commit
218e96b1f0
9 changed files with 27 additions and 34 deletions
|
@ -220,10 +220,8 @@ function bindEditTagsAjax() {
|
|||
// Sets callback for completing/uncompleting task
|
||||
function applyTaskCompletedCallBack() {
|
||||
// First, remove old event handlers, as we use turbolinks
|
||||
$("[data-action='complete-task'], [data-action='uncomplete-task']").off();
|
||||
|
||||
$("[data-action='complete-task'], [data-action='uncomplete-task']")
|
||||
.on('click', function() {
|
||||
.off().on('click', function() {
|
||||
var button = $(this);
|
||||
$.ajax({
|
||||
url: button.data('link-url'),
|
||||
|
|
|
@ -27,9 +27,8 @@ function applyCheckboxCallBack() {
|
|||
// Sets callback for completing/uncompleting step
|
||||
function applyStepCompletedCallBack() {
|
||||
// First, remove old event handlers, as we use turbolinks
|
||||
$("[data-action='complete-step'], [data-action='uncomplete-step']").off();
|
||||
|
||||
$("[data-action='complete-step'], [data-action='uncomplete-step']").on('click', function(e){
|
||||
$("[data-action='complete-step'], [data-action='uncomplete-step']")
|
||||
.off().on('click', function(e){
|
||||
var button = $(this);
|
||||
var step = $(this).parents(".step");
|
||||
var completed = !step.hasClass("completed");
|
||||
|
|
|
@ -192,12 +192,10 @@ class MyModulesController < ApplicationController
|
|||
if saved
|
||||
format.json {
|
||||
alerts = []
|
||||
if @my_module.is_overdue? && !@my_module.completed?
|
||||
alerts << 'alert-red'
|
||||
elsif @my_module.is_one_day_prior? && !@my_module.completed?
|
||||
alerts << 'alert-yellow'
|
||||
elsif @my_module.completed?
|
||||
alerts << 'alert-green'
|
||||
alerts << 'alert-green' if @my_module.completed?
|
||||
unless @my_module.completed?
|
||||
alerts << 'alert-red' if @my_module.is_overdue?
|
||||
alerts << 'alert-yellow' if @my_module.is_one_day_prior?
|
||||
end
|
||||
render json: {
|
||||
status: :ok,
|
||||
|
@ -352,11 +350,8 @@ class MyModulesController < ApplicationController
|
|||
completed = @my_module.completed?
|
||||
if @my_module.save
|
||||
# Create activity
|
||||
str = if completed
|
||||
'activities.complete_module'
|
||||
else
|
||||
'activities.uncomplete_module'
|
||||
end
|
||||
str = 'activities.uncomplete_module'
|
||||
str = 'activities.complete_module' if completed
|
||||
message = t(str,
|
||||
user: current_user.full_name,
|
||||
module: @my_module.name)
|
||||
|
@ -398,11 +393,8 @@ class MyModulesController < ApplicationController
|
|||
end
|
||||
|
||||
# Create localized title for complete/uncomplete button
|
||||
button_title = if completed
|
||||
t('my_modules.buttons.uncomplete')
|
||||
else
|
||||
t('my_modules.buttons.complete')
|
||||
end
|
||||
button_title = t('my_modules.buttons.complete')
|
||||
button_title = t('my_modules.buttons.uncomplete') if completed
|
||||
|
||||
format.json do
|
||||
render json: {
|
||||
|
|
|
@ -19,6 +19,17 @@ module MyModulesHelper
|
|||
my_module.results.where(archived: false).order(created_at: :desc)
|
||||
end
|
||||
|
||||
def get_task_alert_color(my_module)
|
||||
alert = ''
|
||||
if !my_module.completed?
|
||||
alert = ' alert-yellow' if my_module.is_one_day_prior?
|
||||
alert = ' alert-red' if my_module.is_overdue?
|
||||
elsif my_module.completed?
|
||||
alert = ' alert-green'
|
||||
end
|
||||
alert
|
||||
end
|
||||
|
||||
def is_steps_page?
|
||||
action_name == "steps"
|
||||
end
|
||||
|
|
|
@ -389,8 +389,7 @@ class MyModule < ActiveRecord::Base
|
|||
completed = false unless step.completed
|
||||
end
|
||||
if completed
|
||||
complete
|
||||
save!
|
||||
update_attributes(state: 'completed', completed_on: DateTime.now)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<div class="panel panel-default module-large
|
||||
<%= " alert-red" if my_module.is_overdue? && !my_module.completed? %>
|
||||
<%= " alert-yellow" if my_module.is_one_day_prior? && !my_module.completed? %>
|
||||
<%= " alert-green" if my_module.completed? %>"
|
||||
<%= get_task_alert_color(my_module) %>
|
||||
id="<%= my_module.id %>"
|
||||
data-module-id="<%= my_module.id %>"
|
||||
data-module-name="<%= my_module.name %>"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<div class="panel panel-default module-medium
|
||||
<%= " alert-red" if my_module.is_overdue? && !my_module.completed? %>
|
||||
<%= " alert-yellow" if my_module.is_one_day_prior? && !my_module.completed? %>
|
||||
<%= " alert-green" if my_module.completed? %>"
|
||||
<%= get_task_alert_color(my_module) %>"
|
||||
id="<%= my_module.id %>"
|
||||
data-module-id="<%= my_module.id %>"
|
||||
data-module-name="<%= my_module.name %>"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<div class="module-small
|
||||
<%= " alert-red" if my_module.is_overdue? && !my_module.completed? %>
|
||||
<%= " alert-yellow" if my_module.is_one_day_prior? && !my_module.completed? %>
|
||||
<%= " alert-green" if my_module.completed? %>"
|
||||
<%= get_task_alert_color(my_module) %>"
|
||||
id="<%= my_module.id %>"
|
||||
data-module-id="<%= my_module.id %>"
|
||||
data-module-name="<%= my_module.name %>"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="btn-group" style="margin-left: 15px;">
|
||||
<div class="btn-group pull-right">
|
||||
<% if !@my_module.completed? %>
|
||||
<div data-action="complete-task" data-link-url="<%= toggle_task_state_my_module_path(@my_module) %>">
|
||||
<button class="btn btn-primary">
|
||||
|
|
Loading…
Reference in a new issue