Skip to content

Toward vuejs v2.0 #89

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 24 commits into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["es2015", "stage-0"],
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changed to stage-2 from 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stage-2 is the default in the vue-cli webpack preset. It is less bleeding edge, I guess ? I don't mind putting it back to were it was, I just did that when I was debugging to exclude differences between your config and the proposed webpack config.
You use ES7 features ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently not, just I'm using stage-0 in my other projects too.

"comments": false
}
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
<a name="0.6.1"></a>
## 0.6.1 (2016-11-28)

* :package: Build v0.6.1 ([79580a2](https://github.com/icebob/vue-form-generator/commit/79580a2))
* Add missing opening brace ([6842f1b](https://github.com/icebob/vue-form-generator/commit/6842f1b))
* bump version ([1976b4a](https://github.com/icebob/vue-form-generator/commit/1976b4a))
* Fixed bower file syntax error #98 ([06b0022](https://github.com/icebob/vue-form-generator/commit/06b0022)), closes [#98](https://github.com/icebob/vue-form-generator/issues/98)



<a name="0.6.0"></a>
# 0.6.0 (2016-11-14)

* :bug: Fix options prop default #91 ([3d2e821](https://github.com/icebob/vue-form-generator/commit/3d2e821)), closes [#91](https://github.com/icebob/vue-form-generator/issues/91)
* :package: build ([51abcca](https://github.com/icebob/vue-form-generator/commit/51abcca))
* :package: Build ([ce72dc4](https://github.com/icebob/vue-form-generator/commit/ce72dc4))
* :package: bump version & build ([d56f93c](https://github.com/icebob/vue-form-generator/commit/d56f93c))
* add bower ([ce44822](https://github.com/icebob/vue-form-generator/commit/ce44822))
* add number prop to input field ([a40e23c](https://github.com/icebob/vue-form-generator/commit/a40e23c))
* add step attribute to number field #92 ([ce64c4e](https://github.com/icebob/vue-form-generator/commit/ce64c4e))
* Fix #82 ([7a83777](https://github.com/icebob/vue-form-generator/commit/7a83777)), closes [#82](https://github.com/icebob/vue-form-generator/issues/82)
* Fix #84 ([2c36001](https://github.com/icebob/vue-form-generator/commit/2c36001)), closes [#84](https://github.com/icebob/vue-form-generator/issues/84)
* Fix #84 ([58093c7](https://github.com/icebob/vue-form-generator/commit/58093c7)), closes [#84](https://github.com/icebob/vue-form-generator/issues/84)
* fix lints ([1f8f3d9](https://github.com/icebob/vue-form-generator/commit/1f8f3d9))
* Implement #78 ([f92b193](https://github.com/icebob/vue-form-generator/commit/f92b193))
* quick fix for #85 ([cad76da](https://github.com/icebob/vue-form-generator/commit/cad76da)), closes [#85](https://github.com/icebob/vue-form-generator/issues/85)
* remote customLabel prop from multiselect because give errors ([5dfc5bb](https://github.com/icebob/vue-form-generator/commit/5dfc5bb))
* remove commit message package ([682c6ab](https://github.com/icebob/vue-form-generator/commit/682c6ab))
* Update README.md ([8128a52](https://github.com/icebob/vue-form-generator/commit/8128a52))
* docs: fix npms.io badge url ([475eb91](https://github.com/icebob/vue-form-generator/commit/475eb91))
* test: add attr checker to switch field ([2ed434e](https://github.com/icebob/vue-form-generator/commit/2ed434e))
* test: add file input attr test ([352fb20](https://github.com/icebob/vue-form-generator/commit/352fb20))
* test: add test to #82 ([aefdbac](https://github.com/icebob/vue-form-generator/commit/aefdbac))
* test: attr test to submit field ([1627c71](https://github.com/icebob/vue-form-generator/commit/1627c71))
* test: lock multiselect version ([5b0a4d0](https://github.com/icebob/vue-form-generator/commit/5b0a4d0))
* fix: customLabel return a basic function when undefined instead of null ([9b3d51d](https://github.com/icebob/vue-form-generator/commit/9b3d51d))
* bug: fix quotes ([13d6e0f](https://github.com/icebob/vue-form-generator/commit/13d6e0f))
* new: add form POST example ([08412c7](https://github.com/icebob/vue-form-generator/commit/08412c7))



<a name="0.5.0"></a>
# 0.5.0 (2016-09-28)

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ A schema-based form generator component for Vue.js v1.x.x
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/912039aa815e40de8315032519aa7e6c)](https://www.codacy.com/app/mereg-norbert/vue-form-generator?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=icebob/vue-form-generator&amp;utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/icebob/vue-form-generator.svg?branch=master)](https://travis-ci.org/icebob/vue-form-generator)
[![Coverage Status](https://coveralls.io/repos/github/icebob/vue-form-generator/badge.svg?branch=master)](https://coveralls.io/github/icebob/vue-form-generator?branch=master)
[![NPMS.io score](https://badges.npms.io/cross-spawn.svg)]()
[![NPMS.io score](https://badges.npms.io/vue-form-generator.svg)]()
[![Package Quality](http://npm.packagequality.com/shield/vue-form-generator.svg)](http://packagequality.com/#?package=vue-form-generator)

[![Dependency Status](https://david-dm.org/icebob/vue-form-generator.svg)](https://david-dm.org/icebob/vue-form-generator)
[![devDependency Status](https://david-dm.org/icebob/vue-form-generator/dev-status.svg)](https://david-dm.org/icebob/vue-form-generator#info=devDependencies)
[![Downloads](https://img.shields.io/npm/dt/vue-form-generator.svg)](https://www.npmjs.com/package/vue-form-generator)

**Vue v2.x is not supported!**
**Vue v2.x support is under development!**

## Demo
[JSFiddle simple example](https://jsfiddle.net/icebob/0mg1v81e/)
Expand Down Expand Up @@ -65,7 +66,7 @@ Vue.use(VueFormGenerator);
export default {
data: {

model:
model: {
id: 1,
name: "John Doe",
password: "J0hnD03!x4",
Expand Down
32 changes: 32 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "vue-form-generator",
"version": "0.6.1",
"homepage": "https://github.com/icebob/vue-form-generator",
"authors": [
"Icebob"
],
"description": "A schema-based form generator component for Vue.js",
"main": [
"dist/vue-form-generator.js",
"dist/vue-form-generator.css"
],
"moduleType": [
"amd"
],
"keywords": [
"vue",
"vuejs",
"form",
"generator",
"schema",
"json"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
98 changes: 54 additions & 44 deletions dev/app.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
<template lang="jade">
.row
.col-md-10.col-md-offset-1
data-table(:rows="rows", :selected="selected", :select="selectRow")

.row(v-show="model")
.col-md-5.col-md-offset-1
.control-buttons.text-center
button.btn.btn-default.new(@click="newModel")
i.fa.fa-plus
| New
button.btn.btn-primary.save(@click="saveModel")
i.fa.fa-floppy-o
| Save
i.fa.fa-warning(v-if="showWarning()")
button.btn.btn-danger.delete(@click="deleteModel")
i.fa.fa-trash
| Delete

.errors.text-center
div.alert.alert-danger(v-for="item in validationErrors", track-by="$index") {{ item.field.label}}:
strong {{ item.error }}

vue-form-generator(:schema='schema', :model='model', :options='formOptions', :multiple="selected.length > 1", v-ref:form, :is-new-model="isNewModel")


.col-md-6
pre(v-if='model') {{{ model | prettyJSON }}}
<template>
<div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<data-table :rows="rows" :selected="selected" :select="selectRow"></data-table>
</div>
</div>
<div v-show="model" class="row">
<div class="col-md-5 col-md-offset-1">
<div class="control-buttons text-center">
<button @click="newModel" class="btn btn-default new"> <i class="fa fa-plus"></i>New</button>
<button @click="saveModel" class="btn btn-primary save"> <i class="fa fa-floppy-o"></i>Save<i v-if="showWarning()" class="fa fa-warning"></i></button>
<button @click="deleteModel" class="btn btn-danger delete"> <i class="fa fa-trash"></i>Delete</button>
</div>
<div class="errors text-center">
<div v-for="item in validationErrors" track-by="$index" class="alert alert-danger">{{ item.field.label}}: <strong>{{ item.error }}</strong></div>
</div>
<vue-form-generator :schema="schema" :model="model" :options="formOptions" :multiple="selected.length > 1" ref="form" :is-new-model="isNewModel" @model-updated="modelUpdated"></vue-form-generator>
</div>
<div class="col-md-6">
<pre v-if="model" v-html="prettyModel"></pre>
</div>
</div>
</div>

</template>

Expand Down Expand Up @@ -82,6 +78,9 @@
return this.$refs.form.errors;

return [];
},
prettyModel(){
return filters.prettyJSON(this.model);
}
},

Expand All @@ -95,10 +94,12 @@
selectRow(event, row, add) {
this.isNewModel = false;
if ( (add || (event && event.ctrlKey))) {
if (this.selected.indexOf(row) != -1)
this.selected.$remove(row);
else
if (this.selected.indexOf(row) != -1){
var index = this.selected.indexOf(row);
this.selected.splice(index, 1);
} else {
this.selected.push(row);
}
} else {
this.clearSelection();
this.selected.push(row);
Expand All @@ -114,12 +115,11 @@
generateModel() {
if (this.selected.length == 1) {
this.model = cloneDeep(this.selected[0]);
}
else if (this.selected.length > 1) {
} else if (this.selected.length > 1) {
this.model = VueFormGenerator.schema.mergeMultiObjectFields(Schema, this.selected);
}
else
} else {
this.model = null;
}
},

newModel() {
Expand All @@ -146,6 +146,7 @@
}

} else {
console.warn("Error saving model...");
// Validation error
}
},
Expand All @@ -162,7 +163,8 @@
deleteModel() {
if (this.selected.length > 0) {
each(this.selected, (row) => {
this.rows.$remove(row);
let index = this.rows.indexOf(row);
this.rows.splice(index, 1)
})
this.clearSelection();
}
Expand All @@ -180,22 +182,30 @@
},

validate() {
console.log("validate", this.$refs.form, this.$refs.form.validate());
return this.$refs.form.validate();
},

modelUpdated(newVal, schema) {
console.log("main model has updated", newVal, schema);
// this.model[schema] = newVal;
}


},

ready() {
window.app = this;
mounted() {
this.$nextTick(function () {
window.app = this;

if (users.length > 0) {
this.selectRow(null, fakerator.random.arrayElement(users));
}
if (users.length > 0) {
this.selectRow(null, fakerator.random.arrayElement(users));
}

// Localize validate errors
VueFormGenerator.validators.resources.fieldIsRequired = "Ezt a mezőt kötelező kitölteni!";
VueFormGenerator.validators.resources.textTooSmall = "A szöveg túl rövid! Jelenleg: {0}, minimum: {1}";
// Localize validate errors
// VueFormGenerator.validators.resources.fieldIsRequired = "Ezt a mezőt kötelező kitölteni!";
// VueFormGenerator.validators.resources.textTooSmall = "A szöveg túl rövid! Jelenleg: {0}, minimum: {1}";
})
}
}

Expand Down
28 changes: 14 additions & 14 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
<head>
<meta charset="utf-8">
<title>vue-form-generator development</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.1/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/css/bootstrap-select.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/css/ion.rangeSlider.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/css/ion.rangeSlider.skinHTML5.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/9.0.0/nouislider.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/css/pikaday.min.css">


<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.4/lodash.min.js"></script>
<!-- jQuery dependent -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js"></script>
<!-- Vanilla libs -->
<script type="text/javascript" src="https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js"></script>
<script type="text/javascript" src="https://rawgit.com/monterail/vue-multiselect/2.0/lib/vue-multiselect.min.js"></script>
<script type="text/javascript" src="https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js"></script>
<script type="text/javascript" src="https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/9.0.0/nouislider.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCEz-sX9bRJorDS-D_JL0JkZVZe2gzoUMw&amp;libraries=places"></script>

</head>
<body>
<div class="container-fluid"></div>
<app></app>
<div id="app"></div>
<script src="/app.js"></script>
</body>
</html>
20 changes: 11 additions & 9 deletions dev/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* global Vue */
$(function() {
let App = require("./App.vue");

let app = new Vue({
el: "body",
components: {
App
}
});
});
// var App = require('./app.vue');
// $(function() {
// App.$mount('#app');
// });

import Vue from 'vue';
import App from './app.vue';

new Vue({
...App
}).$mount('#app');
Loading