Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon configuration #61

Open
hornetnz opened this issue Dec 11, 2018 · 4 comments
Open

Icon configuration #61

hornetnz opened this issue Dec 11, 2018 · 4 comments

Comments

@hornetnz
Copy link

Using v0.7.0

I'm attempting to set the icons global, but it doesn't seem to be working. I'm sure I'm missing something stupid, but haven't found many examples to go by...

module.exports = function (environment) {
    let ENV = {
        modulePrefix: 'web-directory',
        environment,
        rootURL: '/',
        locationType: 'hash',
        EmberENV: {
            MODEL_FACTORY_INJECTIONS: true,
            FEATURES: {
            }
        },

        APP: {
            version: pkg.version,
            semver: pkg.version + '-edge',
            urlprefix: '',
            buildNumber: process.env.BUILD_NUMBER || 'BUILDNUM',
            libs: buildLibraryVersions()
        },

        'ember-cli-bootstrap-datetimepicker': {
            icons: {
                date: 'fa fa-calendar-alt',
                next: 'fa fa-chevron-right',
                previous: 'fa fa-chevron-left'
            }
        },

I can see the icons object when I do require('web-directory/config/environment') from the Chrome Inspector console...but when I step into the breakpoint at date: this.getWithDefault('config.icons.date', defaults.icons.date),, there's nothing at root.config.

I'm not sure if it makes a difference, but the environment config file is on my parent app, while the datetimepicker component is in an addon being used by one of the engines inside the parent app. It's clear that the datetimepicker code is being loaded, but for some reason it seems that its not loading, or not finding, the env variables?

@btecu
Copy link
Owner

btecu commented Dec 11, 2018

By default you don't have access to ENV in addons. Can you console log in your component init the ENV to see check if you actually have access?

@hornetnz
Copy link
Author

Yeah Im not seeing it. Would a import ENV from 'application-name/config/environment'; on the component work in this case?

@btecu
Copy link
Owner

btecu commented Dec 12, 2018

No, I doubt it. It's not exposed by default if you're using the addon folder - which is the preferred way.

One way is to move your addon code to the app folder - you now have full access to the ENV.
Another way is to inject it into the component, similar to how this addon is doing it: https://github.com/btecu/ember-cli-bootstrap-datetimepicker/blob/master/app/components/bs-datetimepicker.js

@hornetnz
Copy link
Author

hornetnz commented Dec 12, 2018

I added the import/inject to the component...

import DateTimePicker from '../datetimepicker';
import layout from './template';
import ENV from 'web-directory/config/environment';

export default DateTimePicker.extend({
    layout,
    config: ENV['ember-cli-bootstrap-datetimepicker'],

    didReceiveAttrs() {
        this._super(...arguments);
        const fieldKey = this.get('control.key');
    }
});

At my breakpoint in the didReceive, I can see my icon settings...
image

But still when going into the getWithDefault, it doesn't look like config is on this...
image

The attributes on this are: date, format, locale and openOnFocus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants