Permalink
Browse files

feat(component): default the type to "text" when not a valid type

  • Loading branch information...
bas080
bas080 committed May 20, 2016
1 parent ba5b97f commit 812740511ebb4960f523231ccbb8bb32a6c2e2c9
Showing with 33 additions and 11 deletions.
  1. +7 −10 src/component.js
  2. +26 −1 src/schema-form.js
@@ -1,20 +1,17 @@
/**
* returns contains the logic for getting the path of the component of a
* specfic type
* return the location of the component to be used for that type. If custom
* components are defined, the path to them are returned instead of the
* framework component.
*
* @param {String} type
* @returns {String} which represents the path of either a custom, framework or
* @param {object} config
* @param {object} schema
* @returns {string} which represents the path of either a custom, framework or
* default component
*/
export function component(config, schema) {
let type = schema.type;

return customComponent() || frameworkComponent() || defaultComponent();

function defaultComponent() {
type = 'text';
return customComponent() || frameworkComponent();
}
return customComponent() || frameworkComponent();

function customComponent() {
let comp = config.components[type]; // has custom component?
@@ -7,5 +7,30 @@ export class schemaFormCustomElement {
@bindable({defaultBindingMode: bindingMode.twoWay})
model

@bindable submit
// constructor(formElement) {
// this.element = formElement;
// }

// attached () {
// if (this.model.hasValidation && this.model.hasValidation()) {
// this.validation = this.model.getValidation();
// }
// }

// submit () {
// return this.onSubmit();
// }

// onSubmit () {
// if (this.model.hasValidation && !this.model.hasValidation()) {
// return this.element.dispatchEvent(new CustomEvent('complete', this.model.asObject()));
// }

// this.validation.validate()
// .then(() => {
// this.element.dispatchEvent(new CustomEvent('complete', this.model.asObject()));
// })
// .catch(error => {});
// }

}

0 comments on commit 8127405

Please sign in to comment.