Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisM committed Feb 18, 2014
0 parents commit de04249
Show file tree
Hide file tree
Showing 743 changed files with 254,448 additions and 0 deletions.
Binary file added .bower.json.un~
Binary file not shown.
Binary file added .iframe.html.un~
Binary file not shown.
Binary file added .start.php.un~
Binary file not shown.
Binary file added assets/.PositionModels.coffee.un~
Binary file not shown.
Binary file added assets/.PositionsApplication.coffee.un~
Binary file not shown.
Binary file added assets/.PositionsController.coffee.un~
Binary file not shown.
Binary file added assets/.PositionsViews.coffee.un~
Binary file not shown.
Binary file added assets/.setup.coffee.un~
Binary file not shown.
2 changes: 2 additions & 0 deletions assets/PositionsApplication.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
positionsApp = new Backbone.Marionette.Application

18 changes: 18 additions & 0 deletions assets/PositionsController.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
positionsApp.module 'Controller', (PositionsController, App, Backbone, Marionette, $, _) ->

class PositionsController.Controller extends Marionette.Controller
constructor: ->

start: ->
createView = new positionsApp.View.CreatePosition()
createView.show()
App.vent.on 'position:add', (position) ->
that.positions.add position



PositionsController.addInitializer ->
controller = new PositionsController.Controller

controller.start()

84 changes: 84 additions & 0 deletions assets/PositionsViews.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
positionsApp.module 'Views', (Views, App, Backbone) ->
Helpers =
calculatePensum: ((weeklyHours) ->
(workload) ->
Math.round(workload / weeklyHours * 1000) / 10
)(Bejoo.organisation.weeklyHours)


class Views.CreatePosition extends Marionette.View
template: Handlebars.compile $('#create-view-template').html()
el: 'article#content'
events:
'click .submit-position': 'submitPosition'
'click .x': 'hide'
'change #workload-position': 'workloadChanged'

ui:
title: '.title-position'
indefinite: '#indefinite'
description: '.description-position'
workload: '#workload-position'
from: '.from-position'
to: '.to-position'
pensum: '.pensum-number'
duration: '#duration'
mon: '#mon'
tue: '#tue'
wed: '#wed'
thu: '#thu'
fri: '#fri'
sat: '#sat'
sun: '#sun'

show: ->
if not $('article#content #create-panel').length
$('article#content').prepend @render()
@bindUIElements()
@workloadChanged()
else
$('#create-panel').show()

hide: ->
$('#create-panel').hide()

render: ->
@template { }

submitPosition: (e) ->
e.preventDefault()
formData = @formData()
formData.created_at = new Date
formData.closed_at = new Date
formData.user_id = 83

position = new positionsApp.Models.Position formData

positionsApp.vent.trigger 'position:add', position

position.save()

checkboxToValue: (box) ->
if box.is ':checked' then 1 else 0

formData: ->
title: @ui.title.val()
description: @ui.description.val()
workload: parseFloat @ui.workload.val(), 10
from: new Date @ui.from.val()
to: new Date @ui.to.val()
duration: @ui.duration.val()
indefinite: @ui.indefinite.val()
weekdays:
Mon: @checkboxToValue @ui.mon
Tue: @checkboxToValue @ui.tue
Wed: @checkboxToValue @ui.wed
Thu: @checkboxToValue @ui.thu
Fri: @checkboxToValue @ui.fri
Sat: @checkboxToValue @ui.sat
Sun: @checkboxToValue @ui.sun

workloadChanged: ->
workload = parseFloat @ui.workload.val(), 10
@ui.pensum.html Helpers.calculatePensum workload

Loading

0 comments on commit de04249

Please sign in to comment.