jeudi 20 avril 2023

my data from different adapters is stored in a single model how do i store them in different models

Ember Data: cli 4.12

I have created 2 modles user and repo and 2 adapters with same name user and repo also 2 serializers with same names.

I am calling store.findAll 2 times in a single route's model hook for both repo and user and returning the data.

when I check ember data in ember inspector I only see one model name ie user with repo data appended at bottom for same attribute names and undefined for others.

I want to know how to set models for different calls.

I dont have any code available to paste right now ask me if you dont understand this query, thank you.

i tried asking chatGPT turns out its not great for ember framework and keeps givng me weired codes probably of older cli and new ones mixed




mercredi 12 avril 2023

caught TypeError: requireNode is not a function at window.require

''' ( function (win) => { const { requireNode, require: requireAMD } = win; if (requireAMD) { win.require = (...args) => { try { return requireAMD(...args); } catch(error) { if (error.toString().includes('Error: Could not find module')) { return requireNode(...args); } console.error(error); } }; Object.assign(win.require, requireNode, requireAMD); } else {win.require = requireNode;` } })(window); '''

Facing error for requireNode as 'requireNode is not defined' in catch block return requireNode(...args);.




lundi 10 avril 2023

How to implement infinite scroll in columns?

Here I have a work scenario where I need to add columns based on Dates and granularities (last 48 hrs - 15 mins).

In this case, I need to create - 2 Columns (eg- 10/04/2023 and 09/04/2023) and 192 Children columns (96 children each (15min x 4 x 24))

So all the above 192 columns will get created dynamically based on user selection.

So here our problem comes into the picture while creating 192 columns at once definitely my screen will get freeze for a while.

To make it efficient I want to implement infinite scrollable columns so that it doesn't need to render a large number of columns at once.

Any suggestions will be appreciated!!




dimanche 2 avril 2023

Nothing is getting displayed on webpage while using ember.js

I am building a simple web application using ember.js ,but in the webpage ,nothing is displayed ,in the console the following error is being displayed.I am using mirage as the back end

