-
-
Save BramKaashoek/cdc217817aa394de21ef64eceaf6197f to your computer and use it in GitHub Desktop.
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
define(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout', 'promise', 'ojs/ojmodel'], | |
function (oj, ko, $) { | |
function MeetingsService() { | |
var meetingUrl = "http://localhost:3030/meetings"; | |
function parseMeeting(response) { | |
return { | |
_id: response['_id'], | |
title: response['title'], | |
startDate: response['startDate'], | |
endDate: response['endDate'], | |
location: response['location'], | |
description: response['description'], | |
owner: response['owner'] | |
} | |
}; | |
function parseSaveMeeting(response) { | |
return { | |
title: response['title'], | |
startDate: response['startDate'], | |
endDate: response['endDate'], | |
location: response['location'], | |
description: response['description'] | |
} | |
}; | |
function meetingModel() { | |
var Meeting = oj.Model.extend({ | |
urlRoot: meetingUrl, | |
parse: parseMeeting, | |
parseSave: parseSaveMeeting, | |
idAttribute: '_id' | |
}); | |
return new Meeting(); | |
}; | |
function meetingCollection() { | |
var Meetings = oj.Collection.extend({ | |
url: meetingUrl, | |
model: meetingModel(), | |
comparator: 'startDate' | |
}); | |
return new Meetings(); | |
}; | |
this.meetingsCol = meetingCollection(); | |
} | |
return new MeetingsService(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment