vendredi 29 novembre 2019

Is it necessary to import jquery in Ember CLI 1.13

I am working on an old project which uses Ember CLI 1.13.12 where every file (including app.js/controllers/routes/components) has the following import at the top

import $ from 'jquery';

I removed the above line from all the files and still the app is running perfectly with all jquery code ( using $() or this.$()).

I tried to find if jquery is enabled in any config file but I couldn't. Also, there is no optional-features.json file in the project where jquery-integration can be set to true.

So, is it necessary to import jquery in an Ember CLI 1.13 project?

Can we disable the default jquery in Ember CLI 1.13?

I am new to Ember and that too to an old version so finding it difficult to understand.




jeudi 28 novembre 2019

Emberjs - how to render nested route template without parent route content?

Summary

I want to continue to use nested routes but without displaying top level content when the nested route is accessed. I'm not sure this is possible ?

Detail

Initially my requirement was to to display a list of, eg, foods and offer the user the option to add a food item foods/add . Using the outlet tag at the top of the list template allowed a form to add a food item to become visible at the top of the list, transitioning back to food after the add resulted in the list being displayed without the form.

New Requirement

The requirement has now changed and it's necessary to show the form without the the contents of the list and after a succesful add show the list without any form.

Question

I know I could abandon the sub-routes approach and create a route such as food-add but is there any other way of preserving the sub-route (and the corresponding file structure, which I like) but allow the the template for foods/add to be rendered without the list content ?




mercredi 27 novembre 2019

Ember-cli is ignoring options .babelrc

I want to configure my Ember app to either ignore the data-stubs folder, or set compact to false so I can silence the following error during builds:

[Babel: my-app > applyPatches][BABEL] 
 Note: The code generator has deoptimised the styling of dev/my-app/tests/data-stubs/foo.js
 as it exceeds the max of 500KB.

Accepted answers on StackOverflow say to configure the .babelrc file, but that isn't working with ember-cli builds. Answer: BABEL Note: The code generator has deoptimised the styling of "app.js" as it exceeds the max of "100KB in Meteor

I made a .babelrc file in the root folder of my ember app and have tried many different configurations:

{
  "ignore": ["**/data-stubs/*.js", "tests/data-stubs/*", "*tests/data-stubs/*"], //do not translate our stub files
  "compact": false,
  "env": {
    "development": {
      "compact": false
    }
  }
}

None has any effect and always results in the The code generator has deoptimised the styling error message. I also put a .babelrc file into the data-stubs folder with the same settings as above, and that isn't working either.




mardi 26 novembre 2019

Ember.js: EmberObject.create error on computed property inside a mixin

I am upgrading my ember app from 3.9 to 3.10.

I started getting an error.

Assertion Failed: EmberObject.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().

I am not 100% sure, but after some tracking down, this piece of code seems to be causing this error (the computed property inside this mixin).

