Replaced hardcoded infinity values with constants. Added quotation marks to Ruby string constants in JS.

This commit is contained in:
Matej Zrimšek 2016-10-13 11:05:11 +02:00
parent a6a2a237aa
commit f2cd9890dd
21 changed files with 44 additions and 32 deletions

View file

@ -36,7 +36,7 @@ var DEFAULT_CONNECTOR_STYLE =
} ];
var DEFAULT_CONNECTOR_STYLE_2 =
{
strokeStyle: "<%= Constants::COLOR_WHITE %>",
strokeStyle: '<%= Constants::COLOR_WHITE %>',
lineWidth: 1.5,
outlineColor: "transparent",
outlineWidth: 0
@ -57,7 +57,7 @@ var EDIT_ENDPOINT_STYLE =
} ];
var EDIT_CONNECTOR_STYLE_2 =
{
strokeStyle: "<%= Constants::COLOR_WHITE %>",
strokeStyle: '<%= Constants::COLOR_WHITE %>',
lineWidth: 3,
outlineColor: "transparent",
outlineWidth: 0

View file

@ -466,12 +466,12 @@
.find('.form-submit-link')
.css({
'pointer-events': 'none',
'color': <%= Constants::COLOR_ALTO %>});
'color': '<%= Constants::COLOR_ALTO %>'});
$(el)
.find('[data-action="edit"]')
.css({
'pointer-events': 'none',
'color': <%= Constants::COLOR_ALTO %>});
'color': '<%= Constants::COLOR_ALTO %>'});
});
}
});
@ -489,12 +489,12 @@
.find('.form-submit-link')
.css({
'pointer-events': 'auto',
'color': <%= Constants::COLOR_NERO %>});
'color': '<%= Constants::COLOR_NERO %>'});
$(el)
.find('[data-action="edit"]')
.css({
'pointer-events': 'auto',
'color': <%= Constants::COLOR_NERO %>});
'color': '<%= Constants::COLOR_NERO %>'});
});
}

View file

@ -4,7 +4,7 @@
*= require jquery-ui/draggable
*= require rails_bootstrap_forms
*= require bootstrap-select
*= require colors
*= require constants
*= require introjs
*= stub reports_pdf
*/

View file

@ -1,3 +1,7 @@
//==============================================================================
// Colors
//==============================================================================
// Theme colors
$color-theme-primary: #37a0d9;
$color-theme-secondary: #8fd13f;
@ -28,3 +32,10 @@ $color-candlelight: #ffda23;
$color-mojo: #cf4b48;
$color-apple-blossom: #a94442;
$color-milano-red: #a70b05;
//==============================================================================
// Other
//==============================================================================
// Some big value which is still supported by all browsers
$infinity: 9999999;

View file

