Skip to content

Commit

Permalink
introduce new dynamic object component
Browse files Browse the repository at this point in the history
  • Loading branch information
scascarini committed Jan 23, 2017
1 parent 7e4aba6 commit 524aea3
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 105 deletions.
58 changes: 29 additions & 29 deletions Demo/NakedObjects.Rest.App.Demo/Web.Debug.config
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
60 changes: 30 additions & 30 deletions Demo/NakedObjects.Rest.App.Demo/Web.Release.config
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
5 changes: 5 additions & 0 deletions Spa2/nakedobjectsspa/nakedobjectsspa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<Content Include="src\app\collection\collection.component.html" />
<Content Include="src\app\dialog\dialog.component.css" />
<Content Include="src\app\dialog\dialog.component.html" />
<Content Include="src\app\dynamic-object\dynamic-object.component.css" />
<Content Include="src\app\dynamic-object\dynamic-object.component.html" />
<Content Include="src\app\edit-property\edit-property.component.css" />
<Content Include="src\app\edit-property\edit-property.component.html" />
<Content Include="src\app\error\error.component.css" />
Expand Down Expand Up @@ -115,7 +117,10 @@
<TypeScriptCompile Include="src\app\config.ts" />
<TypeScriptCompile Include="src\app\constants.ts" />
<TypeScriptCompile Include="src\app\context.service.ts" />
<TypeScriptCompile Include="src\app\custom-component-config.service.ts" />
<TypeScriptCompile Include="src\app\custom-component.service.ts" />
<TypeScriptCompile Include="src\app\dialog\dialog.component.ts" />
<TypeScriptCompile Include="src\app\dynamic-object\dynamic-object.component.ts" />
<TypeScriptCompile Include="src\app\edit-property\edit-property.component.ts" />
<TypeScriptCompile Include="src\app\error.handler.ts" />
<TypeScriptCompile Include="src\app\error.service.ts" />
Expand Down
6 changes: 3 additions & 3 deletions Spa2/nakedobjectsspa/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RecentComponent } from './recent/recent.component';
import { ApplicationPropertiesComponent } from './application-properties/application-properties.component';
import { AttachmentComponent } from './attachment/attachment.component';
import { MultiLineDialogComponent } from './multi-line-dialog/multi-line-dialog.component';

import { DynamicObjectComponent } from './dynamic-object/dynamic-object.component';
const routes: Routes = [
{
path: '',
Expand All @@ -29,11 +29,11 @@ const routes: Routes = [
},
{
path: 'gemini/object',
component: ObjectComponent,
component: DynamicObjectComponent,
data: { pane: 1, class: "single" },
children: [
{ path: "home", component: HomeComponent, data: { pane: 2, class: "split" } },
{ path: "object", component: ObjectComponent, data: { pane: 2, class: "split" } },
{ path: "object", component: DynamicObjectComponent, data: { pane: 2, class: "split" } },
{ path: "list", component: ListComponent, data: { pane: 2, class: "split" } },
{ path: "attachment", component: AttachmentComponent, data: { pane: 2, class: "split" } },
{ path: "recent", component: RecentComponent, data: { pane: 2, class: "split" } }
Expand Down
92 changes: 49 additions & 43 deletions Spa2/nakedobjectsspa/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,56 +37,60 @@ import { MaskConfigService } from './mask-config.service';
import { CollectionComponent } from './collection/collection.component';
// temp hack todo fix
import { DndModule } from 'ng2-dnd';
import { ReactiveFormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import { AttachmentComponent } from './attachment/attachment.component';
import { MultiLineDialogComponent } from './multi-line-dialog/multi-line-dialog.component';
import { ViewParameterComponent } from './view-parameter/view-parameter.component';
import { GeminiErrorHandler } from './error.handler';
import { MenusComponent } from './menus/menus.component';
import { MenuComponent } from './menu/menu.component';
import { ButtonsComponent } from './buttons/buttons.component';
import { ButtonComponent } from './button/button.component'
import { ButtonComponent } from './button/button.component';
import { DynamicObjectComponent } from './dynamic-object/dynamic-object.component'
import * as Customcomponentservice from './custom-component.service';
import * as Customcomponentconfigservice from './custom-component-config.service';

@NgModule({
declarations: [
AppComponent,
FooterComponent,
HomeComponent,
ObjectComponent,
ListComponent,
ErrorComponent,
ActionsComponent,
ActionComponent,
PropertiesComponent,
CollectionsComponent,
DialogComponent,
ParametersComponent,
EditPropertyComponent,
ViewPropertyComponent,
EditParameterComponent,
RecentComponent,
ApplicationPropertiesComponent,
GeminiClickDirective,
GeminiBooleanDirective,
GeminiClearDirective,
CollectionComponent,
AttachmentComponent,
MultiLineDialogComponent,
ViewParameterComponent,
MenusComponent,
MenuComponent,
ButtonsComponent,
ButtonComponent
],
imports: [
BrowserModule,
DndModule.forRoot(),
FormsModule,
HttpModule,
RoutingModule,
ReactiveFormsModule
],
providers: [
declarations: [
AppComponent,
FooterComponent,
HomeComponent,
ObjectComponent,
ListComponent,
ErrorComponent,
ActionsComponent,
ActionComponent,
PropertiesComponent,
CollectionsComponent,
DialogComponent,
ParametersComponent,
EditPropertyComponent,
ViewPropertyComponent,
EditParameterComponent,
RecentComponent,
ApplicationPropertiesComponent,
GeminiClickDirective,
GeminiBooleanDirective,
GeminiClearDirective,
CollectionComponent,
AttachmentComponent,
MultiLineDialogComponent,
ViewParameterComponent,
MenusComponent,
MenuComponent,
ButtonsComponent,
ButtonComponent,
DynamicObjectComponent
],
imports: [
BrowserModule,
DndModule.forRoot(),
FormsModule,
HttpModule,
RoutingModule,
ReactiveFormsModule
],
providers: [
UrlManagerService,
ClickHandlerService,
ContextService,
Expand All @@ -97,8 +101,10 @@ import { ButtonComponent } from './button/button.component'
MaskService,
ColorConfigService,
MaskConfigService,
Customcomponentservice.CustomComponentService,
Customcomponentconfigservice.CustomComponentConfigService,
{ provide: ErrorHandler, useClass: GeminiErrorHandler }
],
bootstrap: [AppComponent]
],
bootstrap: [AppComponent]
})
export class AppModule { }
14 changes: 14 additions & 0 deletions Spa2/nakedobjectsspa/src/app/custom-component-config.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Injectable } from '@angular/core';

@Injectable()
export class CustomComponentConfigService {

constructor() { }


configure(customComponent: any) {


}

}
8 changes: 8 additions & 0 deletions Spa2/nakedobjectsspa/src/app/custom-component.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@angular/core';

@Injectable()
export class CustomComponentService {

constructor() { }

}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div #parent></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, OnInit, ComponentFactoryResolver, ViewChild, ViewContainerRef } from '@angular/core';
import { ObjectComponent } from '../object/object.component';

@Component({
selector: 'nof-dynamic-object',
templateUrl: './dynamic-object.component.html',
styleUrls: ['./dynamic-object.component.css']
})
export class DynamicObjectComponent implements OnInit {

@ViewChild('parent', { read: ViewContainerRef })
parent: ViewContainerRef;

constructor(private readonly componentFactoryResolver: ComponentFactoryResolver) {
}

ngOnInit() {
const childComponent = this.componentFactoryResolver.resolveComponentFactory(ObjectComponent);
this.parent.createComponent(childComponent);
}
}

0 comments on commit 524aea3

Please sign in to comment.