import Mixin from '@ember/object/mixin';
import { get, set, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import DS from 'ember-data';

const { PromiseArray } = DS;

export default Mixin.create({
  ajax: service(),
  intl: service(),

  patientAnalysis: computed(function() {
    return this.getPatientAnalysis();
  }),

This mixin is being imported and used in another component, like so

import Analyses from 'ui/mixins/components/patient/analyses';
[...]
export default Component.extend(Analyses, {

I have read a few thread about this specific error, such as this one, but I can't figure out exactly how to make this work. I am not even sure why I am getting this error from upgrading to version 3.10 as this does not seems to have been deprecated or removed in that version.

I tried rewritting my mixin as the example from the ember doc, but without success.

If anyone could help me out figure out what exactly is going on and how to fix it, that would be appreciated.




lundi 25 novembre 2019

How to disable checkbox in certain column Ember js?

**enter image description here** May I know how can I disable the rest of the checkbox except for step 2,3 and 4? Those checkbox are link from the checkbox component. And i link the checkbox component into route at columns propertyName:"active". Below is a part of the route code.

export default Route.extend({
    model() {
        let results = {
            workflow: {
                columns: [
                    {
                        "propertyName": "step",
                        "title": "Step",
                        editable: false
                    },
                    {
                        "propertyName": "workflowName",
                        "title": "Workflow Name",
                    },
                    {
                        "propertyName": "preferredName",
                        "title": "Your Company Preferred Name",
                    },
                    {
                        "propertyName": "active",
                        "title": "Active",
                        component: "adk-workflow-select-row",
                        editable: false
                    },
                    {
                        title: "Edit",
                        component: "edit-row",
                        editable: false
                    }],
                rows: [
                    {
                        step: '0',
                        workflowName: 'New',
                        preferredName: '新',
                    },
                    {
                        step: '1',
                        workflowName: 'Budget Approval',
                        preferredName: '预算批准',
                    },
                    {
                        step: '2',
                        workflowName: 'Creative',
                        preferredName: '创作的',
                    },
                    {
                        step: '3',
                        workflowName: 'Visualize',
                        preferredName: '想象',
                    },
                    {
                        step: '4',
                        workflowName: 'Implementation',
                        preferredName: '履行',
                    },
                    {
                        step: '5',
                        workflowName: 'In Play',
                        preferredName: '活性',
                    },
                    {
                        step: '6',
                        workflowName: 'Completed',
                        preferredName: '已完成',
                    },
                    {
                        step: '7',
                        workflowName: 'Canceled',
                        preferredName: '取消',
                    },
                ]
            },

This is the adk-workflow-select-row which is the checkbox component. The code below is how i render the checkbox at. This enable all the checkbox. But i only need step 2,3 and 4 checkbox to be enable.





dimanche 24 novembre 2019

Why is Ember-Cli 3.14 throwing an ESLint No-New-Mixin error

I have three custom mixins that no longer work in Ember-Cli 3.14 (I had to step back down to 3.13.2). All I get is an Ember error saying no-new-mixins for each of the mixins. While the WebUI compiles and is hosted, the WebUI that is accessible no longer works properly. The errors appear to be thrown by ESLint.

Has anyone else had this problem with Ember 3.14?

https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-new-mixins.md

I am hesitant to capriciously ignore a rule just because it does not get along with a new version of Ember, but works in others. So, I am checking with SO first.




vendredi 22 novembre 2019

How to pass input data from template to the component class in ember?

I am trying to pass the data which is in the input field to the component class

This is my component-class alpha.js

@tracked choice;

    @action next() {
        this.choice = this.get('this.choice');
        console.log(this.choice);
    }

This is my template alpha.hbs

    <Input @value= type="text"  />
    <button onclick=>Next</button>

I am getting Uncaught TypeError: this.get is not a function

Any help would be appreciated. Thanks




Ember unknown relationship

I'm currently building software with Rails + Ember 3.12, but hitting a strange issue.

My models are the following:

// test-case-run
import DS from 'ember-data';
const { Model } = DS;

export default Model.extend({
  testCase: DS.belongsTo('test-case'),
  testCaseRunLogs: DS.hasMany('test-case-run-logs')
});

// test-case-run-log
import DS from 'ember-data';
const { Model } = DS;

export default Model.extend({
  testCaseRun: DS.belongsTo('test-case-run'),
  payload: DS.attr('')
});

And, my backend is returning the following payload:

{
  "data": {
    "id": "83",
    "type": "test_case_run",
    "relationships": {
      "test_case": {
        "data": {
          "id": "90",
          "type": "test_case"
        }
      },
      "test_case_run_logs": {
        "data": []
      }
    }
  }
}
{
  "data": {
    "id": "83",
    "type": "test_case_run",
    "relationships": {
      "test_case": {
        "data": {
          "id": "90",
          "type": "test_case"
        }
      },
      "test_case_run_logs": {
        "data": [
          {
            "id": "426",
            "type": "test_case_run_log"
          }
        ]
      }
    }
  },
  "included": [
    {
      "id": "426",
      "type": "test_case_run_log",
      "attributes": {
        "payload": "SCREENSHOT"
      },
      "relationships": {
        "test_case_run": {
          "data": {
            "id": "83",
            "type": "test_case_run"
          }
        }
      }
    }
  ]
}

I've got a custom adapter defining:

  pathForType(type) {
    return underscore(pluralize(type));
  }

So, I think that everything should go well.

However, when I get into the ember inspector, I've got the following: enter image description here

It seems that my relationship is not loaded properly. And, I cannot access any data, such as:

log.get('testCaseRun') // that is null 
run.get('testCaseRunLogs.length') // it returns 0 

This is quite strange, as my records are loaded in the store, but not their relationships. I have no idea on how to troubleshoot this, since the amount of information I can get from ember is quite limited (there is no error, the format looks good, ...).

Could someone help me to understand what's wrong with my calls? I've tried many things, such as renaming my models, but this does not improve the situation.

Moreover, this model is the only one, which I have problem with. All my other models don't have this problem. So, that's a bit weird.

Thanks a lot




jeudi 21 novembre 2019

EmebrJS + CKEDITOR error while adding links using its dialog box

Type of report

Links adding with CKEditor in chrome 78.0.3904.97 gives an error of following and i have checked latest firefox also and i can reproduce this

link.js?t=J8Q8:27 Uncaught TypeError: Cannot read property 'length' of undefined
    at CKEDITOR.dialog.onOk (link.js?t=J8Q8:27)
    at CKEDITOR.dialog.<anonymous> (ckeditor.js:613)
    at CKEDITOR.dialog.l (ckeditor.js:10)
    at CKEDITOR.dialog.fire (ckeditor.js:12)
    at button.onClick (ckeditor.js:637)
    at button.<anonymous> (ckeditor.js:575)
    at button.l (ckeditor.js:10)
    at button.fire (ckeditor.js:12)
    at button.click (ckeditor.js:574)
    at CKEDITOR.dom.element.<anonymous> (ckeditor.js:566)

reproduction steps

  1. enable links for CKeditor
  2. click the link icon in ckeditor toolbar
  3. it opens a dialog to add display name and the link
  4. adding link and display name 5.click ok

Expected result

close the dialog box and adding the link to the ckeditor text area

Actual result

dialog box is not closing and console gives

link.js?t=J8Q8:27 Uncaught TypeError: Cannot read property 'length' of undefined
    at CKEDITOR.dialog.onOk (link.js?t=J8Q8:27)
    at CKEDITOR.dialog.<anonymous> (ckeditor.js:613)
    at CKEDITOR.dialog.l (ckeditor.js:10)
    at CKEDITOR.dialog.fire (ckeditor.js:12)
    at button.onClick (ckeditor.js:637)
    at button.<anonymous> (ckeditor.js:575)
    at button.l (ckeditor.js:10)
    at button.fire (ckeditor.js:12)
    at button.click (ckeditor.js:574)
    at CKEDITOR.dom.element.<anonymous> (ckeditor.js:566)

Other details

  • Browser: chrome 78.0.3904.97 / firefox
  • OS:Mac
  • CKEditor version: 4.13.0
  • Installed CKEditor plugins:

Using CKEditor as Emberjs Component

components/ckeditor.js

import Ember from 'ember'; import config from 'project/config/environment';

export default Ember.Component.extend( {

  allowLinks: true,

  didInsertElement: function() {

    var self        = this,
        $textarea   = this.$().find( 'textarea' )[0],
        ckconfig    = {

          toolbarGroups: [

            { name: 'styles' },
            { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
            { name: 'paragraph',   groups: [ 'list' ] },
            { name: 'others' },
            { name: 'clipboard',   groups: [ 'undo' ] },
            { name: 'editing',     groups: [ 'find', 'selection' ] },
                { name: 'colors' }
          ],
          removeButtons: 'Subscript,Superscript,Cut,Copy,Paste,PasteText,PasteFromWord,Anchor,Styles,Font,FontSize,Find,Replace,SelectAll,BGColor',
          format_tags: 'h1;p',
          removeDialogTabs: 'link:advanced;link:target',
          removePlugins: 'magicline',
          disallowedContent :  {
            '$1': {
              styles: 'color'
            }
          }

        },
        outputRules = {

          indent: false,
          breakBeforeOpen: false,
          breakAfterOpen: false,
          breakBeforeClose: false,
          breakAfterClose: false
      };

    // custom config
    if ( this.get( 'allowLinks' ) ) ckconfig.toolbarGroups.splice( 3, 0, { name: 'links' } );

    CKEDITOR.config.customConfig    = false;
    CKEDITOR.config.defaultLanguage = 'en';
    CKEDITOR.config.language        = 'en';
    CKEDITOR.config.contentsCss     = config.baseURL + 'ckeditor.css' ;
    CKEDITOR.config.height          = 420;
    CKEDITOR.config.skin            = 'bootstrapck,' + config.baseURL + 'assets/bootstrapck/';
    CKEDITOR.config.colorButton_colors = '0000FF,FFA500';
    CKEDITOR.config.colorButton_enableMore = false;

    CKEDITOR.on( 'instanceReady', function(e) {

      e.editor.dataProcessor.writer.setRules( 'h1', outputRules );
      e.editor.dataProcessor.writer.setRules( 'p', outputRules );
      e.editor.dataProcessor.writer.setRules( 'ol', outputRules );
      e.editor.dataProcessor.writer.setRules( 'ul', outputRules );
      e.editor.dataProcessor.writer.setRules( 'li', outputRules );
    } );

    CKEDITOR.on( 'dialogDefinition', function(e) {

      var dialogName       = e.data.name,
          dialogDefinition = e.data.definition;

      if ( dialogName === 'link' ) {

        dialogDefinition.onShow = function () {

            var dialog        = CKEDITOR.dialog.getCurrent(),
                linkType      = dialog.getContentElement( 'info' , 'linkType' ),
                anchorOptions = dialog.getContentElement( 'info' , 'anchorOptions' ),
                emailOptions  = dialog.getContentElement( 'info' , 'emailOptions' ),
                protocol      = dialog.getContentElement( 'info' , 'protocol' );

            linkType.getElement().hide();
            anchorOptions.getElement().hide();
            emailOptions.getElement().hide();
            protocol.disable();
        };
      }
    } );

    Ember.run( function() {

      $textarea.value = self.get( 'value' ) || '';

      CKEDITOR.replace( $textarea, ckconfig ).on( 'change', function(e) {

        self.set( 'value', e.editor.getData() );
      } );
    } );
  }
} );

anyone has any idea how can i fixed it ? i have checked their github issues as well but unfortunately i couldn't find any thing




how to convert UTC time to specified format in momentjs in ember helper

i am working in ember with moment js. this below code convert my local time to UTC format

and output is like Tue Nov 26 2019 00:00:00 GMT+0000.

But i want to display the output like Tue, 26 Nov, 2019.

i tried moment-format for utc time but no luck




Ember Test for parent route with method calls

I was brought in on the "back-end" of a project and asked to help write tests for an app. I am very new to Ember and need just a little help getting started. We are trying to provide unit test for the routes, so we can have a bit more molecular scope over the app, instead of acceptance test. I have looked at some tutorials and went through every possible scenario that I could think of. I just need a bit of jumpstart.

Here is the part of the route.js for this route.

  • down stream of this parent route, we have another nested route that shows a list of contacts and when a user clicks on a show button it calls "model" and returns that variable "rec" for the template and the url


export default Route.extend(ScrollTo, {
  flashMessages: service(),

  model: function(params) {
    let rec= this.store.peekRecord('contact', params.contact_id);
    return rec;
  },

  actions: {
    saveContact: function() {
      let model = this.currentRouteModel();
      model
        .save()
        .then(() => {
          //this.refresh();
          //this.setModelHash();
          this.flashMessages
            .success(`Saved Contact: ${model.get('title')}`);

          //this.transitionTo('contacts');
        });
    }

Here is pre-generated code for the test. I really haven't made any modifications, because I really didn't know where to start.

  • This app doesn't have a back-end, it's design is to take in information and provide a iso file based on whatever standard the user wants.
  • I am sure I need to provide some mock data for the test and send that to the method, but again I am not sure what Qunit parts I use.
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Route | contact/show', function(hooks) {
  setupTest(hooks)

  test('it exists', function(assert) {
    var route = this.owner.lookup('route:contact/show');
    assert.ok(route, 'contact.show route works');
  });
});



uniq() returns a duplicate record

I'm using ember 2.6 and the uniq() return a duplicate records even if I used the uniq()

Even if I used the uniq it does still return the duplicate records, my question is my approach below is to return the uniq but it still return a duplicate record

foos: computed.alias('model.foos'),
bars: computed.mapBy('foos', 'bar.content'),
uniqBars: computed.uniq('bars'),



mercredi 20 novembre 2019

How to avoid downloading js files and authentication ember SPA

We have an ember single page application. On a specific page, while clicking on a hyperlink, I want to open a specific route in the new window.

The problem here is, it starts downloading all the js files (main.js) and authenticating the session and then only it is loading the route. This is taking too much time and giving a poor user experience. Since the hyperlink can be clicked only when the user is already logged in, is there a way to avoid downloading all the js files and authentication in ember? Something like a child window of the current window, so that the route will be loaded immediately.




EmberJS: queryRecord - adapter returns a JSON object but the call ultimately returns null

I am dumbfounded and have a hard time debugging this.

This is my adapter, it returns a settings object.

import DS from "ember-data";
import * as authServer from "doodledocs-app/config/auth-ms";
import DataAdapterMixin from "ember-simple-auth/mixins/data-adapter-mixin";

export default DS.RESTAdapter.extend(DataAdapterMixin, {
  authorizer: "authorizer:devise",
  async queryRecord(store, type, data) {
    const response = await fetch(`${authServer.HOST}/settings`, {
      method: "GET",
      headers: { Authorization: data.token }
    });
    const json = await response.json();
    console.log("res settings", json); //this works
    return json; //it doesn't matter what I return, queryRecord ultimately returns null
  }
});

It returns: settings {id: 1, pencil_thickness: 1, pencil_pressure_sensitivity: 1, eraser_thickness: 20, annotation_options: true, …}

The model is straightforward:

import DS from "ember-data";

export default DS.Model.extend({
  user: DS.belongsTo("user"),
  pencil_thickness: DS.attr("number"),
  pencil_pressure_sensitivity: DS.attr("number"),
  eraser_thickness: DS.attr("number"),
  annotation_options: DS.attr("boolean")
});

This is my route of settings.js

import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";

export default Route.extend({
  session: service(),
  async model() {
    const session = this.session.data.authenticated;
    const result = await this.store.queryRecord("settings", session);
    console.log("result", result); //this returns null...
  }
});

How come that it returns null and not the settings record?




Manually trigger keyboard on IOS devices (via javascript)

I encountered the following issue:

I have input in modal window and want to trigger keyboard once modal is open, example:

HTML:
<input type="search" />

JS:
didOpen () {
    ...

    input.focus();

    ...
},

but on IOS devices keyboard isn't opened. Maybe you know some workaround to implement it?




lundi 18 novembre 2019

How to reload the data in an ember-light-table from the database without a page refresh

Currently I have an ember-light table which is connected to a model from a django database. New things are pushed into this database all the time and I need my table to be up to date.

At the moment I refresh the page every minute which fetches from the database if the cache is old (using store.query). However, this causes the page to reload everything and the page goes blank for a while.

Is it possible to reload the data from the django db and update the table and have the table stay on screen the whole time?

Route:

  actions: {
  refresh: function () {
    this.refresh();
  }
},



Write Ember Octane Component test to check if state is correct after I submit a form?

I want to write a test such that when I submit a string, then a @tracked array =[0,0,0] field will change. I have a simple <Textarea @value= ></Textarea> for hbs.
if input is 1 then the tracked array becomes [0,1,0]. How do I do this?? So far I have the following code that DOESN'T work:

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | array', function(hooks) {
    setupRenderingTest(hooks);



    test('Textarea should display PLACE [0,1,0]"', async function(assert) {

        await render(hbs`<Array />`);
        assert.equal(find('textarea').value, 'testing"')
      });

});



dimanche 17 novembre 2019

Proper way to toggle classes in Ember Octane with Handlebars?

I want to toggle between class display on and display-off using Ember.js Octane. How do I do this? Do I need an @action or @tracked?

<img src="flower.jpg" alt="flower" class="display-on">  
or
<img src="flower.jpg" alt="flower" class="display-off"> 



How do I write a scanner to get string commands in a text file?

I have a text file which needs to be scanned for commands which need a required format.
The commands must be in the following order and aren't string sensitive however integers must be of length 1.

1) START 2,4,GO
2) Like
3) ATE, SWAM, SING, DANCE

Note, 3rd command has to be one of those 4. What's the best way to do this? Should I make an array and then use regexp? Seems complicated...




samedi 16 novembre 2019

Tricky RegExp question? How would I do this?

I want a simple validation and case of words don't matter. How would I do this? Preferably I'd like to do this using RegExp and I'll have an array of strings. i.e.) LOCaTe 9,0,uP

I have a simple array ["Locate", "9", "," ,"4", "up"] . This array will work. If I have an array like ["Locate"," asdf", "9", "," ,"4", "up"] that array wont work. It has to be a string then number then comma then number then string.




how can i understand ,which ember addon version compatibility with ember-cli or node version

I have not much experienced in Ember dependency

I have searched but i can not find which ember addon version compatibility with ember-cli or node version

I can find only this ember-cli node support https://github.com/ember-cli/ember-cli/blob/master/docs/node-support.md

Do I have to experience all , I can only guess version compatibility

For example : ember-simple-auth@2.1.0 compatible with ember-cli 3.x , ember-simple-auth@1.1.0 compatible with ember-cli 2.x

https://www.npmjs.com/package/ember-simple-auth/v/2.1.0

In the topic "Basic Usage" , i saw the Ember code syntax then this is it

For example : nodejs v6.x , npm v3.x, ember-cli 2.13 , Let's say it is working i want to add "ember-cli-sass" , which version i must choose ?

Is there a way to find out or isn't there something like that

Thanks




vendredi 15 novembre 2019

Running ember tests with Chrome in separate container

I have a gitlab pipeline that runs our acceptance tests in containers. I have access to a chromedriver service that runs in a container and is available on port 4444. The problem is I can't figure out what config to use to tell the tests to use Chrome on that port. Is this even possible?




Add a parent route in ember for existing routes

Here is my problem, assume I am having an ember app with following ember route configuration:

Router.map(function() {
  this.route('todos', function() {
    this.route('new');
    this.route('view', {
      path: "/:id"
    });
  });
  this.route('articles', function() {
    this.route('view', {
      path: "/:id"
    });
    this.route('new');
  });
});

Now i want to add the add the prefix for each route based on some user information i would be fetching. For eg: Below are the two user information

dev = {
 id: 1, 
 workspace: 'DEV'
}
qa = {
 id: 2,
 workspace:'TEST'
} 

once the dev is landing in the app, route must be like: todos:

/DEV/todos/new

and same for the other users. once the qa is landing in the page, route must be like:

/TEST/todos/new

to solve this i know we generate the parent route and add all the other route as child, need to change the file structure for this case.

Here is Ember :

ember-cli: 2.13.3,
ember-data: 2.18.5



Cookies are cleared on every page navigation (on development)

Happens Only On The Development Environment

On an Ember + Ember-Simple-Auth (CookieStore) SPA with Rails + Devise on the backend I have the situation that every time I navigate somewhere (different URLs, reload on the same URL) the cookies are cleared by default and I can't find where this happens.

Once I reload the cookies that are sent to the backend are already cleared, which makes me guess that it's not Rails that's doing that.




jeudi 14 novembre 2019

How to build CSS/PostCSS only during CSS changes?

Everytime I update .js code in my Ember App (components, tests, etc.) my app.css file is rebuilt, even though I'm not touching any CSS!

I am using PostCSS and TailwindCSS plugin. Every time I save a .js the entire TailwindCSS library is rebuilt and takes 1200-2000ms. This is really unnecessary and I would like to know how to avoid it. If I disable TailwindCSS the rebuild time of PostCSS drops to 191ms on every .js save.

There are a few solution ideas I'd like to explore:

  1. Is it possible to configure Ember rebuild my CSS ONLY when I change CSS?
  2. Is it possible to configure PostCSS to rebuild only when CSS has changed?
  3. How can I configure TailwindCSS to use a static CSS file, and then setup PostCSS to build only my custom tailwind configurations using the tailwind plugin?

ember-cli-build.js

    postcssOptions: {
      compile: {
        plugins: [
          {
            module: require("postcss-import"),
            options: {
              path: ["node_modules"]
            }
          },
          require("tailwindcss")("./config/tailwind.config.js")
        ]
      }
    }

config/tailwind.config.js

module.exports = {
  theme: {
    extend: {
      height: {
        "80": "20rem",
        "screen-80": "80vh",
        "screen-60": "60vh"
      },
      minWidth: {
        "96": "24rem",
        screen: "100vw"
      },
      maxWidth: {
        "min-content": "min-content",
        screen: "100vw"
      },
      screens: {
        xxl: "1920px"
      },
      zIndex: {
        "9999": 9999
      },
      colors: {
        puke: {
          100: "#fff5f7",
          200: "#fed7e2",
          300: "#fbb6ce",
          400: "#f687b3",
          500: "#ed64a6",
          600: "#d53f8c",
          700: "#b83280",
          800: "#97266d",
          900: "#702459"
        }
      },
      backgroundColor: theme => theme("colors"),
      textColor: theme => theme("colors"),
      borderColor: theme => ({
        ...theme("colors"),
        default: theme("colors.gray.300", "currentColor")
      })
    }
  },
  variants: {},
  plugins: []
};




mercredi 13 novembre 2019

Using result of one helper function in another helper function within Handlebars

I am checking if there is anyway that I can use the result of one helper function in another helper function and how can I use it, for example, I am looping through as below And then if I am getting an another element as below, using the same index: Then how can I use this element that we have got in a statement like below, to check if that is first or last element etc? Any help please - thanks in advance




How do I make an optional action for an Octane component?

I want to write an Octane/Glimmer style component where passing in the action is optional. What is the best way to write this?

For example, I want both of these uses of the component to be valid:

<MyComponent />
<MyComponent @validate= />

Right now, my component class has a lot of code that looks like this, checking to see if an action was passed in before calling it:

if (this.args.validate) {
  this.args.validate()
}

That works fine for one action, but not if I need to call several optional methods in succession. What other options are there?




How do I hook up my CSS grid table to an Array?

I have a 5x5 grid set up on my .HBS. I want to hold the state of my game somehow using ember.js OCTANE. How do I do this, and what's the best way? Please share ideas. Do I need to create a model? I'm new to Octane so please help. So far, I've just created a grid component and I'm trying to use glimmer tracking with an array.

HBS:

    <table class="quantize" style="width: 80%">
        
        <tr class="">
             
                    <td
                     class="border border-dark"
                     style="width:10%">
                                                
                    </td>           
            
        </tr>
        
    </table>



mardi 12 novembre 2019

Comparison operators in Ember Handlebar files

I have a file ifCond.js, in which I have bunch of helper functions, but I am concerned with mainly two functions log (which logs in values in hbs file) and IMS.ConditionHelper, I am not able to use IMS.ConditionHelper why, I want to use this function for that purpose, how can I do it - any help please? Here is my ifCond.js code:

export default () => {
    var log = function (data) {
        console.log(data);
    }
    var log = Ember.assign(log, {
        print: function (style, message) {
            var template = "";
            style.forEach(function (item) {
                if (typeof item == 'object') {
                    for (var prop in item) {
                        template += prop + ":" + item[prop] + ";";
                    }
                } else {
                    var style = log.styles[item];
                    if (style)
                        for (var prop in style) {
                            template += prop + ":" + style[prop] + ";";
                        }
                }
            })
        },
        styles: {
            title: {
                'font-size': '30px',
            },
            italic: {
                'font-style': 'italic'
            },
            bold: {
                'font-weight': 'bold'
            },
            underline: {
                'text-decoration': 'underline'
            },
            success: {
                'color': '#23aa15'
            },
            error: {
                'color': '#ee3619'
            },
            attention: {
                'color': '#ee339e'
            }
        }
    });

     IMS.ConditionHelper = Ember.Helper.extend({
        compute: function (args) {
            var v1 = args[0],
                operator = args[1],
                v2 = args[2];
            if (v1 === undefined || v2 === undefined) {
                console.warn("Condition BoundHelper received undefined value");
                return false;
            }
            switch (operator) {
                case '!=':
                    return (v1 != v2) ? true : false;
                case '==':
                    return (v1 == v2) ? true : false;
                case '===':
                    return (v1 === v2) ? true : false;
                case '<':
                    return (v1 < v2) ? true : false;
                case '<=':
                    return (v1 <= v2) ? true : false;
                case '>':
                    return (v1 > v2) ? true : false;
                case '>=':
                    return (v1 >= v2) ? true : false;
                case '&&':
                    return (v1 && v2) ? true : false;
                case '||':
                    return (v1 || v2) ? true : false;
                default:
                    return false;
            }
        }
})
}

Any help, I want a conditional operator - any help would be very very helpful - thanks in advance. I am not sure if I am using Ember-cli or Ember webpack but application is working except this ConditionHelper function being called in the Handlebar file - any help would be greatly helpful - thanks in advance




How can I provide dynamic values for an 'extend'? (or 'how does extend work in this case' ?)

I'm looking at a class (this one). The doco for it suggests you can extend the class to change a property of the class. That is true, it works for me.

However what I want to do is dynamically provide the values for the setting.

I've got two questions.

First

How can I adapt the demo so that I can dynamically supply the values used.

Second

I realise when I look at the class, this seems to be the significant part of the code ...

  ajax (url, data = {}, method = this.method) {
    const ajaxSettings = assign(
      {},
      {
        contentType: false,
        processData: false,
        xhr: () => {
          const xhr = $.ajaxSettings.xhr();
          xhr.upload.onprogress = (event) => {
            this.didProgress(event);
          };
          this.one('isAborting', () => xhr.abort());
          return xhr;
        },
        url,
        data,
        method
      },
      get(this, 'ajaxSettings')
    );

    return this.ajaxPromise(ajaxSettings);
  },

... I'm not confident that I understand how the 'extend' is doing what it's doing . ajaxSettings is used within the ajax function so how does the extend reach within the function and merge the value provided in the extend into the hardcoded values in the function ?

Hope the question makes sense ... I'll happily settle for an answer to 'First' if you can't manage 'Second' without writing a book ;-)




Adding custom helper functions or ember-truth-helpers to my Ember application

I have an Ember Application, maybe it started as Visual Studio some MVC or some project template and later they have added, now I am trying hard to add "ember-truth-helpers" in many ways like using yarn add or npm add, in any of the ways its not being added, all I am trying to do is to execute the below code:

                          
                        
                        

I am getting the following error: ember.debug.js:43618 Uncaught (in promise) Error: Compile Error: eq is not a helper

And my package.json file looks as below

    {
  "name": "ims-ember",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "build": "ember build",
    "babel-preset-env": "^1.7.0",
    "lint:hbs": "ember-template-lint .",
    "babel-preset-es2016": "^6.24.1",
    "lint:js": "eslint .",
    "bootbox.js": "^4.3.0",
    "start": "JOBS=1 ember serve",
    "bootstrap": "^3.3.7",
    "test": "ember test"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "babel-core": "^6.26.3",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2016": "^6.24.1",
    "bootbox.js": "^4.3.0",
    "bootstrap": "^3.3.7",
    "bootstrap-datepicker": "^1.9.0",
    "bootstrap-hover-dropdown": "^2.2.1",
    "chosen-js": "^1.8.7",
    "datatables": "^1.10.18",
    "ember-cli-windows": "github:felixrieseberg/ember-cli-windows",
    "file-loader": "^4.2.0",
    "font-awesome": "^4.7.0",
    "gulp": "^4.0.2",
    "gulp-babel": "^8.0.0",
    "gulp-clean": "^0.4.0",
    "gulp-clean-css": "^4.2.0",
    "gulp-concat": "^2.6.1",
    "gulp-concat-sourcemap": "^1.3.1",
    "gulp-declare": "^0.3.0",
    "gulp-filter": "^6.0.0",
    "gulp-if": "^3.0.0",
    "gulp-insert": "^0.5.0",
    "gulp-less": "^4.0.1",
    "gulp-replace": "^1.0.0",
    "gulp-uglify": "^3.0.2",
    "gulp-wrap": "^0.15.0",
    "gulp-wrap-file": "^0.1.2",
    "handlebars": "^4.4.2",
    "icons-loader": "0.0.6",
    "inputmask": "^4.0.9",
    "jquery": "^3.4.1",
    "jquery-ui": "^1.12.1",
    "json-stringify-safe": "^5.0.1",
    "lightbox2": "^2.11.1",
    "loader-utils": "^1.2.3",
    "moment": "^2.24.0",
    "mssql": "^5.1.0",
    "node-sass": "^4.12.0",
    "npm": "^6.13.0",
    "popper.js": "^1.15.0",
    "rimraf": "^3.0.0",
    "sass-loader": "^8.0.0",
    "schema-utils": "^2.4.1",
    "toastr": "^2.1.4",
    "typeahead.js": "^0.11.1",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "uuid": "^3.3.3"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/preset-env": "^7.6.2",
    "babel-loader": "^8.0.6",
    "css-loader": "^3.2.0",
    "ember-truth-helpers": "^2.1.0",
    "install": "^0.13.0",
    "less-loader": "^5.0.0",
    "style-loader": "^1.0.0",
    "webpack": "^4.41.0",
    "webpack-cli": "^3.3.10"
  }
}

any help please?




Is it possible to make a checkered table in Ember.js using ONLY Handlebars and ember-composable-helpers

I'm new to Ember.js and I'm trying to make a simple checkered table. I'm using Bootstrap 4, ember-composable-helpers, and Handlebars. I want to know if anyone knows how to do this WITHOUT using javascript?

My mockup code is as follows however I don't know how to insert logic into the #if HBS helper:

<h1>Table</h1>
<table class="w-100">
    
    <tr class="">
        

            
                <td class="bg-dark"></td>
            
        
    </tr>
    
</table>

Should I just make a ternary class? Anywho I'd like to see if anyone knows just for knowhow purposes...




The adapter operation was aborted in ember FASTBOOT mode

Working Ember app Environment:

DEBUG: -------------------------------
index.js:194 DEBUG: Ember             : 3.14.1
index.js:194 DEBUG: Ember Data        : 3.13.1
index.js:194 DEBUG: jQuery            : 3.4.1
index.js:194 DEBUG: Ember Bootstrap   : 2.8.1
index.js:194 DEBUG: Ember Simple Auth : 2.1.0
index.js:194 DEBUG: -------------------------------

emebr Frontend works on localhost:4200

php Backend works on localhost:8000

NOTE: http://localhost:4200/?fastboot=false - works as expected on the same server and configuration

I have a problem with dataAdapter after installing fastboot.

export default DS.JSONAPIAdapter.extend({
  host: 'http://localhost:8000', # the app do not crash when I disable this line in fastboot
  namespace: 'api/v1',
});

Log:

Error: The adapter operation was aborted
    at ErrorClass.AdapterError (/tmp/broccoli-15ZQyaTQRX5gGt/out-370-append_ember_auto_import_analyzer/assets/addon-tree-output/@ember-data/adapter/error.js:93:1)
    at new ErrorClass (/tmp/broccoli-15ZQyaTQRX5gGt/out-370-append_ember_auto_import_analyzer/assets/addon-tree-output/@ember-data/adapter/error.js:127:1)
    at handleAbort (/tmp/broccoli-15ZQyaTQRX5gGt/out-370-append_ember_auto_import_analyzer/assets/addon-tree-output/@ember-data/adapter/rest.js:1165:1)
    at ajaxError (/tmp/broccoli-15ZQyaTQRX5gGt/out-370-append_ember_auto_import_analyzer/assets/addon-tree-output/@ember-data/adapter/rest.js:1137:1)
    at ajaxErrorHandler (/tmp/broccoli-15ZQyaTQRX5gGt/out-370-append_ember_auto_import_analyzer/assets/addon-tree-output/@ember-data/adapter/rest.js:1197:1)
    at Object.hash.error (/tmp/broccoli-15ZQyaTQRX5gGt/out-370-append_ember_auto_import_analyzer/assets/addon-tree-output/@ember-data/adapter/rest.js:913:1)
    at fire (/app/node_modules/jquery-deferred/lib/jquery-callbacks.js:78:30)
    at Object.fireWith (/app/node_modules/jquery-deferred/lib/jquery-callbacks.js:188:7)
    at Object.fire [as reject] (/app/node_modules/jquery-deferred/lib/jquery-callbacks.js:195:10)
    at ClientRequest.onError (/app/node_modules/najax/lib/najax.js:208:9)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:401:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:66:8)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)

Tried to use proxy as ember server --proxy=http://127.0.0.1:8000

Error proxying to http://127.0.0.1:8000
nodejs_1      | connect ECONNREFUSED 127.0.0.1:8000

Ready to provide additional logs & information




lundi 11 novembre 2019

Notes Addon on Storybookjs with Ember

Trying to use notes with storybookjs in ember I'm unable to get the notes to display

export const text = () => ({
  template: hbs`<button >Hello Button</button>`,
notes,"Awesome Notes.. The Best Notes",
  context: {
    onClick: action('clicked'),
  },
});




ember-cli-mirage loses relationship when models are sideloaded

I've got following models:

// venue.js
export default Model.extend({
  name: DS.attr('string')
});

// web.js
export default Model.extend({
  webname: DS.attr('string'),
  venue: DS.belongsTo('venue', {async: false})
});

and I use the RESTAdapter. I defined my Mirage configuration as following:

// serializers/application.js
import { RestSerializer } from 'ember-cli-mirage';

export default RestSerializer.extend({
});

// config.js
export default function() {
  this.get('/webs', schema => {
    let venue = schema.venues.create({name: 'venue name'});
    let web = schema.webs.create({
      webname: 'web name',
      venue: venue
    });


    return {
      web: web,
      venue: venue
    }
  })
}

This model sideloading is a part of our application, so I have to use it. Anyways as you can see the response is fine here, i.e. it correctly identifies the foreign keys etc:

chrome tools

But when I receive the response I can't access the venue from the web - it's null. The ember inspector confirms that:

enter image description here

Does anyone have any idea of how I can preserve the relationship when I obtain the data?




Facebook Pixel displays 'custom_data' with '_removed_' value

I'm using ember-metrics to send custom event to Facebook Pixel. This is my code:

this.get('metrics').trackEvent('FacebookPixel', {event:'FreeTrial', custom_data: { location:location, url:'free-trial', campaign:campaign}});

When I go to Facebook control panel I see the following:

Nov 11, 2019, 9:53 AM
iPhone
custom_data:_removed_,

Facebook have the following help pop-up for this field: The parameters sent with this event. Parameter values may be removed if they were hashed before being sent to Facebook, or contain sensitive information that we detect.

Anyone had this issue before? What am I doing entirely wrong?




dimanche 10 novembre 2019

How setup an adapter to return data from an API for my application route in Ember data?

I'm learning to use ember data. I want to build an image searching app using Pixabay's free API.

I want to send search queries to adapter and get the results in route via model. First of all, I'm not sure how to create adapter for application route. I found many tutorials on ember data, they all built adapters and model for a specific model not on the application route.

app/routes/application.js

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

export default Route.extend({
  model(){
    return this.store.findAll('application');
  }
});

app/models/application.js

import DS from 'ember-data';
import Model from 'ember-data/model'
const { attr } = DS;

export default Model.extend({
    largeImageURL : attr('string')
});

app/adapters/application.js

import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
    host:"https://pixabay.com/api/?key=<API-KEY>&q=<queries>",
    pathForType(){
        return '/';
    }
});



