Skip to content

Commit

Permalink
First realease Angular Crud with Master Detail
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonatan89 committed Feb 2, 2018
1 parent b6f8cff commit b0cdc0e
Show file tree
Hide file tree
Showing 41 changed files with 664 additions and 225 deletions.
43 changes: 43 additions & 0 deletions ComponentGenerator/assets/components.angen
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package componentGroup{

import services.*
import models.*

Components{
Crud BookCrud{
model: Book;
showAsGallery: true;
enableMock: true;
createService: BookServices.createBook;
updateService: BookServices.updateBook;
listService: BookServices.searchBooks;
listNumService: BookServices.searchNumBooks;
deleteService: BookServices.deleteBook;
getService: BookServices.getBook;

}
Crud AuthorCrud{
model: Author;
showAsGallery: true;
enableMock: true;
createService: AuthorServices.createAuthor;
updateService: AuthorServices.updateAuthor;
listService: AuthorServices.searchAuthors;
listNumService: AuthorServices.searchNumAuthors;
deleteService: AuthorServices.deleteAuthor;
getService: AuthorServices.getAuthor;

}
Crud Review{
model: Review;
showAsGallery: true;
enableMock: true;
createService: ReviewServices.createReview;
updateService: ReviewServices.updateReview;
listService: ReviewServices.searchReviews;
listNumService: ReviewServices.searchNumReviews;
deleteService: ReviewServices.deleteReview;
getService: ReviewServices.getReview;
}
}
}
36 changes: 5 additions & 31 deletions ComponentGenerator/assets/grammarBook.angen
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LibraryApp {

import services.*
import models.*
import componentGroup.*

Modules {
VisualModule Main {
Expand All @@ -18,7 +19,7 @@ LibraryApp {
parent: Main;
imports: [];
exports: [];
route: ["Book.BookCrudComponent","Author.AuthorCrudComponent"];
route: ["Book.BookCrud","Author.AuthorCrud", "Author.Review"];
show:[];
defaultRoute: "Book.BookCrudComponent";
showLayout: List;
Expand All @@ -27,8 +28,8 @@ LibraryApp {
ContainerModule Author{
parent: Library;
imports: [];
exports: [AuthorCrud];
components: [AuthorCrud];
exports: [AuthorCrud,Review];
components: [AuthorCrud,Review];
}
ContainerModule Book{
parent: Library;
Expand All @@ -37,34 +38,7 @@ LibraryApp {
components: [BookCrud];
}
}
Components{
Crud BookCrud{
model: Book;
showAsGallery: true;
enableMock: true;
createService: BookServices.createBook;
updateService: BookServices.updateBook;
listService: BookServices.searchBooks;
listNumService: BookServices.searchNumBooks;
deleteService: BookServices.deleteBook;
getService: BookServices.getBook;

}
Crud AuthorCrud{
model: Author;
createService: AuthorServices.createAuthor;
updateService: AuthorServices.updateAuthor;
listService: AuthorServices.searchAuthors;
listNumService: AuthorServices.searchNumAuthors;
deleteService: AuthorServices.deleteAuthor;
getService: AuthorServices.getAuthor;

}
SearchComboBox university{
model: University;
service: Shared.getUniversity;
}
}


}

Expand Down
22 changes: 22 additions & 0 deletions ComponentGenerator/assets/justComponents.angen
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import services.*
import models.*

Components{
Crud BookCrud{
model: Book;
showAsGallery: true;
enableMock: false;
createService: BookServices.createBook;
updateService: BookServices.updateBook;
listService: BookServices.searchBooks;
listNumService: BookServices.searchNumBooks;
deleteService: BookServices.deleteBook;
getService: BookServices.getBook;
}
}






18 changes: 12 additions & 6 deletions ComponentGenerator/assets/models.angen
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package models{

import componentGroup.*

Models {
Model Book{
attributes: [
Expand All @@ -8,7 +10,10 @@ package models{
{attributeName: editorial, type: String, isRequired: true, mockType: 'Company Name'},
{attributeName: author, type:String, isRequired: true},
{attributeName: price, type:Number, isRequired: true},
// {attributeName: university, type:SearchComboBox, component: university, isRequired: true},
];
children: [
Author{component: AuthorCrud, attributeName: "Authors", relationshipType: Shared},
Review{component: Review, attributeName: "Reviews", relationshipType: Composite},
];
idAtribute: id;
showAttributeList: name;
Expand All @@ -20,21 +25,22 @@ package models{
{attributeName: age, type: Number, isRequired: true},
{attributeName: profile, type:String}
];
children: [
Book{component: BookCrud, attributeName: "Best Seller", relationshipType: Simple},
];
idAtribute: id;
showAttributeList: name;
}
Model University{
Model Review{
attributes: [
{attributeName: id, type: Number},
{attributeName: name, type: String, isRequired: true},
{attributeName: code, type: Number, isRequired: true},
{attributeName: contryName, type:String}
{attributeName: description, type: String},
];
idAtribute: id;
showAttributeList: name;
}

}



}
19 changes: 13 additions & 6 deletions ComponentGenerator/assets/services.angen
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ package services {

}

ServicesGroup Shared {
baseUrl: api
Service getUniversity {url: "searchUniversitiesServlet",type: GET,collectionName: universities}

}
ServicesGroup ReviewServices{
baseUrl: api
Service createReview {url: "reviews", type: PUT}
Service updateReview {url: "reviews", type: POST}
Service searchReviews {url: "reviews", type: GET}
Service searchNumReviews {url: "reviews/searchNum", type: GET}
Service getReview {url: "reviews",type: GET}
Service deleteReview {url: "reviews",type: DELETE}
}




}
}
44 changes: 15 additions & 29 deletions ComponentGenerator/grammarBook.xmi
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,26 @@
<elements xsi:type="generator:Application" name="LibraryApp">
<elements xsi:type="generator:Import" importedNamespace="services.*"/>
<elements xsi:type="generator:Import" importedNamespace="models.*"/>
<elements xsi:type="generator:Import" importedNamespace="componentGroup.*"/>
<elements xsi:type="generator:Modules">
<modules xsi:type="generator:VisualModule" name="Main" defaultRoute="&quot;Library.LibraryComponent&quot;" type="GALLERY">
<routes>&quot;Library.LibraryComponent&quot;</routes>
</modules>
<modules xsi:type="generator:VisualModule" name="Library" parent="//@elements.0/@elements.2/@modules.0" defaultRoute="&quot;Book.BookCrudComponent&quot;">
<routes>&quot;Book.BookCrudComponent&quot;</routes>
<routes>&quot;Author.AuthorCrudComponent&quot;</routes>
<modules xsi:type="generator:VisualModule" name="Library" parent="//@elements.0/@elements.3/@modules.0" defaultRoute="&quot;Book.BookCrudComponent&quot;">
<routes>&quot;Book.BookCrud&quot;</routes>
<routes>&quot;Author.AuthorCrud&quot;</routes>
<routes>&quot;Author.Review&quot;</routes>
</modules>
<modules xsi:type="generator:ContainerModule" name="Author" parent="//@elements.0/@elements.3/@modules.1">
<components href="platform:/resource/ComponentGenerator/assets/components.angen#//@elements.0/@elements.2/@components.1"/>
<components href="platform:/resource/ComponentGenerator/assets/components.angen#//@elements.0/@elements.2/@components.2"/>
<exports href="platform:/resource/ComponentGenerator/assets/components.angen#//@elements.0/@elements.2/@components.1"/>
<exports href="platform:/resource/ComponentGenerator/assets/components.angen#//@elements.0/@elements.2/@components.2"/>
</modules>
<modules xsi:type="generator:ContainerModule" name="Book" parent="//@elements.0/@elements.3/@modules.1">
<components href="platform:/resource/ComponentGenerator/assets/components.angen#//@elements.0/@elements.2/@components.0"/>
<exports href="platform:/resource/ComponentGenerator/assets/components.angen#//@elements.0/@elements.2/@components.0"/>
</modules>
<modules xsi:type="generator:ContainerModule" name="Author" parent="//@elements.0/@elements.2/@modules.1" components="//@elements.0/@elements.3/@components.1" exports="//@elements.0/@elements.3/@components.1"/>
<modules xsi:type="generator:ContainerModule" name="Book" parent="//@elements.0/@elements.2/@modules.1" components="//@elements.0/@elements.3/@components.0" exports="//@elements.0/@elements.3/@components.0"/>
</elements>
<elements xsi:type="generator:Components">
<components xsi:type="generator:Crud" name="BookCrud" showAsGallery="true" enableMock="true">
<modelData href="platform:/resource/ComponentGenerator/assets/models.angen#//@elements.0/@elements.0/@models.0"/>
<create href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.0"/>
<update href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.1"/>
<list href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.2"/>
<listNum href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.3"/>
<deleteItem href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.5"/>
<get href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.4"/>
</components>
<components xsi:type="generator:Crud" name="AuthorCrud">
<modelData href="platform:/resource/ComponentGenerator/assets/models.angen#//@elements.0/@elements.0/@models.1"/>
<create href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.0/@services.0"/>
<update href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.0/@services.1"/>
<list href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.0/@services.2"/>
<listNum href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.0/@services.3"/>
<deleteItem href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.0/@services.5"/>
<get href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.0/@services.4"/>
</components>
<components xsi:type="generator:SearchComboBox" name="university">
<modelData href="platform:/resource/ComponentGenerator/assets/models.angen#//@elements.0/@elements.0/@models.2"/>
<service href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.2/@services.0"/>
</components>
</elements>
</elements>
</generator:Root>
16 changes: 16 additions & 0 deletions ComponentGenerator/justComponents.xmi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="ASCII"?>
<generator:Root xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:generator="http://www.academia.uniandes/Generator">
<elements xsi:type="generator:Import" importedNamespace="services.*"/>
<elements xsi:type="generator:Import" importedNamespace="models.*"/>
<elements xsi:type="generator:Components">
<components xsi:type="generator:Crud" name="BookCrud" showAsGallery="true">
<modelData href="platform:/resource/ComponentGenerator/assets/models.angen#//@elements.0/@elements.0/@models.0"/>
<create href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.0"/>
<update href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.1"/>
<list href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.2"/>
<listNum href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.3"/>
<deleteItem href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.5"/>
<get href="platform:/resource/ComponentGenerator/assets/services.angen#//@elements.0/@elements.1/@services.4"/>
</components>
</elements>
</generator:Root>
2 changes: 1 addition & 1 deletion ComponentGenerator/mtcs/default.mtc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<transformations xsi:type="com.mtcflow.model:M2TTransformation" name="Model2Text" URI="main.egl" target="${generated path}"/>
<configurations>
<variables name="model path" defaultValue="../grammarBook.xmi"/>
<variables name="generated path" defaultValue="gen/crudBeta2"/>
<variables name="generated path" defaultValue="gen/crudBeta5"/>
</configurations>
<outputFiles transformation="//@transformations.0" file="//@files.0"/>
</com.mtcflow.model:MTC>
20 changes: 10 additions & 10 deletions ComponentGenerator/mtcs/default.mtcd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkF7xLA0Eeeobb-IypwpXQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_vkEtobA0Eeeobb-IypwpXQ" fontName="Segoe UI" fontHeight="10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkEtorA0Eeeobb-IypwpXQ" x="340" y="85" width="90" height="110"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkEtorA0Eeeobb-IypwpXQ" x="315" y="85" width="90" height="110"/>
</children>
<children xmi:type="notation:Node" xmi:id="_vkFUsrA0Eeeobb-IypwpXQ" type="2001" element="_vj5HcLA0Eeeobb-IypwpXQ">
<children xmi:type="notation:Node" xmi:id="_vkF7wLA0Eeeobb-IypwpXQ" type="5002">
Expand All @@ -33,7 +33,7 @@
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkGi0rA0Eeeobb-IypwpXQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_vkFUs7A0Eeeobb-IypwpXQ" fontName="Segoe UI" fontHeight="10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkFUtLA0Eeeobb-IypwpXQ" x="350" y="280" width="90" height="110"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkFUtLA0Eeeobb-IypwpXQ" x="310" y="265" width="90" height="110"/>
</children>
<children xmi:type="notation:Node" xmi:id="_8yeBkLA0Eeeobb-IypwpXQ" type="2003" element="_8yTpgLA0Eeeobb-IypwpXQ">
<children xmi:type="notation:Node" xmi:id="_8yeooLA0Eeeobb-IypwpXQ" type="5007"/>
Expand Down Expand Up @@ -77,33 +77,33 @@
<styles xmi:type="notation:DiagramStyle" xmi:id="_GwhsMnWkEeOHkLQMMBSUFQ"/>
<edges xmi:type="notation:Edge" xmi:id="_vkQ64LA0Eeeobb-IypwpXQ" type="4001" element="_vkC4cLA0Eeeobb-IypwpXQ" source="_vkFUsrA0Eeeobb-IypwpXQ" target="_vkEtoLA0Eeeobb-IypwpXQ">
<children xmi:type="notation:Node" xmi:id="_vkRh8LA0Eeeobb-IypwpXQ" type="6001">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkRh8bA0Eeeobb-IypwpXQ" y="-10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkRh8bA0Eeeobb-IypwpXQ" x="14" y="31"/>
</children>
<children xmi:type="notation:Node" xmi:id="_vkSJALA0Eeeobb-IypwpXQ" type="6002">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkSJAbA0Eeeobb-IypwpXQ" y="10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkSJAbA0Eeeobb-IypwpXQ" x="3" y="10"/>
</children>
<children xmi:type="notation:Node" xmi:id="_vkSwELA0Eeeobb-IypwpXQ" type="6003">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkSwEbA0Eeeobb-IypwpXQ" y="10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_vkSwEbA0Eeeobb-IypwpXQ" x="-7" y="10"/>
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_vkQ64bA0Eeeobb-IypwpXQ" routing="Rectilinear" jumpLinkStatus="Above"/>
<styles xmi:type="notation:FontStyle" xmi:id="_vkQ64rA0Eeeobb-IypwpXQ" fontName="Segoe UI" fontHeight="7"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_vkQ647A0Eeeobb-IypwpXQ" points="[124, 276, 124, 276]$[94, 246, 94, 246]"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_vkQ647A0Eeeobb-IypwpXQ" points="[-5, -55, -10, 125]$[-5, -125, -10, 55]"/>
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_vkYPoLA0Eeeobb-IypwpXQ" id="(0.5,0.5)"/>
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_vkYPobA0Eeeobb-IypwpXQ" id="(0.5,0.5)"/>
</edges>
<edges xmi:type="notation:Edge" xmi:id="_P5ogdbqNEeeNKZnUZD22qA" type="4001" element="_P5pHhrqNEeeNKZnUZD22qA" source="_vkFUsrA0Eeeobb-IypwpXQ" target="_P5n5ZLqNEeeNKZnUZD22qA">
<children xmi:type="notation:Node" xmi:id="_P5ogdrqNEeeNKZnUZD22qA" type="6001">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_P5ogd7qNEeeNKZnUZD22qA" x="18" y="11"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_P5ogd7qNEeeNKZnUZD22qA" x="38" y="11"/>
</children>
<children xmi:type="notation:Node" xmi:id="_P5ogeLqNEeeNKZnUZD22qA" type="6002">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_P5ogebqNEeeNKZnUZD22qA" y="10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_P5ogebqNEeeNKZnUZD22qA" x="34" y="10"/>
</children>
<children xmi:type="notation:Node" xmi:id="_P5ogerqNEeeNKZnUZD22qA" type="6003">
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_P5oge7qNEeeNKZnUZD22qA" y="10"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_P5oge7qNEeeNKZnUZD22qA" x="6" y="10"/>
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_P5ogfLqNEeeNKZnUZD22qA" routing="Rectilinear" jumpLinkStatus="Above"/>
<styles xmi:type="notation:FontStyle" xmi:id="_P5ogfbqNEeeNKZnUZD22qA" fontName="Segoe UI"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_P5ogfrqNEeeNKZnUZD22qA" points="[20, 0, -111, 0]$[120, 0, -11, 0]"/>
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_P5ogfrqNEeeNKZnUZD22qA" points="[20, 5, -136, -15]$[145, 5, -11, -15]"/>
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_P5ogf7qNEeeNKZnUZD22qA" id="(0.7777777777777778,0.4636363636363636)"/>
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_P5oggLqNEeeNKZnUZD22qA" id="(0.06875,0.52)"/>
</edges>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"@angular/router": "^5.0.3",
"@ngx-translate/core": "9.0.1",
"@ngx-translate/http-loader": "^2.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"bootstrap": "^3.3.7",
"jquery": "3.2.1",
"core-js": "^2.4.1",
"ngx-academia-uniandes-library": "^0.1.5",
"ngx-bootstrap": "^2.0.2",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
var materialModule:Template:= TemplateFactory.load(rootPath + 'angularMaterial.egl');
materialModule.generate(getRootLocation() + "src/app/angular-material.module.ts");

var ngxBootstrapModule:Template:= TemplateFactory.load(rootPath + 'ngx-bootstrapModule.egl');
ngxBootstrapModule.generate(getRootLocation() + "src/app/ngx-bootstrap.module.ts");




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { RouterModule, Routes } from '@angular/router';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
import { AngularMaterialModule } from './angular-material.module'
import { ServiceMainLocator } from './service-locator-main';
[% for(route in parent.routes ){ %]
Expand Down Expand Up @@ -38,7 +37,6 @@ const routes: Routes = [
HttpClientModule,
AngularMaterialModule,
RouterModule.forRoot(routes),
NgbModule.forRoot(),
[% for(mod in VisualModule.allInstances().select(m | m.parent = parent)){ %]
[%=mod.name.firstToUpperCase()%]Module [%if(hasMore){%],[%}%]
[% } %]
Expand Down
Loading

0 comments on commit b0cdc0e

Please sign in to comment.