-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #480 from crossroads/master
[Release] Admin v0.17.9
- Loading branch information
Showing
49 changed files
with
1,457 additions
and
92 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Ember from "ember"; | ||
import DS from "ember-data"; | ||
import config from "../config/environment"; | ||
|
||
export default DS.JSONAPIAdapter.extend({ | ||
namespace: config.APP.NAMESPACE_V2, | ||
host: config.APP.API_HOST_URL, | ||
session: Ember.inject.service(), | ||
|
||
headers: Ember.computed("session.authToken", function() { | ||
return { | ||
Authorization: `Bearer ${this.get("session.authToken")}`, | ||
"Accept-Language": this.get("session.language"), | ||
"X-GOODCITY-APP-NAME": config.APP.NAME, | ||
"X-GOODCITY-APP-VERSION": config.APP.VERSION, | ||
"X-GOODCITY-APP-SHA": config.APP.SHA, | ||
"X-GOODCITY-APP-SHARED-SHA": config.APP.SHARED_SHA | ||
}; | ||
}), | ||
|
||
updateRecord(store, type, snapshot) { | ||
var data = {}; | ||
var serializer = store.serializerFor(type.modelName); | ||
|
||
serializer.serializeIntoHash(data, type, snapshot, { includeId: true }); | ||
|
||
var id = snapshot.id; | ||
var url = this.buildURL(type.modelName, id, snapshot, "updateRecord"); | ||
|
||
return this.ajax(url, "PUT", { data }); | ||
} | ||
}); |
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 |
---|---|---|
|
@@ -39,17 +39,40 @@ export default Ember.Controller.extend({ | |
return this.store.peekAll("message"); | ||
}), | ||
|
||
messages: Ember.computed("allMessages.[]", "offer", "item", function() { | ||
var messages = this.get("allMessages"); | ||
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 => { | ||
return Boolean(m.get("isPrivate")) === this.get("isPrivate"); | ||
}); | ||
}), | ||
messages: Ember.computed( | ||
"allMessages.[]", | ||
"[email protected]", | ||
"offer", | ||
"item", | ||
"isPrivate", | ||
"recipientId", | ||
function() { | ||
var messages = this.get("allMessages"); | ||
messages = this.get("isItemThread") | ||
? messages.filterBy("itemId", this.get("item.id")) | ||
: messages | ||
.filterBy("offerId", this.get("offer.id")) | ||
.filterBy("item", null); | ||
|
||
// For a public chat with no recipient, we default to the donor | ||
let recipientId = | ||
this.get("recipientId") || | ||
(this.get("isPrivate") ? null : this.get("offer.createdById")); | ||
|
||
if (recipientId) { | ||
messages = messages.filter(m => { | ||
return ( | ||
m.get("recipientId") === recipientId || | ||
m.get("senderId") === recipientId | ||
); | ||
}); | ||
} | ||
|
||
return messages.filter(m => { | ||
return Boolean(m.get("isPrivate")) === this.get("isPrivate"); | ||
}); | ||
} | ||
), | ||
|
||
messagesAndVersions: Ember.computed( | ||
"messages.[]", | ||
|
@@ -163,6 +186,12 @@ export default Ember.Controller.extend({ | |
"user", | ||
this.get("session.currentUser.id") | ||
); | ||
|
||
if (!this.get("isPrivate")) { | ||
values.recipientId = | ||
this.get("recipientId") || this.get("offer.createdById"); | ||
} | ||
|
||
this.get("messageLinkConvertor").convert(values); | ||
var message = this.store.createRecord("message", values); | ||
message | ||
|
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 |
---|---|---|
|
@@ -13,6 +13,45 @@ export default Ember.Controller.extend(AsyncTasksMixin, { | |
displayCompleteReviewPopup: false, | ||
displayCompleteReceivePopup: false, | ||
|
||
allShareables: Ember.computed(function() { | ||
return this.get("store").peekAll("shareable"); | ||
}), | ||
|
||
allMessages: Ember.computed(function() { | ||
return this.get("store").peekAll("message"); | ||
}), | ||
|
||
offerShareable: Ember.computed( | ||
"offer.id", | ||
"allShareables.length", | ||
"allShareables.[]", | ||
"allShareables.@each.{id,active,publicUid}", | ||
function() { | ||
return this.get("allShareables").find(sh => { | ||
return ( | ||
sh.get("resourceType") == "Offer" && | ||
sh.get("resourceId") == this.get("offer.id") && | ||
sh.get("active") | ||
); | ||
}); | ||
} | ||
), | ||
|
||
unreadCharityMessages: Ember.computed( | ||
"offer.id", | ||
"allMessages.[]", | ||
"allMessages.length", | ||
"[email protected]", | ||
function() { | ||
return this.get("allMessages") | ||
.filterBy("isCharityConversation") | ||
.filterBy("isUnread") | ||
.filterBy("offerId", this.get("offer.id")); | ||
} | ||
), | ||
|
||
isShared: Ember.computed.alias("offerShareable"), | ||
|
||
displayOfferOptions: Ember.computed({ | ||
get: function() { | ||
return false; | ||
|
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 |
---|---|---|
|
@@ -7,6 +7,28 @@ export default Ember.Controller.extend({ | |
offer: Ember.computed.alias("model"), | ||
reviewOffer: Ember.inject.controller(), | ||
|
||
lastMessage: Ember.computed( | ||
"offer.messages", | ||
"offer.messages.[]", | ||
function() { | ||
return this.get("offer.messages") | ||
.filter(m => !m.get("isCharityConversation")) | ||
.sortBy("createdAt") | ||
.get("lastObject"); | ||
} | ||
), | ||
|
||
unreadOfferMessagesCount: Ember.computed( | ||
"offer.messages", | ||
"offer.messages.[]", | ||
function() { | ||
return this.get("offer.messages") | ||
.filter(m => !m.get("isCharityConversation")) | ||
.filterBy("isUnread") | ||
.get("length"); | ||
} | ||
), | ||
|
||
offerAndItems: Ember.computed("[email protected]", function() { | ||
// avoid deleted-items which are not persisted yet. | ||
var elements = this.get("items") | ||
|
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,11 @@ | ||
import Ember from "ember"; | ||
import AsyncTasksMixin from "../../mixins/async_tasks"; | ||
|
||
export default Ember.Controller.extend(AsyncTasksMixin, { | ||
store: Ember.inject.service(), | ||
offerService: Ember.inject.service(), | ||
parentController: Ember.inject.controller("review_offer"), | ||
offer: Ember.computed.alias("parentController.offer"), | ||
isShared: Ember.computed.alias("parentController.isShared"), | ||
offerShareable: Ember.computed.alias("parentController.offerShareable") | ||
}); |
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,11 @@ | ||
import MessagesBaseController from "goodcity/controllers/message_base_controller"; | ||
|
||
export default MessagesBaseController.extend({ | ||
displayCannedMessages: true, | ||
|
||
actions: { | ||
leave() { | ||
this.replaceRoute("review_offer.share"); | ||
} | ||
} | ||
}); |
Oops, something went wrong.