vendredi 8 novembre 2019

How to create promise based action (instead of sendAction) in ember?

I have a use case where the action should get the value from another component, based on that I need to do some actions. Initially, I used sendAction (instead of promiseAction()) to do some actions. But closeDataModal() runs immediately after finishing the sendAction. I want the first function to finish up and then run the second one.

saveAction() {
  promiseAction()
  closeDataModal() -> Run after resolving the promiseAction
}



jeudi 7 novembre 2019

Writing a javascript method in controller or some other place and calling it from Handlebars

for some reason whatever helper functions that I am writing , they are not working in my Handlebars, saying that they are not helper functions. I want two things:

  1. Is there anyway I can write functions in controller and call them easily from the Ember? If yes can you please give me example or link or some help how can I do it?
  2. Can I assign variables etc in ember each loops, like if I can declare a variable in outer each loop and assign it in the inner each loop and then use that assigned value after the inner loop finishes
  3. For some reason, my ifCond helper is not working, it says that ifCond is not a helper, is there any builtin if for comparing two values and return true or false in ember, like two different string etc

Any help please - thank you.




Using each in ember Handlebars

I have an each loop like the below, I want to add a '(' before the first element and ')' after the last element. Can somebody please help me how can I do it? Any help would be very very helpful - thanks

                          
                          : 
                          <br/>                                         
                          



