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

md-autocomplete #6

Open
Anthropic opened this issue Oct 10, 2015 · 6 comments
Open

md-autocomplete #6

Anthropic opened this issue Oct 10, 2015 · 6 comments
Assignees
Milestone

Comments

@Anthropic
Copy link
Member

Add autocomplete and allow for template usage.

Based on: https://material.angularjs.org/HEAD/#/demo/material.components.autocomplete

Needs to allow template via schema form attribute or reference to included template.

@Anthropic Anthropic self-assigned this Oct 10, 2015
@Anthropic Anthropic added this to the Backlog milestone Oct 10, 2015
@Anthropic
Copy link
Member Author

Added basic functionality in fbf7bfc

@Anthropic Anthropic modified the milestones: Backlog, 0.1.0 Nov 3, 2015
@Anthropic Anthropic changed the title mdAutocomplete md-autocomplete Nov 3, 2015
@brianpkelley
Copy link

Not sure if something changed, but I had to double escape the single quotes in md-items in the autocomplete.html file.

md-items="item in evalExpr('this[\\''+form.optionFilter+'\\'](\\''+searchText+'\\')')"

@Anthropic
Copy link
Member Author

@brianpkelley it may have, which version of MD did you run with?

@brianpkelley
Copy link

Angular 1.5.6
Angular Material 1.0.9
Angular Schema Form 0.8.13
Angular Schema Form Material current Develop branch

I also commented on #11 not sure if it notified you.

@brianpkelley
Copy link

brianpkelley commented Aug 10, 2016

Disclaimer

Sorry for spamming code everywhere, I'd love to pull down a fresh copy but just don't have the time right now. Rushing to get a project out the door for work, so I'm posting these as notes for anyone with time or for when I get time to issue clean PR's


In the same vein as #18, md-autocomplete (and other fields that are of type object) pass null to the validator when empty. I may be wrong, and this is intended behavior, but this should be set to undefined like on empty strings, numbers etc.

    // Object fields (material - autocomplete ) will give a null value when we're looking for an object or undefined
    if (schema.type === 'object' && value === null) {
       value = undefined;
    }

I know this is still a work in progress, but I needed to make a few changes to the md-autocopmlete template to work with errors. Because the md-autocomplete directive creates it's own md-input-container sf-messages needs to be moved from the container div to the inner md-autocomplete as well as an option for md-required-match

    if ( args.form.schema.requireMatch ) {
        mdAutocompleteFrag.setAttribute('md-require-match', true);
    }
<div class="form-group {{::form.htmlClass ? form.htmlClass : 'flex-100'}} schema-form-select " sf-layout>
  <md-autocomplete flex
    sf-messages
    ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false}"
    ng-disabled="form.readonly"
    ng-model="$$value$$"
    sf-autocomplete
    sf-field-model="replaceAll"
    sf-changed-auto-complete="form"
    schema-validate="form"
    md-selected-item="$$value$$"
    md-search-text="searchText"
    md-selected-item-change="'todo';"
    md-items="item in evalExpr('this[\\''+form.optionFilter+'\\'](\\''+searchText+'\\')')"
    md-item-text="item.name"
    md-floating-label="{{::form.title}}"
    md-menu-class="autocomplete-custom-template"
    >
    <md-item-template>
      <span md-highlight-text="searchText">{{item.name}}</span>
    </md-item-template>
    <md-not-found>
      No matches found
    </md-not-found>
  </md-autocomplete>
</div>

@Anthropic
Copy link
Member Author

Thanks @brianpkelley back from holiday so I'll try to sort it out soon, yes autocomplete was the least finished of all the components, really hacked together for my own project at the time.

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

No branches or pull requests

2 participants