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