-
Notifications
You must be signed in to change notification settings - Fork 78
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
98 changed files
with
2,463 additions
and
484 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
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,10 @@ | ||
import Component from '@ember/component'; | ||
import { empty } from '@ember/object/computed'; | ||
|
||
export default Component.extend({ | ||
classNames: ['conversation-composer'], | ||
|
||
body: null, | ||
|
||
submitDisabled: empty('body') | ||
}); |
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,4 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
}); |
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,26 @@ | ||
import Component from '@ember/component'; | ||
import { computed, get } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Component.extend({ | ||
classNames: ['conversation-part'], | ||
classNameBindings: ['isSelf:conversation-part--is-self'], | ||
|
||
author: null, | ||
body: null, | ||
readAt: null, | ||
sentAt: null, | ||
|
||
currentUser: service(), | ||
|
||
user: alias('currentUser.user'), | ||
|
||
avatarTooltipSide: computed('isSelf', function() { | ||
return get(this, 'isSelf') ? 'right' : 'left'; | ||
}), | ||
|
||
isSelf: computed('author', 'user', function() { | ||
return get(this, 'author.id') === get(this, 'user.id'); | ||
}) | ||
}); |
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 Component from '@ember/component'; | ||
import { run } from '@ember/runloop'; | ||
|
||
export default Component.extend({ | ||
classNames: ['conversation-thread'], | ||
|
||
_setup: (function() { | ||
this.scrollBottomAfterRender(); | ||
}).on('didInsertElement'), | ||
|
||
didUpdateAttrs() { | ||
this.scrollBottomAfterRender(); | ||
}, | ||
|
||
scrollBottom() { | ||
let [thread] = this.$(); | ||
thread.scrollTop = thread.scrollHeight; | ||
}, | ||
|
||
scrollBottomAfterRender() { | ||
run.scheduleOnce('afterRender', this, 'scrollBottom'); | ||
} | ||
}); |
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,74 @@ | ||
import Component from '@ember/component'; | ||
import { get, set } from '@ember/object'; | ||
import { and, not, notEmpty } from '@ember/object/computed'; | ||
import { inject as service } from '@ember/service'; | ||
import RSVP from 'rsvp'; | ||
|
||
const SAVE_SUCCESS = 'Your message is queued to send.'; | ||
|
||
export default Component.extend({ | ||
classNames: ['new-conversation-modal-container'], | ||
|
||
showModal: false, | ||
|
||
initiatedBy: null, | ||
message: null, | ||
project: null, | ||
user: null, | ||
|
||
currentUser: service(), | ||
flashMessages: service(), | ||
store: service(), | ||
|
||
isBodyPresent: notEmpty('message.body'), | ||
isSubjectPresent: notEmpty('message.subject'), | ||
submitDisabled: not('submitEnabled'), | ||
submitEnabled: and('isBodyPresent', 'isSubjectPresent'), | ||
|
||
createConversation() { | ||
let store = get(this, 'store'); | ||
let currentUser = get(this, 'currentUser.user'); | ||
let project = get(this, 'project'); | ||
let user = get(this, 'user'); | ||
|
||
let message = store.createRecord('message', { | ||
author: currentUser, | ||
initiatedBy: 'admin', | ||
project | ||
}); | ||
|
||
let conversation = store.createRecord('conversation', { user }); | ||
|
||
get(message, 'conversations').pushObject(conversation); | ||
|
||
set(this, 'message', message); | ||
}, | ||
|
||
discardConversation() { | ||
let confirmed = window.confirm('You will lose any unsaved information if you close. Are you sure?'); | ||
if (confirmed) { | ||
let message = get(this, 'message'); | ||
get(message, 'conversations.firstObject').destroyRecord(); | ||
message.destroyRecord(); | ||
} else { | ||
// Stop the pipe by rejecting | ||
return RSVP.reject(); | ||
} | ||
}, | ||
|
||
actions: { | ||
send(message) { | ||
// Since it's created without an ID, the store will not detect the | ||
// association was saved and will keep it around. | ||
// We need to store a reference to it, so we can unload it on save | ||
let unsavedConversation = get(message, 'conversations.firstObject'); | ||
|
||
let onSaved = () => { | ||
get(this, 'flashMessages').clearMessages().success(SAVE_SUCCESS); | ||
get(this, 'store').unloadRecord(unsavedConversation); | ||
}; | ||
|
||
return message.save().then(onSaved); | ||
} | ||
} | ||
}); |
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,5 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
classNames: ['conversation-details'] | ||
}); |
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
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,4 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default Controller.extend({ | ||
}); |
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,20 @@ | ||
import Controller from '@ember/controller'; | ||
import { get } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Controller.extend({ | ||
currentUser: service(), | ||
|
||
conversation: alias('model'), | ||
user: alias('currentUser.user'), | ||
|
||
send(body) { | ||
let conversation = get(this, 'conversation'); | ||
let store = get(this, 'store'); | ||
let user = get(this, 'user'); | ||
|
||
let params = { author: user, body, conversation }; | ||
return store.createRecord('conversation-part', params).save(); | ||
} | ||
}); |
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 Model from 'ember-data/model'; | ||
import attr from 'ember-data/attr'; | ||
import { belongsTo } from 'ember-data/relationships'; | ||
|
||
export default Model.extend({ | ||
body: attr(), | ||
insertedAt: attr(), | ||
readAt: attr(), | ||
updatedAt: attr(), | ||
|
||
author: belongsTo('user', { async: true }), | ||
conversation: belongsTo('conversation', { async: 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,14 @@ | ||
import Model from 'ember-data/model'; | ||
import attr from 'ember-data/attr'; | ||
import { belongsTo, hasMany } from 'ember-data/relationships'; | ||
|
||
export default Model.extend({ | ||
insertedAt: attr(), | ||
readAt: attr(), | ||
status: attr(), | ||
updatedAt: attr(), | ||
|
||
conversationParts: hasMany('conversation-part', { async: true }), | ||
message: belongsTo('message', { async: true }), | ||
user: belongsTo('user', { async: 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,16 @@ | ||
import Model from 'ember-data/model'; | ||
import attr from 'ember-data/attr'; | ||
import { belongsTo, hasMany } from 'ember-data/relationships'; | ||
|
||
export default Model.extend({ | ||
body: attr(), | ||
initiatedBy: attr(), | ||
insertedAt: attr(), | ||
subject: attr(), | ||
updatedAt: attr(), | ||
|
||
author: belongsTo('user', { async: true }), | ||
project: belongsTo('project', { async: true }), | ||
|
||
conversations: hasMany('conversation', { aync: true }) | ||
}); |
Oops, something went wrong.