UNPKG

@hicoder/angular-cli

Version:

Angular UI componenets and service generator. It works with the mean-rest-express package to generate the end to end web application. The input to this generator is the Mongoose schema defined for the express application. mean-rest-express exposes the Res

54 lines (53 loc) 3.71 kB
// Import components for each schema <%_ for (let sch_name in schemaMap) { let schm = schemaMap[sch_name]; let api = schm.api; %> <%_ if (api.includes("L")) {%>import { <%-schm.SchemaName%>ListGeneralComponent } from './<%-schm.schemaName%>/<%-schm.schemaName%>-list/<%-schm.schemaName%>-list-general.component';<%}%> <%_ if (api.includes("L") && schm.listCalendarRoute) {%>import { <%-schm.SchemaName%>ListWidgetCalendarComponent } from './<%-schm.schemaName%>/<%-schm.schemaName%>-list/<%-schm.schemaName%>-list-widget-calendar.component';<%}%> <%_ if (api.includes("R")) {%>import { <%-schm.SchemaName%>DetailGeneralComponent } from './<%-schm.schemaName%>/<%-schm.schemaName%>-detail/<%-schm.schemaName%>-detail-general.component';<%}%> <%_ if (api.includes("U") || api.includes("C")) {%>import { <%-schm.SchemaName%>EditComponent } from './<%-schm.schemaName%>/<%-schm.schemaName%>-edit/<%-schm.schemaName%>-edit.component';<%}%> <%_ if (schm.sFeatures.hasRef) { if (api.includes("L")) {%>import { <%-schm.SchemaName%>ListSubComponent } from './<%-schm.schemaName%>/<%-schm.schemaName%>-list/<%-schm.schemaName%>-list-sub.component';<%} }%><%_if (api.includes("R")) { if (schm.associationRoutes.length > 0 ) {%> import { <%-schm.SchemaName%>DetailAssociationComponent } from './<%-schm.schemaName%>/<%-schm.schemaName%>-detail/<%-schm.schemaName%>-detail-association.component';<%} }%> <%_ }%> <%_ if (authRequired) {%> import { AuthGuard } from '@hicoder/angular-auth'; <%}%> <%_ for (let sch_name in schemaMap) { let schm = schemaMap[sch_name]; let api = schm.api; %><%if (schm.sFeatures.hasRef) {%> <%_ if (api.includes("L")) { %>const <%-schm.schemaName%>SubPath = [ {path: 'list', component: <%-schm.SchemaName%>ListSubComponent} ];<%}%> <%}} %> <%_ for (let sch_name in schemaMap) { let schm = schemaMap[sch_name]; let api = schm.api; if (schm.referred) {%> <%_ if (api.includes("R")) {%>const <%-schm.schemaName%>DetailPath = [ <%_for (let item of schm.referredBy) { let subApi = item[8]; %> <%if (subApi.includes("L")) {%>{path: '<%-item[0]%>', children: <%-item[0]%>SubPath, data: {'mraLevel': 2, 'item': '<%-item[0]%>'}},<%}%><%_ } %> ];<%}%> <%}} %> <%_ for (let sch_name in schemaMap) { let schm = schemaMap[sch_name]; let api = schm.api; %> export const <%-schm.schemaName%>RoutingCorePath = [ <%if (api.includes("L")) {%>{path: 'list', component: <%-schm.SchemaName%>ListGeneralComponent<% if (!schm.permission.includes('R')) {%>, canActivate: [AuthGuard]<%}%>},<%}%> <%if (api.includes("L") && schm.listCalendarRoute) {%>{path: 'calendar', component: <%-schm.SchemaName%>ListWidgetCalendarComponent<% if (!schm.permission.includes('R')) {%>, canActivate: [AuthGuard]<%}%>},<%}%> <%if (api.includes("R")) {%>{path: 'detail/:id', component: <%-schm.SchemaName%>DetailGeneralComponent<% if (!schm.permission.includes('R')) {%>, canActivate: [AuthGuard]<%}%>},<%}%> <% if (api.includes("U")) {%>{path: 'edit/:id', component: <%-schm.SchemaName%>EditComponent<% if (!schm.permission.includes('U')) {%>, canActivate: [AuthGuard]<%}%>},<%}%> <% if (api.includes("C")) {%>{path: 'new', component: <%-schm.SchemaName%>EditComponent<% if (!schm.permission.includes('C')) {%>, canActivate: [AuthGuard]<%}%>},<%}%> <%if (api.includes("R")) { for (let r of schm.associationRoutes) {%> {path: 'association/:id/<%-r[0]%>/<%-r[2]%>', component: <%-schm.SchemaName%>DetailAssociationComponent<% if (!schm.permission.includes('R')) {%>, canActivate: [AuthGuard]<%}%>},<%}%><%}%> <%if (api.includes("L")) {%>{path: '**', redirectTo: 'list', pathMatch: 'full'}<%}%> ]; <%_ }%>