-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lml#347: Convert native confirm to dialog based confirm.
- Add user_settings migration, model and controller. - Add JS to intercept for confirmation. - Add dialog HTML.
- Loading branch information
Showing
9 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
# License version 3 or later. See the COPYRIGHT file for details. | ||
|
||
class UserSettingsController < ApplicationController | ||
skip_before_filter :authenticate_user! | ||
|
||
def index | ||
@settings = UserSettings.for(present_user) | ||
end | ||
|
||
def update | ||
@settings = UserSettings.for(present_user) | ||
respond_to do |format| | ||
if @settings.update_attributes(params[:settings]) | ||
format.json { render json: {:success => true, message: 'Settings were successfully updated.'}} | ||
else | ||
Rails.logger.info(@settings.errors.messages.inspect) | ||
format.json { render json: {:success => false, message: 'Unable to update settings.'} } | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
# License version 3 or later. See the COPYRIGHT file for details. | ||
|
||
class UserSettings < ActiveRecord::Base | ||
store :settings | ||
|
||
store_typed_accessor :settings, :boolean, :skip_answer_lockin_message | ||
|
||
attr_accessible :skip_answer_lockin_message, :user_id | ||
|
||
after_initialize :supply_missing_values | ||
|
||
def self.for (user) | ||
if user | ||
find_or_create_by_user_id(:user_id => user.id) | ||
else | ||
nil | ||
end | ||
end | ||
|
||
def supply_missing_values | ||
self.skip_answer_lockin_message ||= false | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
# License version 3 or later. See the COPYRIGHT file for details. | ||
|
||
class AddUserSettings < ActiveRecord::Migration | ||
def change | ||
create_table(:user_settings) do |t| | ||
t.integer :user_id, :null => false | ||
t.text :settings, :null => true | ||
t.timestamps | ||
end | ||
|
||
add_index :user_settings, :user_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters