Giter VIP home page Giter VIP logo

grails-angularjs-scaffolding's Introduction

Grails AngularJS Scaffolding Plugin

Java CI

A plugin for generating client side assets based on domain classes

grails-angularjs-scaffolding's People

Contributors

jameskleeh avatar puneetbehl avatar renovate[bot] avatar sdelamo avatar thojo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

grails-angularjs-scaffolding's Issues

Bootstrap class naming conflicts

When I add grails angular scaffolding plugin to my project and import project to IntelliJ IDEA, then IDEA show naming conflict in Bootstrap class, because IDEA find two Bootstrap.groovy: in my project and in library grails-angular-scaffolding.

How fix this problem?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/gradle.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/gradle-build-action v2
  • gradle/gradle-build-action v2
  • scacap/action-surefire-report v1
  • gradle/gradle-build-action v2
  • gradle/gradle-build-action v2
.github/workflows/release-notes.yml
  • actions/checkout v4
  • release-drafter/release-drafter v5.25.0
  • ncipollo/release-action v1
.github/workflows/release.yml
  • actions/checkout v4
  • gradle/wrapper-validation-action v1
  • actions/setup-java v4
  • gradle/gradle-build-action v2
  • gradle/gradle-build-action v2
gradle
gradle.properties
  • org.grails:grails-bom 5.3.6
  • org.grails:scaffolding-core 2.1.0
  • org.spockframework:spock-core 2.3-groovy-3.0
settings.gradle
build.gradle
  • org.asciidoctor.convert 2.4.0
buildSrc/build.gradle
  • org.grails:grails-gradle-plugin 5.3.1
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 6.9.4

  • Check this box to trigger a request for Renovate to run again on this repository

Cannot edit Domains with nullable associations

Given domain resources like the following where the association is nullable:

Publisher {
    String name
}

class Book {
    String title
    Publisher publisher
    static constraints = {
        publisher nullable: true
    }
}

The result is that for a Book without a Publisher, the show screen displays "test.Publisher : (unsaved)". When you attempt to update the book and the update button is clicked a null pointer exception is encountered:

ERROR org.grails.web.errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [PUT] /book/1
Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: null
        at test.BookController.$tt__update(BookController.groovy:54)
        at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
        at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
        at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
        at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
        ... 3 common frames omitted

I think the issue is that the JSON submitted for the update ends up including a empty publisher when none is selected:

{
    id: 1, 
    title: "Along Came a Spider", 
    publisher: {}
}

Sample project: https://github.com/scrain/angular-scaffolding-nullable-association-issue

Error for auto time stamp when saving an edited object

When editing an object controller gets the dateCreated and lastUpdated dates and makes it part of the modal. Thus while saving it we send it back to the server via the ajax call as well. This is causing following validation errors


Property dateCreated must be a valid Date
Property lastUpdated must be a valid Date

The quick fix is to remove them from EditController right before the update method is called and let the server take care of the dates.
We can add the following in the EditController angular template

if(${controllerAs}.${propertyName}['dateCreated']){
            delete ${controllerAs}.${propertyName}['dateCreated'];
        }
        if(${controllerAs}.${propertyName}['lastUpdated']){
            delete ${controllerAs}.${propertyName}['lastUpdated'];
        }

NoUniqueBeanDefinitionException - No qualifying bean of type [org.grails.datastore.mapping.model.MappingContext]

| Grails Version: 3.2.0.M1
| Groovy Version: 2.4.6
| JVM Version: 1.8.0_92

Hi @Schlogen, I'm using Grails with MongoDB as DataSource and I'm getting the same error reported here when I run ng-generate-all <domainClass>.

Here is my build.gradle:

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
        classpath "org.grails.plugins:hibernate4:5.0.6"
    classpath "org.grails.plugins:angular-scaffolding:1.0.0.RC1"
    }
}

