-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
595 additions
and
37 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,81 @@ | ||
import Ember from 'ember'; | ||
import FacilityBase from './base'; | ||
|
||
export default Ember.Controller.extend({ | ||
export default FacilityBase.extend({ | ||
userIsTrainer: true, | ||
userIdTrainerSet: false, | ||
actions:{ | ||
save:function(model){ | ||
var self = this; | ||
model.set('countryCode','US'); | ||
self.validate().then(function(){ | ||
model.save().then(function(){ | ||
var uid = self.get('session').get('currentUser').get('id'); | ||
// save the address | ||
self.store.findRecord('address',model.get('address').get('id')).then((address)=>{ | ||
address.set('parentId',model.get('id')); | ||
address.save(); | ||
// update user and save | ||
|
||
self.store.findRecord('user',uid).then((user)=>{ | ||
user.get('clients').pushObject(model); | ||
user.get('addresses').pushObject(address); | ||
user.save(); | ||
}); | ||
}); | ||
|
||
// update organization and save | ||
self.store.findRecord('organization',model.get('organizationId')).then((org)=>{ | ||
org.get('clients').pushObject(model); | ||
org.save(); | ||
|
||
model.get('invite').then((invite)=>{ | ||
console.log("inviteEmail:"+invite.get('email')); | ||
if(invite.get('email')){ | ||
invite.set('parentId',model.id); | ||
invite.set('organization',org); | ||
invite.set('name',model.get('name')); | ||
invite.save(); | ||
|
||
//TODO Send Invite Email | ||
|
||
invite.set('emailSent', true); | ||
invite.set('emailSentDate', new Date()); | ||
invite.save(); | ||
|
||
self.notifications.addNotification({ | ||
message: 'Invite Email Sent!', | ||
type: 'success', | ||
autoClear: true, | ||
}); | ||
|
||
|
||
} else { | ||
model.get('invite').then((invite)=>{ | ||
invite.destroyRecord(); | ||
}); | ||
} | ||
}); | ||
|
||
|
||
}); | ||
|
||
self.set('addSuccess', true); | ||
self.notifications.addNotification({ | ||
message: 'Client successfully added!', | ||
type: 'success', | ||
autoClear: true, | ||
}); | ||
|
||
|
||
|
||
self.transitionToRoute('dashboard.clients.index'); | ||
}).catch(function(err){ | ||
console.log("errors:"+err); | ||
}); | ||
}).catch(function(){ | ||
console.log('unepxected validation errors'); | ||
self.set('hasValidationErrors',true); | ||
}); | ||
}, | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Ember from 'ember'; | ||
import EmberValidations from 'ember-validations'; | ||
|
||
export default Ember.Controller.extend(EmberValidations, { | ||
validationModel: Ember.computed.alias('model'), | ||
validationModelAddress: Ember.computed.alias('model.address'), | ||
hasValidationErrors: false, | ||
addSuccess: false, | ||
userOrganizations: null, | ||
validations: { | ||
'validationModel.name': { | ||
presence: {message: " Name is required"}, | ||
}, | ||
'validationModel.organizationId':{ | ||
presence: {message: " Must select an organization"}, | ||
}, | ||
'validationModelAddress.name':{ | ||
presence: {message: " Address name is required"}, | ||
}, | ||
'validationModelAddress.line1':{ | ||
presence: {message: " Line 1 is required"}, | ||
}, | ||
'validationModelAddress.city':{ | ||
presence: {message: " City is required"}, | ||
}, | ||
'validationModelAddress.state':{ | ||
presence: {message: " State is required"}, | ||
}, | ||
'validationModelAddress.postCode':{ | ||
presence: {message: " Zip is required"}, | ||
} | ||
|
||
}, | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,75 @@ | ||
import Ember from 'ember'; | ||
import FacilityBase from './base'; | ||
|
||
export default Ember.Controller.extend({ | ||
}); | ||
export default FacilityBase.extend({ | ||
actions:{ | ||
save:function(model){ | ||
var self = this; | ||
model.set('countryCode','US'); | ||
self.validate().then(function(){ | ||
model.save().then(function(){ | ||
// save the address | ||
self.store.findRecord('address',model.get('address').get('id')).then((address)=>{ | ||
address.save(); | ||
}); | ||
|
||
var changed = model.changedAttributes(); | ||
|
||
self.store.findRecord('organization',model.get('organizationId')).then((org)=>{ | ||
|
||
if(changed['organizationId']){ | ||
// update previous organization and save | ||
self.store.findRecord('organization',changed['organizationId'][0]).then((previousOrg)=>{ | ||
previousOrg.get('clients').removeObject(model); | ||
previousOrg.save(); | ||
}); | ||
|
||
org.get('clients').pushObject(model); | ||
org.save(); | ||
} | ||
|
||
model.get('invite').then((invite)=>{ | ||
|
||
if(invite.get('email')){ | ||
invite.set('parentId',model.id); | ||
invite.set('organization',org); | ||
invite.set('name',model.get('name')); | ||
invite.save(); | ||
|
||
//TODO Send Invite Email | ||
|
||
if(invite.get('emailSent')===false) | ||
{ | ||
invite.set('emailSent', true); | ||
invite.set('emailSentDate', new Date()); | ||
invite.save(); | ||
|
||
self.notifications.addNotification({ | ||
message: 'Invite Email Sent!', | ||
type: 'success', | ||
autoClear: true, | ||
}); | ||
} | ||
} else { | ||
model.get('invite').then((invite)=>{ | ||
invite.destroyRecord(); | ||
}); | ||
} | ||
}); | ||
|
||
self.notifications.addNotification({ | ||
message: 'Client successfully saved!', | ||
type: 'success', | ||
autoClear: true, | ||
}); | ||
}); | ||
self.transitionToRoute('dashboard.clients.index'); | ||
}).catch(function(err){ | ||
console.log("errors:"+err); | ||
}); | ||
}).catch(function(){ | ||
console.log('unepxected validation errors'); | ||
self.set('hasValidationErrors',true); | ||
}); | ||
}, | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
actions:{ | ||
delete:function(model){ | ||
var self = this; | ||
var organizationId = model.get('organizationId'); | ||
model.destroyRecord().then(function(){ | ||
var uid = self.get('session').get('currentUser').get('id'); | ||
self.store.findRecord('user',uid).then((user)=>{ | ||
user.get('rates').removeObject(model); | ||
user.save(); | ||
}); | ||
|
||
self.get('store').findRecord('organization',organizationId).then((organization)=>{ | ||
organization.get('rates').removeObject(model); | ||
organization.save(); | ||
}); | ||
|
||
self.notifications.addNotification({ | ||
message: 'Rate successfully deleted!', | ||
type: 'warning', | ||
autoClear: true, | ||
}); | ||
|
||
}).catch(function(err){ | ||
// TODO | ||
console.log("errors:"+err); | ||
}); | ||
|
||
|
||
}, | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import FacilityBase from './base'; | ||
|
||
export default FacilityBase.extend({ | ||
actions:{ | ||
save:function(model){ | ||
var self = this; | ||
|
||
self.validate().then(function(){ | ||
model.save().then(function(){ | ||
var uid = self.get('session').get('currentUser').get('id'); | ||
// save the address | ||
self.store.findRecord('user',uid).then((user)=>{ | ||
user.get('rates').pushObject(model); | ||
user.save(); | ||
}); | ||
|
||
// update organization and save | ||
self.store.findRecord('organization',model.get('organizationId')).then((org)=>{ | ||
org.get('rates').pushObject(model); | ||
org.save(); | ||
}); | ||
|
||
self.set('addSuccess', true); | ||
self.notifications.addNotification({ | ||
message: 'Rate successfully added!', | ||
type: 'success', | ||
autoClear: true, | ||
}); | ||
self.transitionToRoute('dashboard.rates.index'); | ||
}).catch(function(err){ | ||
console.log("errors:"+err); | ||
}); | ||
}).catch(function(){ | ||
console.log('unepxected validation errors'); | ||
self.set('hasValidationErrors',true); | ||
}); | ||
}, | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Ember from 'ember'; | ||
import EmberValidations from 'ember-validations'; | ||
|
||
export default Ember.Controller.extend(EmberValidations, { | ||
validationModel: Ember.computed.alias('model'), | ||
hasValidationErrors: false, | ||
addSuccess: false, | ||
userOrganizations: null, | ||
validations: { | ||
'validationModel.name': { | ||
presence: {message: " Name is required"}, | ||
}, | ||
'validationModel.rate': { | ||
presence: {message: " Rate is required"}, | ||
}, | ||
'validationModel.organizationId':{ | ||
presence: {message: " Must select an organization"}, | ||
}, | ||
|
||
|
||
}, | ||
|
||
}); |
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
name: DS.attr('string'), | ||
rate: DS.belongsTo('rate',{async:true}), | ||
discount: DS.attr('number'), | ||
organizationId: DS.attr('string'), | ||
numberOfSessions : DS.attr('number'), | ||
owner: DS.attr('string'), | ||
createdDate: DS.attr('date', { | ||
defaultValue() { return new Date(); } | ||
}), | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
name: DS.attr('string'), | ||
rate: DS.attr('number'), | ||
organizationId: DS.attr('string'), | ||
image: DS.attr('string'), | ||
owner: DS.attr('string'), | ||
createdDate: DS.attr('date', { | ||
defaultValue() { return new Date(); } | ||
}), | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
name: DS.attr('string'), | ||
rate: DS.belongsTo('rate',{async:true}), | ||
package: DS.belongsTo('package',{async:true}), | ||
sessionDate: DS.attr('date'), | ||
organizationId: DS.attr('string'), | ||
trainer: DS.belongsTo('trainer', {async:true}), | ||
client: DS.belongsTo('client', {async:true}), | ||
facility: DS.belongsTo('facility', {async:true}), | ||
location: DS.attr('string'), | ||
owner: DS.attr('string'), | ||
createdDate: DS.attr('date', { | ||
defaultValue() { return new Date(); } | ||
}), | ||
}); |
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
Oops, something went wrong.