Giter Club home page Giter Club logo

angular-schema-form-material's Introduction

Angular Material Decorator

Join the chat at https://gitter.im/json-schema-form/angular-schema-form-material

For https://github.com/json-schema-form/angular-schema-form

Work In Progress

Angular Material has reached 1.0.0 however I do not feel it is remotely stable yet, this decorator is progressing very cautiously until that project hits a more stable milestone. That said, I have made an early alpha available and will continue to release alpha releases as I add new features, these are not production quality as the name alpha implies.

All this means is that it is very much a work in progress.

Testing

To test clone repo and:

npm install
bower install
gulp minify

Start favorite http server (http-server or puer for instance) and open examples/material-example.html

There is also a gulp watch task that minifys on change.

Known Issues

  • Almost nothing works if the schema uses bootstrap decorator features, it does not have array or complex keys yet and many other features are still missing or have no equivalent.
  • Needs development branch of angular schema form.
  • Only basic support for inputs, textarea, radios, radiobuttons, checkboxes, datepicker and tabs are implemented.
  • Angular material theme only works when $mdThemingProvider.alwaysWatchTheme(true); is used.
  • Until Angular Material hits 1.0.0 there is still chances that features may break again.

Contributing

Contributions are welcome! Please see Contributing.md for more info.

Future

Using the new builder opens up for a lot of optimization. Primarily we can get rid of a lot of small watches by using build helpers. For instance, slapping on a sf-changed directive only if the form definition has an onChange option.

Testing

npm install -g protractor
protractor test/protractor/conf.js

change baseurl in test/protractor/conf.js to match ur local environment.

Copyright (c) 2016 Marcel John Bennett, David Jensen

angular-schema-form-material's People

Contributors

anthropic avatar davidlgj avatar dennishalmstad avatar gitter-badger avatar ikulikov avatar juanrapoport avatar marvinosswald avatar pvgnd avatar rudolffrederiksen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-schema-form-material's Issues

Flex layout

Should be able to handle varying options for flex layouts to replace the Boostrap decorator's grid.

Inputs doesn't show model values until click in input

The form doesn't show values of model until click input.

After some investigation I saw that the element md-input-container doesn't have the css class md-input-has-value when the field has value from model.

Also, some of the options like fieldAddonLeft are not available in the templates of the inputs.
The decorator needs to be updated with the new options.

Here is my plunker to demonstrate what I am saying: https://plnkr.co/edit/835TaC61a6O88r7TDuOM?p=preview

Scott added a name to the form, swapped to bootstrap, and moved the titleMaps to the UI form schema from the JSON schema to indicate that it does look like material needs to be updated.
https://plnkr.co/edit/2C1HOB3o9Do8jUVo3Hau?p=preview

Inacurate textarea maxlength error

I created an exemple to reproduce the behavior.
http://codepen.io/anon/pen/RRVQpv?editors=1010

If the input overextends the limit we have three errors

{
  "schemaForm": true,
  "md-maxlength": true,
  "tv4-201": true
}

If we remove some characters until we reach the limit, 200 characters in my example.
The field remains invalid.

Proposition :
I think the problem comes from a remaining schemaForm error set by angular-schema-form.
I looked at its code and I saw two interesting lines used for validation :

// Any error and we're out of here!
return !Object.keys(ngModel.$error).some(function(e) { return e !== 'schemaForm';});
// In Angular 1.3 we use one $validator to stop the model value from getting updated.
// this means that we always end up with a 'schemaForm' error.
errors = errors.filter(function(e) { return e !== 'schemaForm'; });