rsvp.js:26 Uncaught TypeError: Cannot read properties of undefined (reading 'sentence')
    at Temp.title (post.js:10:1)
    at eval (mirage-esm.js:485:24)
    at Array.forEach (<anonymous>)
    at sortAttrs (mirage-esm.js:481:22)
    at Factory.build (mirage-esm.js:388:16)
    at EmberServer.build (mirage-esm.js:7325:24)
    at EmberServer.create (mirage-esm.js:7397:30)
    at EmberServer.createList (mirage-esm.js:7466:31)
    at Object._default [as default] (default.js:9:1)
    at EmberServer.config (mirage-esm.js:7152:37

I am adding some files code here for the understanding , application.hbs


<div class ="jumbo">
<h2 id="title">
    My ember blog
    
</h2>
</div>


posts.js under templates



<ul>
  
    <li>
      
    </li>
  
</ul>

post.js under model folder in app

import Model, { attr } from '@ember-data/model';

export default class PostModel extends Model {
  @attr title;
  @attr body;
  @attr('date') publishedAt;
}

posts under routes in app folder

import Route from '@ember/routing/route';

export default class PostsRoute extends Route {
  model() {
    return this.store.findAll('post');
  }
}

posts.js under factories under mirage folder

import { Factory } from 'miragejs';

import faker from '@faker-js/faker';

export default Factory.extend({
  title() {
    return faker.lorem.sentence();
  },

  body() {
    return faker.lorem.paragraph();
  },

  publishedAt() {
    return faker.date.past();
  },
});

So these are the files that I have used in this project .and if you know the structure of emp app ,you will be able to understand these files. My ember-cli version is 3.24.0 node: 14.21.3 os: linux x64 Please help me in resolving this ,I am beginner in ember




mercredi 22 mars 2023

Ember-ace not works on clear ember project with ember-infinity installs as dependency

Can someone explain why ? I have no warnings in console. So, i need ember-infinity for my project, but don't know how to force to work ember-infinity with ember-ace.

Using ember-infinity: 2.3.0 and ember-ace: 3.0.0. Ember-cli version: 4.10.0

if I remove ember infinity from the project, then everything is ok




mardi 21 mars 2023

In Ember, in resetController function, why is transition undefined sometimes?

I am using Ember 3.16

I have an Ember application which has multiple routes.

For one of the routes, let's call it route x, I need it to reset only when it leaves the page. So I use resetController and only reset when isExiting and transition is true, like below:

resetController(controller, isExiting, transition) { if (isExiting && transition) {...} },

I need to check transition because I have pagination so when it goes to the next page, it refreshes the route.

The problem is when I navigate to some of the routes, transition is undefined so when I come back to route x, it does not reset. I need it to reset every time we go to a different page.

I do not understand why transition is defined when navigating to some routes and not others, anyone have any insights?

I tried comparing the routes where transition is defined to the ones they are not defined. I could not find a pattern. For some of the differences I even tried making them similar to see if it fixes it. It did not work.

I used Ember Inspector to see the routes change, and the routes always change. When transition is defined or undefined, I see routes changing.




mercredi 1 mars 2023

How do I successfully use jquery in emberjs

I'm attempting to change the value of an ember 'Input Helper' whenever a separate 'Input Helper' is clicked. The array of js objects is displayed in a child component as is the two Input Helpers the user interacts with. I have the actions bubble up into the template controller and handle and changes to the data there, where I would have thought the tracked objects array would update to show the new 'Input Helper' value. That isn't the case however.

I've moved onto installing the @ember/jquery add-on with

ember install @ember/jquery

and importing into my project with

import jQuery from 'jquery';

I even enabled Ember's jquery integration, even though I'm fairly certain it has been deprecated, according to this: https://rfcs.emberjs.com/id/0705-deprecate-jquery-optional-feature/After all of this is said and done, ember throws the following error:

TypeError: requireNode is not a function

Here is the full error stack:

Navigated to http://10.0.0.69:4200/add-cards
DEBUG: ------------------------------- index.js:170
DEBUG: Ember      : 4.10.0 index.js:170
DEBUG: Ember Data : 4.9.1 index.js:170
DEBUG: ------------------------------- index.js:170
GEThttp://10.0.0.69:4200/favicon.ico
[HTTP/1.1 404 Not Found 0ms]



Error occurred:

- While rendering:
  -top-level
    application
      add-cards

runtime.js:4985
Uncaught (in promise) TypeError: requireNode is not a function
    require wrap-require.js:12
    Ember 13
    resolveComponent opcode-compiler.js:194
    encodeOp opcode-compiler.js:2126
    pushOp opcode-compiler.js:2067
    <anonymous> opcode-compiler.js:1715
    compile opcode-compiler.js:417
    compileStatements opcode-compiler.js:2070
    maybeCompile opcode-compiler.js:2049
    compile opcode-compiler.js:2032
    <anonymous> runtime.js:2973
    evaluate runtime.js:1052
    evaluateSyscall runtime.js:4214
    evaluateInner runtime.js:4185
    evaluateOuter runtime.js:4178
    next runtime.js:5009
    _execute runtime.js:4996
    execute runtime.js:4971
    sync runtime.js:5054
    runInTrackingTransaction validator.js:138
    sync runtime.js:5054
    Ember 3
    inTransaction runtime.js:4090
    Ember 5
    invoke backburner.js:284
    flush backburner.js:197
    flush backburner.js:360
    _end backburner.js:801
    _boundAutorunEnd backburner.js:525
    promise callback*buildNext/< backburner.js:26
    flush Ember
    _scheduleAutorun backburner.js:967
    _end backburner.js:807
    _boundAutorunEnd backburner.js:525
    promise callback*buildNext/< backburner.js:26
    flush Ember
    _scheduleAutorun backburner.js:967
    _end backburner.js:807
    _boundAutorunEnd backburner.js:525
    promise callback*buildNext/< backburner.js:26
    flush Ember
    _scheduleAutorun backburner.js:967
    _end backburner.js:807
    _boundAutorunEnd backburner.js:525
    promise callback*buildNext/< backburner.js:26
    flush Ember
    _scheduleAutorun backburner.js:967
    _end backburner.js:807
    _boundAutorunEnd backburner.js:525
    promise callback*buildNext/< backburner.js:26
    flush Ember
    _scheduleAutorun backburner.js:967
    _ensureInstance backburner.js:958
    schedule backburner.js:651
    <anonymous> Ember
    fulfill rsvp.js:383
    resolve$1 rsvp.js:363
    initializePromise rsvp.js:465
    Ember 2
    initializePromise rsvp.js:460
    Promise rsvp.js:916
    Ember 7
    invokeCallback rsvp.js:435
    then rsvp.js:492
    <anonymous> Ember
    invoke backburner.js:282
    flush backburner.js:197
    flush backburner.js:360
    _end backburner.js:801
    end backburner.js:592
    _run backburner.js:845
    run backburner.js:627
    Ember 7
wrap-require.js:12

I wasn't able to identify what the issue was or why this would occur. There isn't much that I found relating to this specific error.