Looping through two arrays simultaneously and printing in Handlebars Ember

I have two arrays NOVNoticeTypeName and NOVNumber, they both have the same number of elements, now I want to loop through one of them and print the values side by side as blow:

                    
                {( )
                

I understand looping is a mess in the Ember handlebars, can somebody please help me how can I achieve this, thanks a lot.




Is there a way to remove ember-data from emberfire?

My app does not use ember-data, it uses only apollo for graphql to retrieve/manage data.

But after installing emberfire, we must have to install ember-data too. We just use emberfire/firebase for authentication :)

If I try to remove it I've got an error:

Cannot find module 'ember-data/package.json' from '/Users/bruno/octane-graphql/node_modules/emberfire'



mercredi 6 novembre 2019

How do I get `this.args` within a component function? I get "TypeError: this is undefined"

I'm writing some Octane-style components in Ember v3.13, together with the ember-render-modifier. However, when the function tied to did-insert is called, I get TypeError: this is undefined. What am I doing wrong?

Here's my component template:

<div class="cardhost-monaco-container" ></div>

And here's the component's JavaScript class:

import Component from '@glimmer/component';


export default class CodeEditor extends Component {
  renderEditor(el) {
    console.log(this.args.code)
  }
}



Ember router breaks on redirect to '/'

