diff --git a/README.md b/README.md index e9688d48..4dd9d8e5 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ TODO ## Installation ### NPM TODO + ### Manual TODO @@ -35,13 +36,14 @@ npm run build TODO ## TODO -* [ ] Date picker with bootstrap-datepicker +* [x] Date picker with bootstrap-datepicker * [ ] Time picker * [ ] Color picker with spectrum * [ ] Image editor * [ ] Better slider * [ ] Groupable fields * [ ] Validation handling with multiple models +* [ ] Bundle for vendor files ## License vue-form-generator is available under the [MIT license](https://tldrlegal.com/license/mit-license). diff --git a/dev/data.js b/dev/data.js index 07a21675..ece925c9 100644 --- a/dev/data.js +++ b/dev/data.js @@ -41,6 +41,7 @@ module.exports = { user.language = lang; user.status = faker.helpers.randomize([true, false, true]); user.created = faker.date.recent(30).valueOf(); + user.dt = faker.date.recent(30).valueOf(); if (user.type == "business") { user.company = { diff --git a/dev/index.html b/dev/index.html index 99e99857..555f1153 100644 --- a/dev/index.html +++ b/dev/index.html @@ -7,11 +7,15 @@ + + + +
diff --git a/dev/schema.js b/dev/schema.js index b93fff34..8c32f41c 100644 --- a/dev/schema.js +++ b/dev/schema.js @@ -143,7 +143,21 @@ module.exports = { model.age = moment().year() - moment(newVal).year(); } - }, + }, + + { + type: "dateTime", + label: "DT", + model: "dt", + multi: true, + validator: [ + validators.date + ], + dateTimePickerOptions: { + format: "YYYY-MM-DD HH:mm:ss" + } + + }, { type: "slider", label: "Rank", diff --git a/dist/vue-form-generator.js b/dist/vue-form-generator.js index fe0a534a..a064fb40 100644 --- a/dist/vue-form-generator.js +++ b/dist/vue-form-generator.js @@ -64,8 +64,8 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = { component: __webpack_require__(1), - schema: __webpack_require__(184), - validators: __webpack_require__(185) + schema: __webpack_require__(189), + validators: __webpack_require__(190) }; /***/ }, @@ -79,7 +79,7 @@ return /******/ (function(modules) { // webpackBootstrap __vue_script__.__esModule && Object.keys(__vue_script__).length > 1) { console.warn("[vue-loader] src\\formGenerator.vue: named exports in *.vue files are ignored.")} - __vue_template__ = __webpack_require__(183) + __vue_template__ = __webpack_require__(188) module.exports = __vue_script__ || {} if (module.exports.__esModule) module.exports = module.exports.default if (__vue_template__) { @@ -456,9 +456,11 @@ return /******/ (function(modules) { // webpackBootstrap var _this = this; var res = []; - (0, _lodash.each)(this.schema.fields, function (field) { - if (!_this.multiple || field.multi === true) res.push(field); - }); + if (this.schema) { + (0, _lodash.each)(this.schema.fields, function (field) { + if (!_this.multiple || field.multi === true) res.push(field); + }); + } return res; } @@ -519,7 +521,12 @@ return /******/ (function(modules) { // webpackBootstrap (0, _lodash.each)(this.$children, function (child) { if ((0, _lodash.isFunction)(child.validate)) { var err = child.validate(); - Array.prototype.push.apply(_this2.errors, err); + (0, _lodash.each)(err, function (err) { + _this2.errors.push({ + field: child.schema, + error: err + }); + }); } }); @@ -26619,17 +26626,18 @@ return /******/ (function(modules) { // webpackBootstrap "./fieldCheckbox.vue": 12, "./fieldChecklist.vue": 16, "./fieldDate.vue": 21, - "./fieldEmail.vue": 128, - "./fieldLabel.vue": 133, - "./fieldNumber.vue": 138, - "./fieldPassword.vue": 143, - "./fieldRange.vue": 148, - "./fieldSelect.vue": 153, - "./fieldSelectEx.vue": 158, - "./fieldSlider.vue": 163, - "./fieldStaticMap.vue": 168, - "./fieldText.vue": 173, - "./fieldTextArea.vue": 178 + "./fieldDateTime.vue": 128, + "./fieldEmail.vue": 133, + "./fieldLabel.vue": 138, + "./fieldNumber.vue": 143, + "./fieldPassword.vue": 148, + "./fieldRange.vue": 153, + "./fieldSelect.vue": 158, + "./fieldSelectEx.vue": 163, + "./fieldSlider.vue": 168, + "./fieldStaticMap.vue": 173, + "./fieldText.vue": 178, + "./fieldTextArea.vue": 183 }; function webpackContext(req) { return __webpack_require__(webpackContextResolve(req)); @@ -26713,7 +26721,7 @@ return /******/ (function(modules) { // webpackBootstrap cache: false, get: function get() { var val = void 0; - if ((0, _lodash.isFunction)(this.schema.get)) val = this.schema.get(this.model);else if (this.schema.model) val = this.$get("model." + this.schema.model); + if ((0, _lodash.isFunction)(this.schema.get)) val = this.schema.get(this.model);else if (this.model && this.schema.model) val = this.$get("model." + this.schema.model); if ((0, _lodash.isFunction)(this.formatValueToField)) val = this.formatValueToField(val); @@ -26762,7 +26770,6 @@ return /******/ (function(modules) { // webpackBootstrap var err = validator(_this.value, _this.schema); if (err && err.length > 0) { Array.prototype.push.apply(_this.schema.errors, err); - // console.log(this.schema.errors); } }); })(); @@ -40833,7 +40840,7 @@ return /******/ (function(modules) { // webpackBootstrap if (__vue_script__ && __vue_script__.__esModule && Object.keys(__vue_script__).length > 1) { - console.warn("[vue-loader] src\\fields\\fieldEmail.vue: named exports in *.vue files are ignored.")} + console.warn("[vue-loader] src\\fields\\fieldDateTime.vue: named exports in *.vue files are ignored.")} __vue_template__ = __webpack_require__(132) module.exports = __vue_script__ || {} if (module.exports.__esModule) module.exports = module.exports.default @@ -40844,7 +40851,7 @@ return /******/ (function(modules) { // webpackBootstrap var hotAPI = require("vue-hot-reload-api") hotAPI.install(require("vue"), true) if (!hotAPI.compatible) return - var id = "d:\\Work\\vue-form-generator\\src\\fields\\fieldEmail.vue" + var id = "d:\\Work\\vue-form-generator\\src\\fields\\fieldDateTime.vue" if (!module.hot.data) { hotAPI.createRecord(id, module.exports) } else { @@ -40868,8 +40875,8 @@ return /******/ (function(modules) { // webpackBootstrap if(false) { // When the styles change, update the diff --git a/webpack.build.config.js b/webpack.build.config.js index 10e7b80d..632b122b 100644 --- a/webpack.build.config.js +++ b/webpack.build.config.js @@ -22,44 +22,43 @@ var loaders = [ ]; module.exports = [ - -{ - entry: "./src/index", - output: { - path: "./dist", - filename: "vue-form-generator.js", - library: "VueFormGenerator", - libraryTarget: "umd" + { + entry: "./src/index", + output: { + path: "./dist", + filename: "vue-form-generator.js", + library: "VueFormGenerator", + libraryTarget: "umd" + }, + plugins: [ + new webpack.BannerPlugin(banner, { + raw: true + })], + module: { + loaders: loaders + } }, - plugins: [ - new webpack.BannerPlugin(banner, { - raw: true - })], - module: { - loaders: loaders - } -}, -{ - entry: "./src/index", - output: { - path: "./dist", - filename: "vue-form-generator.min.js", - library: "VueFormGenerator", - libraryTarget: "umd" - }, - plugins: [ - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false + { + entry: "./src/index", + output: { + path: "./dist", + filename: "vue-form-generator.min.js", + library: "VueFormGenerator", + libraryTarget: "umd" + }, + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + } + }), + new webpack.BannerPlugin(banner, { + raw: true + })], + module: { + loaders: loaders } - }), - new webpack.BannerPlugin(banner, { - raw: true - })], - module: { - loaders: loaders } -} ]; \ No newline at end of file