@ -1,6 +1,6 @@
/* Extending Bootstrap */
@import "colors";
@import 'constants';
/* navbar avatar image */
.navbar-nav .avatar {

View file

@ -1,4 +1,4 @@
@import "colors";
@import 'constants';
@import "mixins";
.notifications-container {
@ -56,7 +56,7 @@
font-size: 13px;
height: 30px;
padding-top: 5px;
width: 30px;
width: 30px;
}
.system-message {

View file

@ -4,7 +4,7 @@
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
*/
@import "colors";
@import 'constants';
@import "mixins";
$wrapper-width: 280px;

View file

@ -1,4 +1,4 @@
@import "colors";
@import 'constants';
@import "mixins";
.tree {

View file

@ -1,4 +1,4 @@
@import "colors";
@import 'constants';
@import "mixins";
// Some color definitions

View file

@ -1,4 +1,4 @@
@import "colors";
@import 'constants';
@import "mixins";
/* Index page */

View file

@ -1,4 +1,4 @@
@import "colors";
@import 'constants';
@import "mixins";
/** Custom CSS for report print (& PDF) */

View file

@ -2,7 +2,7 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@import 'colors';
@import 'constants';
#search-content {
background-color: $color-white;

View file

@ -1,4 +1,4 @@
@import "colors";
@import 'constants';
@import "mixins";
/** Layout **/
@ -88,7 +88,7 @@ table {
margin-left: 12px;
padding: 1px 6px;
position: relative;
z-index: 999999;
z-index: $infinity;
}
}
@ -1331,10 +1331,10 @@ html.turbolinks-progress-bar::before {
}
.introjs-tooltipReferenceLayer {
z-index: 999999 !important;
z-index: $infinity !important;
&.max {
z-index: 99999999 !important;
z-index: calc($infinity + 1) !important;
}
}
@ -1355,7 +1355,7 @@ html.turbolinks-progress-bar::before {
padding: 5px;
border-radius: 6px;
position: absolute;
z-index: 999999;
z-index: $infinity;
}
.modal-tooltip:hover .modal-tooltiptext {

View file

@ -153,7 +153,7 @@ class MyModule < ActiveRecord::Base
# Get module comments ordered by created_at time. Results are paginated
# using last comment id and per_page parameters.
def last_comments(last_id = 1, per_page = Constants::COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
last_id = Constants::INFINITY if last_id <= 1
comments = Comment.joins(:my_module_comment)
.where(my_module_comments: { my_module_id: id })
.where('comments.id < ?', last_id)
@ -164,7 +164,7 @@ class MyModule < ActiveRecord::Base
def last_activities(last_id = 1,
count = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
last_id = Constants::INFINITY if last_id <= 1
Activity.joins(:my_module)
.where(my_module_id: id)
.where('activities.id < ?', last_id)

View file

@ -81,7 +81,7 @@ class Project < ActiveRecord::Base
# Get project comments order by created_at time. Results are paginated
# using last comment id and per_page parameters.
def last_comments(last_id = 1, per_page = Constants::COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
last_id = Constants::INFINITY if last_id <= 1
comments = Comment.joins(:project_comment)
.where(project_comments: { project_id: id })
.where('comments.id < ?', last_id)

View file

@ -73,7 +73,7 @@ class Result < ActiveRecord::Base
end
def last_comments(last_id = 1, per_page = Constants::COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
last_id = Constants::INFINITY if last_id <= 1
comments = Comment.joins(:result_comment)
.where(result_comments: { result_id: id })
.where('comments.id < ?', last_id)

View file

@ -89,7 +89,7 @@ class Step < ActiveRecord::Base
end
def last_comments(last_id = 1, per_page = Constants::COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
last_id = Constants::INFINITY if last_id <= 1
comments = Comment.joins(:step_comment)
.where(step_comments: { step_id: id })
.where('comments.id < ?', last_id)

View file

@ -241,8 +241,7 @@ class User < ActiveRecord::Base
# module.
def last_activities(last_activity_id = nil,
per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
# TODO replace with some kind of Infinity value
last_activity_id = 999999999999999999999999 if last_activity_id < 1
last_activity_id = Constants::INFINITY if last_activity_id < 1
Activity
.joins(project: :user_projects)
.joins("LEFT OUTER JOIN my_modules ON activities.my_module_id = my_modules.id")

View file

@ -11,7 +11,7 @@ class UserNotification < ActiveRecord::Base
last_notification_id = nil,
per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT
)
last_notification_id = 999999999999999999999999 if last_notification_id < 1
last_notification_id = Constants::INFINITY if last_notification_id < 1
Notification.joins(:user_notifications)
.where('user_notifications.user_id = ?', user.id)
.where('notifications.id < ?', last_notification_id)
@ -23,7 +23,7 @@ class UserNotification < ActiveRecord::Base
Notification.joins(:user_notifications)
.where('user_notifications.user_id = ?', user.id)
.order(created_at: :DESC)
.limit(Constants::COMMENTS_SEARCH_LIMIT)
.limit(Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
end
def self.unseen_notification_count(user)

View file

@ -22,7 +22,7 @@ module RenamingUtil
# Get the max. length validation, if it exist
# IF MAX_LENGTH IS VERY LOW, this code here could
# potentially cause trouble. Let's hope max_length is always 10+
max_length = 99999
max_length = Constants::INFINITY
clazz
.validators_on(name_col)
.select{ |v| v.class == ActiveModel::Validations::LengthValidator }
@ -58,4 +58,4 @@ module RenamingUtil
return record.valid?
end
end
end

View file

@ -24,6 +24,8 @@ class Constants
# Standard max length for email
EMAIL_MAX_LENGTH = 254
INFINITY = 999999999999999999
#=============================================================================
# Query/display limits
#=============================================================================