Skip to content

Commit

Permalink
Add migration to remove impaired column from database
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Jan 24, 2019
1 parent be30a7c commit ec7627e
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 147 deletions.
19 changes: 3 additions & 16 deletions app/controllers/account_controller.rb
Expand Up @@ -200,8 +200,7 @@ def activate_self_registered(token)

if user.save
token.destroy
flash[:notice] = with_accessibility_notice :notice_account_activated,
locale: user.language
flash[:notice] = I18n.t(:notice_account_activated)
else
flash[:error] = I18n.t(:notice_activation_failed)
end
Expand Down Expand Up @@ -513,8 +512,7 @@ def register_and_login_via_authsource(_user, session, permitted_params)
if @user.save
session[:auth_source_registration] = nil
self.logged_user = @user
flash[:notice] = with_accessibility_notice :notice_account_activated,
locale: @user.language
flash[:notice] = I18n.t(:notice_account_activated)
redirect_to controller: '/my', action: 'account'
end
# Otherwise render register view again
Expand Down Expand Up @@ -619,8 +617,7 @@ def finish_registration!(user, opts = Hash(session.delete(:finish_registration))
OpenProject::OmniAuth::Authorization.after_login! user, auth_hash, self
end

flash[:notice] = with_accessibility_notice :notice_account_registered_and_logged_in,
locale: user.language
flash[:notice] = I18n.t(:notice_account_registered_and_logged_in)
redirect_after_login user
end

Expand Down Expand Up @@ -709,14 +706,4 @@ def invited_user
token.user
end
end

def with_accessibility_notice(key, locale:)
locale = locale.presence || I18n.locale
text = I18n.t(key, locale: locale)
notice = link_translate(:notice_accessibility_mode,
links: { url: my_settings_url },
locale: locale)

"#{text} #{notice}".html_safe
end
end
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
Expand Up @@ -161,11 +161,11 @@ def render_flash_message(type, message, html_options = {})
html_options = { class: css_classes.join(' '), role: 'alert' }.merge(html_options)

content_tag :div, html_options do
concat(join_flash_messages(message))
concat(content_tag(:i, '', class: 'icon-close close-handler',
tabindex: '0',
role: 'button',
aria: { label: ::I18n.t('js.close_popup_title') }))
concat(join_flash_messages(message))
concat(content_tag(:i, '', class: 'icon-close close-handler',
tabindex: '0',
role: 'button',
aria: { label: ::I18n.t('js.close_popup_title') }))
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/permitted_params.rb
Expand Up @@ -285,7 +285,7 @@ def wiki_content
end

def pref
params.require(:pref).permit(:hide_mail, :time_zone, :impaired, :theme,
params.require(:pref).permit(:hide_mail, :time_zone, :theme,
:comments_sorting, :warn_on_leaving_unsaved,
:auto_hide_popups)
end
Expand Down
13 changes: 0 additions & 13 deletions app/models/user.rb
Expand Up @@ -434,19 +434,6 @@ def time_zone
@time_zone ||= (pref.time_zone.blank? ? nil : ActiveSupport::TimeZone[pref.time_zone])
end

def impaired=(value)
pref.update_attribute(:impaired, !!value)
!!value
end

def impaired
(anonymous? && Setting.accessibility_mode_for_anonymous?) || pref.impaired?
end

def impaired?
impaired
end

def wants_comments_in_reverse_order?
pref.comments_in_reverse_order?
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/user_preference.rb
Expand Up @@ -103,10 +103,6 @@ def canonical_time_zone
end
end

def impaired?
!!impaired
end

private

def to_boolean(value)
Expand Down
7 changes: 0 additions & 7 deletions app/views/users/_preferences.html.erb
Expand Up @@ -42,12 +42,5 @@ See docs/COPYRIGHT.rdoc for more details.
container_class: (defined? input_size) ? "-#{input_size}" : '' %>
</div>
<div class="form--field"><%= pref_fields.check_box :warn_on_leaving_unsaved %></div>
<div class="form--field">
<%= pref_fields.check_box :impaired, aria: {labelledby: 'accessibility-instructions'} %>
<div class="form--field-instructions" id="accessibility-instructions">
<span class="hidden-for-sighted"><%= t('activerecord.attributes.user_preference.impaired') + '. ' %></span>
<%= t(:text_accessibility_hint) %>
</div>
</div>
<div class="form--field"><%= pref_fields.check_box :auto_hide_popups %></div>
<% end %>
1 change: 0 additions & 1 deletion config/initializers/assets.rb
Expand Up @@ -5,7 +5,6 @@
favicon.ico
openproject.css
accessibility.css
accessibility.js
admin_users.js
autocompleter.js
calendar/lang/*.js
Expand Down
15 changes: 15 additions & 0 deletions db/migrate/20190124081710_remove_accessibility_mode.rb
@@ -0,0 +1,15 @@
class RemoveAccessibilityMode < ActiveRecord::Migration[5.2]
def change
remove_column :user_preferences, :impaired
delete_accessibility_mode_from_settings
end

private

def delete_accessibility_mode_from_settings
delete <<-SQL
DELETE FROM settings
WHERE name = 'accessibility_mode_for_anonymous'
SQL
end
end
2 changes: 1 addition & 1 deletion docs/development/accessibility-checklist.md
Expand Up @@ -55,7 +55,7 @@ Web sites should be:
## 3. Understandable - Content and interface are understandable

### 3.1. Texts
* The language of the page is identified using the HTML lang attribute (<html lang="en">, for example).
* The language of the page is identified using the HTML lang attribute (`<html lang="en">`, for example).
* Words that may be ambiguous, unknown, or used in a very specific way are defined through adjacent text, a definition list, a glossary, or other suitable method.

### 3.2. Predictable
Expand Down
Expand Up @@ -71,7 +71,6 @@ export class UserActivityComponent extends WorkPackageCommentFieldHandler implem
edit_comment: this.I18n.t('js.label_edit_comment'),
};

public accessibilityModeEnabled = this.ConfigurationService.accessibilityModeEnabled();
private $element:JQuery;

constructor(readonly elementRef:ElementRef,
Expand Down Expand Up @@ -123,7 +122,7 @@ export class UserActivityComponent extends WorkPackageCommentFieldHandler implem
}

public shouldHideIcons():boolean {
return !(this.isComment && (this.focussing() || this.accessibilityModeEnabled));
return !(this.isComment && this.focussing());
}

public get postedComment() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/wp-new/wp-new-split-view.html
Expand Up @@ -8,7 +8,7 @@
<div class="work-packages--details-content -create-mode">
<div class="work-packages--new-details-header">
<wp-type-status [workPackage]="newWorkPackage"></wp-type-status>
<div class="hidden-for-accessibility wp--details--switch-fullscreen-wrapper">
<div class="wp--details--switch-fullscreen-wrapper">
<a (click)="switchToFullscreen()"
class="work-packages-show-view-button wp--details--switch-fullscreen ">
<span class="icon-context icon-to-fullscreen"></span>
Expand Down
Expand Up @@ -72,7 +72,6 @@ export class ConfigurationService {
enabled_modules: [],
display: {},
user_preferences: {
impaired: false,
time_zone: '',
others: {
comments_sorting: 'asc',
Expand All @@ -95,9 +94,6 @@ export class ConfigurationService {
this.settings.display[setting] !== false;
}

public accessibilityModeEnabled() {
return this.settings.user_preferences.impaired;
}
public commentsSortedInDescendingOrder() {
return this.settings.user_preferences.others.comments_sorting === 'desc';
}
Expand Down
Expand Up @@ -65,10 +65,7 @@ export class CopyToClipboardDirective implements OnInit {
let notification = this.NotificationsService[type](message);

// Remove the notification some time later
// but only when we're not in accessible mode
if (!this.ConfigurationService.accessibilityModeEnabled()) {
setTimeout(() => this.NotificationsService.remove(notification), 5000);
}
setTimeout(() => this.NotificationsService.remove(notification), 5000);
}

onClick($event:JQueryEventObject) {
Expand Down
Expand Up @@ -53,11 +53,8 @@ export class OpDatePickerComponent implements OnInit, OnDestroy {
ngOnInit() {
this.$element = jQuery(this.elementRef.nativeElement);

// we don't want the date picker in the accessibility mode
if (!this.ConfigurationService.accessibilityModeEnabled()) {
this.input = this.$element.find('input');
this.setup();
}
this.input = this.$element.find('input');
this.setup();
}

ngOnDestroy() {
Expand Down
3 changes: 0 additions & 3 deletions lib/api/v3/user_preferences/user_preferences_representer.rb
Expand Up @@ -64,9 +64,6 @@ class UserPreferencesRepresenter < ::API::Decorators::Single
as: :commentSortDescending
property :auto_hide_popups

property :impaired?,
as: :accessibilityMode

def _type
'UserPreferences'
end
Expand Down
Expand Up @@ -339,16 +339,6 @@ fieldset.collapsible.header_collapsible legend.in_row {
z-index: 10;
}

/* Overwrite normal h3 definition - a h-tag is needed for accessibility purposes */
h3.reporting_formatting {
font-weight:normal;
font-size: 13px;
margin:0px;
padding:0px;
color:#333;
border:0px;
}

/* -- end group-by -- */

td .drill_down, th .drill_down {
Expand Down
3 changes: 0 additions & 3 deletions spec/features/members/membership_spec.rb
Expand Up @@ -103,9 +103,6 @@
context 'with a user' do
it_behaves_like 'adding and removing principals'

# The following scenario is only tested with an unimpaired user
# as it does not make a difference whether or not the user is impaired.

scenario 'Escaping should work properly when selecting a user' do
members_page.visit!
members_page.open_new_member!
Expand Down
Expand Up @@ -48,7 +48,6 @@
it { is_expected.to have_json_path('commentSortDescending') }
it { is_expected.to have_json_path('warnOnLeavingUnsaved') }
it { is_expected.to have_json_path('autoHidePopups') }
it { is_expected.to have_json_path('accessibilityMode') }

describe 'timeZone' do
context 'no time zone set' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/permitted_params_spec.rb
Expand Up @@ -118,7 +118,7 @@
let(:attribute) { :pref }

let(:hash) do
acceptable_params = %w(hide_mail time_zone impaired
acceptable_params = %w(hide_mail time_zone
comments_sorting warn_on_leaving_unsaved)

acceptable_params.map { |x| [x, 'value'] }.to_h
Expand Down

0 comments on commit ec7627e

Please sign in to comment.