Almost functional calendar
parent
c6e7ce473d
commit
c68307500c
|
@ -6,8 +6,19 @@ controller = ($scope, Data) ->
|
|||
{show: 'Weeks', value: 'weekly'},
|
||||
{show: 'Months', value: 'monthly'},
|
||||
{show: 'Years', value: 'yearly'}]
|
||||
|
||||
Data.findAll('sequence', {}).catch(nope)
|
||||
Data.bindAll 'sequence', {}, $scope, 'sequences'
|
||||
Data.bindAll('sequence', {}, $scope, 'sequences')
|
||||
Data.findAll('schedule', {}).catch(nope)
|
||||
Data.bindAll('schedule', {}, $scope, 'schedules')
|
||||
|
||||
$scope.prettyDates = []
|
||||
$scope.$watchCollection 'schedules', ->
|
||||
pretty = _.groupBy $scope.schedules, (s) ->
|
||||
new Date(s.start_time).toDateString().substring(4, 10)
|
||||
$scope.prettyDates = pretty
|
||||
console.log $scope.prettyDates
|
||||
|
||||
$scope.submit = ->
|
||||
Data
|
||||
.create('schedule', $scope.jsonPayload())
|
||||
|
|
|
@ -30,9 +30,9 @@ data = (DS) ->
|
|||
basePath: '/api',
|
||||
idAttribute: "_id"
|
||||
# relations:
|
||||
# hasMany:
|
||||
# step:
|
||||
# localField: "steps"
|
||||
# hasOne:
|
||||
# sequence:
|
||||
# localField: "sequence"
|
||||
# foreignKey: "sequence_id"
|
||||
|
||||
return DS
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
module Api
|
||||
class SchedulesController < Api::AbstractController
|
||||
def index
|
||||
# Follow this for better querying in the future:
|
||||
# http://www.js-data.io/v1.3.0/docs/query-syntax
|
||||
render json: Schedule.where(user: current_user)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ module Api
|
|||
class SequencesController < Api::AbstractController
|
||||
# TODO add user authorization maybe (privacy)
|
||||
def index
|
||||
render json: Sequence.where(user: current_user)
|
||||
query = {user: current_user}
|
||||
query.merge!(schedule_id: params[:schedule_id]) if params[:schedule_id]
|
||||
render json: Sequence.where(query)
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
class ScheduleSerializer < ActiveModel::Serializer
|
||||
attributes :_id, :start_time, :end_time, :next_time, :repeat, :time_unit,
|
||||
:sequence_id
|
||||
:sequence_id, :sequence_name
|
||||
|
||||
# TODO: This is almost certainly wrong. I shouldn't need to write this method.
|
||||
def sequence_id
|
||||
object.sequence._id.to_s
|
||||
end
|
||||
|
||||
def sequence_name
|
||||
object.sequence.name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,55 +6,17 @@
|
|||
.row
|
||||
.small-12.columns
|
||||
.content-wrapper
|
||||
.row.day
|
||||
.row.day{'ng-repeat' => '(date, scheds) in prettyDates'}
|
||||
.small-2.columns
|
||||
%h6.calendar-date 21
|
||||
.calendar-month Aug
|
||||
.small-10.columns
|
||||
.small-12.columns.event.past
|
||||
.row
|
||||
.small-12.columns
|
||||
.event-time 2pm
|
||||
%i.event-icon.fi-target
|
||||
.event-title Deep Watering
|
||||
%i.edit-icon.fi-pencil.right
|
||||
.small-12.columns.event.past
|
||||
.row
|
||||
.small-12.columns
|
||||
.event-time 4pm
|
||||
%i.event-icon.fi-target
|
||||
.event-title Seed Injection
|
||||
%i.edit-icon.fi-pencil.right
|
||||
.small-12.columns.event.next
|
||||
.row
|
||||
.small-12.columns
|
||||
.event-time 6pm
|
||||
%i.event-icon.fi-target
|
||||
.event-title Harvest
|
||||
%i.edit-icon.fi-pencil.right
|
||||
.row.day
|
||||
.small-2.columns
|
||||
%h6.calendar-date 22
|
||||
.calendar-month Aug
|
||||
.small-10.columns
|
||||
%h6.calendar-date {{ date.substring(0, 3) }}
|
||||
.calendar-month {{ date.substring(4, 6) }}
|
||||
.small-10.columns{'ng-repeat' => 's in scheds'}
|
||||
.small-12.columns.event
|
||||
// .past is a thing, FYI.
|
||||
// See examples in source control from 2/25/15
|
||||
.row
|
||||
.small-12.columns
|
||||
.event-time 2pm
|
||||
.event-time {{ s.start_time | date: 'h a' }}
|
||||
%i.event-icon.fi-target
|
||||
.event-title Deep Watering
|
||||
%i.edit-icon.fi-pencil.right
|
||||
.small-12.columns.event
|
||||
.row
|
||||
.small-12.columns
|
||||
.event-time 4pm
|
||||
%i.event-icon.fi-target
|
||||
.event-title Seed Injection
|
||||
%i.edit-icon.fi-pencil.right
|
||||
.small-12.columns.event
|
||||
.row
|
||||
.small-12.columns
|
||||
.event-time 6pm
|
||||
%i.event-icon.fi-target
|
||||
.event-title Harvest
|
||||
.event-title {{ s.sequence_name }}
|
||||
%i.edit-icon.fi-pencil.right
|
||||
|
|
Loading…
Reference in New Issue