-
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 #499 from crossroads/master
[Release] v0.18.1
- Loading branch information
Showing
60 changed files
with
1,524 additions
and
426 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
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,61 @@ | ||
import Ember from "ember"; | ||
import _ from "lodash"; | ||
import AsyncTasksMixin, { ERROR_STRATEGIES } from "../mixins/async_tasks"; | ||
|
||
export default Ember.Component.extend(AsyncTasksMixin, { | ||
messageService: Ember.inject.service(), | ||
store: Ember.inject.service(), | ||
|
||
async didReceiveAttrs() { | ||
const editMessage = this.get("messageService.editMessage"); | ||
const store = this.get("store"); | ||
const message = | ||
store.peekRecord("canned_response", editMessage.messageId) || | ||
store.createRecord("canned-response"); | ||
this.set("message", message); | ||
this.set("isEnglish", true); | ||
}, | ||
|
||
disableCreateEdit: Ember.computed( | ||
"message.nameEn", | ||
"message.contentEn", | ||
function() { | ||
return !(this.get("message.nameEn") && this.get("message.contentEn")); | ||
} | ||
), | ||
|
||
actions: { | ||
createCannedMessage() { | ||
this.runTask( | ||
this.get("message") | ||
.save() | ||
.then(() => this.set("messageService.isAddMessageVisible", false)) | ||
); | ||
}, | ||
|
||
closeOverlay() { | ||
this.set("messageService.isAddMessageVisible", false); | ||
this.set("messageService.editMessage.language", "en"); | ||
this.set("messageService.editMessage.messageId", ""); | ||
}, | ||
|
||
setLanguage(lang = "en") { | ||
this.set("isEnglish", lang == "en"); | ||
}, | ||
|
||
deleteMessage() { | ||
const store = this.get("store"); | ||
const message = store.peekRecord( | ||
"canned_response", | ||
this.get("message").id | ||
); | ||
this.runTask( | ||
message.destroyRecord().then(() => { | ||
store.unloadRecord(message); | ||
this.set("messageService.isAddMessageVisible", false); | ||
}), | ||
ERROR_STRATEGIES | ||
); | ||
} | ||
} | ||
}); |
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,20 @@ | ||
import Ember from "ember"; | ||
|
||
/** | ||
* @module Components/let-alias | ||
* @description Small helper component allowing to rename variables within the .hbs file | ||
* @example | ||
* | ||
* {{#let-alias model.someReallyLongPropertyName as |short| }} | ||
* <div> This is {{short}} </div> | ||
* <div> I can use {{short}} many times {{short}} </div> | ||
* <div> because it's very {{short}} </div | ||
* {{/let-alias}} | ||
*/ | ||
const AliasComponent = Ember.Component.extend(); | ||
|
||
AliasComponent.reopenClass({ | ||
positionalParams: ["value"] | ||
}); | ||
|
||
export default AliasComponent; |
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,67 @@ | ||
import Ember from "ember"; | ||
import _ from "lodash"; | ||
|
||
export default Ember.Component.extend({ | ||
messageService: Ember.inject.service(), | ||
store: Ember.inject.service(), | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.set("isSelected", true); | ||
}, | ||
|
||
onSearchTextChange: Ember.observer("searchText", function() { | ||
Ember.run.debounce(this, this.reloadResults, 500); | ||
}), | ||
|
||
refreshDisplayResult: Ember.observer( | ||
"messageService.isAddMessageVisible", | ||
function() { | ||
if (!this.get("messageService.isAddMessageVisible")) { | ||
this.reloadResults(); | ||
} | ||
} | ||
), | ||
|
||
didRender() { | ||
if (this.get("messageService.isProFormaMessageVisible")) { | ||
this.set("displayResults", true); | ||
} | ||
}, | ||
|
||
reloadResults() { | ||
this.set("displayResults", false); | ||
Ember.run.debounce(this, () => this.set("displayResults", true), 500); | ||
}, | ||
|
||
hasSearchText: Ember.computed("searchText", function() { | ||
return this.get("searchText") && this.get("searchText").trim().length; | ||
}), | ||
|
||
actions: { | ||
loadMoreCannedMessages() { | ||
const params = { | ||
searchText: this.get("searchText") | ||
}; | ||
return this.get("store").query("canned_response", params); | ||
}, | ||
|
||
addMessage() { | ||
this.set("messageService.isAddMessageVisible", true); | ||
}, | ||
|
||
closeOverlay() { | ||
this.set("messageService.isProFormaMessageVisible", false); | ||
}, | ||
|
||
editMessage(message, lang) { | ||
this.set("messageService.editMessage.messageId", message.id); | ||
this.set("messageService.editMessage.language", lang); | ||
this.send("addMessage"); | ||
}, | ||
|
||
cancel() { | ||
this.set("open", 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
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,59 @@ | ||
import config from "../config/environment"; | ||
|
||
export default Ember.Controller.extend({ | ||
cordova: Ember.inject.service(), | ||
subscriptions: Ember.inject.controller(), | ||
messageService: Ember.inject.service(), | ||
isMobileApp: config.cordova.enabled, | ||
config, | ||
|
||
app_id: config.APP.ANDROID_APP_ID, | ||
ios_app_id: config.APP.IOS_APP_ID, | ||
appTitle: config.APP.TITLE, | ||
bannerImage: config.APP.BANNER_IMAGE, | ||
|
||
initSubscriptions: Ember.on("init", function() { | ||
if (this.session.get("isLoggedIn")) { | ||
this.send("setSubscriptions"); | ||
} | ||
}), | ||
|
||
supportGCLink: Ember.computed("session.language", function() { | ||
return this.get("session.language") === "zh-tw" | ||
? "https://www.crossroads.org.hk/zh-hant/home/donate-funds/" | ||
: "https://www.crossroads.org.hk/home/donate-funds/"; | ||
}), | ||
|
||
appVersion: Ember.computed(function() { | ||
return config.cordova.enabled ? config.APP.VERSION : null; | ||
}), | ||
|
||
actions: { | ||
logMeOut() { | ||
this.session.clear(); // this should be first since it updates isLoggedIn status | ||
this.get("subscriptions").send("unwire"); | ||
this.get("subscriptions").send("unloadNotifications"); | ||
this.store.unloadAll(); | ||
var _this = this; | ||
config.APP.PRELOAD_TYPES.forEach(function(type) { | ||
_this.store.findAll(type); | ||
}); | ||
this.transitionToRoute("login"); | ||
}, | ||
|
||
logMeIn() { | ||
this.send("setSubscriptions"); | ||
}, | ||
|
||
setSubscriptions() { | ||
this.get("subscriptions").send("wire"); | ||
}, | ||
|
||
rateApp() { | ||
if (this.get("cordova").isIOS()) { | ||
this.set("app_id", this.get("ios_app_id")); | ||
} | ||
LaunchReview.launch(this.get("app_id")); | ||
} | ||
} | ||
}); |
Oops, something went wrong.