Skip to content

Commit

Permalink
learning material files now persisting through refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoolestguy committed Aug 5, 2015
1 parent 92882b3 commit fb6b8e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 1 addition & 5 deletions app/components/detail-learning-materials.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default Ember.Component.extend({
addNewLearningMaterial: function(type){
var self = this;
if(type === 'file' || type === 'citation' || type === 'link'){
this.get('learningMaterialStatuses').then(function(statuses){
self.get('learningMaterialStatuses').then(function(statuses){
self.get('learningMaterialUserRoles').then(function(roles){
//default the status to Final if that status exists
var defaultStatus = statuses.find(function(status){
Expand All @@ -157,14 +157,12 @@ export default Ember.Component.extend({
self.get('newLearningMaterials').removeObject(lm);
if(this.get('isCourse')){
subjectLm = this.get('store').createRecord('course-learning-material', {
learningMaterial: lm,
course: this.get('subject')
});
lmCollectionType = 'courseLearningMaterials';
}
if(this.get('isSession')){
subjectLm = this.get('store').createRecord('session-learning-material', {
learningMaterial: lm,
session: this.get('subject')
});
lmCollectionType = 'sessionLearningMaterials';
Expand All @@ -178,8 +176,6 @@ export default Ember.Component.extend({

self.get('subject.learningMaterials').then(function(lms){
lms.addObject(savedSubjectLm);
lms.save();
lm.save();
});
});
});
Expand Down
13 changes: 12 additions & 1 deletion app/models/learning-material.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import DS from 'ember-data';
import Ember from 'ember';

export default DS.Model.extend({
title: DS.attr('string'),
description: DS.attr('string'),
uploadDate: DS.attr('date'),
originalAuthor: DS.attr('string'),
type: DS.attr('string'),
type: Ember.computed('filename', 'citation', 'link', function(){
if (this.get('filename')) {
return 'file';
}
if (this.get('citation')) {
return 'citation';
}
if (this.get('link')) {
return 'link';
}
}),
token: DS.attr('string'),
path: DS.attr('string'),
copyrightPermission: DS.attr('boolean'),
Expand Down

0 comments on commit fb6b8e8

Please sign in to comment.