ember.js

Chained promises and preserving `this`

我只是一个虾纸丫 提交于 2020-02-02 06:03:14
问题 I have a click handler that needs to make several async calls, one after another. I've chosen to structure these calls using promises (RSVP, to be precise). Below, you can see the clickA handler, inside the controller (it's an Ember app, but the problem is more general, I think): App.SomeController = Ember.Controller.extend({ actions: { clickA: function() { var self = this; function startProcess() { return makeAjaxCall(url, { 'foo': self.get('foo') }); } function continueProcess(response) {

Ember js @each one level deep but I have a two deep level relationship [duplicate]

痴心易碎 提交于 2020-02-02 05:37:05
问题 This question already has answers here : Ember.js 2.3 implement @each.property observer on a HasMany relationship? (2 answers) Closed 3 years ago . I have to access a property that is two level's deep on my controller, but the [] only can access one level deep via the emberjs guide. model(params) { params.paramMapping = { page: "page", perPage: "per_page", total_pages: "pages" }; return this.findPaged('contractf', params); }, setupController(controller, model) { model.forEach(function(item) {

How to integrate Ember.JS and Keycloak SSO system

爷,独闯天下 提交于 2020-01-25 13:03:43
问题 My question is quite simple : does anybody know how to integrate Ember.JS and Keycloak (the SSO system) ? We currently face a problem using the Keycloak JS Bower library (https://github.com/keycloak/keycloak-js-bower) to redirect users to Keycloak own login page, and to generally integrate Ember.JS with Keycloak. Our problems are : Double page reload on page reloading, 401 unauthorized HTTP code on login to the Ember App. Thanks for your (precious) support. 回答1: You can use script JS: Check

How to integrate Ember.JS and Keycloak SSO system

旧时模样 提交于 2020-01-25 13:03:28
问题 My question is quite simple : does anybody know how to integrate Ember.JS and Keycloak (the SSO system) ? We currently face a problem using the Keycloak JS Bower library (https://github.com/keycloak/keycloak-js-bower) to redirect users to Keycloak own login page, and to generally integrate Ember.JS with Keycloak. Our problems are : Double page reload on page reloading, 401 unauthorized HTTP code on login to the Ember App. Thanks for your (precious) support. 回答1: You can use script JS: Check

Ember.js embedded records don't work

烈酒焚心 提交于 2020-01-25 12:44:45
问题 I have a json like { "meta":{ "per":20, "page":1, "total":2 }, "users":[ { "id":119506, "first_name":"erglk", "last_name":"wfe", "email":"bent@exemple.com", "groups":[ { "id":5282, "name":"test" }, { "id":8880, "name":"everybody" } ] }, { "id":119507, "first_name":"eriglk", "last_name":"wife", "email":"benit@exemple.com", "groups":[ { "id":5284, "name":"testf" }, { "id":8880, "name":"everybody" } ] } ] } For the moment no problem to access the user but I have some difficulties to access the

Ember alternative to query params with service

主宰稳场 提交于 2020-01-25 07:47:10
问题 So I have a route with this model: model() { var self = this; return RSVP.hash({ comptes : this.get('store').findAll('compte'), contrats: this.get('store').findAll('contrat').then(function(contrats) { return contrats.filterBy("contrat_fk.id", self.get('currentContract.contrat.id')); }), }) } My goal is to filter the model contrat with the value provided by my service currentContract. It works fine when the page is reloaded, but when I change the route and comeback to this route, the model

PDFJS: error on Text rendering for the PDF

天大地大妈咪最大 提交于 2020-01-25 06:59:25
问题 Recently the PDF rendering get a messed up text layer where text gets duplicated with the grey colored overlay. No idea about how to fix it as when i remove textLayerFactory: new pdfjsViewer.DefaultTextLayerFactory() it works fine. but need this as if not is render as images which takes a lot of time for large documents Im using pdfjsViewer.PDFPageView my code as follows getPdf() { var pdfDocument; if ( this._state !== 'inDOM' ) return false; pdfjsLib.disableRange = true; pdfjsLib

Unit testing ember-concurrency tasks and yields

匆匆过客 提交于 2020-01-25 04:35:07
问题 We have a lot of code in our project that isn't covered because of ember concurrency tasks. Is there a straightforward way of unit testing an controller that contains something like the following: export default Controller.extend({ updateProject: task(function* () { this.model.project.set('title', this.newTitle); try { yield this.model.project.save(); this.growl.success('success'); } catch (error) { this.growl.alert(error.message); } }) });``` 回答1: You can unit test a task like that by

Ember invoking closure action

有些话、适合烂在心里 提交于 2020-01-25 00:21:11
问题 In Ember JS, say I have a component defined as below (HBS/JS) parent.hbs {{longclaw-sword attack=(action swing)}} app/components/longclaw-sword.js export default Ember.Component.extend({ click() { this.attack(); } }); Is there any difference between calling the closure action using this.attack() V/s this.attr.attack() ? In which cases is "attr" used ? Can it be used for reference to normal properties OR is it only for actions ? 回答1: attr is kinda unofficially deprecated afaik. in the upcoming

Mocking HTTP requests in ember-qunit

安稳与你 提交于 2020-01-24 22:06:03
问题 In an ember-cli app, testing is done using ember-qunit. I would like to mock HTTP requests, but have not been able to find a recommended way of doing this in the documentation. I have found this thread which discusses this, but it appears to be out of date (for ember-cli anyway). How do you mock HTTP requests? 回答1: This is how I mock HTTP requests. One improvement could be done by encapsulating mockjax with helper like: function stubEndpointForHttpRequest(url, json) { $.mockjax({ url: url,