Skip to content

missing 'md-input-has-value' if model exists #11

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

Merged
merged 1 commit into from
Nov 8, 2015
Merged

missing 'md-input-has-value' if model exists #11

merged 1 commit into from
Nov 8, 2015

Conversation

petermekhaeil
Copy link
Contributor

In Angular Materials 1.0.0-rc2, there is an md-input-has-value class that gets added to that changes the style of the input field.

Without it, visibly it looks like the input field has no value until the user clicks on the field.

I have also added the missing gulp-jscs required to run "gulp build".

@Anthropic
Copy link
Member

Awesome I will fix the rest of the fields this weekend, I was wondering what had caused that to happen, thanks for saving me time @petermekhaeil .

Ideally if you could update it to use sf-field-model="replaceAll" on the tag with the ng-class then anywhere you want to refer to the field you can add $$value$$

So the ng-class would be ng-class="{'md-input-has-value':$$value$$}".

Anthropic added a commit that referenced this pull request Nov 8, 2015
missing 'md-input-has-value' if model exists and missing gulp-jscs from package.json
@Anthropic Anthropic merged commit b7abbbc into json-schema-form:develop Nov 8, 2015
@petermekhaeil
Copy link
Contributor Author

I had trouble using sf-field-model="replaceAll" (didn't play as well as we expected) so I left it as it is now in the PR.

@Anthropic
Copy link
Member

Thanks @petermekhaeil I ran out of time on the weekend as I had to work, so hopefully I will do the other fields one night this week.

@Anthropic
Copy link
Member

@petermekhaeil for future reference I got it working with model['{{form.key.join('']['')}}']

Not sure why $$value$$ didn't work, must be the timing of $$value$$ vs ngClass init

I'm hopeful they will fix it in Angular Material so I can remove it at some point anyway...

@brianpkelley
Copy link

brianpkelley commented Jun 20, 2016

This wasn't working for me using :
Angular 1.5.6
Angular Material 1.0.9
Angular Schema Form 0.8.13
Angular Schema Form Material current Develop branch

Initially I tried to hack in some focus/blur events to trigger the md-input-container "normally", numerous model[...] hacks, $$value$$ etc. (believe this isn't working because the field fragment is created and compiled before the builders act on it, but honestly have no idea.

I finally hacked the angular schema form code to pass the model object to the sfBuilder.build function which then adds it to the args object that is passed to the individual builders. I then added a custom mdInputBuilder which has this code:

    function mdInputBuilder( args ) {
        function reduceHelper(obj,i) {return obj[i]}

        var modelValue;
        try {
            modelValue = args.form.key.reduce(reduceHelper, args.model);
        } catch(e) {
            modelValue = undefined;
        }

        if ( modelValue ) {
            var container = args.fieldFrag.querySelector('md-input-container');
            container.className = container.className + " md-input-has-value";
        }
    }

@brianpkelley brianpkelley mentioned this pull request Jun 24, 2016
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

Successfully merging this pull request may close these issues.

3 participants