Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

schema.rb

  • Loading branch information...
commit e903f84b826c04b7172d5e2271f7399dbbdd40d5 2 parents 368307c + 1de91ef
Rob Sterner fermion authored
190 app/assets/javascripts/templates/user.templates.js.coffee
View
@@ -37,128 +37,149 @@ _templates =
'''
edit:
userEdit: '''
- <div data-model=user>
- <div class="control-group">
- <label class="control-label" for="user_first_name">First name</label>
- <div class="controls">
- <input id="user_first_name" data-attribute=first_name size="30" type="text" value={{user.first_name}}>
+ <fieldset>
+ <legend>User Information</legend>
+ <div data-model=user>
+ <div class="control-group">
+ <label class="control-label" for="user_first_name">First name</label>
+ <div class="controls">
+ <input id="user_first_name" data-attribute=first_name size="30" type="text" value={{user.first_name}}>
+ </div>
</div>
- </div>
- <div class="control-group">
- <label class="control-label" for="user_last_name">Last name</label>
- <div class="controls">
- <input id="user_last_name" data-attribute=last_name size="30" type="text" value={{user.last_name}}>
- </div>
- </div>
+ <div class="control-group">
+ <label class="control-label" for="user_last_name">Last name</label>
+ <div class="controls">
+ <input id="user_last_name" data-attribute=last_name size="30" type="text" value={{user.last_name}}>
+ </div>
+ </div>
- <div class="control-group">
- <label class="control-label" for="user_email">Email</label>
- <div class="controls">
- <input id="user_email" data-attribute=email size="30" type="text" value="{{user.email}}">
+ <div class="control-group">
+ <label class="control-label" for="user_email">Email</label>
+ <div class="controls">
+ <input id="user_email" data-attribute=email size="30" type="text" value="{{user.email}}">
+ </div>
</div>
</div>
- </div>
+ </fieldset>
- <div data-model="user_preferences">
- <div class="control-group">
- <label class="control-label">User Preferences</label>
- <div class="controls">
- <input data-attribute=email_reminder {{#if emailReminder}}checked=checked{{/if}} type="checkbox"> If active, user will receive email reminders when he doesn't commit hours as expected
+ <fieldset>
+ <legend>User Preferences</legend>
+ <div data-model="user_preferences">
+ <div class="control-group">
+ <div class="controls">
+ <label>
+ <input id="email_reminder" data-attribute="email_reminder" {{#if emailReminder}}checked=checked{{/if}} type="checkbox" name="email_reminder">
+ Email reminder
+ </label>
+ <span class='help-block'>If active, user will receive email reminders when she/he doesn't commit hours as expected</span>
+ </div>
</div>
- </div>
- </div>
-
- <div data-model=membership>
- <div id="employment_status">
<div class="control-group">
- <label class="control-label" for="user_employment_status">Employment status</label>
<div class="controls">
- <select id="user_employment_status" data-attribute=employment_status>
- {{#each membershipInfo.status}}
- <option value="{{name}}" {{#if selected}}selected=selected{{/if}}>{{capitalizedName}}</option>
- {{/each}}
- </select>
+ <label>
+ <input id="display_dates" data-attribute="display_dates" {{#if displayDates}}checked=checked{{/if}} type="checkbox">
+ Display dates
+ </label>
+ <span class='help-block'>If active, the weeks on the different pages will be MM/DD instead of W1/W2</span>
</div>
</div>
</div>
-
- <div id="permissions">
- {{#each membershipInfo.permissions}}
+ </fieldset>
+
+ <fieldset>
+ <legend>Employment-related Information</legend>
+ <div data-model=membership>
+ <div id="employment_status">
<div class="control-group">
- <label class="control-label checkbox" for="user_permissions_{{name}}"></label>
+ <label class="control-label" for="user_employment_status">Employment status</label>
<div class="controls">
- <input data-attribute=permissions {{#if userHasPermission}}checked=checked{{/if}} type="checkbox" value="{{name}}"> {{capitalizedName}}
+ <select id="user_employment_status" data-attribute=employment_status>
+ {{#each membershipInfo.status}}
+ <option value="{{name}}" {{#if selected}}selected=selected{{/if}}>{{capitalizedName}}</option>
+ {{/each}}
+ </select>
</div>
</div>
- {{/each}}
- </div>
-
- <div id="permissions">
- <div class="control-group">
- <label class="control-label checkbox" for="user_archived"></label>
- <div class="controls">
- <input data-model="membership" data-attribute="archived" {{#if membershipInfo.archived}}checked=checked{{/if}} type="checkbox" value="archived">
- Archived
- <span class="help-block">Archiving a user enables them to access company data when they log in but removes them from most views.</span>
- </div>
</div>
- <div class="control-group">
- <label class="control-label checkbox" for="user_disabled"></label>
- <div class="controls">
- <input data-model="membership" data-attribute="disabled" {{#if membershipInfo.disabled}}checked=checked{{/if}} type="checkbox" value="disabled">
- Disabled
- <span class="help-block">Disabling a user prohibits them from accessing any of your company's data when they log in.</span>
- </div>
+
+ <div id="permissions">
+ {{#each membershipInfo.permissions}}
+ <div class="control-group">
+ <label class="control-label checkbox" for="user_permissions_{{name}}"></label>
+ <div class="controls">
+ <input data-attribute=permissions {{#if userHasPermission}}checked=checked{{/if}} type="checkbox" value="{{name}}"> {{capitalizedName}}
+ </div>
+ </div>
+ {{/each}}
</div>
- </div>
- <div id="salary_information">
- {{#if membershipInfo.status.fte}}
- <div class="salary fte">
+ <div id="permissions">
<div class="control-group">
- <label class="control-label" for="user_salary">Salary</label>
+ <label class="control-label checkbox" for="user_archived"></label>
<div class="controls">
- <input id="user_salary" data-attribute=salary size="30" type="number" value="{{membershipInfo.salary.salary}}">
+ <input data-model="membership" data-attribute="archived" {{#if membershipInfo.archived}}checked=checked{{/if}} type="checkbox" value="archived">
+ Archived
+ <span class="help-block">Archiving a user enables them to access company data when they log in but removes them from most views.</span>
</div>
</div>
<div class="control-group">
- <label class="control-label" for="user_fte">Full-Time Equivalent</label>
+ <label class="control-label checkbox" for="user_disabled"></label>
<div class="controls">
- <input id="user_full_time_equivalent" data-attribute=full_time_equivalent size="30" type="number" value="{{membershipInfo.salary.full_time_equivalent}}">
+ <input data-model="membership" data-attribute="disabled" {{#if membershipInfo.disabled}}checked=checked{{/if}} type="checkbox" value="disabled">
+ Disabled
+ <span class="help-block">Disabling a user prohibits them from accessing any of your company's data when they log in.</span>
</div>
</div>
</div>
- {{/if}}
-
- {{#if membershipInfo.status.contractor}}
- <div class="salary contractor">
+
+ <div id="salary_information">
+ {{#if membershipInfo.status.fte}}
+ <div class="salary fte">
<div class="control-group">
- <label class="control-label" for="user_weekly_allocation">Weekly allocation</label>
+ <label class="control-label" for="user_salary">Salary</label>
<div class="controls">
- <input id="user_weekly_allocation" data-attribute=weekly_allocation size="30" value="{{membershipInfo.salary.weekly_allocation}}" type="number">
+ <input id="user_salary" data-attribute=salary size="30" type="number" value="{{membershipInfo.salary.salary}}">
</div>
</div>
<div class="control-group">
- <label class="control-label" for="user_payment_frequency">Payment frequency</label>
+ <label class="control-label" for="user_fte">Full-Time Equivalent</label>
<div class="controls">
- <select id="user_payment_frequency" data-attribute=payment_frequency>
- {{#each membershipInfo.salary.payment_frequency}}
- <option value="{{name}}" {{#if selectedFrequency}}selected=selected{{/if}}>{{capitalizedName}}</option>
- {{/each}}
- </select>
+ <input id="user_full_time_equivalent" data-attribute=full_time_equivalent size="30" type="number" value="{{membershipInfo.salary.full_time_equivalent}}">
</div>
</div>
- <div class="control-group">
- <label class="control-label" for="user_rate">Rate</label>
- <div class="controls">
- <input id="user_rate" data-attribute=rate size="30" value="{{membershipInfo.salary.rate}}" type="number">
+ </div>
+ {{/if}}
+
+ {{#if membershipInfo.status.contractor}}
+ <div class="salary contractor">
+ <div class="control-group">
+ <label class="control-label" for="user_weekly_allocation">Weekly allocation</label>
+ <div class="controls">
+ <input id="user_weekly_allocation" data-attribute=weekly_allocation size="30" value="{{membershipInfo.salary.weekly_allocation}}" type="number">
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="user_payment_frequency">Payment frequency</label>
+ <div class="controls">
+ <select id="user_payment_frequency" data-attribute=payment_frequency>
+ {{#each membershipInfo.salary.payment_frequency}}
+ <option value="{{name}}" {{#if selectedFrequency}}selected=selected{{/if}}>{{capitalizedName}}</option>
+ {{/each}}
+ </select>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="user_rate">Rate</label>
+ <div class="controls">
+ <input id="user_rate" data-attribute=rate size="30" value="{{membershipInfo.salary.rate}}" type="number">
+ </div>
</div>
</div>
- </div>
- {{/if}}
+ {{/if}}
+ </div>
</div>
- </div>
+ </fieldset>
<div class="form-actions">
<a href="#" data-action="update" type="submit" class="btn btn-primary">Update user</a>
@@ -231,8 +252,7 @@ _templates =
</div>
</div>
</div>
-
-
+
<div id="permissions">
<div class="control-group">
<label class="control-label" for="user_permissions_admin">Admin</label>
9 app/assets/javascripts/views/date_range_view.js.coffee
View
@@ -46,26 +46,27 @@ class StaffPlan.Views.DateRangeView extends Support.CompositeView
@remove()
render: ->
+ displayDates = StaffPlan.users.get(StaffPlan.currentUser.id).preferences.get("display_dates")
data = _.map @collection, (timestamp) ->
m = moment(timestamp)
weekNumber = Math.ceil(m.date() / 7)
switch weekNumber
when 1
month: m.format("MMM")
- week: "W" + weekNumber
+ week: if displayDates then m.format("M/D") else "W" + weekNumber
timestamp: timestamp
when 2
if m.month() is 0
month: "(#{m.year()})"
- week: "W" + weekNumber
+ week: if displayDates then m.format("M/D") else "W" + weekNumber
timestamp: timestamp
else
month: ""
- week: "W" + weekNumber
+ week: if displayDates then m.format("M/D") else "W" + weekNumber
timestamp: timestamp
else
month: "&nbsp;"
- week: "W" + weekNumber
+ week: if displayDates then m.format("M/D") else "W" + weekNumber
timestamp: timestamp
m = moment()
timestampAtBeginningOfWeek = m.utc().startOf('day').subtract('days', m.day() - 1).valueOf()
2  app/assets/javascripts/views/users/edit.js.coffee
View
@@ -46,7 +46,6 @@ class window.StaffPlan.Views.Users.Edit extends StaffPlan.View
model.membership.set resource
@model.preferences.save preferencesAttributes,
success: (resource, response) ->
- console.log resource
Backbone.history.navigate("/users", true)
error: (model, xhr, options) =>
@errorHandler xhr, "preferences"
@@ -63,6 +62,7 @@ class window.StaffPlan.Views.Users.Edit extends StaffPlan.View
@$el.find('section.main').html StaffPlan.Templates.Users.edit.userEdit
user: @model.attributes
emailReminder: @model.preferences.get("email_reminder")
+ displayDates: @model.preferences.get("display_dates")
membershipInfo: @model.getMembershipInformation()
@
2  app/controllers/users/user_preferences_controller.rb
View
@@ -19,7 +19,7 @@ def update
private
def whitelist_attributes(parameters)
- parameters.slice(:email_reminder)
+ parameters.slice(:email_reminder, :display_dates)
end
end
8 app/models/user.rb
View
@@ -31,13 +31,17 @@ def update_timestamp!(time = Time.now)
self.save
end
-
validates_presence_of :email, :first_name, :last_name
validates_uniqueness_of :email
- validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/
+ validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/
+ before_validation :initialize_user_preferences
after_validation :handle_empty_password_digest
+ def initialize_user_preferences
+ self.build_user_preferences if self.user_preferences.nil?
+ end
+
def handle_empty_password_digest
if self.password_digest.blank? &&
self.registration_token.present? &&
2  app/models/user_preferences.rb
View
@@ -1,4 +1,4 @@
class UserPreferences < ActiveRecord::Base
- attr_accessible :email_reminder, :user_id
+ attr_accessible :email_reminder, :display_dates, :user_id
belongs_to :user
end
9 db/migrate/20130221193221_add_display_dates_to_user_preferences.rb
View
@@ -0,0 +1,9 @@
+class AddDisplayDatesToUserPreferences < ActiveRecord::Migration
+ def change
+ add_column(:user_preferences, :display_dates, :boolean, :null => false, :default => false)
+
+ User.all.each do |u|
+ u.create_user_preferences
+ end
+ end
+end
15 db/schema.rb
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130227192027) do
+ActiveRecord::Schema.define(:version => 20130221193221) do
create_table "assignments", :force => true do |t|
t.integer "user_id"
@@ -70,8 +70,9 @@
create_table "user_preferences", :force => true do |t|
t.boolean "email_reminder"
t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.boolean "display_dates", :default => false, :null => false
end
create_table "users", :force => true do |t|
@@ -99,14 +100,12 @@
create_table "work_weeks", :force => true do |t|
t.integer "estimated_hours"
t.integer "actual_hours"
- t.integer "cweek"
- t.integer "year"
+ t.integer "cweek", :limit => 2
+ t.integer "year", :limit => 2
t.datetime "created_at"
t.datetime "updated_at"
t.integer "assignment_id"
- t.decimal "beginning_of_week", :precision => 15, :scale => 0
+ t.decimal "beginning_of_week", :precision => 15, :scale => 0
end
- add_index "work_weeks", ["assignment_id", "beginning_of_week"], :name => "index_work_weeks_on_assignment_id_and_beginning_of_week", :unique => true
-
end
Please sign in to comment.
Something went wrong with that request. Please try again.