I'm having a hard time making my router understand that we are on a certain page and it should be displayed in the navigation as active. The situation is as follows:

 this.route('mainRoute', function() {
     this.route('list');
 });

The path we are interested in is /mainRoute. Unfortunately, there are a lot of legacy links that point to /mainRoute/list. The workaround for this was to redirect from the /mainRoute/list component back to the /mainRoute component.

beforeModel() {
   this.replaceWith('/mainRoute');
}

Now, my issue is that the /mainRoute navigation link will never be seen as active. I've tried adding a path for the /mainRoute ('/', '/mainRoute', 'mainRoute'), I've tried transforming it to a resource and a bunch of other things that passed my mind. But it either won't work, or will go in an infinite redirecting loop.

Any thoughts on this? Thanks so much, I really need a solution for this!




mardi 5 novembre 2019

I am gettting the error: Compile Error: ifCond is not a helper when I am trying to write a helper function in Ember

I have a helper function (ifCond) in ember.js as below

 export default () => {
    Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
        alert("hi");
        if (params[3]) {  //handle case insensitive conditions if 4 param is passed.
            params[0] = params[0].toLowerCase();
            params[2] = params[2].toLowerCase();
        }
    let v1 = params[0];
    let operator = params[1];
    let v2 = params[2];

    switch (operator) {
        case '==':
            return (v1 == v2);
        case '!=':
            return (v1 != v2);
        case '===':
            return (v1 === v2);
        case '<':
            return (v1 < v2);
        case '<=':
            return (v1 <= v2);
        case '>':
            return (v1 > v2);
        case '>=':
            return (v1 >= v2);
        case '&&':
            return !!(v1 && v2);
        case '||':
            return !!(v1 || v2);
        default:
            return false;
    }
    });
}