Changing e !== 'schemaForm'; by error.indexOf('tv4-') === 0 fixed the problem.
Basically if we don't have an error from tv4 validation, we ignore it.
(It also fixes an error on textarea error messages because md-maxlength error is also ignored. I'll have a PR for this soon)

However I guess it breaks any custom validation --> https://github.com/json-schema-form/angular-schema-form/blob/development/docs/index.md#custom-validation

Does anyone have a better fix idea for this problem ?

Datepicker always invalid

The datepicker is not working. When the date is selected from the datepicker the form always stays as invalid. I tried it using angular-material 1.0.7.

I also clone the repo and tried the "simple" example that fails too.

Any idea what can be happening?

Thanks
JM

Tabs

Working on implementation of mdTabs...

[Error] Error: [$compile:multidir] Multiple directives [mdTabs (module: material.components.tabs), sfField] asking for new/isolated scope on: <md-tabs md-dynamic-height="" md-border-bottom="" sf-field="0">

angular-material: breaking formatting changes

There are formatting issues added in the latest version of Angular Material that turn input-containers into inline-block instead of block and now require to be set to block.

I have to consider what ASF users would expect the default behaviour to be (assuming block so far) and then provide both options. As the format is defined by attributes this will need to be handled as part of the sfBuilder process.

Error message issues - with fixes

Repeating this process on a required field was creating duplicated error messages:

  1. focus field
  2. fill field
  3. blur field
  4. focus field
  5. empty field
  6. blur field
    • Error message displayed.

Fixed by changing ng-if to ng-show on ng-messages dummy element created by sfMessagesNodeHandler.

I believe the behavior is documented here by the angular team. angular/angular.js#7549 (comment)


Error messages were not being removed on autocomplete fields, I'm not sure if this is better here or in the main angular-schema-form issue list, but I only noticed it on the md-autocomplete field.

Fixed by adding a method to the messages.js file for angular-schema-form and changing the ngModel watch to use it instead of update

    var updateAsync = function( checkForErrors ) {
        $timeout( function() { update(checkForErrors); } );
    };

...

    var once = scope.$watch('ngModel',function(ngModel) {
        if (ngModel) {
          // We also listen to changes of the model via parsers and formatters.
          // This is since both the error message can change and given a pristine
          // option to not show errors the ngModel.$error might not have changed
          // but we're not pristine any more so we should change!
          ngModel.$parsers.push(function(val) { updateAsync(true); return val; });
          ngModel.$formatters.push(function(val) { updateAsync(true); return val; });
          once();
        }
      });

Checkbox not rendering correctly on load

I am saving off my form and repopulating at a later time. Everything renders fine except for the checkbox.html. Whenever I load up using a previous model, schema form material doesnt seem to add the md-checked class and thus my checkboxes never get the checkmark. My model looks good, when I inspect the html, the tag shows aria-checked = true but not checkbox and no md-checked class.

Anybody else experience this?

Some elements cannot be flex containers

Angular Material keeps complaining about this:

Markup '<fieldset flex></fieldset>' may not work as expected in IE Browsers. Consult 
'https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers' for details.

Markup '<md-button flex></md-button>' may not work as expected in IE Browsers. Consult 
'https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers' for details.

More information here:
https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers

Some culprits include fieldset.html and submit.html which have flex on a <fieldset> and <md-button> respectively.

model with previus data not showing correctly

Hi,

I am creating a form with only inputs of text, and is working ok. but when I put a model with data previusly loaded, the text int the input don't show correctly, but if I click the input, then the text is showed.

How can I fix this?

Thanks!!.

Understanding how to present the user with the ng-message

I'm trying to present the user with the error messages below the input fields, just as they do with the bootstrap schema form. But I'm unable to understand this. I can see that we have something called sf-messages on the elements, but how do I populate them?

Release NPM

Hey,

could you please make a release and a npm package.

thanks

Form Action Buttons not responding to onClick

action.html probably missing something to handle the onClick that is passed.
e.g

        {
          type: 'actions',
          items: [
            { type: 'button',
            "style": "md-warn", title: 'Regress', onClick: () => {
              console.log('REG');
              }
            },
            { type: 'button', title: 'Advance', onClick: () => {
              console.log('ADV');
              }
            }
          ]
        },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.