version "0.1"
group "app32"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:scaffolding"
    //compile "org.grails.plugins:hibernate4"
    //compile "org.hibernate:hibernate-ehcache"
    console "org.grails:grails-console"
    compile "org.grails.plugins:spring-security-core:3.0.4"
    compile "org.grails.plugins:mongodb:5.0.8"
    profile "org.grails.profiles:web:3.2.0.M1"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
    //runtime "com.h2database:h2"
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
    compile "org.grails.plugins:angular-scaffolding:1.0.0.RC1"
}

task wrapper(type: Wrapper) {
    gradleVersion = gradleWrapperVersion
}

assets {
    minifyJs = true
    minifyCss = true
}

Error output:

:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:ngGenerateAll

Configuring Spring Security Core ...
... finished configuring Spring Security Core

Command execution error: Error creating bean with name 'grails.angular.scaffolding.NgGenerateAllCommand': Unsatisfied dependency expressed through bean property 'grailsDomainClassMappingContext': No qualifying bean of type [org.grails.datastore.mapping.model.MappingContext] is defined: expected single matching bean but found 2: grailsDomainClassMappingContext,gormMongoMappingContext; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.grails.datastore.mapping.model.MappingContext] is defined: expected single matching bean but found 2: grailsDomainClassMappingContext,gormMongoMappingContext
:ngGenerateAll FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ngGenerateAll'.
> Process 'command '/***/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 19.844 secs
| Error Command [ng-generate-all] error: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.13-all.zip'. (Use --stacktrace to see the full trace)

Would it be the case to apply the same fix for 'grails-angular-scaffolding' plugin?

Thank you!

domainToManyConversion fails where a domain object has zero instances of linked domain object

The function domainToManyConversion will attempt to create an object representation of linked domain objects.

The code that does this is as follows:

domain[property] = domain[property].map(function (obj) {
    return new Domain(obj);
});

from src/main/templates/angular/javascripts/services/domainToManyConversion.js

If domain[property] is null, this will error out.

When I created a domain object with a hasMany relationship, and that relationship was empty (i.e. no entries), I encountered this error.

I wrapped the code block above in a null check to get around this.

if(domain[property] != null) {
    domain[property] = domain[property].map(function (obj) {
        return new Domain(obj);
    });
}

Running ng-generate-all results in "Ambiguous method overloading for method"

This is the output I receive when I run ng-generate-all using a new app:

Ambiguous method overloading for method grails.plugin.scaffolding.angular.markup.AngularContextMarkupRendererImpl#inputContext.
Cannot resolve which method to invoke for [null, class grails.plugin.scaffolding.markup.DomainMarkupRendererImpl$_renderForm_closure2] due to overlapping prototypes between:
    [interface grails.plugin.scaffolding.model.property.DomainProperty, class groovy.lang.Closure]
    [interface org.grails.datastore.mapping.model.PersistentEntity, class groovy.lang.Closure]
