lundi 31 octobre 2022

emberjs, how to bind method from controller to service?

I have big emberjs application and I need to start using ember service a little bit more. so I have a method in my controller that I want it to be available as a service in all the modals, and components where I inject the service.

but its not working, and with no error... si is this a good way to do this? why its not wotking?

so my method in the controller is:

openModalPrices () {
        //method in controller
    },

the service has another method:

openModalPricesFromService () {
        //method in service
    },

and in my INIT in the Controller I am binding like this:

init: function() {
   this._super(...arguments);
   this.get('priceService').openModalPricesFromService(this.openModalPrices.bind(this));
}



jeudi 27 octobre 2022

Ember - webpack returned errors to ember-auto-import

I tried switching from NPM to Yarn on a project built with Ember.js version 3.28. All the required dependencies seem installed correctly.

When I try to run or build the app with Ember CLI I get the following error:

Build Error (WebpackBundler)

webpack returned errors to ember-auto-import

Stack Trace and Error Report: /tmp/error.dump.10ee9f3c2877596ebfbf63516378bbee.log

I tried building and running multiple times and reinstalling dependencies.

I'm on macOS Monterey 12.6 M1 Pro.

Node version 18.10.

The same process when the dependencies are installed with NPM works fine.




mercredi 19 octobre 2022

Micro frontend using module federation with EmberJS

We would like to know the feasibility of WebPack module federation build system in Ember JS App for invoking federated code from Ember App to connect with other front end codebase developed in React JS or other SPA.

Basically, we would to implement Micro-frontend using module federation approach where multiple frontends are already developed on Ember js and reactJS. In addition to that, our usecase depends on deeplinking, datasharing between these microfrontends.

Based on our understanding EmberJS by default uses broccoli and doesn't have support for webpack, Which is essential for Module Federation approach to accomplish Micro Frontend.

Looking forward for some pointers here




mardi 18 octobre 2022

Why this.$ is not available in Ember Controller

Ember.$ is available in the controller whereas this.$ is not. But it is available in components. Ember.$(".loading-splash").hide(); is working on controller where as this.$(".loading-splash").hide(); is throwing an exception "this.$() is unavailable"




dimanche 16 octobre 2022

Can I create record in Ember without the record name

My Backend Rails API consumes POST requests in the form of

{
    "name": "Mark White",
    "email" : "mark@xyz.com"
}

Have tried this in Postman and this creates a record successfully.

In my ember frontend, Im using the following code to create a new record, from a form input:

app/routes/addUser.js

import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
        addUser(){
            let formData = {
                "name": this.controller.get('name'),
                "poster_url": this.controller.get('email')
            };

            let newUser = this.store.createRecord('user',formData);
            newUser.save();
       }
  }

});

which generates the request as

{
  "user": {
    "name": "Mark White",
    "email" : "mark@xyz.com"
  }
}

which my backend is not prepared to handle and throws an error.

Any way I can quickly conform to the json format that works for me in Postman.




vendredi 7 octobre 2022

Best practice in integrating JS framework single-page-app into Spring Boot?

I am looking for your thoughts as an experienced Spring Boot engineer that have integrated Vue.js/React/Angular/Ember etc as a Single Page App into Spring Boot.

What is the best way to integrate the SPA to Spring Boot framework?

I have previously implemented this as a single project with a single Spring Thymeleaf template in resource where the bundled js would be linked after NPM builds.

It worked, and it worked well, but there might be more streamlined ways out there. There were a lot of manual setup get it work, and I am wondering if any Maven/Gradle enhancements in this area.




dimanche 2 octobre 2022

How can i dynamically add an Input select element on click of a button in ember

Am creating an ember application where am in need of dynamicaly adding a select element which will have options fetched from a server. so the select elements look like this.enter image description here And instead of having all dropdown boxes predefined i need to add them dynamicaly like on a click of a button like( + add more). and each of those drop down boxes should contain the datas that is fetched from the server. my .hbs for the current drop down page is..

map.hbs

<center><h4>Map</h4></center>
<container class = "cond">

    <select class = "sel">
        
        <option value = ></option>
        
        
    </select><br>

I tried ember-dynamic-fields but its depracted and I couldnt able to use it.. and all other solutions on web or for ember way older versions.. nothing works on ember 4.6 so could anyone helpout?