when I am trying to access this function in my hbs file as below

                                                    
                                                    
                                                    <br />
                                                    

I am getting error as below:

Any help please - thanks in advance




If condition in ember handlebars

I have an ember helper method as below

export default () => { 
        Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
            if (params[3]) {  //handle case insensitive conditions if 4 param is passed.
                params[0] = params[0].toLowerCase();
                params[2] = params[2].toLowerCase();
            }

        let v1 = params[0];
        let operator = params[1];
        let v2 = params[2];

        switch (operator) {
            case '==':
                return (v1 == v2);
            case '!=':
                return (v1 != v2);
            case '===':
                return (v1 === v2);
            case '<':
                return (v1 < v2);
            case '<=':
                return (v1 <= v2);
            case '>':
                return (v1 > v2);
            case '>=':
                return (v1 >= v2);
            case '&&':
                return !!(v1 && v2);
            case '||':
                return !!(v1 || v2);
            default:
                return false;
    }
}); 
 }

I am trying to call it from my hbs file as below


But I am getting the following error, can somebody suggest me something please, thank you.

contacts.hbs:41 Uncaught Error: Module build failed (from ./.webpack/webpack-handlebars.js):
Error: if doesn't match each - 372:59
    at validateClose (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:11014:13)
    at Object.prepareBlock (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:11125:7)
    at Object.anonymous (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:8339:25)
    at Parser.parse (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:10142:38)
    at parse (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:11271:36)
    at preprocess (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:5817:71)
    at precompile (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:3949:38)
    at Object.precompile (C:\SourceCode\IMS\Development\IMS\IMS.Ember\node_modules\ember-source\dist\ember-template-compiler.js:8119:37)
    at Object.module.exports (C:\SourceCode\IMS\Development\IMS\IMS.Ember\.webpack\webpack-handlebars.js:15:29)
    at Object.<anonymous> (http://localhost:58799/Ember/dist/templates.js?version=1572992916177.89:22620:7)



Getting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember'

I am trying to write a javascript helper function in my Ember application called compare.js, and that js file is trying to import Ember, where its throwing error, can anybody please suggest me something how to get-rid of this type errors? Here is my compare.js files code - thank you.

import Ember from 'ember';

export function compare(params) {
    if (params[3]) {  //handle case insensitive conditions if 4 param is passed.
        params[0] = params[0].toLowerCase();
        params[2] = params[2].toLowerCase();
    }
    let v1 = params[0];
    let operator = params[1];
    let v2 = params[2];
    switch (operator) {
        case '==':
            return (v1 == v2);
        case '!=':
            return (v1 != v2);
        case '===':
            return (v1 === v2);
        case '<':
            return (v1 < v2);
        case '<=':
            return (v1 <= v2);
        case '>':
            return (v1 > v2);
        case '>=':
            return (v1 >= v2);
        case '&&':
            return !!(v1 && v2);
        case '||':
            return !!(v1 || v2);
        default:
            return false;
    }
}

export default Ember.Helper.helper(compare);

I want to be able to import or use this function in my hbs file, how can I do it any help please to fix these two things please - need some help - thank you.




lundi 4 novembre 2019

Loading of a td value using another td value in Ember hbs file

I have an ember hbs component, in which we have table, in which the value of a td should be decided depending upon the value of the previous td, here is my hbs code, any help please?

                            <div class="row">
                            <div class="col-md-12">
                                
                                    <table class="table table-striped">
                                        <thead>
                                            <tr>
                                                <th>Notice#</th>
                                                <th>Type</th>
                                                <th>Violation</th>
                                                <th>Inspection Item</th>
                                                <th>
                                                    Action
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>                                               
                                            
                                            <tr>
                                                <td></td>
                                                <td> </td>
                                                <td>
                                                    
                                                    
                                                    
                                                    
                                                    
                                                    (VIN#:
                                                    )
                                                    
                                                    <br />
                                                    
                                                </td>
                                                <td>
                                                    
                                                    
                                                    <br />
                                                    
                                                </td>
                                                <td>
                                                    
                                                    <div class="btn btn-xs btn-default" onclick=>
                                                        <i class="fa fa-eye"></i>
                                                        View Notice
                                                    </div>
                                                    <div class="btn btn-xs btn-default" onclick=>
                                                        <i class="fa fa-file"></i>
                                                        Generate Investigation
                                                    </div>
                                                    
                                                    <div class="btn btn-xs btn-default" onclick=>
                                                        <i class="fa fa-edit"></i>
                                                        Edit Notice
                                                    </div>
                                                    
                                                </td>
                                            </tr>
                                            
                                        </tbody>
                                    </table>
                                
                                    
                                        
                                            <div class="well text-center no-margin">
                                                Click here to add a Notice.
                                            </div>
                                        
                                        
                                        <div class="well text-center no-margin">
                                            No notices...
                                        </div>
                                    
                                
                            </div>
                        </div>

In the above code, the model.result.items has Violation element, how can I display the novi.itemNum for the novv.ViolationNumber that is displayed, any help please - thanks in advance.




Problem with rendering a custom component

I try to create a custom component for my application with emberJS, I have followed the quickstart tutoriel and now I try to create a upload button as a component.

It seems I don't have code issues but my component don't render on my main page. I have use the ember component generator to create it

here my upload-button.hbs :

<button type="button"></button>

now my upload-button.js :

import Component from '@ember/component';

export default Component.extend({
    actions: {
        showExplorer(){
            alert()
        }
    }
});

for the moment I simply put a alert() method in showExplorer()

and now my main page, application.hbs :

<upload-button @buttonText="Uploader un fichier" />


I expect to see my button but I just have a blank page with no code error.

I suspect that's a really stupid mistake but I can't find it.




Why should we learn front-end frameworks?

I am new to React and, frankly, started learning the framework due to great bandwagon on the use of this framework. But later asked myself Why on earth should we learn front-end frameworks? Why were front-end frameworks created and what problems do they help us to solve. After some research, I found out that, for example, React with its virtual dom helps to achieve efficiency when we change dom. Also, React helps to achieve easier maintenance and reusability thanks to components. Am I correct with these statements?, that is, if we do not use front-end frameworks, then dom updates will be costly and slow and ui will be harder to maintain and reuse since we do not use components. Is that true?




dimanche 3 novembre 2019

In an integration test, using the test helper `triggerKeyEvent` on an input inside a ` ` does not submit the ` `

This question is based on the demo repo https://github.com/bartocc/so-enter-key-integration-test

This demo Ember.js app contains the <XFoo> component. When rendered, it displays a simple <form> with a text input and a submit button.

The <form> has an action bound on its submit event that will set the component's submitted property to true. By default, it is false.

The desired behaviour is to display a thank you message instead of the <form> after submitting it.

Here is the component's template:


  <span>
    Thank you for your submission
  </span>

  <form >
    
    <input type="text" />
    <button type="submit">
      Save
    </button>
  </form>

I've added 2 integration tests for <XFoo>:

  • one tries to send the Enter keydown event to the <input> tag with the code
await render(hbs`<XFoo />`);
await triggerKeyEvent('input', 'keydown', 'Enter');
  • the other clicks the submit button with
await render(hbs`<XFoo />`);
await click('button');

Both tests check the presence of the thank you message with:

assert.dom('span').hasText('Thank you for your submission', 'displays the thank you span');

The first test fails, the second one passes.

I would like to understand why using triggerKeyEvent does not submit the form.




samedi 2 novembre 2019

How to create a link to each document from _id?

Can someone tell me what is wrong with my router? I am working with graphql queries. I need to use _id as links in the list of "heroes". I will give the code of the main files below. Thanks in advance!

router.js

import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = EmberRouter.extend({
  location: config.locationType,
  rootURL: config.rootURL
});

Router.map(function() {
  this.route('heroes', function() {
    this.route('hero', { path: '/:hero_id' });
  });
  this.route('addhero');
});

export default Router;

heroes.js

import Route from '@ember/routing/route';
import { queryManager } from 'ember-apollo-client';
import gql from 'graphql-tag';

const query = gql`
  query {
    heroes {
      _id
      title
      description
      date
    }
  }
`;

export default Route.extend({
  apollo: queryManager(),
  model() {
    return this.apollo.watchQuery({ query }, 'heroes');
  }
});

heroes.hbs

<div class="container">
  
  <div class="row">
    <div class="col s11 m11 l11">
      <LinkTo @route="heroes.hero" @model=>
        <h5></h5>
      </LinkTo>
      <p></p>
    </div>
  </div>
  
</div>