406 Auxiliary Angular Typescript Classes LeptonX Lite UI - chempkovsky/CS82ANGULAR GitHub Wiki
- 00000 ContextLevelBatch
- 00010 AssetsFolderData
- 00020 Modify app.module.ts
- 00030 Add ngx-flexible-layout
- Before creating angular typescript classes for the very first View, all auxiliary interfaces, services, components and modules must be in place and ready for use.
- It’s time to note that the order of generated classes is extremely important. For instance, @Component() references “html” and “css” files. So, “html” and “css” must be generated first.
- The second point relates to script types. All scripts are divided into two large sets:
- The first one consists of the context level scripts. These scripts are used to generate interfaces, classes, services that are used across the Views and application level components.
- The second set consists of the View level scripts. They are scripts that are used to generate the code for the given view. For instance, Edit form for one View is not applicable for another one because of captions, validations and so on.
- These two large sets are organized as follows:
- Scripts with a range of 00000-00999 are context level scripts.
- Scripts with a range of 01000-99999 are view level scripts
- Run Visual Studio 2022 and open
rupbes.firstapp
- Add
Client
solution folder - right click
Client
-folder and chooseAdd/Existing Web Site
-menu item - In
Add existing Web site
-dialog chooseE:\development\rupbes.firstapp\angular\src
-folder- DO NOT choose
E:\development\rupbes.firstapp\angular
-folder
- DO NOT choose
- To Generate Typescript files
- Run Visual Studio and Open “PhonebookSolution” solution
- Right Click
app
-folder of theClient\src
-folder that was created by “Add/Existing Web Site”-command.
Click to show the picture
- On the first page of the dialog the destination folder is shown. The destination folder is the folder in which the generated file will be created. Click
Next
-button.
Click to show the picture
- On the second page of the Wizard we select DbContext that will be used to choose the entity for the View. Select
rupbes.firstapp.EntityFrameworkCore.csproj
and thefirstappDbContext
class using the drop-down lists. ClickNext
-button.
Click to show the picture
- On the third page of the Wizard
-
- select ==Context==
-
- if to
generate localized typescript code
-CheckBox usingAngular i18n
- if to
-
- Click
Next
-button
Click to show the picture
- On the Fourth page of the Wizard click
Batch processing
-button.
Click to show the picture
- On the
Batch Action Dialog
of the Wizard- choose
00000-ContextLevelBatch.json
-batch script - click
Start
-button.
- choose
Click to show the picture
- After
00000-ContextLevelBatch.json
-script completed- Close
Batch Action Dialog
- Close Wizard form
- Close
- To Generate Typescript files
- Run Visual Studio and Open “rupbes.firstapp” solution
- Right Click “Client\src”-project that was created by “Add/Existing Web Site”-command.
Click to show the picture
- Repeat the steps as for
00000 ContextLevelBatch
until00000 Batch Action Dialog
. - On the
Batch Action Dialog
of the Wizard- choose
00010-AssetsFolderData.json
-batch script - click
Start
-button.
- choose
- To modify
app.module.ts
-file- Run Visual Studio, open
rupbes.firstapp\angular\src\app\app.module.ts
-file and modify as follows
- Run Visual Studio, open
Click to show the code
import { CoreModule, provideAbpCore, withOptions } from '@abp/ng.core';
import { provideAbpOAuth } from '@abp/ng.oauth';
import { provideSettingManagementConfig } from '@abp/ng.setting-management/config';
import { provideFeatureManagementConfig } from '@abp/ng.feature-management';
import { ThemeSharedModule, provideAbpThemeShared,} from '@abp/ng.theme.shared';
import { provideIdentityConfig } from '@abp/ng.identity/config';
import { provideAccountConfig } from '@abp/ng.account/config';
import { provideTenantManagementConfig } from '@abp/ng.tenant-management/config';
import { registerLocale } from '@abp/ng.core/locale';
import { ThemeLeptonXModule } from '@abp/ng.theme.lepton-x';
import { SideMenuLayoutModule } from '@abp/ng.theme.lepton-x/layouts';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { environment } from '../environments/environment';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { APP_ROUTE_PROVIDER } from './route.provider';
// start adding custom code
import { AppConfigService } from './shared/services/app-config.service';
import { APP_INITIALIZER } from '@angular/core';
import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
const appInitializerFn = (appConfig: AppConfigService) => {
return () => {
return appConfig.loadAppConfig();
}
};
class CustomDateAdapter {
fromModel(value: string): NgbDateStruct {
if (!value) return null;
let parts = value.split('T');
parts = parts[0].split('-');
return { year: +parts[0], month: +parts[1], day: +parts[2] };
}
toModel(date: NgbDateStruct): string // from internal model -> your mode
{
return date ? date.year + "-" + ('0' + date.month).slice(-2) + "-" + ('0' + date.day).slice(-2) : null;
}
}
// end adding custom code
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
ThemeSharedModule,
CoreModule,
ThemeLeptonXModule.forRoot(),
SideMenuLayoutModule.forRoot(),
],
providers: [
APP_ROUTE_PROVIDER,
provideAbpCore(
withOptions({
environment,
registerLocaleFn: registerLocale(),
}),
),
// start adding custom code
AppConfigService,
{
provide: APP_INITIALIZER,
useFactory: appInitializerFn,
multi: true,
deps: [AppConfigService]
},
{
provide: NgbDateAdapter,
useClass: CustomDateAdapter
},
// end adding custom code
provideAbpOAuth(),
provideIdentityConfig(),
provideSettingManagementConfig(),
provideFeatureManagementConfig(),
provideAccountConfig(),
provideTenantManagementConfig(),
provideAbpThemeShared(),
],
bootstrap: [AppComponent],
})
export class AppModule {}
- to add
ngx-flexible-layout
-package into anglar project- start command-line terminal
cmd.exe
- in the command-line terminal make run two commands
- start command-line terminal
cd E:\development\rupbes.firstapp\angular
yarn add ngx-flexible-layout