null
[groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:3238), groovy.lang.MetaClassImpl.chooseMethodInternal(MetaClassImpl.java:3191), groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:3134), groovy.lang.MetaClassImpl.getMethodWithCachingInternal(MetaClassImpl.java:1330), groovy.lang.MetaClassImpl.createPogoCallSite(MetaClassImpl.java:3402), org.codehaus.groovy.runtime.callsite.CallSiteArray.createPogoSite(CallSiteArray.java:150), org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:164), org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(Cal

Is there something I am missing?

Error: Cannot cast object 'grails.gorm.validation.PersistentEn:ngGenerateAll'

Hello,
I just created a new grails project using the profile angularjs, and then created an empty domain (Post) with one property 'title', when I run ngGenerate Post I got:

Command execution error: Cannot cast object 'grails.gorm.validation.PersistentEn:ngGenerateAll FAILED
ator' to class 'org.grails.validation.GrailsDomainClassValidator'
FAILURE: Build failed with an exception.

| Grails Version: 3.3.6
| Groovy Version: 2.4.15
| JVM Version: 1.8.0_181
OS: OSX 10.12
build.gradle is the default generated by create-app command with "angularjs-scaffolding:1.0.3"

URLs in angular service binding do not match up to URL Mappings for new angular grails project

Grails Version: 3.2.0.M1
Groovy Version: 2.4.6
JVM Version: 1.8.0_92
grails-angular-scaffolding: 1.0.0.RC1

To demonstrate this issue, I did the following:

  • Created a new grails app with profile angular
  • Create a simple domain object 'fruit'
  • Use grails generate-all on the new domain object
  • Use grails ngGenerateAll on the new domain object.
  • Add a reference to the new domain object's angular classes to the main angular JS import file

The front-end correctly displayed instances of the domain object in a list. However, CRUD operations did not work correctly.

Inspecting the requests being made by the Angular service, I found the following requests were being used:

However in a new 'angular' grails app, these paths were not mapped to the corresponding controller actions.

The URL Mapping in a new angular grails app is as follows:


  "/$controller/$action?/$id?(.$format)?"{
            constraints {
                // apply constraints here
            }
        }

I changed this to the following and front-end CRUD worked.

    "/$controller/$id" {
            action = [ GET : "show", PUT: "update", DELETE: "delete" ]
        }

        "/$controller/" {
            action = [POST: "save", "GET": "index" ]
        }

Not sure if the best way is to modify the angular service templates or to have the default URL mapping changed, but I would say that for new users it's probably best if they don't have to deal with this.

How to use the plugin? grails ng-generate-all [domain] throws a dependency error

I have created a fresh new project with --profile=angular, using grails 3.1.7:

grails create-app ngscaff --profile=angular

then I have added this line into build.gradle depedencies block:

dependencies {
...
compile 'org.grails.plugins:angular-scaffolding:1.0.0.M1'
...
}

When I run the command:

grails ng-generate-all ngscaff.TaskLevel

grails throws these error:

Error |
Command [ng-generate-all] error: Profile [org.grails.profiles:rest-api:3.1.7] declares and invalid dependency on parent profile [org.grails.profiles:rest-api:3.1.7](Use --stacktrace to see the full trace)

parent module in application not edited by grails-angular-scaffolding plugin

Created application - library
Added grails create-domain-resource Book
added changes like in blog posting.
run ngGenerateAll
grails ngGenerateAll library.Book true
:compileJava UP-TO-DATE
:compileGroovy
:buildProperties UP-TO-DATE
:processResources UP-TO-DATE
:classes
:findMainClass
:ngGenerateAll
Warning | Destination file grails-app/assets/javascripts/library/core/library.core.js already exists, skipping...
Rendered template module.js to destination grails-app/assets/javascripts/library/book/library.book.js
Rendered template create.tpl.html to destination grails-app/assets/javascripts/library/book/templates/create.tpl.html
Rendered template edit.tpl.html to destination grails-app/assets/javascripts/library/book/templates/edit.tpl.html
Rendered template show.tpl.html to destination grails-app/assets/javascripts/library/book/templates/show.tpl.html
Rendered template list.tpl.html to destination grails-app/assets/javascripts/library/book/templates/list.tpl.html
Rendered template createController.js to destination grails-app/assets/javascripts/library/book/controllers/bookCreateController.js
Rendered template editController.js to destination grails-app/assets/javascripts/library/book/controllers/bookEditController.js
Rendered template listController.js to destination grails-app/assets/javascripts/library/book/controllers/bookListController.js
Rendered template showController.js to destination grails-app/assets/javascripts/library/book/controllers/bookShowController.js
Rendered template domain.js to destination grails-app/assets/javascripts/library/book/domain/Book.js

BUILD SUCCESSFUL

Total time: 1 mins 47.582 secs

But grails-app/assets/javascripts/library/library.js was not updated as it should be.
Have spoken to James Kleeh and he asked me to raise defect.
If there is further information you need then please ask.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.