Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
Make 3rd beta build
Browse files Browse the repository at this point in the history
  • Loading branch information
yarbshk committed Jul 27, 2017
1 parent 4e3d3b7 commit a73123b
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 144 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ typings/

# Project source files
/assets/

# Ignore Start project
start/
dist/app.bundle.js
dist/app.bundle.css
index.html
webpack.start.config.js
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,25 @@ Simple example of creating an input type with a static button (span):
fields: [
{
key: 'email',
type: 'input-with-field', // Easy wrapping with Field component,
type: 'input-with-field', // Easy wrapping with a Field component
templateOptions: {
properties: {
'placeholder': 'Your email' // Recommends to use quotes and kebab-case
properties: {
'placeholder': 'Your email' // Recommends to use quotes and kebab-case
},
controls: {
after: [
{
type: Span, // Use the Span helper as a field control
options: { // Config object for the Span helper
label: '@gmail.com',
properties: {
'class': 'button is-static'
wrapper: { // Configuration object of the Field component
controls: {
after: [
{
type: Span, // Use the Span helper as a field control
options: { // Configuration object of the field control
label: '@gmail.com',
properties: {
'class': 'button is-static'
}
}
}
}
]
]
}
}
}
}
Expand All @@ -95,7 +97,7 @@ The code above will generate the following Buefy markup:
```
## Status
The plugin passes the **beta testing** stage now. Follow this project
The plugin passes the **beta testing** stage now.
## Issues
Be free to open new issue if you notice a bug. Let's make web a little bit better together :)
Expand Down
4 changes: 2 additions & 2 deletions dist/vue-formly-buefy.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/vue-formly-buefy.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-formly-buefy",
"version": "0.1.1",
"version": "0.1.5",
"description": "Vue.js plugin that covers the Buefy form fields for Formly.",
"keywords": [
"vue",
Expand All @@ -19,7 +19,7 @@
"scripts": {
"test": "./node_modules/karma/bin/karma start",
"watch": "./node_modules/.bin/webpack --progress --watch",
"start": "./node_modules/.bin/webpack-dev-server -d -w --content-base ./dist --hot --host 0.0.0.0",
"start": "./node_modules/.bin/webpack-dev-server --config webpack.start.config.js -d -w --hot --host 0.0.0.0",
"build": "./node_modules/.bin/webpack"
},
"repository": {
Expand Down Expand Up @@ -56,6 +56,7 @@
"mocha": "^3.4.2",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"vue": "^2.4.1",
"vue-formly": "^2.4.5",
"vue-loader": "^12.2.2",
Expand Down
9 changes: 7 additions & 2 deletions src/mixins/base-field.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ export default {
/**
* Get a message from a current field's errors stack.
*/
let error
let validators = this.getFieldValueOf('validators', {})
const errors = Object.keys(this._errors)
let error, validators = this.getFieldValueOf('validators', {})
if (validators[name]) validators = {name: validators[name]}
if (validators[name]) {
validators = {
name: validators[name]
}
}
Object.keys(validators).some(key => {
if (errors.indexOf(key) !== -1 && validators[key].message) {
error = validators[key].message
Expand Down
126 changes: 7 additions & 119 deletions test/unit/specs/components.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Vue from 'vue'
import Buefy from 'buefy'

import assert from 'assert'
import { mount } from 'vuenit'

import Field from 'src/components/form/field'
import Input from 'src/components/form/input'
import Checkbox from 'src/components/form/checkbox'
import Radio from 'src/components/form/radio'
import Select from 'src/components/form/select'
import Switch from 'src/components/form/switch'

Vue.use(Buefy)

const props = () => ({
form: {},
Expand All @@ -15,64 +17,6 @@ const props = () => ({
to: {}
})

function onBlur(vm, ...args) {
vm.form[vm.field.key].$dirty = false
vm.toggleActiveState(true)
assert.strictEqual(vm._dirty, false)
assert.strictEqual(vm._active, true)
vm.$trigger('blur', args)
assert.strictEqual(vm._dirty, true)
assert.strictEqual(vm._active, false)
}

function onFocus(vm, ...args) {
vm.toggleActiveState(false)
assert.strictEqual(vm._active, false)
vm.$trigger('focus', args)
assert.strictEqual(vm._active, true)
}

function onChange(vm, ...args) {
vm.form[vm.field.key].$dirty = false
assert.strictEqual(vm._dirty, false)
vm.$trigger('change', args)
assert.strictEqual(vm._dirty, true)
}

describe('Textarea', function () {
let vm = null

beforeEach(function () {
vm = mount(Input, {
props: Object.assign({}, props(), {
model: { name: '' },
field: { key: 'name', type: 'input' },
to: { properties: { 'type': 'textarea' } }
})
})
})

describe('event handling', function () {
it('should correct handle all types of events', function () {
onBlur(vm)
onFocus(vm)
onChange(vm)
})

it('should type several words in a textarea', function () {
const message = 'Test message'
vm.$trigger('focus', null)
assert.strictEqual(vm._active, true)
vm.model[vm.field.key] = message
vm.$trigger('change', null)
vm.$trigger('blur', null)
assert.strictEqual(vm._dirty, true)
assert.strictEqual(vm._active, false)
assert.equal(vm._model, message)
})
})
})

describe('Field.Wrapper', function () {
let vm = null

Expand All @@ -92,40 +36,8 @@ describe('Field.Wrapper', function () {

describe('computed', function () {
it('should insert validation state into field properties', function () {
assert.strictEqual('type' in vm.fieldProperties, true)
assert.strictEqual('message' in vm.fieldProperties, true)
})
})
})

describe('Checkbox', function () {
let vm = null

beforeEach(function () {
vm = mount(Checkbox.CheckboxGroup, {
props: props()
})
})

describe('event handling', function () {
it('should correct handle all types of events', function () {
onChange(vm)
})
})
})

describe('Radio', function () {
let vm = null

beforeEach(function () {
vm = mount(Radio.Radio, {
props: props()
})
})

describe('event handling', function () {
it('should correct handle all types of events', function () {
onChange(vm)
assert.strictEqual('type' in vm.extendedProperties, true)
assert.strictEqual('message' in vm.extendedProperties, true)
})
})
})
Expand All @@ -151,28 +63,4 @@ describe('Select', function () {
assert.equal(vm.templateType, vm.templateTypes.COMBINED)
})
})

describe('event handling', function () {
it('should correct handle all types of events', function () {
onBlur(vm)
onFocus(vm)
onChange(vm)
})
})
})

describe('Switch', function () {
let vm = null

beforeEach(function () {
vm = mount(Switch, {
props: props()
})
})

describe('event handling', function () {
it('should correct handle all types of events', function () {
onChange(vm)
})
})
})
11 changes: 8 additions & 3 deletions test/unit/specs/mixins.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const props = () => ({
form: {
$errors: {
name: {
required: 'Fill out this field!'
boom: true
}
},
$valid: false,
Expand All @@ -23,7 +23,12 @@ const props = () => ({
field: {
key: 'name',
type: 'input',
required: true
validators: {
boom: {
expression: 'model[field.key].length > 5',
message: 'Fill out this field!'
}
}
},
to: {
events: {
Expand Down Expand Up @@ -85,7 +90,7 @@ describe('BaseFormlyFieldMixin', function () {

describe('errors handling', function () {
it('should return readable error message', function () {
assert.equal(vm.getReadableErrorMessage(), 'Fill out this field!')
assert.equal(vm.getErrorMessage(), 'Fill out this field!')
})

it('should return correct validation state', function () {
Expand Down
29 changes: 29 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ babel-plugin-syntax-jsx@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"

babel-plugin-syntax-object-rest-spread@^6.13.0, babel-plugin-syntax-object-rest-spread@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"

babel-plugin-syntax-trailing-function-commas@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3"
Expand Down Expand Up @@ -620,6 +624,13 @@ babel-plugin-transform-exponentiation-operator@^6.22.0:
babel-plugin-syntax-exponentiation-operator "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-object-rest-spread@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.23.0.tgz#875d6bc9be761c58a2ae3feee5dc4895d8c7f921"
dependencies:
babel-plugin-syntax-object-rest-spread "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-regenerator@^6.22.0:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz#b8da305ad43c3c99b4848e4fe4037b770d23c418"
Expand Down Expand Up @@ -922,6 +933,13 @@ browserslist@^2.1.2:
caniuse-lite "^1.0.30000701"
electron-to-chromium "^1.3.15"

buefy@^0.4.6:
version "0.4.6"
resolved "https://registry.yarnpkg.com/buefy/-/buefy-0.4.6.tgz#c0ee584b1ada78f09684529e7758fcaa9acf1fe1"
dependencies:
bulma "^0.4.4"
vue "^2.4.1"

buffer-indexof@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.0.tgz#f54f647c4f4e25228baa656a2e57e43d5f270982"
Expand All @@ -946,6 +964,10 @@ builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"

bulma@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.4.4.tgz#182a3d9fb15026b4602aa8da3cf42140bfb9bb2c"

[email protected]:
version "2.4.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339"
Expand Down Expand Up @@ -5124,6 +5146,13 @@ strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"

style-loader@^0.18.2:
version "0.18.2"
resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-0.18.2.tgz#cc31459afbcd6d80b7220ee54b291a9fd66ff5eb"
dependencies:
loader-utils "^1.0.2"
schema-utils "^0.3.0"

[email protected], supports-color@^3.1.0, supports-color@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5"
Expand Down

0 comments on commit a73123b

Please sign in to comment.