-
Notifications
You must be signed in to change notification settings - Fork 4
GCW-3167 User mentions #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bharat619
wants to merge
8
commits into
master
Choose a base branch
from
GCW-3167-user-mentions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c747ce9
adding polymorphic relation changes
9e9250c
GCW-3167 initial commit
88756a3
GCW-3167 adding parsed message body
5b2c45d
GCW-3167 adding parser changes
100383f
GCW-3167 correcting node version
b4453cc
GCW-3167 adding escape expressions
8a6913d
GCW-3167 reverting messages computed property
a22626a
GCW-3167 updating style
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -13,12 +13,18 @@ export default Ember.Controller.extend({ | |
| sortedElements: Ember.computed.sort("messagesAndVersions", "sortProperties"), | ||
| isItemThread: Ember.computed.notEmpty("item"), | ||
|
|
||
| autoMarkAsRead: Ember.on('init', | ||
| Ember.observer('isActive', 'messages.[]', '[email protected]', function() { | ||
| if (this.get('isActive')) { | ||
| Ember.run.debounce(this, this.markConversationAsRead, 1500); | ||
| autoMarkAsRead: Ember.on( | ||
| "init", | ||
| Ember.observer( | ||
| "isActive", | ||
| "messages.[]", | ||
| "[email protected]", | ||
| function() { | ||
| if (this.get("isActive")) { | ||
| Ember.run.debounce(this, this.markConversationAsRead, 1500); | ||
| } | ||
| } | ||
| }) | ||
| ) | ||
| ), | ||
|
|
||
| disabled: Ember.computed("offer.isCancelled", "item.isDraft", function() { | ||
|
|
@@ -35,9 +41,9 @@ export default Ember.Controller.extend({ | |
|
|
||
| messages: Ember.computed("allMessages.[]", "offer", "item", function() { | ||
| var messages = this.get("allMessages"); | ||
| messages = this.get("isItemThread") ? | ||
| messages.filterBy("itemId", this.get("item.id")) : | ||
| messages | ||
| messages = this.get("isItemThread") | ||
| ? messages.filterBy("itemId", this.get("item.id")) | ||
| : messages | ||
| .filterBy("offerId", this.get("offer.id")) | ||
| .filterBy("item", null); | ||
| return messages.filter(m => { | ||
|
|
@@ -139,14 +145,30 @@ export default Ember.Controller.extend({ | |
| }, | ||
|
|
||
| actions: { | ||
| setMessageContext: function(message) { | ||
| this.set("body", message.parsedText); | ||
| this.set("displayText", message.displayText); | ||
| }, | ||
|
|
||
| sendMessage() { | ||
| // To hide soft keyboard | ||
| Ember.$("textarea").trigger("blur"); | ||
|
|
||
| this.set("inProgress", true); | ||
| var values = this.getProperties("body", "offer", "item", "isPrivate"); | ||
| values.itemId = this.get("item.id"); | ||
| values.offerId = this.get("offer.id"); | ||
| var values = this.getProperties("offer", "item", "isPrivate"); | ||
| values.body = this.get("body"); | ||
| values.body = Ember.Handlebars.Utils.escapeExpression(values.body || ""); | ||
| values.body = values.body.replace(/(\r\n|\n|\r)/gm, "<br>"); | ||
| values.parsedBody = this.get("displayText"); | ||
| const itemId = this.get("item.id"); | ||
| const offerId = this.get("offer.id"); | ||
| if (itemId) { | ||
| values.messageableType = "Item"; | ||
| values.messageableId = itemId; | ||
| } else { | ||
| values.messageableType = "Offer"; | ||
| values.messageableId = offerId; | ||
| } | ||
| values.createdAt = new Date(); | ||
| values.sender = this.store.peekRecord( | ||
| "user", | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,12 +1,7 @@ | ||
| import Ember from "ember"; | ||
|
|
||
| export default Ember.Helper.helper(function(value) { | ||
| var text; | ||
| if(/<[a-z][\s\S]*>/i.test(value)) { | ||
| text = value; | ||
| } else { | ||
| text = Ember.Handlebars.Utils.escapeExpression(value); | ||
| text = text.replace(/(\r\n|\n|\r)/gm, '<br>'); | ||
| } | ||
| return new Ember.Handlebars.SafeString(text); | ||
| value = new Ember.Handlebars.SafeString(value[0] || "").string; | ||
| value = value.replace(/(\r\n|\n|\r)/gm, "<br>"); | ||
| return new Ember.String.htmlSafe(value); | ||
| }); |
This file contains hidden or 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 hidden or 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,14 +1,49 @@ | ||
| import { ActiveModelSerializer } from 'active-model-adapter'; | ||
| import { ActiveModelSerializer } from "active-model-adapter"; | ||
| import _ from "npm:lodash"; | ||
|
|
||
| // Polymorphic associations are not supported in ember-data beta version: | ||
| // refer: https://github.com/emberjs/data/issues/1574 | ||
|
|
||
| export default ActiveModelSerializer.extend({ | ||
| function normalize(payload) { | ||
| const key = | ||
| (payload.hasOwnProperty("messages") && "messages") || | ||
| (payload.hasOwnProperty("message") && "message"); | ||
| if (key) { | ||
| const messages = Array.isArray(payload[key]) | ||
| ? payload[key] | ||
| : Array(payload[key]); | ||
| messages.forEach(m => { | ||
| m[`${m.messageable_type.toLowerCase()}`] = m.messageable_id; | ||
| }); | ||
| } | ||
|
|
||
| const messages = _.flatten([payload.messages, payload.message]).filter( | ||
| _.identity | ||
| ); | ||
|
|
||
| _.each(messages, m => { | ||
| m[`${m.messageable_type.toLowerCase()}`] = m.messageable_id; | ||
|
|
||
| if (typeof m.lookup === "object") { | ||
| m.lookup = JSON.stringify(m.lookup); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| export default ActiveModelSerializer.extend({ | ||
| keyForAttribute: function(attr, method) { | ||
| if (attr === "addressable") { | ||
| return "addressable_id"; | ||
| } | ||
| return this._super(attr, method); | ||
| }, | ||
| normalizeResponse(store, primaryModelClass, payload, id, requestType) { | ||
| normalize(payload); | ||
| return this._super(...arguments); | ||
| }, | ||
|
|
||
| pushPayload(store, payload) { | ||
| normalize(payload); | ||
| return this._super(...arguments); | ||
| } | ||
| }); |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,6 +2,10 @@ | |
| display: block; | ||
| } | ||
|
|
||
| .tribute-container { | ||
| margin-top: 1rem; | ||
| } | ||
|
|
||
| #messageBox { | ||
| display: block; | ||
| opacity: 1; | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax: better to use
if { } else {}for multi-line statements. Ternary is useful for single line.cc @patrixr for an opinion