Skip to content

Commit

Permalink
Merge pull request #8 from dionmaicon/remove_old_sintax_js
Browse files Browse the repository at this point in the history
fix errors javascript
  • Loading branch information
dionmaicon committed Dec 10, 2019
2 parents 6b70b85 + aacb012 commit 41a4712
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 40 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ CRUD (Create, Read, Update and Delete) basic generator for Vue.js

[![Coverage Status](https://coveralls.io/repos/github/dionmaicon/vue-crudgen/badge.svg?branch=master)](https://coveralls.io/github/dionmaicon/vue-crudgen?branch=master)
[![Build Status](https://travis-ci.org/dionmaicon/vue-crudgen.svg?branch=master)](https://travis-ci.org/dionmaicon/vue-crudgen)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=dionmaicon_vue-crudgen&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=dionmaicon_vue-crudgen)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=dionmaicon_vue-crudgen&metric=ncloc)](https://sonarcloud.io/dashboard?id=dionmaicon_vue-crudgen)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=dionmaicon_vue-crudgen&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=dionmaicon_vue-crudgen)
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=dionmaicon_vue-crudgen)](https://sonarcloud.io/dashboard?id=dionmaicon_vue-crudgen)

The focus this package is front-end with vue..

Expand Down
19 changes: 9 additions & 10 deletions js/bootstrap/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const Form = class {

getTemplate() {
let capitalizedName = capitalize(this.modelName);
let pluralizedAndCapitalizedName = pluralize(capitalizedName);

let template =
`<template>
Expand All @@ -27,7 +26,7 @@ const Form = class {

let countFiles = 0;
//Template Struct
for (var property in this.model) {
for (let property in this.model) {
if (property.includes("hidden_fields")) continue; //if property includes 'hide'in your text this loop skip once

if (this.model.hasOwnProperty(property)) {
Expand All @@ -48,12 +47,12 @@ const Form = class {
templateStruct += `\t<textarea id="${property}" style="width: 100%" v-model="${this.modelName}.${property}" rows="10">You text here...</textarea>\n\n`;
} else if (this.model[property].type == "radio") {
templateStruct += "<br />";
for (var option of this.model[property].options) {
for (let option of this.model[property].options) {
templateStruct += `\t<input type="radio" id="${option.id}" value="${option.value}" v-model="${this.modelName}.${property}">\n`;
templateStruct += `\t<label for="${option.id}">${option.value}</label><br>\n\n`;
}
} else if (this.model[property].type == "checkbox") {
for (var option of this.model[property].options) {
for (let option of this.model[property].options) {
templateStruct += `\t<input type="checkbox" id="${option.id}" value="${option.value}" v-model="${this.modelName}.${property}">\n`;
templateStruct += `\t<label for="${option.id}">${option.value}</label><br>\n\n`;
}
Expand Down Expand Up @@ -112,7 +111,7 @@ const Form = class {
\n`;
} else {
templateStruct += `\t<input id="${property}" class="form-control" `;
for (var htmlProp in this.model[property]) {
for (let htmlProp in this.model[property]) {
if (this.model[property].hasOwnProperty(htmlProp)) {
templateStruct += ` ${htmlProp}="${this.model[property][htmlProp]}" `;
}
Expand Down Expand Up @@ -200,7 +199,7 @@ const Form = class {
get${capitalizedName}(this.id)
.then(response => {
let instance = response.data;
for (var property in instance) {
for (let property in instance) {
if (instance.hasOwnProperty(property) && this.${this.modelName}.hasOwnProperty(property)) {
this.${this.modelName}[property] = instance[property];
}
Expand Down Expand Up @@ -237,7 +236,7 @@ const Form = class {
let dataImport = ``;
let dataComponent = ``;

for (var property in this.model) {
for (let property in this.model) {
if (this.model.hasOwnProperty(property)) {
if (property.includes("hidden_fields")) continue; //If contains word hide continue loop for next iteration

Expand All @@ -258,7 +257,7 @@ const Form = class {
let dataScript = ``;
let relationsScript = ``;

for (var property in this.model) {
for (let property in this.model) {
if (this.model.hasOwnProperty(property)) {
if (property.includes("hidden_fields")) continue;

Expand Down Expand Up @@ -292,7 +291,7 @@ const Form = class {
let relationsFetchScript = ``;
let relationsImport = ``;

for (var property in this.model) {
for (let property in this.model) {
if (this.model.hasOwnProperty(property)) {
if (property.includes("hidden_fields")) continue;

Expand All @@ -318,7 +317,7 @@ const Form = class {
let methodsScript = ``;

if (countFiles > 0) {
for (var property in this.model) {
for (let property in this.model) {
if (this.model.hasOwnProperty(property)) {
if (this.model[property].type == "file") {
methodsScript += `
Expand Down
12 changes: 6 additions & 6 deletions js/bootstrap/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable */
const capitalize = require("../libs/capitalize");
const pluralize = require("pluralize");

const View = class {
constructor(name, model, resource) {
Expand All @@ -11,10 +10,8 @@ const View = class {

getTemplate() {
let capitalizedName = capitalize(this.modelName);
let pluralizedAndCapitalizedName = pluralize(capitalizedName);

let template =
`<template>
let template = `<template>
<div class="view">
<div class="breadcrumbs">
<nav style="display: inline">
Expand Down Expand Up @@ -122,7 +119,10 @@ const View = class {
if (this.model.hasOwnProperty(property)) {
if (property.includes("hidden_fields")) continue;

if (this.model[property].type === "oneToMany" || this.model[property].type === "oneToOne") {
if (
this.model[property].type === "oneToMany" ||
this.model[property].type === "oneToOne"
) {
viewStruct += `
<li v-if="${this.modelName}.${property}" class="list-group-item">
<span class="liTitle">
Expand All @@ -132,7 +132,7 @@ const View = class {
>
</vue-json-pretty>
</li> \n`;
continue;
continue;
}

viewStruct += `
Expand Down
34 changes: 10 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const createTemplates = async (name, model, resource) => {
const InstallLocalDependecies = async () => {
try {
if (config.bootstrap) {
const child = exec(
exec(
`npm install --save bootstrap axios v-money vue-the-mask vue-multiselect vuex-persist vue-json-pretty @fortawesome/fontawesome-free`,
(error, stdout, stderr) => {
if (error) {
Expand All @@ -134,7 +134,7 @@ const InstallLocalDependecies = async () => {
);
} else {
config.frontend = "vuetify";
const child = exec(
exec(
"npm install --save vuetify axios v-money vue-the-mask vue-multiselect vuex-persist vue-json-pretty",
(error, stdout, stderr) => {
if (error) {
Expand Down Expand Up @@ -192,34 +192,20 @@ async function main() {
}

if (program.models) {
let models = await initModels();
await initModels();
}

if (program.unique) {
await initModel();
}

const childLintVue = exec(
"npx eslint --fix --ext=vue ./src/",
(error, stdout, stderr) => {
// if (error) {
// throw error;
// }
// console.log(stdout);
console.log(stdout);
}
);

const childLintJs = exec(
"npx eslint --fix --ext=js ./src/",
(error, stdout, stderr) => {
// if (error) {
// throw error;
// }
// console.log(stdout);
console.log(stdout);
}
);
exec("npx eslint --fix --ext=vue ./src/", (error, stdout, stderr) => {
console.log(stdout);
});

exec("npx eslint --fix --ext=js ./src/", (error, stdout, stderr) => {
console.log(stdout);
});
}

main();

0 comments on commit 41a4712

Please sign in to comment.